Merge
authorlana
Fri, 21 Apr 2017 03:34:11 +0000
changeset 44782 15f36f4cf2b7
parent 44703 755b714df450 (current diff)
parent 44781 5a43cca8fc10 (diff)
child 44784 f2e3396a6a6b
Merge
jdk/make/CopySamples.gmk
jdk/src/demo/share/jvmti/agent_util/README.txt
jdk/src/demo/share/jvmti/agent_util/agent_util.c
jdk/src/demo/share/jvmti/agent_util/agent_util.h
jdk/src/demo/share/jvmti/compiledMethodLoad/README.txt
jdk/src/demo/share/jvmti/compiledMethodLoad/compiledMethodLoad.c
jdk/src/demo/share/jvmti/compiledMethodLoad/sample.makefile.txt
jdk/src/demo/share/jvmti/gctest/README.txt
jdk/src/demo/share/jvmti/gctest/gctest.c
jdk/src/demo/share/jvmti/gctest/sample.makefile.txt
jdk/src/demo/share/jvmti/heapTracker/HeapTracker.java
jdk/src/demo/share/jvmti/heapTracker/README.txt
jdk/src/demo/share/jvmti/heapTracker/heapTracker.c
jdk/src/demo/share/jvmti/heapTracker/heapTracker.h
jdk/src/demo/share/jvmti/heapTracker/sample.makefile.txt
jdk/src/demo/share/jvmti/heapViewer/README.txt
jdk/src/demo/share/jvmti/heapViewer/heapViewer.c
jdk/src/demo/share/jvmti/heapViewer/sample.makefile.txt
jdk/src/demo/share/jvmti/index.html
jdk/src/demo/share/jvmti/java_crw_demo/README.txt
jdk/src/demo/share/jvmti/java_crw_demo/java_crw_demo.c
jdk/src/demo/share/jvmti/java_crw_demo/java_crw_demo.h
jdk/src/demo/share/jvmti/java_crw_demo/sample.makefile.txt
jdk/src/demo/share/jvmti/minst/Minst.java
jdk/src/demo/share/jvmti/minst/README.txt
jdk/src/demo/share/jvmti/minst/minst.c
jdk/src/demo/share/jvmti/minst/minst.h
jdk/src/demo/share/jvmti/minst/sample.makefile.txt
jdk/src/demo/share/jvmti/mtrace/Mtrace.java
jdk/src/demo/share/jvmti/mtrace/README.txt
jdk/src/demo/share/jvmti/mtrace/mtrace.c
jdk/src/demo/share/jvmti/mtrace/mtrace.h
jdk/src/demo/share/jvmti/mtrace/sample.makefile.txt
jdk/src/demo/share/jvmti/versionCheck/README.txt
jdk/src/demo/share/jvmti/versionCheck/sample.makefile.txt
jdk/src/demo/share/jvmti/versionCheck/versionCheck.c
jdk/src/demo/share/jvmti/waiters/Agent.cpp
jdk/src/demo/share/jvmti/waiters/Agent.hpp
jdk/src/demo/share/jvmti/waiters/Monitor.cpp
jdk/src/demo/share/jvmti/waiters/Monitor.hpp
jdk/src/demo/share/jvmti/waiters/README.txt
jdk/src/demo/share/jvmti/waiters/Thread.cpp
jdk/src/demo/share/jvmti/waiters/Thread.hpp
jdk/src/demo/share/jvmti/waiters/sample.makefile.txt
jdk/src/demo/share/jvmti/waiters/waiters.cpp
jdk/src/demo/share/management/FullThreadDump/Deadlock.java
jdk/src/demo/share/management/FullThreadDump/FullThreadDump.java
jdk/src/demo/share/management/FullThreadDump/README.txt
jdk/src/demo/share/management/FullThreadDump/ThreadMonitor.java
jdk/src/demo/share/management/JTop/JTop.java
jdk/src/demo/share/management/JTop/JTopPlugin.java
jdk/src/demo/share/management/JTop/META-INF/services/com.sun.tools.jconsole.JConsolePlugin
jdk/src/demo/share/management/JTop/README.txt
jdk/src/demo/share/management/MemoryMonitor/MemoryMonitor.java
jdk/src/demo/share/management/MemoryMonitor/README.txt
jdk/src/demo/share/management/VerboseGC/PrintGCStat.java
jdk/src/demo/share/management/VerboseGC/README.txt
jdk/src/demo/share/management/VerboseGC/VerboseGC.java
jdk/src/demo/share/management/index.html
jdk/src/demo/share/scripting/jconsole-plugin/README.txt
jdk/src/demo/share/scripting/jconsole-plugin/build.xml
jdk/src/demo/share/scripting/jconsole-plugin/src/META-INF/services/com.sun.tools.jconsole.JConsolePlugin
jdk/src/demo/share/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/EditableAtEndDocument.java
jdk/src/demo/share/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/ScriptJConsolePlugin.java
jdk/src/demo/share/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/ScriptShellPanel.java
jdk/src/demo/share/scripting/jconsole-plugin/src/resources/jconsole.js
jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/heapdump.js
jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/hello.js
jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/invoke.js
jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/jstack.js
jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/jtop.js
jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/sysprops.js
jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/verbose.js
jdk/src/demo/solaris/jni/Poller/Client.java
jdk/src/demo/solaris/jni/Poller/LinkedQueue.java
jdk/src/demo/solaris/jni/Poller/Poller.c
jdk/src/demo/solaris/jni/Poller/Poller.java
jdk/src/demo/solaris/jni/Poller/PollingServer.java
jdk/src/demo/solaris/jni/Poller/README.txt
jdk/src/demo/solaris/jni/Poller/SimpleServer.java
jdk/src/sample/share/README
jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/Device.java
jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/Kettle.xml
jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/Module.java
jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/PluginChecker.java
jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/Require.java
jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/RequireContainer.java
jdk/src/sample/share/annotations/DependencyChecker/Plugins/src/plugins/BoilerPlugin.java
jdk/src/sample/share/annotations/DependencyChecker/Plugins/src/plugins/ExtendedBoilerPlugin.java
jdk/src/sample/share/annotations/DependencyChecker/Plugins/src/plugins/TimerPlugin.java
jdk/src/sample/share/annotations/Validator/src/PositiveIntegerSupplier.java
jdk/src/sample/share/annotations/Validator/src/SupplierValidator.java
jdk/src/sample/share/annotations/Validator/src/Validate.java
jdk/src/sample/share/annotations/Validator/src/Validator.java
jdk/src/sample/share/annotations/index.html
jdk/src/sample/share/forkjoin/mergesort/MergeDemo.java
jdk/src/sample/share/forkjoin/mergesort/MergeSort.java
jdk/src/sample/share/jmx/jmx-scandir/build.properties
jdk/src/sample/share/jmx/jmx-scandir/build.xml
jdk/src/sample/share/jmx/jmx-scandir/index.html
jdk/src/sample/share/jmx/jmx-scandir/logging.properties
jdk/src/sample/share/jmx/jmx-scandir/manifest.mf
jdk/src/sample/share/jmx/jmx-scandir/nbproject/file-targets.xml
jdk/src/sample/share/jmx/jmx-scandir/nbproject/jdk.xml
jdk/src/sample/share/jmx/jmx-scandir/nbproject/netbeans-targets.xml
jdk/src/sample/share/jmx/jmx-scandir/nbproject/project.xml
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/DirectoryScanner.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ResultLogManager.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanDirAgent.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanDirClient.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanDirConfig.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanManager.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanManagerMXBean.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/DirectoryScannerConfig.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/FileMatch.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/ResultLogConfig.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/ResultRecord.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/ScanManagerConfig.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/XmlConfigUtils.java
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/package.html
jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/package.html
jdk/src/sample/share/jmx/jmx-scandir/src/etc/access.properties
jdk/src/sample/share/jmx/jmx-scandir/src/etc/management.properties
jdk/src/sample/share/jmx/jmx-scandir/src/etc/password.properties
jdk/src/sample/share/jmx/jmx-scandir/src/etc/testconfig.xml
jdk/src/sample/share/jmx/jmx-scandir/test/com/sun/jmx/examples/scandir/DirectoryScannerTest.java
jdk/src/sample/share/jmx/jmx-scandir/test/com/sun/jmx/examples/scandir/ScanDirConfigTest.java
jdk/src/sample/share/jmx/jmx-scandir/test/com/sun/jmx/examples/scandir/ScanManagerTest.java
jdk/src/sample/share/jmx/jmx-scandir/test/com/sun/jmx/examples/scandir/TestUtils.java
jdk/src/sample/share/jmx/jmx-scandir/test/com/sun/jmx/examples/scandir/config/XmlConfigUtilsTest.java
jdk/src/sample/share/lambda/BulkDataOperations/index.html
jdk/src/sample/share/lambda/BulkDataOperations/src/CSVProcessor.java
jdk/src/sample/share/lambda/BulkDataOperations/src/Grep.java
jdk/src/sample/share/lambda/BulkDataOperations/src/PasswordGenerator.java
jdk/src/sample/share/lambda/BulkDataOperations/src/WC.java
jdk/src/sample/share/lambda/DefaultMethods/ArrayIterator.java
jdk/src/sample/share/lambda/DefaultMethods/DiamondInheritance.java
jdk/src/sample/share/lambda/DefaultMethods/Inheritance.java
jdk/src/sample/share/lambda/DefaultMethods/MixIn.java
jdk/src/sample/share/lambda/DefaultMethods/Reflection.java
jdk/src/sample/share/lambda/DefaultMethods/SimplestUsage.java
jdk/src/sample/share/nbproject/project.xml
jdk/src/sample/share/nio/chatserver/ChatServer.java
jdk/src/sample/share/nio/chatserver/Client.java
jdk/src/sample/share/nio/chatserver/ClientReader.java
jdk/src/sample/share/nio/chatserver/DataReader.java
jdk/src/sample/share/nio/chatserver/MessageReader.java
jdk/src/sample/share/nio/chatserver/NameReader.java
jdk/src/sample/share/nio/chatserver/README.txt
jdk/src/sample/share/nio/file/AclEdit.java
jdk/src/sample/share/nio/file/Chmod.java
jdk/src/sample/share/nio/file/Copy.java
jdk/src/sample/share/nio/file/DiskUsage.java
jdk/src/sample/share/nio/file/FileType.java
jdk/src/sample/share/nio/file/WatchDir.java
jdk/src/sample/share/nio/file/Xdd.java
jdk/src/sample/share/nio/multicast/MulticastAddress.java
jdk/src/sample/share/nio/multicast/Reader.java
jdk/src/sample/share/nio/multicast/Sender.java
jdk/src/sample/share/nio/server/AcceptHandler.java
jdk/src/sample/share/nio/server/Acceptor.java
jdk/src/sample/share/nio/server/B1.java
jdk/src/sample/share/nio/server/BN.java
jdk/src/sample/share/nio/server/BP.java
jdk/src/sample/share/nio/server/ChannelIO.java
jdk/src/sample/share/nio/server/ChannelIOSecure.java
jdk/src/sample/share/nio/server/Content.java
jdk/src/sample/share/nio/server/Dispatcher.java
jdk/src/sample/share/nio/server/Dispatcher1.java
jdk/src/sample/share/nio/server/DispatcherN.java
jdk/src/sample/share/nio/server/FileContent.java
jdk/src/sample/share/nio/server/Handler.java
jdk/src/sample/share/nio/server/MalformedRequestException.java
jdk/src/sample/share/nio/server/N1.java
jdk/src/sample/share/nio/server/N2.java
jdk/src/sample/share/nio/server/README.txt
jdk/src/sample/share/nio/server/Reply.java
jdk/src/sample/share/nio/server/Request.java
jdk/src/sample/share/nio/server/RequestHandler.java
jdk/src/sample/share/nio/server/RequestServicer.java
jdk/src/sample/share/nio/server/Sendable.java
jdk/src/sample/share/nio/server/Server.java
jdk/src/sample/share/nio/server/StringContent.java
jdk/src/sample/share/nio/server/URLDumper.java
jdk/src/sample/share/scripting/scriptpad/README.txt
jdk/src/sample/share/scripting/scriptpad/build.properties
jdk/src/sample/share/scripting/scriptpad/build.xml
jdk/src/sample/share/scripting/scriptpad/nbproject/file-targets.xml
jdk/src/sample/share/scripting/scriptpad/nbproject/jdk.xml
jdk/src/sample/share/scripting/scriptpad/nbproject/netbeans-targets.xml
jdk/src/sample/share/scripting/scriptpad/nbproject/project.xml
jdk/src/sample/share/scripting/scriptpad/src/META-INF/manifest.mf
jdk/src/sample/share/scripting/scriptpad/src/com/sun/sample/scriptpad/Main.java
jdk/src/sample/share/scripting/scriptpad/src/resources/Main.js
jdk/src/sample/share/scripting/scriptpad/src/resources/conc.js
jdk/src/sample/share/scripting/scriptpad/src/resources/gui.js
jdk/src/sample/share/scripting/scriptpad/src/resources/mm.js
jdk/src/sample/share/scripting/scriptpad/src/resources/scriptpad.js
jdk/src/sample/share/scripting/scriptpad/src/scripts/README.txt
jdk/src/sample/share/scripting/scriptpad/src/scripts/browse.js
jdk/src/sample/share/scripting/scriptpad/src/scripts/insertfile.js
jdk/src/sample/share/scripting/scriptpad/src/scripts/linewrap.js
jdk/src/sample/share/scripting/scriptpad/src/scripts/mail.js
jdk/src/sample/share/scripting/scriptpad/src/scripts/memmonitor.js
jdk/src/sample/share/scripting/scriptpad/src/scripts/memory.bat
jdk/src/sample/share/scripting/scriptpad/src/scripts/memory.js
jdk/src/sample/share/scripting/scriptpad/src/scripts/memory.sh
jdk/src/sample/share/scripting/scriptpad/src/scripts/textcolor.js
jdk/src/sample/share/try-with-resources/index.html
jdk/src/sample/share/try-with-resources/src/CustomAutoCloseableSample.java
jdk/src/sample/share/try-with-resources/src/Unzip.java
jdk/src/sample/share/try-with-resources/src/ZipCat.java
jdk/src/sample/share/vm/clr-jvm/Makefile
jdk/src/sample/share/vm/clr-jvm/README.txt
jdk/src/sample/share/vm/clr-jvm/invoked.java
jdk/src/sample/share/vm/clr-jvm/invoker.cs
jdk/src/sample/share/vm/clr-jvm/jinvoker.cpp
jdk/src/sample/share/vm/clr-jvm/jinvokerExp.h
jdk/src/sample/share/vm/jvm-clr/Makefile
jdk/src/sample/share/vm/jvm-clr/README.txt
jdk/src/sample/share/vm/jvm-clr/invoked.cs
jdk/src/sample/share/vm/jvm-clr/invoker.cpp
jdk/src/sample/share/vm/jvm-clr/invoker.h
jdk/src/sample/share/vm/jvm-clr/invoker.java
jdk/src/sample/share/vm/jvm-clr/invokerExp.h
jdk/src/sample/solaris/dtrace/README.txt
jdk/src/sample/solaris/dtrace/helpers/dtrace_helper.d
jdk/src/sample/solaris/dtrace/hotspot/README.txt
jdk/src/sample/solaris/dtrace/hotspot/class_loading_stat.d
jdk/src/sample/solaris/dtrace/hotspot/gc_time_stat.d
jdk/src/sample/solaris/dtrace/hotspot/hotspot_calls_tree.d
jdk/src/sample/solaris/dtrace/hotspot/method_compile_stat.d
jdk/src/sample/solaris/dtrace/hotspot/method_invocation_stat.d
jdk/src/sample/solaris/dtrace/hotspot/method_invocation_stat_filter.d
jdk/src/sample/solaris/dtrace/hotspot/method_invocation_tree.d
jdk/src/sample/solaris/dtrace/hotspot/monitors.d
jdk/src/sample/solaris/dtrace/hotspot/object_allocation_stat.d
jdk/src/sample/solaris/dtrace/hotspot_jni/CriticalSection.d
jdk/src/sample/solaris/dtrace/hotspot_jni/CriticalSection_slow.d
jdk/src/sample/solaris/dtrace/hotspot_jni/README.txt
jdk/src/sample/solaris/dtrace/hotspot_jni/hotspot_jni_calls_stat.d
jdk/src/sample/solaris/dtrace/hotspot_jni/hotspot_jni_calls_tree.d
jdk/test/java/time/TEST.properties
jdk/test/jdk/asm/AsmSanity.java
--- a/jdk/make/CompileDemos.gmk	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/make/CompileDemos.gmk	Fri Apr 21 03:34:11 2017 +0000
@@ -263,239 +263,13 @@
     MAIN_CLASS := transparentruler.Ruler, \
 ))
 
-$(eval $(call SetupBuildDemo, jconsole-plugin, \
-    DEMO_SUBDIR := scripting, \
-    SRC_SUB_DIR := src, \
-    MAIN_CLASS := NONE, \
-))
-
-$(eval $(call SetupBuildDemo, FullThreadDump, \
-    DEMO_SUBDIR := management, \
-))
-
-$(eval $(call SetupBuildDemo, JTop, \
-    DEMO_SUBDIR := management, \
-))
-
-$(eval $(call SetupBuildDemo, MemoryMonitor, \
-    DEMO_SUBDIR := management, \
-))
-
-$(eval $(call SetupBuildDemo, VerboseGC, \
-    DEMO_SUBDIR := management, \
-))
-
-################################################################################
-# Build JVMTI demos.
-
-# Setup make rules for building a JVMTI demo.
-#
-# Parameter 1 is the name of the rule. This name is used as variable prefix,
-# and the targets generated are listed in a variable by that name.
-#
-# Remaining parameters are named arguments. These include:
-# EXTRA_SRC_SUBDIR   Also include these subdirectories
-# TOOLCHAIN   Optionally specify toolchain to use
-SetupBuildJvmtiDemo = $(NamedParamsMacroTemplate)
-define SetupBuildJvmtiDemoBody
-  $1_SRC := \
-      $(DEMO_SHARE_SRC)/jvmti/$1 \
-      $$(wildcard $$(addprefix $(DEMO_SHARE_SRC)/jvmti/, \
-          agent_util $$($1_EXTRA_SRC_SUBDIR)))
-
-  ### Build the native lib
-  $1_CFLAGS_INCLUDE := $$(addprefix -I, $$($1_SRC))
-
-  $1_CXXFLAGS := $$($1_CFLAGS_INCLUDE) $(CXXFLAGS_JDKLIB) $(CXXFLAGS_DEBUG_SYMBOLS)
-
-  ifeq ($$($1_TOOLCHAIN), TOOLCHAIN_LINK_CXX)
-    # For C++, we also need some special treatment.
-    $1_LDFLAGS := $$(LDFLAGS_CXX_JDK)
-    $1_LIBS := $(LIBCXX)
-
-    ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
-      $1_CXXFLAGS := $$(filter-out -xregs=no%appl, $$($1_CXXFLAGS))
-    endif
-  endif
-
-  # Remove the -incremental:no setting to get .ilk-files like in the old build.
-  $$(eval $$(call SetupNativeCompilation, BUILD_DEMO_JVMTI_NATIVE_$1, \
-      SRC := $$($1_SRC), \
-      TOOLCHAIN := $$($1_TOOLCHAIN), \
-      OPTIMIZATION := LOW, \
-      CFLAGS := $$($1_CFLAGS_INCLUDE) $$(CFLAGS_JDKLIB) $$(CFLAGS_DEBUG_SYMBOLS), \
-      CXXFLAGS := $$($1_CXXFLAGS), \
-      LDFLAGS := $(filter-out -incremental:no -opt:ref, $$(LDFLAGS_JDKLIB)) \
-          $$($1_LDFLAGS), \
-      LDFLAGS_macosx := $$(call SET_EXECUTABLE_ORIGIN), \
-      LIBS := $$($1_LIBS), \
-      LIBS_solaris := -lc, \
-      VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-      RC_FLAGS := $$(RC_FLAGS) \
-          -D "JDK_FNAME=$1.dll" \
-          -D "JDK_INTERNAL_NAME=$1" \
-          -D "JDK_FTYPE=0x2L", \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/demos/native/jvmti/$1, \
-      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/demos/image/jvmti/$1/lib, \
-      LIBRARY := $1, \
-      STRIP_SYMBOLS := false, \
-  ))
-
-  $1 += $$(BUILD_DEMO_JVMTI_NATIVE_$1)
-
-  ### Build the jar, if we have java sources
-  ifneq ($$(wildcard $(DEMO_SHARE_SRC)/jvmti/$1/*.java), )
-    $$(eval $$(call SetupJavaCompilation, BUILD_DEMO_JVMTI_JAVA_$1, \
-        SETUP := GENERATE_USINGJDKBYTECODE, \
-        SRC := $(DEMO_SHARE_SRC)/jvmti/$1, \
-        BIN := $(SUPPORT_OUTPUTDIR)/demos/classes/jvmti/$1, \
-        COPY := $(COPY_TO_JAR), \
-        JAR := $(SUPPORT_OUTPUTDIR)/demos/image/jvmti/$1/$1.jar, \
-        EXTRA_MANIFEST_ATTR := Main-Class: \n, \
-        MANIFEST := $(DEMO_MANIFEST), \
-    ))
-
-    $1 += $$(BUILD_DEMO_JVMTI_JAVA_$1_JAR)
-  endif
-
-  ### Build the source zip
-  $1_EXCLUDE_FILES := \
-      $$(wildcard $$(patsubst %, $(DEMO_SHARE_SRC)/jvmti/%/README.txt, \
-          agent_util $$($1_EXTRA_SRC_SUBDIR))) \
-      $$(wildcard $$(patsubst %, $(DEMO_SHARE_SRC)/jvmti/%/sample.makefile.txt, \
-          agent_util $$($1_EXTRA_SRC_SUBDIR)))
-
-  $$(eval $$(call SetupZipArchive, BUILD_DEMO_JVMTI_SRC_$1, \
-      SRC := $$($1_SRC), \
-      EXCLUDE_FILES := $$($1_EXCLUDE_FILES), \
-      ZIP := $(SUPPORT_OUTPUTDIR)/demos/image/jvmti/$1/src.zip, \
-  ))
-
-  $1 += $$(BUILD_DEMO_JVMTI_SRC_$1)
-
-  # Copy files to image
-  $(SUPPORT_OUTPUTDIR)/demos/image/jvmti/$1/README.txt: $(DEMO_SHARE_SRC)/jvmti/$1/README.txt
-	$$(call install-file)
-	$(CHMOD) -f ug+w $$@
-
-  $1 += $(SUPPORT_OUTPUTDIR)/demos/image/jvmti/$1/README.txt
-
-  ifeq ($(OPENJDK_TARGET_OS), windows)
-    # These lib and exp files normally end up in OBJECT_DIR but for demos they
-    # are supposed to be included in the distro. Since they are created as
-    # a side-effect of the library compilation, make does not know about them.
-    $1_SUPPORT_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/demos/native/jvmti/$1
-    $1_IMAGE_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/demos/image/jvmti/$1/lib
-
-    $$($1_SUPPORT_OUTPUTDIR)/$1.lib: $$(BUILD_DEMO_JVMTI_NATIVE_$1)
-
-    $$($1_SUPPORT_OUTPUTDIR)/$1.exp: $$(BUILD_DEMO_JVMTI_NATIVE_$1)
-
-    $$($1_IMAGE_OUTPUTDIR)/$1.lib: $$($1_SUPPORT_OUTPUTDIR)/$1.lib
-	$$(call install-file)
-
-    $$($1_IMAGE_OUTPUTDIR)/$1.exp: $$($1_SUPPORT_OUTPUTDIR)/$1.exp
-	$$(call install-file)
-
-    $1 += $$($1_IMAGE_OUTPUTDIR)/$1.lib $$($1_IMAGE_OUTPUTDIR)/$1.exp
-  endif
-
-  TARGETS += $$($1)
-endef
-
-$(eval $(call SetupBuildJvmtiDemo, compiledMethodLoad))
-$(eval $(call SetupBuildJvmtiDemo, gctest))
-$(eval $(call SetupBuildJvmtiDemo, heapViewer))
-$(eval $(call SetupBuildJvmtiDemo, versionCheck))
-
-$(eval $(call SetupBuildJvmtiDemo, heapTracker, \
-    EXTRA_SRC_SUBDIR := java_crw_demo, \
-))
-
-$(eval $(call SetupBuildJvmtiDemo, minst, \
-    EXTRA_SRC_SUBDIR := java_crw_demo, \
-))
-
-$(eval $(call SetupBuildJvmtiDemo, mtrace, \
-    EXTRA_SRC_SUBDIR := java_crw_demo, \
-))
-
-$(eval $(call SetupBuildJvmtiDemo, waiters, \
-    TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
-))
-
-################################################################################
-# Build the Poller demo (on Solaris only).
-
-ifeq ($(OPENJDK_TARGET_OS), solaris)
-  DEMO_SOLARIS_SRC := $(JDK_TOPDIR)/src/demo/solaris
-
-  $(eval $(call SetupJavaCompilation, BUILD_DEMO_JAVA_Poller, \
-      SETUP := GENERATE_USINGJDKBYTECODE, \
-      SRC := $(DEMO_SOLARIS_SRC)/jni/Poller, \
-      BIN := $(SUPPORT_OUTPUTDIR)/demos/classes/jni/Poller, \
-      HEADERS := $(SUPPORT_OUTPUTDIR)/demos/classes/jni/Poller, \
-      JAR := $(SUPPORT_OUTPUTDIR)/demos/image/jni/Poller/Poller.jar, \
-      MANIFEST := $(SUPPORT_OUTPUTDIR)/demos/java-main-manifest.mf, \
-      SRCZIP := $(SUPPORT_OUTPUTDIR)/demos/image/jni/Poller/src.zip, \
-      COPY := README.txt Poller.c, \
-      JARMAIN := Client, \
-  ))
-
-  TARGETS += $(BUILD_DEMO_JAVA_Poller)
-
-  $(eval $(call SetupNativeCompilation, BUILD_DEMO_NATIVE_Poller, \
-      SRC := $(DEMO_SOLARIS_SRC)/jni/Poller, \
-      OPTIMIZATION := LOW, \
-      CFLAGS := $(CFLAGS_JDKLIB) \
-          -I$(SUPPORT_OUTPUTDIR)/demos/classes/jni/Poller, \
-      LDFLAGS := $(LDFLAGS_JDKLIB), \
-      LIBS_solaris := -lc, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/demos/native/jni/Poller, \
-      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/demos/native, \
-      LIBRARY := Poller, \
-      STRIP_SYMBOLS := false, \
-  ))
-
-  TARGETS += $(BUILD_DEMO_NATIVE_Poller)
-
-  # We can only compile native code after java has been compiled (since we
-  # depend on generated .h files)
-  $(SUPPORT_OUTPUTDIR)/demos/native/jni/Poller/Poller.o: \
-      $(BUILD_DEMO_JAVA_Poller)
-
-  # Copy to image
-  $(SUPPORT_OUTPUTDIR)/demos/image/jni/Poller/README.txt: \
-      $(DEMO_SOLARIS_SRC)/jni/Poller/README.txt
-	$(call install-file)
-	$(CHMOD) -f ug+w $@
-
-  TARGETS += $(SUPPORT_OUTPUTDIR)/demos/image/jni/Poller/README.txt
-
-  $(SUPPORT_OUTPUTDIR)/demos/image/jni/Poller/lib/libPoller.so: \
-      $(SUPPORT_OUTPUTDIR)/demos/native/libPoller.so
-	$(call install-file)
-
-  TARGETS += $(SUPPORT_OUTPUTDIR)/demos/image/jni/Poller/lib/libPoller.so
-endif
-
 ################################################################################
 # Copy html and README files.
 
-$(SUPPORT_OUTPUTDIR)/demos/image/management/index.html: $(DEMO_SHARE_SRC)/management/index.html
-	$(call install-file)
-	$(CHMOD) -f ug+w $@
-
-$(SUPPORT_OUTPUTDIR)/demos/image/jvmti/index.html: $(DEMO_SHARE_SRC)/jvmti/index.html
-	$(call install-file)
-	$(CHMOD) -f ug+w $@
-
 $(SUPPORT_OUTPUTDIR)/demos/image/README: $(DEMO_SHARE_SRC)/README
 	$(call install-file)
 
-TARGETS += $(SUPPORT_OUTPUTDIR)/demos/image/management/index.html \
-    $(SUPPORT_OUTPUTDIR)/demos/image/jvmti/index.html \
-    $(SUPPORT_OUTPUTDIR)/demos/image/README
+TARGETS += $(SUPPORT_OUTPUTDIR)/demos/image/README
 
 ################################################################################
 # Copy netbeans project files.
--- a/jdk/make/CompileTools.gmk	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/make/CompileTools.gmk	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,19 @@
 include JavaCompilation.gmk
 include SetupJavaCompilers.gmk
 
+$(eval $(call IncludeCustomExtension, jdk, CompileTools.gmk))
+
 ################################################################################
 
+# Use += to be able to add to this from a custom extension
+BUILD_TOOLS_SRC_DIRS += \
+    $(JDK_TOPDIR)/make/src/classes \
+    $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes \
+    #
+
 $(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \
     SETUP := GENERATE_OLDBYTECODE, \
-    SRC := $(JDK_TOPDIR)/make/src/classes $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes, \
+    SRC := $(BUILD_TOOLS_SRC_DIRS), \
     EXCLUDES := build/tools/deps \
                 build/tools/jigsaw, \
     BIN := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes))
--- a/jdk/make/CopySamples.gmk	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-default: all
-
-include $(SPEC)
-include MakeBase.gmk
-
-################################################################################
-
-SAMPLE_TARGET_DIR := $(SUPPORT_OUTPUTDIR)/sample/image
-SAMPLE_SOURCE_DIR := $(JDK_TOPDIR)/src/sample/share
-SAMPLE_SOLARIS_SOURCE_DIR := $(JDK_TOPDIR)/src/sample/solaris
-
-# Exclude the vm directory
-$(eval $(call SetupCopyFiles, COPY_SHARE_SAMPLES, \
-    SRC := $(SAMPLE_SOURCE_DIR), \
-    DEST := $(SAMPLE_TARGET_DIR), \
-    FILES := $(filter-out $(SAMPLE_SOURCE_DIR)/vm/%, \
-        $(call CacheFind, $(SAMPLE_SOURCE_DIR))), \
-))
-
-TARGETS += $(COPY_SHARE_SAMPLES)
-
-ifneq (, $(filter $(OPENJDK_TARGET_OS), solaris macosx))
-  $(eval $(call SetupCopyFiles, COPY_SOLARIS_SAMPLES, \
-      SRC := $(SAMPLE_SOLARIS_SOURCE_DIR), \
-      DEST := $(SAMPLE_TARGET_DIR), \
-      FILES := $(call CacheFind, $(SAMPLE_SOLARIS_SOURCE_DIR)), \
-  ))
-
-  TARGETS += $(COPY_SOLARIS_SAMPLES)
-endif
-
-################################################################################
-
-$(eval $(call IncludeCustomExtension, jdk, CopySamples.gmk))
-
-################################################################################
-
-all: $(TARGETS)
-
-.PHONY: all default
--- a/jdk/make/Tools.gmk	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/make/Tools.gmk	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,9 @@
 
 include JavaCompilation.gmk
 
+# Hook to include the corresponding custom file, if present.
+$(eval $(call IncludeCustomExtension, jdk, Tools.gmk))
+
 ################################################################################
 # To avoid reevaluating the compilation setup for the tools each time this file
 # is included, the actual compilation is handled by CompileTools.gmk. The
--- a/jdk/src/demo/share/README	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/demo/share/README	Fri Apr 21 03:34:11 2017 +0000
@@ -1,4 +1,4 @@
-The source code provided with samples and demos for the JDK is meant
+The source code provided with demos for the JDK is meant
 to illustrate the usage of a given feature or technique and has been
 deliberately simplified. Additional steps required for a
 production-quality application, such as security checks, input
--- a/jdk/src/demo/share/jvmti/agent_util/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#
-# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-agent_util sources
-
-Just some shared generic source used by several of the demos.
-
--- a/jdk/src/demo/share/jvmti/agent_util/agent_util.c	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,309 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include <agent_util.h>
-
-/* ------------------------------------------------------------------- */
-/* Generic C utility functions */
-
-/* Send message to stdout or whatever the data output location is */
-void
-stdout_message(const char * format, ...)
-{
-    va_list ap;
-
-    va_start(ap, format);
-    (void)vfprintf(stdout, format, ap);
-    va_end(ap);
-}
-
-/* Send message to stderr or whatever the error output location is and exit  */
-void
-fatal_error(const char * format, ...)
-{
-    va_list ap;
-
-    va_start(ap, format);
-    (void)vfprintf(stderr, format, ap);
-    (void)fflush(stderr);
-    va_end(ap);
-    exit(3);
-}
-
-/* Get a token from a string (strtok is not MT-safe)
- *    str       String to scan
- *    seps      Separation characters
- *    buf       Place to put results
- *    max       Size of buf
- *  Returns NULL if no token available or can't do the scan.
- */
-char *
-get_token(char *str, char *seps, char *buf, int max)
-{
-    int len;
-
-    buf[0] = 0;
-    if ( str==NULL || str[0]==0 ) {
-        return NULL;
-    }
-    str += strspn(str, seps);
-    if ( str[0]==0 ) {
-        return NULL;
-    }
-    len = (int)strcspn(str, seps);
-    if ( len >= max ) {
-        return NULL;
-    }
-    (void)strncpy(buf, str, len);
-    buf[len] = 0;
-    return str+len;
-}
-
-/* Determines if a class/method is specified by a list item
- *   item       String that represents a pattern to match
- *                If it starts with a '*', then any class is allowed
- *                If it ends with a '*', then any method is allowed
- *   cname      Class name, e.g. "java.lang.Object"
- *   mname      Method name, e.g. "<init>"
- *  Returns 1(true) or 0(false).
- */
-static int
-covered_by_list_item(char *item, char *cname, char *mname)
-{
-    int      len;
-
-    len = (int)strlen(item);
-    if ( item[0]=='*' ) {
-        if ( strncmp(mname, item+1, len-1)==0 ) {
-            return 1;
-        }
-    } else if ( item[len-1]=='*' ) {
-        if ( strncmp(cname, item, len-1)==0 ) {
-            return 1;
-        }
-    } else {
-        int cname_len;
-
-        cname_len = (int)strlen(cname);
-        if ( strncmp(cname, item, (len>cname_len?cname_len:len))==0 ) {
-            if ( cname_len >= len ) {
-                /* No method name supplied in item, we must have matched */
-                return 1;
-            } else {
-                int mname_len;
-
-                mname_len = (int)strlen(mname);
-                item += cname_len+1;
-                len -= cname_len+1;
-                if ( strncmp(mname, item, (len>mname_len?mname_len:len))==0 ) {
-                    return 1;
-                }
-            }
-        }
-    }
-    return 0;
-}
-
-/* Determines if a class/method is specified by this list
- *   list       String of comma separated pattern items
- *   cname      Class name, e.g. "java.lang.Object"
- *   mname      Method name, e.g. "<init>"
- *  Returns 1(true) or 0(false).
- */
-static int
-covered_by_list(char *list, char *cname, char *mname)
-{
-    char  token[1024];
-    char *next;
-
-    if ( list[0] == 0 ) {
-        return 0;
-    }
-
-    next = get_token(list, ",", token, sizeof(token));
-    while ( next != NULL ) {
-        if ( covered_by_list_item(token, cname, mname) ) {
-            return 1;
-        }
-        next = get_token(next, ",", token, sizeof(token));
-    }
-    return 0;
-}
-
-/* Determines which class and methods we are interested in
- *   cname              Class name, e.g. "java.lang.Object"
- *   mname              Method name, e.g. "<init>"
- *   include_list       Empty or an explicit list for inclusion
- *   exclude_list       Empty or an explicit list for exclusion
- *  Returns 1(true) or 0(false).
- */
-int
-interested(char *cname, char *mname, char *include_list, char *exclude_list)
-{
-    if ( exclude_list!=NULL && exclude_list[0]!=0 &&
-            covered_by_list(exclude_list, cname, mname) ) {
-        return 0;
-    }
-    if ( include_list!=NULL && include_list[0]!=0 &&
-            !covered_by_list(include_list, cname, mname) ) {
-        return 0;
-    }
-    return 1;
-}
-
-/* ------------------------------------------------------------------- */
-/* Generic JVMTI utility functions */
-
-/* Every JVMTI interface returns an error code, which should be checked
- *   to avoid any cascading errors down the line.
- *   The interface GetErrorName() returns the actual enumeration constant
- *   name, making the error messages much easier to understand.
- */
-void
-check_jvmti_error(jvmtiEnv *jvmti, jvmtiError errnum, const char *str)
-{
-    if ( errnum != JVMTI_ERROR_NONE ) {
-        char       *errnum_str;
-
-        errnum_str = NULL;
-        (void)(*jvmti)->GetErrorName(jvmti, errnum, &errnum_str);
-
-        fatal_error("ERROR: JVMTI: %d(%s): %s\n", errnum,
-                (errnum_str==NULL?"Unknown":errnum_str),
-                (str==NULL?"":str));
-    }
-}
-
-/* All memory allocated by JVMTI must be freed by the JVMTI Deallocate
- *   interface.
- */
-void
-deallocate(jvmtiEnv *jvmti, void *ptr)
-{
-    jvmtiError error;
-
-    error = (*jvmti)->Deallocate(jvmti, ptr);
-    check_jvmti_error(jvmti, error, "Cannot deallocate memory");
-}
-
-/* Allocation of JVMTI managed memory */
-void *
-allocate(jvmtiEnv *jvmti, jint len)
-{
-    jvmtiError error;
-    void      *ptr;
-
-    error = (*jvmti)->Allocate(jvmti, len, (unsigned char **)&ptr);
-    check_jvmti_error(jvmti, error, "Cannot allocate memory");
-    return ptr;
-}
-
-/* Add demo jar file to boot class path (the BCI Tracker class must be
- *     in the boot classpath)
- *
- *   WARNING: This code assumes that the jar file can be found at one of:
- *              ${JAVA_HOME}/demo/jvmti/${DEMO_NAME}/${DEMO_NAME}.jar
- *              ${JAVA_HOME}/../demo/jvmti/${DEMO_NAME}/${DEMO_NAME}.jar
- *            where JAVA_HOME may refer to the jre directory.
- *            Both these values are added to the boot classpath.
- *            These locations are only true for these demos, installed
- *            in the JDK area. Platform specific code could be used to
- *            find the location of the DLL or .so library, and construct a
- *            path name to the jar file, relative to the library location.
- */
-void
-add_demo_jar_to_bootclasspath(jvmtiEnv *jvmti, char *demo_name)
-{
-    jvmtiError error;
-    char      *file_sep;
-    int        max_len;
-    char      *java_home;
-    char       jar_path[FILENAME_MAX+1];
-
-    java_home = NULL;
-    error = (*jvmti)->GetSystemProperty(jvmti, "java.home", &java_home);
-    check_jvmti_error(jvmti, error, "Cannot get java.home property value");
-    if ( java_home == NULL || java_home[0] == 0 ) {
-        fatal_error("ERROR: Java home not found\n");
-    }
-
-#ifdef WIN32
-    file_sep = "\\";
-#else
-    file_sep = "/";
-#endif
-
-    max_len = (int)(strlen(java_home) + strlen(demo_name)*2 +
-                         strlen(file_sep)*5 +
-                         16 /* ".." "demo" "jvmti" ".jar" NULL */ );
-    if ( max_len > (int)sizeof(jar_path) ) {
-        fatal_error("ERROR: Path to jar file too long\n");
-    }
-    (void)strcpy(jar_path, java_home);
-    (void)strcat(jar_path, file_sep);
-    (void)strcat(jar_path, "demo");
-    (void)strcat(jar_path, file_sep);
-    (void)strcat(jar_path, "jvmti");
-    (void)strcat(jar_path, file_sep);
-    (void)strcat(jar_path, demo_name);
-    (void)strcat(jar_path, file_sep);
-    (void)strcat(jar_path, demo_name);
-    (void)strcat(jar_path, ".jar");
-    error = (*jvmti)->AddToBootstrapClassLoaderSearch(jvmti, (const char*)jar_path);
-    check_jvmti_error(jvmti, error, "Cannot add to boot classpath");
-
-    (void)strcpy(jar_path, java_home);
-    (void)strcat(jar_path, file_sep);
-    (void)strcat(jar_path, "..");
-    (void)strcat(jar_path, file_sep);
-    (void)strcat(jar_path, "demo");
-    (void)strcat(jar_path, file_sep);
-    (void)strcat(jar_path, "jvmti");
-    (void)strcat(jar_path, file_sep);
-    (void)strcat(jar_path, demo_name);
-    (void)strcat(jar_path, file_sep);
-    (void)strcat(jar_path, demo_name);
-    (void)strcat(jar_path, ".jar");
-
-    error = (*jvmti)->AddToBootstrapClassLoaderSearch(jvmti, (const char*)jar_path);
-    check_jvmti_error(jvmti, error, "Cannot add to boot classpath");
-}
-
-/* ------------------------------------------------------------------- */
--- a/jdk/src/demo/share/jvmti/agent_util/agent_util.h	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#ifndef AGENT_UTIL_H
-#define AGENT_UTIL_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stddef.h>
-#include <stdarg.h>
-
-#include "jni.h"
-#include "jvmti.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void  stdout_message(const char * format, ...);
-void  fatal_error(const char * format, ...);
-char *get_token(char *str, char *seps, char *buf, int max);
-int   interested(char *cname, char *mname,
-                    char *include_list, char *exclude_list);
-
-void  check_jvmti_error(jvmtiEnv *jvmti, jvmtiError errnum, const char *str);
-void  deallocate(jvmtiEnv *jvmti, void *ptr);
-void *allocate(jvmtiEnv *jvmti, jint len);
-void  add_demo_jar_to_bootclasspath(jvmtiEnv *jvmti, char *demo_name);
-
-#ifdef STATIC_BUILD
-/* Macros for handling declaration of static/dynamic
- * Agent library Load/Attach/Unload functions
- *
- * DEF_Agent_OnLoad, DEF_Agent_OnAttach or DEF_Agent_OnUnload
- * generate the appropriate entrypoint names based on static
- * versus dynamic builds.
- *
- * STATIC_BUILD must be defined to build static versions of these libraries.
- * LIBRARY_NAME must be set to the name of the library for static builds.
- */
-#define ADD_LIB_NAME3(name, lib) name ## lib
-#define ADD_LIB_NAME2(name, lib) ADD_LIB_NAME3(name, lib)
-#define ADD_LIB_NAME(entry) ADD_LIB_NAME2(entry, LIBRARY_NAME)
-
-#define DEF_Agent_OnLoad \
-ADD_LIB_NAME(Agent_OnLoad_)(JavaVM *vm, char *options, void *reserved) \
-{ \
-  jint JNICALL ADD_LIB_NAME(Agent_OnLoad_dynamic_)(JavaVM *vm, char *options, void *reserved); \
-  return ADD_LIB_NAME(Agent_OnLoad_dynamic_)(vm, options, reserved); \
-} \
-jint JNICALL ADD_LIB_NAME(Agent_OnLoad_dynamic_)
-
-#define DEF_Agent_OnAttach \
-ADD_LIB_NAME(Agent_OnAttach_)(JavaVM *vm, char *options, void *reserved) \
-{ \
-  jint JNICALL ADD_LIB_NAME(Agent_OnAttach_dynamic_)(JavaVM *vm, char *options, void *reserved); \
-  return ADD_LIB_NAME(Agent_OnAttach_dynamic_)(vm, options, reserved); \
-} \
-jint JNICALL ADD_LIB_NAME(Agent_OnAttach_dynamic_)
-
-#define DEF_Agent_OnUnload \
-ADD_LIB_NAME(Agent_OnUnload_)(JavaVM *vm) \
-{ \
-  void JNICALL ADD_LIB_NAME(Agent_OnUnload_dynamic_)(JavaVM *vm); \
-  ADD_LIB_NAME(Agent_OnUnload_dynamic_)(vm); \
-} \
-void JNICALL ADD_LIB_NAME(Agent_OnUnload_dynamic_)
-
-#else
-#define DEF_Agent_OnLoad Agent_OnLoad
-#define DEF_Agent_OnAttach Agent_OnAttach
-#define DEF_Agent_OnUnload Agent_OnUnload
-#endif
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif /* __cplusplus */
-
-#endif
--- a/jdk/src/demo/share/jvmti/compiledMethodLoad/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-compiledMethodLoad
-
-This agent library traces CompiledMethodLoad events along
-with the HotSpot specific compile_info parameter.
-
-You can use this agent library as follows:
-
-    java -agentlib:compiledMethodLoad ...
-
-See ${JAVA_HOME}/demo/jvmti/index.html for help running and building agents.
-
--- a/jdk/src/demo/share/jvmti/compiledMethodLoad/compiledMethodLoad.c	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,277 +0,0 @@
-/*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "jni.h"
-#include "jvmti.h"
-#include "jvmticmlr.h"
-
-#include "agent_util.h"
-
-/* Global static data */
-static char          OUTPUT_FILE[] = "compiledMethodLoad.txt";
-static FILE         *fp;
-static jvmtiEnv     *jvmti;
-static jrawMonitorID lock;
-
-/* print a jvmtiCompiledMethodLoadDummyRecord */
-void
-print_dummy_record(jvmtiCompiledMethodLoadDummyRecord* record,
-    jvmtiEnv* jvmti, FILE* fp) {
-
-    if (record != NULL) {
-        fprintf(fp, "Dummy record detected containing message: %s\n",
-            (char *)record->message);
-    }
-}
-
-/* print the specified stack frames */
-void
-print_stack_frames(PCStackInfo* record, jvmtiEnv *jvmti, FILE* fp) {
-    if (record != NULL && record->methods != NULL) {
-        int i;
-
-        for (i = 0; i < record->numstackframes; i++) {
-            jvmtiError err;
-            char* method_name = NULL;
-            char* class_name = NULL;
-            char* method_signature = NULL;
-            char* class_signature = NULL;
-            char* generic_ptr_method = NULL;
-            char* generic_ptr_class = NULL;
-            jmethodID id;
-            jclass declaringclassptr;
-            id = record->methods[i];
-
-            err = (*jvmti)->GetMethodDeclaringClass(jvmti, id,
-                      &declaringclassptr);
-            check_jvmti_error(jvmti, err, "get method declaring class");
-
-            err = (*jvmti)->GetClassSignature(jvmti, declaringclassptr,
-                      &class_signature, &generic_ptr_class);
-            check_jvmti_error(jvmti, err, "get class signature");
-
-            err = (*jvmti)->GetMethodName(jvmti, id, &method_name,
-                      &method_signature, &generic_ptr_method);
-            check_jvmti_error(jvmti, err, "get method name");
-
-            fprintf(fp, "%s::%s %s %s @%d\n", class_signature, method_name,
-                method_signature,
-                generic_ptr_method == NULL ? "" : generic_ptr_method,
-                record->bcis[i]);
-
-            if (method_name != NULL) {
-                err = (*jvmti)->Deallocate(jvmti, (unsigned char*)method_name);
-                check_jvmti_error(jvmti, err, "deallocate method_name");
-            }
-            if (method_signature != NULL) {
-                err = (*jvmti)->Deallocate(jvmti,
-                          (unsigned char*)method_signature);
-                check_jvmti_error(jvmti, err, "deallocate method_signature");
-            }
-            if (generic_ptr_method != NULL) {
-                err = (*jvmti)->Deallocate(jvmti,
-                          (unsigned char*)generic_ptr_method);
-                check_jvmti_error(jvmti, err, "deallocate generic_ptr_method");
-            }
-            if (class_name != NULL) {
-                err = (*jvmti)->Deallocate(jvmti, (unsigned char*)class_name);
-                check_jvmti_error(jvmti, err, "deallocate class_name");
-            }
-            if (class_signature != NULL) {
-                err = (*jvmti)->Deallocate(jvmti,
-                          (unsigned char*)class_signature);
-                check_jvmti_error(jvmti, err, "deallocate class_signature");
-            }
-            if (generic_ptr_class != NULL) {
-                err = (*jvmti)->Deallocate(jvmti,
-                          (unsigned char*)generic_ptr_class);
-                check_jvmti_error(jvmti, err, "deallocate generic_ptr_class");
-            }
-        }
-    }
-}
-
-/* print a jvmtiCompiledMethodLoadInlineRecord */
-void
-print_inline_info_record(jvmtiCompiledMethodLoadInlineRecord* record,
-    jvmtiEnv *jvmti, FILE* fp) {
-
-    if (record != NULL && record->pcinfo != NULL) {
-        int numpcs = record->numpcs;
-        int i;
-
-        for (i = 0; i < numpcs; i++) {
-            PCStackInfo pcrecord = (record->pcinfo[i]);
-            fprintf(fp, "PcDescriptor(pc=%p):\n", pcrecord.pc);
-            print_stack_frames(&pcrecord, jvmti, fp);
-        }
-    }
-}
-
-/* decode kind of CompiledMethodLoadRecord and print */
-void
-print_records(jvmtiCompiledMethodLoadRecordHeader* list, jvmtiEnv *jvmti,
-    FILE* fp)
-{
-    jvmtiCompiledMethodLoadRecordHeader* curr = list;
-    fprintf(fp, "\nPrinting PC Descriptors\n\n");
-    while (curr != NULL) {
-        switch (curr->kind) {
-        case JVMTI_CMLR_DUMMY:
-            print_dummy_record((jvmtiCompiledMethodLoadDummyRecord *)curr,
-                jvmti, fp);
-            break;
-
-        case JVMTI_CMLR_INLINE_INFO:
-            print_inline_info_record(
-                (jvmtiCompiledMethodLoadInlineRecord *)curr, jvmti, fp);
-            break;
-
-        default:
-            fprintf(fp, "Warning: unrecognized record: kind=%d\n", curr->kind);
-            break;
-        }
-
-        curr = (jvmtiCompiledMethodLoadRecordHeader *)curr->next;
-    }
-}
-
-/* Callback for JVMTI_EVENT_COMPILED_METHOD_LOAD */
-void JNICALL
-compiled_method_load(jvmtiEnv *jvmti, jmethodID method, jint code_size,
-    const void* code_addr, jint map_length, const jvmtiAddrLocationMap* map,
-    const void* compile_info)
-{
-    jvmtiError err;
-    char* name = NULL;
-    char* signature = NULL;
-    char* generic_ptr = NULL;
-    jvmtiCompiledMethodLoadRecordHeader* pcs;
-
-    err = (*jvmti)->RawMonitorEnter(jvmti, lock);
-    check_jvmti_error(jvmti, err, "raw monitor enter");
-
-    err = (*jvmti)->GetMethodName(jvmti, method, &name, &signature,
-              &generic_ptr);
-    check_jvmti_error(jvmti, err, "get method name");
-
-    fprintf(fp, "\nCompiled method load event\n");
-    fprintf(fp, "Method name %s %s %s\n\n", name, signature,
-        generic_ptr == NULL ? "" : generic_ptr);
-    pcs = (jvmtiCompiledMethodLoadRecordHeader *)compile_info;
-    if (pcs != NULL) {
-        print_records(pcs, jvmti, fp);
-    }
-
-    if (name != NULL) {
-        err = (*jvmti)->Deallocate(jvmti, (unsigned char*)name);
-        check_jvmti_error(jvmti, err, "deallocate name");
-    }
-    if (signature != NULL) {
-        err = (*jvmti)->Deallocate(jvmti, (unsigned char*)signature);
-        check_jvmti_error(jvmti, err, "deallocate signature");
-    }
-    if (generic_ptr != NULL) {
-        err = (*jvmti)->Deallocate(jvmti, (unsigned char*)generic_ptr);
-        check_jvmti_error(jvmti, err, "deallocate generic_ptr");
-    }
-
-    err = (*jvmti)->RawMonitorExit(jvmti, lock);
-    check_jvmti_error(jvmti, err, "raw monitor exit");
-}
-
-/* Agent_OnLoad() is called first, we prepare for a COMPILED_METHOD_LOAD
- * event here.
- */
-JNIEXPORT jint JNICALL
-DEF_Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
-{
-    jint                rc;
-    jvmtiError          err;
-    jvmtiCapabilities   capabilities;
-    jvmtiEventCallbacks callbacks;
-
-    fp = fopen(OUTPUT_FILE, "w");
-    if (fp == NULL) {
-        fatal_error("ERROR: %s: Unable to create output file\n", OUTPUT_FILE);
-        return -1;
-    }
-
-    /* Get JVMTI environment */
-    rc = (*vm)->GetEnv(vm, (void **)&jvmti, JVMTI_VERSION);
-    if (rc != JNI_OK) {
-        fatal_error(
-            "ERROR: Unable to create jvmtiEnv, GetEnv failed, error=%d\n", rc);
-        return -1;
-    }
-
-    /* add JVMTI capabilities */
-    memset(&capabilities,0, sizeof(capabilities));
-    capabilities.can_generate_compiled_method_load_events = 1;
-    err = (*jvmti)->AddCapabilities(jvmti, &capabilities);
-    check_jvmti_error(jvmti, err, "add capabilities");
-
-    /* set JVMTI callbacks for events */
-    memset(&callbacks, 0, sizeof(callbacks));
-    callbacks.CompiledMethodLoad = &compiled_method_load;
-    err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, sizeof(callbacks));
-    check_jvmti_error(jvmti, err, "set event callbacks");
-
-    /* enable JVMTI events */
-    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                        JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL);
-    check_jvmti_error(jvmti, err, "set event notify");
-
-    /* create coordination monitor */
-    err = (*jvmti)->CreateRawMonitor(jvmti, "agent lock", &lock);
-    check_jvmti_error(jvmti, err, "create raw monitor");
-
-    return 0;
-}
-
-/* Agent_OnUnload() is called last */
-JNIEXPORT void JNICALL
-DEF_Agent_OnUnload(JavaVM *vm)
-{
-}
--- a/jdk/src/demo/share/jvmti/compiledMethodLoad/sample.makefile.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-#
-# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-########################################################################
-#
-# Sample GNU Makefile for building JVMTI Demo compiledMethodLoad
-#
-#  Example uses:    
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
-#       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
-#       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
-#
-########################################################################
-
-# Source lists
-LIBNAME=compiledMethodLoad
-SOURCES=compiledMethodLoad.c ../agent_util/agent_util.c
-
-# Solaris Studio C Compiler Version 12.4
-ifeq ($(OSNAME), solaris)
-    # Sun Solaris Compiler options needed
-    COMMON_FLAGS=-mt -KPIC
-    # Options that help find errors
-    COMMON_FLAGS+= -Xa -v -xc99=%none
-    # Check LIBARCH for any special compiler options
-    LIBARCH=$(shell uname -p)
-    ifeq ($(LIBARCH), sparc)
-        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
-    endif
-    ifeq ($(LIBARCH), sparcv9)
-        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
-    endif
-    ifeq ($(OPT), true)
-        CFLAGS=-xO2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS)
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-z defs -ztext
-    # Libraries we are dependent on
-    LIBRARIES= -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -G -o $@
-endif
-
-# Linux GNU C Compiler
-ifeq ($(OSNAME), linux)
-    # GNU Compiler options needed to build it
-    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
-    # Options that help find errors
-    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
-    ifeq ($(OPT), true)
-        CFLAGS=-O2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
-    # Libraries we are dependent on
-    LIBRARIES=-lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -shared -o $@
-endif
-
-# Windows Microsoft C/C++ Optimizing Compiler Version 12
-ifeq ($(OSNAME), win32)
-    CC=cl
-    # Compiler options needed to build it
-    COMMON_FLAGS=-Gy -DWIN32
-    # Options that help find errors
-    COMMON_FLAGS+=-W0 -WX
-    ifeq ($(OPT), true)
-        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
-    else
-        CFLAGS= -Od -Zi $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.obj)
-    # Library name and options needed to build it
-    LIBRARY=$(LIBNAME).dll
-    LDFLAGS=
-    # Libraries we are dependent on
-    LIBRARIES=
-    # Building a shared library
-    LINK_SHARED=link -dll -out:$@
-endif
-
-# Common -I options
-CFLAGS += -I.
-CFLAGS += -I../agent_util
-CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
-
-# Default rule
-all: $(LIBRARY)
-
-# Build native library
-$(LIBRARY): $(OBJECTS)
-	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
-
-# Cleanup the built bits
-clean:
-	rm -f $(LIBRARY) $(OBJECTS)
-
-# Simple tester
-test: all
-	LD_LIBRARY_PATH=`pwd` $(JDK)/bin/java -agentlib:$(LIBNAME) -version
-
-# Compilation rule only needed on Windows
-ifeq ($(OSNAME), win32)
-%.obj: %.c
-	$(COMPILE.c) $<
-endif
-
--- a/jdk/src/demo/share/jvmti/gctest/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-gctest
-
-This agent library can be used to track garbage collection events.
-
-You can use this agent library as follows:
-
-    java -agentlib:gctest ...  
-	  
-To get help on the available options try:
-
-    java -agentlib:gctest=help
-
-See ${JAVA_HOME}/demo/jvmti/index.html for help running and building agents.
-
-The Events JVMTI_EVENT_GARBAGE_COLLECTION_START,
-JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, and JVMTI_EVENT_OBJECT_FREE 
-all have limitations as to what can be called directly inside the 
-agent callback functions (e.g. no JNI calls are allowed, and limited 
-interface calls can be made). However, by using raw monitors and a separate 
-watcher thread, this agent demonstrates how these limitations can be 
-easily avoided, allowing the watcher thread to do just about anything
-after the JVMTI_EVENT_GARBAGE_COLLECTION_FINISH event.
-
--- a/jdk/src/demo/share/jvmti/gctest/gctest.c	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/* Example of using JVMTI_EVENT_GARBAGE_COLLECTION_START and
- *                  JVMTI_EVENT_GARBAGE_COLLECTION_FINISH events.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "jni.h"
-#include "jvmti.h"
-
-/* For stdout_message(), fatal_error(), and check_jvmti_error() */
-#include "agent_util.h"
-
-/* Global static data */
-static jvmtiEnv     *jvmti;
-static int           gc_count;
-static jrawMonitorID lock;
-
-/* Worker thread that waits for garbage collections */
-static void JNICALL
-worker(jvmtiEnv* jvmti, JNIEnv* jni, void *p)
-{
-    jvmtiError err;
-
-    stdout_message("GC worker started...\n");
-
-    for (;;) {
-        err = (*jvmti)->RawMonitorEnter(jvmti, lock);
-        check_jvmti_error(jvmti, err, "raw monitor enter");
-        while (gc_count == 0) {
-            err = (*jvmti)->RawMonitorWait(jvmti, lock, 0);
-            if (err != JVMTI_ERROR_NONE) {
-                err = (*jvmti)->RawMonitorExit(jvmti, lock);
-                check_jvmti_error(jvmti, err, "raw monitor wait");
-                return;
-            }
-        }
-        gc_count = 0;
-
-        err = (*jvmti)->RawMonitorExit(jvmti, lock);
-        check_jvmti_error(jvmti, err, "raw monitor exit");
-
-        /* Perform arbitrary JVMTI/JNI work here to do post-GC cleanup */
-        stdout_message("post-GarbageCollectionFinish actions...\n");
-    }
-}
-
-/* Creates a new jthread */
-static jthread
-alloc_thread(JNIEnv *env)
-{
-    jclass    thrClass;
-    jmethodID cid;
-    jthread   res;
-
-    thrClass = (*env)->FindClass(env, "java/lang/Thread");
-    if ( thrClass == NULL ) {
-        fatal_error("Cannot find Thread class\n");
-    }
-    cid      = (*env)->GetMethodID(env, thrClass, "<init>", "()V");
-    if ( cid == NULL ) {
-        fatal_error("Cannot find Thread constructor method\n");
-    }
-    res      = (*env)->NewObject(env, thrClass, cid);
-    if ( res == NULL ) {
-        fatal_error("Cannot create new Thread object\n");
-    }
-    return res;
-}
-
-/* Callback for JVMTI_EVENT_VM_INIT */
-static void JNICALL
-vm_init(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    jvmtiError err;
-
-    stdout_message("VMInit...\n");
-
-    err = (*jvmti)->RunAgentThread(jvmti, alloc_thread(env), &worker, NULL,
-        JVMTI_THREAD_MAX_PRIORITY);
-    check_jvmti_error(jvmti, err, "running agent thread");
-}
-
-/* Callback for JVMTI_EVENT_GARBAGE_COLLECTION_START */
-static void JNICALL
-gc_start(jvmtiEnv* jvmti_env)
-{
-    stdout_message("GarbageCollectionStart...\n");
-}
-
-/* Callback for JVMTI_EVENT_GARBAGE_COLLECTION_FINISH */
-static void JNICALL
-gc_finish(jvmtiEnv* jvmti_env)
-{
-    jvmtiError err;
-
-    stdout_message("GarbageCollectionFinish...\n");
-
-    err = (*jvmti)->RawMonitorEnter(jvmti, lock);
-    check_jvmti_error(jvmti, err, "raw monitor enter");
-    gc_count++;
-    err = (*jvmti)->RawMonitorNotify(jvmti, lock);
-    check_jvmti_error(jvmti, err, "raw monitor notify");
-    err = (*jvmti)->RawMonitorExit(jvmti, lock);
-    check_jvmti_error(jvmti, err, "raw monitor exit");
-}
-
-/* Agent_OnLoad() is called first, we prepare for a VM_INIT event here. */
-JNIEXPORT jint JNICALL
-DEF_Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
-{
-    jint                rc;
-    jvmtiError          err;
-    jvmtiCapabilities   capabilities;
-    jvmtiEventCallbacks callbacks;
-
-    /* Get JVMTI environment */
-    rc = (*vm)->GetEnv(vm, (void **)&jvmti, JVMTI_VERSION);
-    if (rc != JNI_OK) {
-        fatal_error("ERROR: Unable to create jvmtiEnv, rc=%d\n", rc);
-        return -1;
-    }
-
-    /* Get/Add JVMTI capabilities */
-    (void)memset(&capabilities, 0, sizeof(capabilities));
-    capabilities.can_generate_garbage_collection_events = 1;
-    err = (*jvmti)->AddCapabilities(jvmti, &capabilities);
-    check_jvmti_error(jvmti, err, "add capabilities");
-
-    /* Set callbacks and enable event notifications */
-    memset(&callbacks, 0, sizeof(callbacks));
-    callbacks.VMInit                  = &vm_init;
-    callbacks.GarbageCollectionStart  = &gc_start;
-    callbacks.GarbageCollectionFinish = &gc_finish;
-    err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, sizeof(callbacks));
-    check_jvmti_error(jvmti, err, "set event callbacks");
-    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                        JVMTI_EVENT_VM_INIT, NULL);
-    check_jvmti_error(jvmti, err, "set event notification");
-    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                        JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL);
-    check_jvmti_error(jvmti, err, "set event notification");
-    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                        JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL);
-    check_jvmti_error(jvmti, err, "set event notification");
-
-    /* Create the necessary raw monitor */
-    err = (*jvmti)->CreateRawMonitor(jvmti, "lock", &lock);
-    check_jvmti_error(jvmti, err, "create raw monitor");
-    return 0;
-}
-
-/* Agent_OnUnload() is called last */
-JNIEXPORT void JNICALL
-DEF_Agent_OnUnload(JavaVM *vm)
-{
-}
--- a/jdk/src/demo/share/jvmti/gctest/sample.makefile.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-#
-# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-########################################################################
-#
-# Sample GNU Makefile for building JVMTI Demo gctest
-#
-#  Example uses:    
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
-#       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
-#       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
-#
-########################################################################
-
-# Source lists
-LIBNAME=gctest
-SOURCES=gctest.c ../agent_util/agent_util.c
-
-# Solaris Studio C Compiler Version 12.4
-ifeq ($(OSNAME), solaris)
-    # Sun Solaris Compiler options needed
-    COMMON_FLAGS=-mt -KPIC
-    # Options that help find errors
-    COMMON_FLAGS+= -Xa -v -xc99=%none
-    # Check LIBARCH for any special compiler options
-    LIBARCH=$(shell uname -p)
-    ifeq ($(LIBARCH), sparc)
-        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
-    endif
-    ifeq ($(LIBARCH), sparcv9)
-        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
-    endif
-    ifeq ($(OPT), true)
-        CFLAGS=-xO2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS)
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-z defs -ztext
-    # Libraries we are dependent on
-    LIBRARIES= -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -G -o $@
-endif
-
-# Linux GNU C Compiler
-ifeq ($(OSNAME), linux)
-    # GNU Compiler options needed to build it
-    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
-    # Options that help find errors
-    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
-    ifeq ($(OPT), true)
-        CFLAGS=-O2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
-    # Libraries we are dependent on
-    LIBRARIES=-lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -shared -o $@
-endif
-
-# Windows Microsoft C/C++ Optimizing Compiler Version 12
-ifeq ($(OSNAME), win32)
-    CC=cl
-    # Compiler options needed to build it
-    COMMON_FLAGS=-Gy -DWIN32
-    # Options that help find errors
-    COMMON_FLAGS+=-W0 -WX
-    ifeq ($(OPT), true)
-        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
-    else
-        CFLAGS= -Od -Zi $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.obj)
-    # Library name and options needed to build it
-    LIBRARY=$(LIBNAME).dll
-    LDFLAGS=
-    # Libraries we are dependent on
-    LIBRARIES=
-    # Building a shared library
-    LINK_SHARED=link -dll -out:$@
-endif
-
-# Common -I options
-CFLAGS += -I.
-CFLAGS += -I../agent_util
-CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
-
-# Default rule
-all: $(LIBRARY)
-
-# Build native library
-$(LIBRARY): $(OBJECTS)
-	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
-
-# Cleanup the built bits
-clean:
-	rm -f $(LIBRARY) $(OBJECTS)
-
-# Simple tester
-test: all
-	LD_LIBRARY_PATH=`pwd` $(JDK)/bin/java -agentlib:$(LIBNAME) -version
-
-# Compilation rule only needed on Windows
-ifeq ($(OSNAME), win32)
-%.obj: %.c
-	$(COMPILE.c) $<
-endif
-
--- a/jdk/src/demo/share/jvmti/heapTracker/HeapTracker.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-
-/* Java class to hold static methods which will be called in byte code
- *    injections of all class files.
- */
-
-public class HeapTracker {
-
-    private static int engaged = 0;
-
-    private static native void _newobj(Object thread, Object o);
-    public static void newobj(Object o)
-    {
-        if ( engaged != 0 ) {
-            _newobj(Thread.currentThread(), o);
-        }
-    }
-
-    private static native void _newarr(Object thread, Object a);
-    public static void newarr(Object a)
-    {
-        if ( engaged != 0 ) {
-            _newarr(Thread.currentThread(), a);
-        }
-    }
-
-}
--- a/jdk/src/demo/share/jvmti/heapTracker/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#
-# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-heapTracker
-
-This agent library can be used to track object allocations.
-It uses the same java_crw_demo library used by HPROF to do BCI
-on all classfiles loaded into the Virtual Machine.
-
-You can use this agent library as follows:
-
-    java -agentlib:heapTracker ...
-
-To get help on the available options try:
-
-    java -agentlib:heapTracker=help
-
-See ${JAVA_HOME}/demo/jvmti/index.html for help running and building agents.
-
--- a/jdk/src/demo/share/jvmti/heapTracker/heapTracker.c	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1016 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include "stdlib.h"
-
-#include "heapTracker.h"
-#include "java_crw_demo.h"
-
-#include "jni.h"
-#include "jvmti.h"
-
-#include "agent_util.h"
-
-/* -------------------------------------------------------------------
- * Some constant names that tie to Java class/method names.
- *    We assume the Java class whose static methods we will be calling
- *    looks like:
- *
- * public class HeapTracker {
- *     private static int engaged;
- *     private static native void _newobj(Object thr, Object o);
- *     public static void newobj(Object o)
- *     {
- *              if ( engaged != 0 ) {
- *               _newobj(Thread.currentThread(), o);
- *           }
- *     }
- *     private static native void _newarr(Object thr, Object a);
- *     public static void newarr(Object a)
- *     {
- *            if ( engaged != 0 ) {
- *               _newarr(Thread.currentThread(), a);
- *           }
- *     }
- * }
- *
- *    The engaged field allows us to inject all classes (even system classes)
- *    and delay the actual calls to the native code until the VM has reached
- *    a safe time to call native methods (Past the JVMTI VM_START event).
- *
- */
-
-#define HEAP_TRACKER_class           HeapTracker /* Name of class we are using */
-#define HEAP_TRACKER_newobj        newobj   /* Name of java init method */
-#define HEAP_TRACKER_newarr        newarr   /* Name of java newarray method */
-#define HEAP_TRACKER_native_newobj _newobj  /* Name of java newobj native */
-#define HEAP_TRACKER_native_newarr _newarr  /* Name of java newarray native */
-#define HEAP_TRACKER_engaged       engaged  /* Name of static field switch */
-
-/* C macros to create strings from tokens */
-#define _STRING(s) #s
-#define STRING(s) _STRING(s)
-
-/* ------------------------------------------------------------------- */
-
-/* Flavors of traces (to separate out stack traces) */
-
-typedef enum {
-    TRACE_FIRST                        = 0,
-    TRACE_USER                        = 0,
-    TRACE_BEFORE_VM_START        = 1,
-    TRACE_BEFORE_VM_INIT        = 2,
-    TRACE_VM_OBJECT                = 3,
-    TRACE_MYSTERY                = 4,
-    TRACE_LAST                        = 4
-} TraceFlavor;
-
-static char * flavorDesc[] = {
-    "",
-    "before VM_START",
-    "before VM_INIT",
-    "VM_OBJECT",
-    "unknown"
-};
-
-/* Trace (Stack Trace) */
-
-#define MAX_FRAMES 6
-typedef struct Trace {
-    /* Number of frames (includes HEAP_TRACKER methods) */
-    jint           nframes;
-    /* Frames from GetStackTrace() (2 extra for HEAP_TRACKER methods) */
-    jvmtiFrameInfo frames[MAX_FRAMES+2];
-    /* Used to make some traces unique */
-    TraceFlavor    flavor;
-} Trace;
-
-/* Trace information (more than one object will have this as a tag) */
-
-typedef struct TraceInfo {
-    /* Trace where this object was allocated from */
-    Trace             trace;
-    /* 64 bit hash code that attempts to identify this specific trace */
-    jlong             hashCode;
-    /* Total space taken up by objects allocated from this trace */
-    jlong             totalSpace;
-    /* Total count of objects ever allocated from this trace */
-    int               totalCount;
-    /* Total live objects that were allocated from this trace */
-    int               useCount;
-    /* The next TraceInfo in the hash bucket chain */
-    struct TraceInfo *next;
-} TraceInfo;
-
-/* Global agent data structure */
-
-typedef struct {
-    /* JVMTI Environment */
-    jvmtiEnv      *jvmti;
-    /* State of the VM flags */
-    jboolean       vmStarted;
-    jboolean       vmInitialized;
-    jboolean       vmDead;
-    /* Options */
-    int            maxDump;
-    /* Data access Lock */
-    jrawMonitorID  lock;
-    /* Counter on classes where BCI has been applied */
-    jint           ccount;
-    /* Hash table to lookup TraceInfo's via Trace's */
-    #define HASH_INDEX_BIT_WIDTH 12 /* 4096 */
-    #define HASH_BUCKET_COUNT (1<<HASH_INDEX_BIT_WIDTH)
-    #define HASH_INDEX_MASK (HASH_BUCKET_COUNT-1)
-    TraceInfo     *hashBuckets[HASH_BUCKET_COUNT];
-    /* Count of TraceInfo's allocated */
-    int            traceInfoCount;
-    /* Pre-defined traces for the system and mystery situations */
-    TraceInfo     *emptyTrace[TRACE_LAST+1];
-} GlobalAgentData;
-
-static GlobalAgentData *gdata;
-
-/* Enter a critical section by doing a JVMTI Raw Monitor Enter */
-static void
-enterCriticalSection(jvmtiEnv *jvmti)
-{
-    jvmtiError error;
-
-    error = (*jvmti)->RawMonitorEnter(jvmti, gdata->lock);
-    check_jvmti_error(jvmti, error, "Cannot enter with raw monitor");
-}
-
-/* Exit a critical section by doing a JVMTI Raw Monitor Exit */
-static void
-exitCriticalSection(jvmtiEnv *jvmti)
-{
-    jvmtiError error;
-
-    error = (*jvmti)->RawMonitorExit(jvmti, gdata->lock);
-    check_jvmti_error(jvmti, error, "Cannot exit with raw monitor");
-}
-
-/* Update stats on a TraceInfo */
-static TraceInfo *
-updateStats(TraceInfo *tinfo)
-{
-    tinfo->totalCount++;
-    tinfo->useCount++;
-    return tinfo;
-}
-
-/* Get TraceInfo for empty stack */
-static TraceInfo *
-emptyTrace(TraceFlavor flavor)
-{
-    return updateStats(gdata->emptyTrace[flavor]);
-}
-
-/* Allocate new TraceInfo */
-static TraceInfo *
-newTraceInfo(Trace *trace, jlong hashCode, TraceFlavor flavor)
-{
-    TraceInfo *tinfo;
-
-    tinfo = (TraceInfo*)calloc(1, sizeof(TraceInfo));
-    if ( tinfo == NULL ) {
-        fatal_error("ERROR: Ran out of malloc() space\n");
-    } else {
-        int hashIndex;
-
-        tinfo->trace = *trace;
-        tinfo->trace.flavor = flavor;
-        tinfo->hashCode = hashCode;
-        gdata->traceInfoCount++;
-        hashIndex = (int)(hashCode & HASH_INDEX_MASK);
-        tinfo->next = gdata->hashBuckets[hashIndex];
-        gdata->hashBuckets[hashIndex] = tinfo;
-    }
-    return tinfo;
-}
-
-/* Create hash code for a Trace */
-static jlong
-hashTrace(Trace *trace)
-{
-    jlong hashCode;
-    int   i;
-
-    hashCode = 0;
-    for ( i = 0 ; i < trace->nframes ; i++ ) {
-        hashCode = (hashCode << 3) +
-                (jlong)(ptrdiff_t)(void*)(trace->frames[i].method);
-        hashCode = (hashCode << 2) +
-                (jlong)(trace->frames[i].location);
-    }
-    hashCode = (hashCode << 3) + trace->nframes;
-    hashCode += trace->flavor;
-    return hashCode;
-}
-
-/* Lookup or create a new TraceInfo */
-static TraceInfo *
-lookupOrEnter(jvmtiEnv *jvmti, Trace *trace, TraceFlavor flavor)
-{
-    TraceInfo *tinfo;
-    jlong      hashCode;
-
-    /* Calculate hash code (outside critical section to lessen contention) */
-    hashCode = hashTrace(trace);
-
-    /* Do a lookup in the hash table */
-    enterCriticalSection(jvmti); {
-        TraceInfo *prev;
-        int        hashIndex;
-
-        /* Start with first item in hash buck chain */
-        prev = NULL;
-        hashIndex = (int)(hashCode & HASH_INDEX_MASK);
-        tinfo = gdata->hashBuckets[hashIndex];
-        while ( tinfo != NULL ) {
-            if ( tinfo->hashCode == hashCode &&
-                 memcmp(trace, &(tinfo->trace), sizeof(Trace))==0 ) {
-                 /* We found one that matches, move to head of bucket chain */
-                 if ( prev != NULL ) {
-                     /* Remove from list and add to head of list */
-                     prev->next = tinfo->next;
-                     tinfo->next = gdata->hashBuckets[hashIndex];
-                     gdata->hashBuckets[hashIndex] = tinfo;
-                 }
-                 /* Break out */
-                 break;
-            }
-            prev = tinfo;
-            tinfo = tinfo->next;
-        }
-
-        /* If we didn't find anything we need to enter a new entry */
-        if ( tinfo == NULL ) {
-            /* Create new hash table element */
-            tinfo = newTraceInfo(trace, hashCode, flavor);
-        }
-
-        /* Update stats */
-        (void)updateStats(tinfo);
-
-    } exitCriticalSection(jvmti);
-
-    return tinfo;
-}
-
-/* Get TraceInfo for this allocation */
-static TraceInfo *
-findTraceInfo(jvmtiEnv *jvmti, jthread thread, TraceFlavor flavor)
-{
-    TraceInfo *tinfo;
-    jvmtiError error;
-
-    tinfo = NULL;
-    if ( thread != NULL ) {
-        static Trace  empty;
-        Trace         trace;
-
-        /* Before VM_INIT thread could be NULL, watch out */
-        trace = empty;
-        error = (*jvmti)->GetStackTrace(jvmti, thread, 0, MAX_FRAMES+2,
-                            trace.frames, &(trace.nframes));
-        /* If we get a PHASE error, the VM isn't ready, or it died */
-        if ( error == JVMTI_ERROR_WRONG_PHASE ) {
-            /* It is assumed this is before VM_INIT */
-            if ( flavor == TRACE_USER ) {
-                tinfo = emptyTrace(TRACE_BEFORE_VM_INIT);
-            } else {
-                tinfo = emptyTrace(flavor);
-            }
-        } else {
-            check_jvmti_error(jvmti, error, "Cannot get stack trace");
-            /* Lookup this entry */
-            tinfo = lookupOrEnter(jvmti, &trace, flavor);
-        }
-    } else {
-        /* If thread==NULL, it's assumed this is before VM_START */
-        if ( flavor == TRACE_USER ) {
-            tinfo = emptyTrace(TRACE_BEFORE_VM_START);
-        } else {
-            tinfo = emptyTrace(flavor);
-        }
-    }
-    return tinfo;
-}
-
-/* Tag an object with a TraceInfo pointer. */
-static void
-tagObjectWithTraceInfo(jvmtiEnv *jvmti, jobject object, TraceInfo *tinfo)
-{
-    jvmtiError error;
-    jlong      tag;
-
-    /* Tag this object with this TraceInfo pointer */
-    tag = (jlong)(ptrdiff_t)(void*)tinfo;
-    error = (*jvmti)->SetTag(jvmti, object, tag);
-    check_jvmti_error(jvmti, error, "Cannot tag object");
-}
-
-/* Java Native Method for Object.<init> */
-static void JNICALL
-HEAP_TRACKER_native_newobj(JNIEnv *env, jclass klass, jthread thread, jobject o)
-{
-    TraceInfo *tinfo;
-
-    if ( gdata->vmDead ) {
-        return;
-    }
-    tinfo = findTraceInfo(gdata->jvmti, thread, TRACE_USER);
-    tagObjectWithTraceInfo(gdata->jvmti, o, tinfo);
-}
-
-/* Java Native Method for newarray */
-static void JNICALL
-HEAP_TRACKER_native_newarr(JNIEnv *env, jclass klass, jthread thread, jobject a)
-{
-    TraceInfo *tinfo;
-
-    if ( gdata->vmDead ) {
-        return;
-    }
-    tinfo = findTraceInfo(gdata->jvmti, thread, TRACE_USER);
-    tagObjectWithTraceInfo(gdata->jvmti, a, tinfo);
-}
-
-/* Callback for JVMTI_EVENT_VM_START */
-static void JNICALL
-cbVMStart(jvmtiEnv *jvmti, JNIEnv *env)
-{
-    enterCriticalSection(jvmti); {
-        jclass klass;
-        jfieldID field;
-        jint rc;
-
-        /* Java Native Methods for class */
-        static JNINativeMethod registry[2] = {
-            {STRING(HEAP_TRACKER_native_newobj), "(Ljava/lang/Object;Ljava/lang/Object;)V",
-                (void*)&HEAP_TRACKER_native_newobj},
-            {STRING(HEAP_TRACKER_native_newarr), "(Ljava/lang/Object;Ljava/lang/Object;)V",
-                (void*)&HEAP_TRACKER_native_newarr}
-        };
-
-        /* Register Natives for class whose methods we use */
-        klass = (*env)->FindClass(env, STRING(HEAP_TRACKER_class));
-        if ( klass == NULL ) {
-            fatal_error("ERROR: JNI: Cannot find %s with FindClass\n",
-                        STRING(HEAP_TRACKER_class));
-        }
-        rc = (*env)->RegisterNatives(env, klass, registry, 2);
-        if ( rc != 0 ) {
-            fatal_error("ERROR: JNI: Cannot register natives for class %s\n",
-                        STRING(HEAP_TRACKER_class));
-        }
-
-        /* Engage calls. */
-        field = (*env)->GetStaticFieldID(env, klass, STRING(HEAP_TRACKER_engaged), "I");
-        if ( field == NULL ) {
-            fatal_error("ERROR: JNI: Cannot get field from %s\n",
-                        STRING(HEAP_TRACKER_class));
-        }
-        (*env)->SetStaticIntField(env, klass, field, 1);
-
-        /* Indicate VM has started */
-        gdata->vmStarted = JNI_TRUE;
-
-    } exitCriticalSection(jvmti);
-}
-
-/* Iterate Through Heap callback */
-static jint JNICALL
-cbObjectTagger(jlong class_tag, jlong size, jlong* tag_ptr, jint length,
-               void *user_data)
-{
-    TraceInfo *tinfo;
-
-    tinfo = emptyTrace(TRACE_BEFORE_VM_INIT);
-    *tag_ptr = (jlong)(ptrdiff_t)(void*)tinfo;
-    return JVMTI_VISIT_OBJECTS;
-}
-
-/* Callback for JVMTI_EVENT_VM_INIT */
-static void JNICALL
-cbVMInit(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    jvmtiHeapCallbacks heapCallbacks;
-    jvmtiError         error;
-
-    /* Iterate through heap, find all untagged objects allocated before this */
-    (void)memset(&heapCallbacks, 0, sizeof(heapCallbacks));
-    heapCallbacks.heap_iteration_callback = &cbObjectTagger;
-    error = (*jvmti)->IterateThroughHeap(jvmti, JVMTI_HEAP_FILTER_TAGGED,
-                                         NULL, &heapCallbacks, NULL);
-    check_jvmti_error(jvmti, error, "Cannot iterate through heap");
-
-    enterCriticalSection(jvmti); {
-
-        /* Indicate VM is initialized */
-        gdata->vmInitialized = JNI_TRUE;
-
-    } exitCriticalSection(jvmti);
-}
-
-/* Iterate Through Heap callback */
-static jint JNICALL
-cbObjectSpaceCounter(jlong class_tag, jlong size, jlong* tag_ptr, jint length,
-                     void *user_data)
-{
-    TraceInfo *tinfo;
-
-    tinfo = (TraceInfo*)(ptrdiff_t)(*tag_ptr);
-    if ( tinfo == NULL ) {
-        tinfo = emptyTrace(TRACE_MYSTERY);
-        *tag_ptr = (jlong)(ptrdiff_t)(void*)tinfo;
-    }
-    tinfo->totalSpace += size;
-    return JVMTI_VISIT_OBJECTS;
-}
-
-/* Qsort compare function */
-static int
-compareInfo(const void *p1, const void *p2)
-{
-    TraceInfo *tinfo1, *tinfo2;
-
-    tinfo1 = *((TraceInfo**)p1);
-    tinfo2 = *((TraceInfo**)p2);
-    return (int)(tinfo2->totalSpace - tinfo1->totalSpace);
-}
-
-/* Frame to text */
-static void
-frameToString(jvmtiEnv *jvmti, char *buf, int buflen, jvmtiFrameInfo *finfo)
-{
-    jvmtiError           error;
-    jclass               klass;
-    char                *signature;
-    char                *methodname;
-    char                *methodsig;
-    jboolean             isNative;
-    char                *filename;
-    int                  lineCount;
-    jvmtiLineNumberEntry*lineTable;
-    int                  lineNumber;
-
-    /* Initialize defaults */
-    buf[0]     = 0;
-    klass      = NULL;
-    signature  = NULL;
-    methodname = NULL;
-    methodsig  = NULL;
-    isNative   = JNI_FALSE;
-    filename   = NULL;
-    lineCount  = 0;
-    lineTable  = NULL;
-    lineNumber = 0;
-
-    /* Get jclass object for the jmethodID */
-    error = (*jvmti)->GetMethodDeclaringClass(jvmti, finfo->method, &klass);
-    check_jvmti_error(jvmti, error, "Cannot get method's class");
-
-    /* Get the class signature */
-    error = (*jvmti)->GetClassSignature(jvmti, klass, &signature, NULL);
-    check_jvmti_error(jvmti, error, "Cannot get class signature");
-
-    /* Skip all this if it's our own Tracker method */
-    if ( strcmp(signature, "L" STRING(HEAP_TRACKER_class) ";" ) == 0 ) {
-        deallocate(jvmti, signature);
-        return;
-    }
-
-    /* Get the name and signature for the method */
-    error = (*jvmti)->GetMethodName(jvmti, finfo->method,
-                &methodname, &methodsig, NULL);
-    check_jvmti_error(jvmti, error, "Cannot method name");
-
-    /* Check to see if it's a native method, which means no lineNumber */
-    error = (*jvmti)->IsMethodNative(jvmti, finfo->method, &isNative);
-    check_jvmti_error(jvmti, error, "Cannot get method native status");
-
-    /* Get source file name */
-    error = (*jvmti)->GetSourceFileName(jvmti, klass, &filename);
-    if ( error != JVMTI_ERROR_NONE && error != JVMTI_ERROR_ABSENT_INFORMATION ) {
-        check_jvmti_error(jvmti, error, "Cannot get source filename");
-    }
-
-    /* Get lineNumber if we can */
-    if ( !isNative ) {
-        int i;
-
-        /* Get method line table */
-        error = (*jvmti)->GetLineNumberTable(jvmti, finfo->method, &lineCount, &lineTable);
-        if ( error == JVMTI_ERROR_NONE ) {
-            /* Search for line */
-            lineNumber = lineTable[0].line_number;
-            for ( i = 1 ; i < lineCount ; i++ ) {
-                if ( finfo->location < lineTable[i].start_location ) {
-                    break;
-                }
-                lineNumber = lineTable[i].line_number;
-            }
-        } else if ( error != JVMTI_ERROR_ABSENT_INFORMATION ) {
-            check_jvmti_error(jvmti, error, "Cannot get method line table");
-        }
-    }
-
-    /* Create string for this frame location.
-     *    NOTE: These char* quantities are mUTF (Modified UTF-8) bytes
-     *          and should actually be converted to the default system
-     *          character encoding. Sending them to things like
-     *          printf() without converting them is actually an I18n
-     *          (Internationalization) error.
-     */
-    (void)sprintf(buf, "%s.%s@%d[%s:%d]",
-            (signature==NULL?"UnknownClass":signature),
-            (methodname==NULL?"UnknownMethod":methodname),
-            (int)finfo->location,
-            (filename==NULL?"UnknownFile":filename),
-            lineNumber);
-
-    /* Free up JVMTI space allocated by the above calls */
-    deallocate(jvmti, signature);
-    deallocate(jvmti, methodname);
-    deallocate(jvmti, methodsig);
-    deallocate(jvmti, filename);
-    deallocate(jvmti, lineTable);
-}
-
-/* Print the information */
-static void
-printTraceInfo(jvmtiEnv *jvmti, int index, TraceInfo* tinfo)
-{
-    if ( tinfo == NULL ) {
-        fatal_error("%d: NULL ENTRY ERROR\n", index);
-        return;
-    }
-
-    stdout_message("%2d: %7d bytes %5d objects %5d live %s",
-                index, (int)tinfo->totalSpace, tinfo->totalCount,
-                tinfo->useCount, flavorDesc[tinfo->trace.flavor]);
-
-    if (  tinfo->trace.nframes > 0 ) {
-        int i;
-        int fcount;
-
-        fcount = 0;
-        stdout_message(" stack=(");
-        for ( i = 0 ; i < tinfo->trace.nframes ; i++ ) {
-            char buf[4096];
-
-            frameToString(jvmti, buf, (int)sizeof(buf), tinfo->trace.frames+i);
-            if ( buf[0] == 0 ) {
-                continue; /* Skip the ones that are from Tracker class */
-            }
-            fcount++;
-            stdout_message("%s", buf);
-            if ( i < (tinfo->trace.nframes-1) ) {
-                stdout_message(",");
-            }
-        }
-        stdout_message(") nframes=%d\n", fcount);
-    } else {
-        stdout_message(" stack=<empty>\n");
-    }
-}
-
-/* Callback for JVMTI_EVENT_VM_DEATH */
-static void JNICALL
-cbVMDeath(jvmtiEnv *jvmti, JNIEnv *env)
-{
-    jvmtiHeapCallbacks heapCallbacks;
-    jvmtiError         error;
-
-    /* These are purposely done outside the critical section */
-
-    /* Force garbage collection now so we get our ObjectFree calls */
-    error = (*jvmti)->ForceGarbageCollection(jvmti);
-    check_jvmti_error(jvmti, error, "Cannot force garbage collection");
-
-    /* Iterate through heap and find all objects */
-    (void)memset(&heapCallbacks, 0, sizeof(heapCallbacks));
-    heapCallbacks.heap_iteration_callback = &cbObjectSpaceCounter;
-    error = (*jvmti)->IterateThroughHeap(jvmti, 0, NULL, &heapCallbacks, NULL);
-    check_jvmti_error(jvmti, error, "Cannot iterate through heap");
-
-    /* Process VM Death */
-    enterCriticalSection(jvmti); {
-        jclass              klass;
-        jfieldID            field;
-        jvmtiEventCallbacks callbacks;
-
-        /* Disengage calls in HEAP_TRACKER_class. */
-        klass = (*env)->FindClass(env, STRING(HEAP_TRACKER_class));
-        if ( klass == NULL ) {
-            fatal_error("ERROR: JNI: Cannot find %s with FindClass\n",
-                        STRING(HEAP_TRACKER_class));
-        }
-        field = (*env)->GetStaticFieldID(env, klass, STRING(HEAP_TRACKER_engaged), "I");
-        if ( field == NULL ) {
-            fatal_error("ERROR: JNI: Cannot get field from %s\n",
-                        STRING(HEAP_TRACKER_class));
-        }
-        (*env)->SetStaticIntField(env, klass, field, 0);
-
-        /* The critical section here is important to hold back the VM death
-         *    until all other callbacks have completed.
-         */
-
-        /* Clear out all callbacks. */
-        (void)memset(&callbacks,0, sizeof(callbacks));
-        error = (*jvmti)->SetEventCallbacks(jvmti, &callbacks,
-                                            (jint)sizeof(callbacks));
-        check_jvmti_error(jvmti, error, "Cannot set jvmti callbacks");
-
-        /* Since this critical section could be holding up other threads
-         *   in other event callbacks, we need to indicate that the VM is
-         *   dead so that the other callbacks can short circuit their work.
-         *   We don't expect an further events after VmDeath but we do need
-         *   to be careful that existing threads might be in our own agent
-         *   callback code.
-         */
-        gdata->vmDead = JNI_TRUE;
-
-        /* Dump all objects */
-        if ( gdata->traceInfoCount > 0 ) {
-            TraceInfo **list;
-            int         count;
-            int         i;
-
-            stdout_message("Dumping heap trace information\n");
-
-            /* Create single array of pointers to TraceInfo's, sort, and
-             *   print top gdata->maxDump top space users.
-             */
-            list = (TraceInfo**)calloc(gdata->traceInfoCount,
-                                              sizeof(TraceInfo*));
-            if ( list == NULL ) {
-                fatal_error("ERROR: Ran out of malloc() space\n");
-            }
-            count = 0;
-            for ( i = 0 ; i < HASH_BUCKET_COUNT ; i++ ) {
-                TraceInfo *tinfo;
-
-                tinfo = gdata->hashBuckets[i];
-                while ( tinfo != NULL ) {
-                    if ( count < gdata->traceInfoCount ) {
-                        list[count++] = tinfo;
-                    }
-                    tinfo = tinfo->next;
-                }
-            }
-            if ( count != gdata->traceInfoCount ) {
-                fatal_error("ERROR: Count found by iterate doesn't match ours:"
-                        " count=%d != traceInfoCount==%d\n",
-                        count, gdata->traceInfoCount);
-            }
-            qsort(list, count, sizeof(TraceInfo*), &compareInfo);
-            for ( i = 0 ; i < count ; i++ ) {
-                if ( i >= gdata->maxDump ) {
-                    break;
-                }
-                printTraceInfo(jvmti, i+1, list[i]);
-            }
-            (void)free(list);
-        }
-
-    } exitCriticalSection(jvmti);
-
-}
-
-/* Callback for JVMTI_EVENT_VM_OBJECT_ALLOC */
-static void JNICALL
-cbVMObjectAlloc(jvmtiEnv *jvmti, JNIEnv *env, jthread thread,
-                jobject object, jclass object_klass, jlong size)
-{
-    TraceInfo *tinfo;
-
-    if ( gdata->vmDead ) {
-        return;
-    }
-    tinfo = findTraceInfo(jvmti, thread, TRACE_VM_OBJECT);
-    tagObjectWithTraceInfo(jvmti, object, tinfo);
-}
-
-/* Callback for JVMTI_EVENT_OBJECT_FREE */
-static void JNICALL
-cbObjectFree(jvmtiEnv *jvmti, jlong tag)
-{
-    TraceInfo *tinfo;
-
-    if ( gdata->vmDead ) {
-        return;
-    }
-
-    /* The object tag is actually a pointer to a TraceInfo structure */
-    tinfo = (TraceInfo*)(void*)(ptrdiff_t)tag;
-
-    /* Decrement the use count */
-    tinfo->useCount--;
-}
-
-/* Callback for JVMTI_EVENT_CLASS_FILE_LOAD_HOOK */
-static void JNICALL
-cbClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv* env,
-                jclass class_being_redefined, jobject loader,
-                const char* name, jobject protection_domain,
-                jint class_data_len, const unsigned char* class_data,
-                jint* new_class_data_len, unsigned char** new_class_data)
-{
-    enterCriticalSection(jvmti); {
-        /* It's possible we get here right after VmDeath event, be careful */
-        if ( !gdata->vmDead ) {
-
-            const char * classname;
-
-            /* Name can be NULL, make sure we avoid SEGV's */
-            if ( name == NULL ) {
-                classname = java_crw_demo_classname(class_data, class_data_len,
-                                NULL);
-                if ( classname == NULL ) {
-                    fatal_error("ERROR: No classname in classfile\n");
-                }
-            } else {
-                classname = strdup(name);
-                if ( classname == NULL ) {
-                    fatal_error("ERROR: Ran out of malloc() space\n");
-                }
-            }
-
-            *new_class_data_len = 0;
-            *new_class_data     = NULL;
-
-            /* The tracker class itself? */
-            if ( strcmp(classname, STRING(HEAP_TRACKER_class)) != 0 ) {
-                jint           cnum;
-                int            systemClass;
-                unsigned char *newImage;
-                long           newLength;
-
-                /* Get number for every class file image loaded */
-                cnum = gdata->ccount++;
-
-                /* Is it a system class? If the class load is before VmStart
-                 *   then we will consider it a system class that should
-                 *   be treated carefully. (See java_crw_demo)
-                 */
-                systemClass = 0;
-                if ( !gdata->vmStarted ) {
-                    systemClass = 1;
-                }
-
-                newImage = NULL;
-                newLength = 0;
-
-                /* Call the class file reader/write demo code */
-                java_crw_demo(cnum,
-                    classname,
-                    class_data,
-                    class_data_len,
-                    systemClass,
-                    STRING(HEAP_TRACKER_class),
-                    "L" STRING(HEAP_TRACKER_class) ";",
-                    NULL, NULL,
-                    NULL, NULL,
-                    STRING(HEAP_TRACKER_newobj), "(Ljava/lang/Object;)V",
-                    STRING(HEAP_TRACKER_newarr), "(Ljava/lang/Object;)V",
-                    &newImage,
-                    &newLength,
-                    NULL,
-                    NULL);
-
-                /* If we got back a new class image, return it back as "the"
-                 *   new class image. This must be JVMTI Allocate space.
-                 */
-                if ( newLength > 0 ) {
-                    unsigned char *jvmti_space;
-
-                    jvmti_space = (unsigned char *)allocate(jvmti, (jint)newLength);
-                    (void)memcpy((void*)jvmti_space, (void*)newImage, (int)newLength);
-                    *new_class_data_len = (jint)newLength;
-                    *new_class_data     = jvmti_space; /* VM will deallocate */
-                }
-
-                /* Always free up the space we get from java_crw_demo() */
-                if ( newImage != NULL ) {
-                    (void)free((void*)newImage); /* Free malloc() space with free() */
-                }
-            }
-
-            (void)free((void*)classname);
-        }
-    } exitCriticalSection(jvmti);
-}
-
-/* Parse the options for this heapTracker agent */
-static void
-parse_agent_options(char *options)
-{
-    #define MAX_TOKEN_LENGTH        16
-    char  token[MAX_TOKEN_LENGTH];
-    char *next;
-
-    /* Defaults */
-    gdata->maxDump = 20;
-
-    /* Parse options and set flags in gdata */
-    if ( options==NULL ) {
-        return;
-    }
-
-    /* Get the first token from the options string. */
-    next = get_token(options, ",=", token, (int)sizeof(token));
-
-    /* While not at the end of the options string, process this option. */
-    while ( next != NULL ) {
-        if ( strcmp(token,"help")==0 ) {
-            stdout_message("The heapTracker JVMTI demo agent\n");
-            stdout_message("\n");
-            stdout_message(" java -agent:heapTracker[=options] ...\n");
-            stdout_message("\n");
-            stdout_message("The options are comma separated:\n");
-            stdout_message("\t help\t\t\t Print help information\n");
-            stdout_message("\t maxDump=n\t\t\t How many TraceInfo's to dump\n");
-            stdout_message("\n");
-            exit(0);
-        } else if ( strcmp(token,"maxDump")==0 ) {
-            char  number[MAX_TOKEN_LENGTH];
-
-            next = get_token(next, ",=", number, (int)sizeof(number));
-            if ( next == NULL ) {
-                fatal_error("ERROR: Cannot parse maxDump=number: %s\n", options);
-            }
-            gdata->maxDump = atoi(number);
-        } else if ( token[0]!=0 ) {
-            /* We got a non-empty token and we don't know what it is. */
-            fatal_error("ERROR: Unknown option: %s\n", token);
-        }
-        /* Get the next token (returns NULL if there are no more) */
-        next = get_token(next, ",=", token, (int)sizeof(token));
-    }
-}
-
-/* Agent_OnLoad: This is called immediately after the shared library is
- *   loaded. This is the first code executed.
- */
-JNIEXPORT jint JNICALL
-DEF_Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
-{
-    static GlobalAgentData data;
-    jvmtiEnv              *jvmti;
-    jvmtiError             error;
-    jint                   res;
-    TraceFlavor            flavor;
-    jvmtiCapabilities      capabilities;
-    jvmtiEventCallbacks    callbacks;
-    static Trace           empty;
-
-    /* Setup initial global agent data area
-     *   Use of static/extern data should be handled carefully here.
-     *   We need to make sure that we are able to cleanup after ourselves
-     *     so anything allocated in this library needs to be freed in
-     *     the Agent_OnUnload() function.
-     */
-    (void)memset((void*)&data, 0, sizeof(data));
-    gdata = &data;
-
-    /* First thing we need to do is get the jvmtiEnv* or JVMTI environment */
-    res = (*vm)->GetEnv(vm, (void **)&jvmti, JVMTI_VERSION_1);
-    if (res != JNI_OK) {
-        /* This means that the VM was unable to obtain this version of the
-         *   JVMTI interface, this is a fatal error.
-         */
-        fatal_error("ERROR: Unable to access JVMTI Version 1 (0x%x),"
-                " is your JDK a 5.0 or newer version?"
-                " JNIEnv's GetEnv() returned %d\n",
-               JVMTI_VERSION_1, res);
-    }
-
-    /* Here we save the jvmtiEnv* for Agent_OnUnload(). */
-    gdata->jvmti = jvmti;
-
-    /* Parse any options supplied on java command line */
-    parse_agent_options(options);
-
-    /* Immediately after getting the jvmtiEnv* we need to ask for the
-     *   capabilities this agent will need.
-     */
-    (void)memset(&capabilities,0, sizeof(capabilities));
-    capabilities.can_generate_all_class_hook_events = 1;
-    capabilities.can_tag_objects  = 1;
-    capabilities.can_generate_object_free_events  = 1;
-    capabilities.can_get_source_file_name  = 1;
-    capabilities.can_get_line_numbers  = 1;
-    capabilities.can_generate_vm_object_alloc_events  = 1;
-    error = (*jvmti)->AddCapabilities(jvmti, &capabilities);
-    check_jvmti_error(jvmti, error, "Unable to get necessary JVMTI capabilities.");
-
-    /* Next we need to provide the pointers to the callback functions to
-     *   to this jvmtiEnv*
-     */
-    (void)memset(&callbacks,0, sizeof(callbacks));
-    /* JVMTI_EVENT_VM_START */
-    callbacks.VMStart           = &cbVMStart;
-    /* JVMTI_EVENT_VM_INIT */
-    callbacks.VMInit            = &cbVMInit;
-    /* JVMTI_EVENT_VM_DEATH */
-    callbacks.VMDeath           = &cbVMDeath;
-    /* JVMTI_EVENT_OBJECT_FREE */
-    callbacks.ObjectFree        = &cbObjectFree;
-    /* JVMTI_EVENT_VM_OBJECT_ALLOC */
-    callbacks.VMObjectAlloc     = &cbVMObjectAlloc;
-    /* JVMTI_EVENT_CLASS_FILE_LOAD_HOOK */
-    callbacks.ClassFileLoadHook = &cbClassFileLoadHook;
-    error = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, (jint)sizeof(callbacks));
-    check_jvmti_error(jvmti, error, "Cannot set jvmti callbacks");
-
-    /* At first the only initial events we are interested in are VM
-     *   initialization, VM death, and Class File Loads.
-     *   Once the VM is initialized we will request more events.
-     */
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_VM_START, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_VM_INIT, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_VM_DEATH, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_OBJECT_FREE, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_VM_OBJECT_ALLOC, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-
-    /* Here we create a raw monitor for our use in this agent to
-     *   protect critical sections of code.
-     */
-    error = (*jvmti)->CreateRawMonitor(jvmti, "agent data", &(gdata->lock));
-    check_jvmti_error(jvmti, error, "Cannot create raw monitor");
-
-    /* Create the TraceInfo for various flavors of empty traces */
-    for ( flavor = TRACE_FIRST ; flavor <= TRACE_LAST ; flavor++ ) {
-        gdata->emptyTrace[flavor] =
-               newTraceInfo(&empty, hashTrace(&empty), flavor);
-    }
-
-    /* Add jar file to boot classpath */
-    add_demo_jar_to_bootclasspath(jvmti, "heapTracker");
-
-    /* We return JNI_OK to signify success */
-    return JNI_OK;
-}
-
-/* Agent_OnUnload: This is called immediately before the shared library is
- *   unloaded. This is the last code executed.
- */
-JNIEXPORT void JNICALL
-DEF_Agent_OnUnload(JavaVM *vm)
-{
-    /* Skip any cleanup, VM is about to die anyway */
-}
--- a/jdk/src/demo/share/jvmti/heapTracker/heapTracker.h	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/* Primary heapTracker #include file, should be included by most if not
- *    all heapTracker source files. Gives access to the global data structure
- *    and all global macros.
- */
-
-#ifndef HEAP_TRACKER_H
-#define HEAP_TRACKER_H
-
-/* Standard C functions used throughout. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stddef.h>
-#include <stdarg.h>
-
-/* General JVM/Java functions, types and macros. */
-
-#include <sys/types.h>
-#include "jni.h"
-#include "jvmti.h"
-
-/* Utility functions */
-
-#include "agent_util.h"
-
-#endif
--- a/jdk/src/demo/share/jvmti/heapTracker/sample.makefile.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-#
-# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-########################################################################
-#
-# Sample GNU Makefile for building JVMTI Demo heapTracker
-#
-#  Example uses:    
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
-#       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
-#       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
-#
-########################################################################
-
-# Source lists
-LIBNAME=heapTracker
-SOURCES=heapTracker.c ../agent_util/agent_util.c
-JAVA_SOURCES=HeapTracker.java
-
-# Name of jar file that needs to be created
-JARFILE=heapTracker.jar
-
-# Solaris Studio C Compiler Version 12.4
-ifeq ($(OSNAME), solaris)
-    # Sun Solaris Compiler options needed
-    COMMON_FLAGS=-mt -KPIC
-    # Options that help find errors
-    COMMON_FLAGS+= -Xa -v -xc99=%none
-    # Check LIBARCH for any special compiler options
-    LIBARCH=$(shell uname -p)
-    ifeq ($(LIBARCH), sparc)
-        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
-    endif
-    ifeq ($(LIBARCH), sparcv9)
-        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
-    endif
-    ifeq ($(OPT), true)
-        CFLAGS=-xO2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS)
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-z defs -ztext
-    # Libraries we are dependent on
-    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -G -o $@
-endif
-
-# Linux GNU C Compiler
-ifeq ($(OSNAME), linux)
-    # GNU Compiler options needed to build it
-    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
-    # Options that help find errors
-    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
-    ifeq ($(OPT), true)
-        CFLAGS=-O2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
-    # Libraries we are dependent on
-    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -shared -o $@
-endif
-
-# Windows Microsoft C/C++ Optimizing Compiler Version 12
-ifeq ($(OSNAME), win32)
-    CC=cl
-    # Compiler options needed to build it
-    COMMON_FLAGS=-Gy -DWIN32
-    # Options that help find errors
-    COMMON_FLAGS+=-W0 -WX
-    ifeq ($(OPT), true)
-        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
-    else
-        CFLAGS= -Od -Zi $(COMMON_FLAGS) 
-    endif
-    # Sources need java_crw_demo
-    SOURCES += ../java_crw_demo/java_crw_demo.c
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.obj)
-    # Library name and options needed to build it
-    LIBRARY=$(LIBNAME).dll
-    LDFLAGS=
-    # Libraries we are dependent on
-    LIBRARIES=$(JDK)/
-    # Building a shared library
-    LINK_SHARED=link -dll -out:$@
-endif
-
-# Common -I options
-CFLAGS += -I.
-CFLAGS += -I../agent_util
-CFLAGS += -I../java_crw_demo
-CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
-
-# Default rule (build both native library and jar file)
-all: $(LIBRARY) $(JARFILE)
-
-# Build native library
-$(LIBRARY): $(OBJECTS)
-	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
-
-# Build jar file
-$(JARFILE): $(JAVA_SOURCES)
-	rm -f -r classes
-	mkdir -p classes
-	$(JDK)/bin/javac -d classes $(JAVA_SOURCES)
-	(cd classes; $(JDK)/bin/jar cf ../$@ *)
-
-# Cleanup the built bits
-clean:
-	rm -f -r classes
-	rm -f $(LIBRARY) $(JARFILE) $(OBJECTS)
-
-# Simple tester
-test: all
-	LD_LIBRARY_PATH=. $(JDK)/bin/java -agentlib:$(LIBNAME) -Xbootclasspath/a:./$(JARFILE) -version
-
-# Compilation rule only needed on Windows
-ifeq ($(OSNAME), win32)
-%.obj: %.c
-	$(COMPILE.c) $<
-endif
-
--- a/jdk/src/demo/share/jvmti/heapViewer/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#
-# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-heapViewer
-
-This agent library demonstrates how to get an easy view of the
-heap in terms of total object count and space used.
-It uses GetLoadedClasses(), SetTag(), and IterateThroughHeap()
-to count up all the objects of all the current loaded classes.
-The heap dump will happen at the event JVMTI_EVENT_VM_DEATH, or the
-event JVMTI_EVENT_DATA_DUMP_REQUEST.
-
-It also demonstrates some more robust agent error handling using 
-GetErrorName(),
-
-Using the heap iterate functions, lots of statistics can be generated
-without resorting to using Byte Code Instrumentation (BCI).
-
-You can use this agent library as follows:
-
-    java -agentlib:heapViewer ...
-
-To get help on the available options try:
-
-    java -agentlib:heapViewer=help
-
-See ${JAVA_HOME}/demo/jvmti/index.html for help running and building agents.
-
--- a/jdk/src/demo/share/jvmti/heapViewer/heapViewer.c	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,288 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "jni.h"
-#include "jvmti.h"
-
-#include "agent_util.h"
-
-/* Global static data */
-typedef struct {
-    jboolean      vmDeathCalled;
-    jboolean      dumpInProgress;
-    jrawMonitorID lock;
-} GlobalData;
-static GlobalData globalData, *gdata = &globalData;
-
-/* Typedef to hold class details */
-typedef struct {
-    char *signature;
-    int   count;
-    int   space;
-} ClassDetails;
-
-/* Enter agent monitor protected section */
-static void
-enterAgentMonitor(jvmtiEnv *jvmti)
-{
-    jvmtiError err;
-
-    err = (*jvmti)->RawMonitorEnter(jvmti, gdata->lock);
-    check_jvmti_error(jvmti, err, "raw monitor enter");
-}
-
-/* Exit agent monitor protected section */
-static void
-exitAgentMonitor(jvmtiEnv *jvmti)
-{
-    jvmtiError err;
-
-    err = (*jvmti)->RawMonitorExit(jvmti, gdata->lock);
-    check_jvmti_error(jvmti, err, "raw monitor exit");
-}
-
-/* Heap object callback */
-static jint JNICALL
-cbHeapObject(jlong class_tag, jlong size, jlong* tag_ptr, jint length,
-           void* user_data)
-{
-    if ( class_tag != (jlong)0 ) {
-        ClassDetails *d;
-
-        d = (ClassDetails*)(void*)(ptrdiff_t)class_tag;
-        (*((jint*)(user_data)))++;
-        d->count++;
-        d->space += (int)size;
-    }
-    return JVMTI_VISIT_OBJECTS;
-}
-
-/* Compare two ClassDetails */
-static int
-compareDetails(const void *p1, const void *p2)
-{
-    return ((ClassDetails*)p2)->space - ((ClassDetails*)p1)->space;
-}
-
-/* Callback for JVMTI_EVENT_DATA_DUMP_REQUEST (Ctrl-\ or at exit) */
-static void JNICALL
-dataDumpRequest(jvmtiEnv *jvmti)
-{
-    enterAgentMonitor(jvmti); {
-        if ( !gdata->vmDeathCalled && !gdata->dumpInProgress ) {
-            jvmtiHeapCallbacks heapCallbacks;
-            ClassDetails      *details;
-            jvmtiError         err;
-            jclass            *classes;
-            jint               totalCount;
-            jint               count;
-            jint               i;
-
-            gdata->dumpInProgress = JNI_TRUE;
-
-            /* Get all the loaded classes */
-            err = (*jvmti)->GetLoadedClasses(jvmti, &count, &classes);
-            check_jvmti_error(jvmti, err, "get loaded classes");
-
-            /* Setup an area to hold details about these classes */
-            details = (ClassDetails*)calloc(sizeof(ClassDetails), count);
-            if ( details == NULL ) {
-                fatal_error("ERROR: Ran out of malloc space\n");
-            }
-            for ( i = 0 ; i < count ; i++ ) {
-                char *sig;
-
-                /* Get and save the class signature */
-                err = (*jvmti)->GetClassSignature(jvmti, classes[i], &sig, NULL);
-                check_jvmti_error(jvmti, err, "get class signature");
-                if ( sig == NULL ) {
-                    fatal_error("ERROR: No class signature found\n");
-                }
-                details[i].signature = strdup(sig);
-                deallocate(jvmti, sig);
-
-                /* Tag this jclass */
-                err = (*jvmti)->SetTag(jvmti, classes[i],
-                                    (jlong)(ptrdiff_t)(void*)(&details[i]));
-                check_jvmti_error(jvmti, err, "set object tag");
-            }
-
-            /* Iterate through the heap and count up uses of jclass */
-            (void)memset(&heapCallbacks, 0, sizeof(heapCallbacks));
-            heapCallbacks.heap_iteration_callback = &cbHeapObject;
-            totalCount = 0;
-            err = (*jvmti)->IterateThroughHeap(jvmti,
-                       JVMTI_HEAP_FILTER_CLASS_UNTAGGED, NULL,
-                       &heapCallbacks, (const void *)&totalCount);
-            check_jvmti_error(jvmti, err, "iterate through heap");
-
-            /* Remove tags */
-            for ( i = 0 ; i < count ; i++ ) {
-                /* Un-Tag this jclass */
-                err = (*jvmti)->SetTag(jvmti, classes[i], (jlong)0);
-                check_jvmti_error(jvmti, err, "set object tag");
-            }
-
-            /* Sort details by space used */
-            qsort(details, count, sizeof(ClassDetails), &compareDetails);
-
-            /* Print out sorted table */
-            stdout_message("Heap View, Total of %d objects found.\n\n",
-                         totalCount);
-
-            stdout_message("Space      Count      Class Signature\n");
-            stdout_message("---------- ---------- ----------------------\n");
-
-            for ( i = 0 ; i < count ; i++ ) {
-                if ( details[i].space == 0 || i > 20 ) {
-                    break;
-                }
-                stdout_message("%10d %10d %s\n",
-                    details[i].space, details[i].count, details[i].signature);
-            }
-            stdout_message("---------- ---------- ----------------------\n\n");
-
-            /* Free up all allocated space */
-            deallocate(jvmti, classes);
-            for ( i = 0 ; i < count ; i++ ) {
-                if ( details[i].signature != NULL ) {
-                    free(details[i].signature);
-                }
-            }
-            free(details);
-
-            gdata->dumpInProgress = JNI_FALSE;
-        }
-    } exitAgentMonitor(jvmti);
-}
-
-/* Callback for JVMTI_EVENT_VM_INIT */
-static void JNICALL
-vmInit(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    enterAgentMonitor(jvmti); {
-        jvmtiError          err;
-
-        err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                            JVMTI_EVENT_DATA_DUMP_REQUEST, NULL);
-        check_jvmti_error(jvmti, err, "set event notification");
-    } exitAgentMonitor(jvmti);
-}
-
-/* Callback for JVMTI_EVENT_VM_DEATH */
-static void JNICALL
-vmDeath(jvmtiEnv *jvmti, JNIEnv *env)
-{
-    jvmtiError          err;
-
-    /* Make sure everything has been garbage collected */
-    err = (*jvmti)->ForceGarbageCollection(jvmti);
-    check_jvmti_error(jvmti, err, "force garbage collection");
-
-    /* Disable events and dump the heap information */
-    enterAgentMonitor(jvmti); {
-        err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_DISABLE,
-                            JVMTI_EVENT_DATA_DUMP_REQUEST, NULL);
-        check_jvmti_error(jvmti, err, "set event notification");
-
-        dataDumpRequest(jvmti);
-
-        gdata->vmDeathCalled = JNI_TRUE;
-    } exitAgentMonitor(jvmti);
-}
-
-/* Agent_OnLoad() is called first, we prepare for a VM_INIT event here. */
-JNIEXPORT jint JNICALL
-DEF_Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
-{
-    jint                rc;
-    jvmtiError          err;
-    jvmtiCapabilities   capabilities;
-    jvmtiEventCallbacks callbacks;
-    jvmtiEnv           *jvmti;
-
-    /* Get JVMTI environment */
-    jvmti = NULL;
-    rc = (*vm)->GetEnv(vm, (void **)&jvmti, JVMTI_VERSION);
-    if (rc != JNI_OK) {
-        fatal_error("ERROR: Unable to create jvmtiEnv, error=%d\n", rc);
-        return -1;
-    }
-    if ( jvmti == NULL ) {
-        fatal_error("ERROR: No jvmtiEnv* returned from GetEnv\n");
-    }
-
-    /* Get/Add JVMTI capabilities */
-    (void)memset(&capabilities, 0, sizeof(capabilities));
-    capabilities.can_tag_objects = 1;
-    capabilities.can_generate_garbage_collection_events = 1;
-    err = (*jvmti)->AddCapabilities(jvmti, &capabilities);
-    check_jvmti_error(jvmti, err, "add capabilities");
-
-    /* Create the raw monitor */
-    err = (*jvmti)->CreateRawMonitor(jvmti, "agent lock", &(gdata->lock));
-    check_jvmti_error(jvmti, err, "create raw monitor");
-
-    /* Set callbacks and enable event notifications */
-    memset(&callbacks, 0, sizeof(callbacks));
-    callbacks.VMInit                  = &vmInit;
-    callbacks.VMDeath                 = &vmDeath;
-    callbacks.DataDumpRequest         = &dataDumpRequest;
-    err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, sizeof(callbacks));
-    check_jvmti_error(jvmti, err, "set event callbacks");
-    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                        JVMTI_EVENT_VM_INIT, NULL);
-    check_jvmti_error(jvmti, err, "set event notifications");
-    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                        JVMTI_EVENT_VM_DEATH, NULL);
-    check_jvmti_error(jvmti, err, "set event notifications");
-    return 0;
-}
-
-/* Agent_OnUnload() is called last */
-JNIEXPORT void JNICALL
-DEF_Agent_OnUnload(JavaVM *vm)
-{
-}
--- a/jdk/src/demo/share/jvmti/heapViewer/sample.makefile.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-#
-# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-########################################################################
-#
-# Sample GNU Makefile for building JVMTI Demo heapViewer
-#
-#  Example uses:    
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
-#       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
-#       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
-#
-########################################################################
-
-# Source lists
-LIBNAME=heapViewer
-SOURCES=heapViewer.c ../agent_util/agent_util.c
-
-# Solaris Studio C Compiler Version 12.4
-ifeq ($(OSNAME), solaris)
-    # Sun Solaris Compiler options needed
-    COMMON_FLAGS=-mt -KPIC
-    # Options that help find errors
-    COMMON_FLAGS+= -Xa -v -xc99=%none
-    # Check LIBARCH for any special compiler options
-    LIBARCH=$(shell uname -p)
-    ifeq ($(LIBARCH), sparc)
-        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
-    endif
-    ifeq ($(LIBARCH), sparcv9)
-        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
-    endif
-    ifeq ($(OPT), true)
-        CFLAGS=-xO2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS)
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-z defs -ztext
-    # Libraries we are dependent on
-    LIBRARIES= -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -G -o $@
-endif
-
-# Linux GNU C Compiler
-ifeq ($(OSNAME), linux)
-    # GNU Compiler options needed to build it
-    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
-    # Options that help find errors
-    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
-    ifeq ($(OPT), true)
-        CFLAGS=-O2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
-    # Libraries we are dependent on
-    LIBRARIES=-lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -shared -o $@
-endif
-
-# Windows Microsoft C/C++ Optimizing Compiler Version 12
-ifeq ($(OSNAME), win32)
-    CC=cl
-    # Compiler options needed to build it
-    COMMON_FLAGS=-Gy -DWIN32
-    # Options that help find errors
-    COMMON_FLAGS+=-W0 -WX
-    ifeq ($(OPT), true)
-        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
-    else
-        CFLAGS= -Od -Zi $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.obj)
-    # Library name and options needed to build it
-    LIBRARY=$(LIBNAME).dll
-    LDFLAGS=
-    # Libraries we are dependent on
-    LIBRARIES=
-    # Building a shared library
-    LINK_SHARED=link -dll -out:$@
-endif
-
-# Common -I options
-CFLAGS += -I.
-CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
-
-# Default rule
-all: $(LIBRARY)
-
-# Build native library
-$(LIBRARY): $(OBJECTS)
-	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
-
-# Cleanup the built bits
-clean:
-	rm -f $(LIBRARY) $(OBJECTS)
-
-# Simple tester
-test: all
-	LD_LIBRARY_PATH=`pwd` $(JDK)/bin/java -agentlib:$(LIBNAME) -version
-
-# Compilation rule only needed on Windows
-ifeq ($(OSNAME), win32)
-%.obj: %.c
-	$(COMPILE.c) $<
-endif
-
--- a/jdk/src/demo/share/jvmti/index.html	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,430 +0,0 @@
-<html>
-<head> <title>JVM TI Demonstration Code</title> </head>
-
-<h1>JVM TI Demonstration Code</h1>
-
-<p>
-The 
-Java&trade; Virtual Machine Tools Interface (JVM TI)
-is a native tool interface provided in JDK 5.0 and newer.
-Native libraries that use JVM TI and are loaded into the 
-Java Virtual Machine
-via the -agentlib, -agentpath, or -Xrun (deprecated) interfaces, are
-called Agents.
-<p>
-<A HREF="http://java.sun.com/j2se/latest/docs/guide/jvmti">JVM TI</A>
-was designed to work with the
-Java Native Interface 
-(<A HREF="http://java.sun.com/j2se/latest/docs/guide/jni">JNI</A>),
-and eventually displace the 
-Java Virtual Machine Debugging Interface 
-(<A HREF="http://java.sun.com/j2se/1.5.0/docs/guide/jpda/jvmdi-spec.html">JVMDI</A>)
-and the 
-Java Virtual Machine Profiling Interface 
-(<A HREF="http://java.sun.com/j2se/1.5.0/docs/guide/jvmpi/index.html">JVMPI</A>).
-
-<p>
-We have created a set of demonstration agents that should
-help show many of the features and abilities of the
-interface. This list of demonstration agents will change over time.
-They are provided as educational tools and as starting
-points for Java tool development.
-
-<p>
-These agents are built with every JDK build and some basic testing is performed
-on a regular basis, but no extensive testbases currently
-exist for these agents.
-Every JDK installation should include all the pre-built binaries and sources for
-all these agents, just look in the demo/jvmti directory of your JDK.
-
-
-<h2>Using or Running These Agents</h2>
-
-<p>
-Using these agents will require the VM to locate the shared library file
-before any actual Java code is run.
-The JDK installation should contain all the agent libraries in 
-the ${JAVA_HOME}/demo/jvmti/<i>agent-name</i>/lib directories.
-The Solaris 64bit version would be contained in the sparcv9 or amd64
-subdirectory.
-If 'java' complains that it can't find the library,
-you may need to add the directory containing the library into the
-LD_LIBRARY_PATH environment variable (Unix), or the PATH environment
-variable (Windows).
-This is system and platform specific.
-If you are using 64bit Solaris (e.g. 'java -d64'), 
-you should use LD_LIBRARY_PATH64.
-Some agents such as the jdwp (debugger backend)
-are located inside the primary JDK directories and will always be found
-in those locations.
-
-<p>
-The agents that instrument classfiles 
-(i.e. BCI, usually through the java_crw_demo library) 
-such as heapTracker, mtrace, and minst, 
-also need to have the Java classes they use available in the bootclasspath.
-The agents will make attempts at automatically adding their jar file
-(e.g. heapTracker.jar, mtrace.jar, or minst.jar) to the bootclasspath
-with AddToBootstrapClassLoaderSearch from JVM TI at startup
-(see the agent_util code).
-This is done by locating this jar file at 
-${JAVA_HOME}/demo/jvmti/<i>agent-name</i>
-where JAVA_HOME is obtained by calling GetSystemProperty from JVM TI
-with "java.home".
-We recognize that this is not ideal, but felt that as just demonstration
-code it was acceptable.
-Ideally the agent could find out the actual directory it came from and
-locate the jar file relative to that location. 
-Our demonstration agents currently do not do this.
-
-<p>
-If you choose to modify or change these agents, the above information
-is important in making everything is found.
-It is recommended that you change the name of the agent when you
-modify it to avoid conflicts with the existing demo agents.
-Or better yet, go to http://jdk.dev.java.net and submit your
-changes to the agent as an RFE to the JDK.
-
-
-<h2> Demonstration Agents Available </h2>
-
-<ul>
-
-<li>
-<A HREF="versionCheck">versionCheck</A>
-<br>
-This is a extremely small agent that does nothing but check the
-version string supplied in the jvmti.h file, with the version
-number supplied by the VM at runtime.
-</li>
-
-<li>
-<A HREF="compiledMethodLoad">compiledMethodLoad</A>
-<br>
-This is a small agent that traces CompiledMethodLoad events along
-with the HotSpot specific compile_info parameter.
-</li>
-
-<li>
-<A HREF="mtrace">mtrace</A>
-<br>
-This is a small agent that does method tracing.
-It uses Bytecode Instrumentation (BCI) via the java_crw_demo library.
-</li>
-
-<li>
-<A HREF="minst">minst</A>
-<br>
-This is an even smaller agent that does just method entry tracing.
-It also uses Bytecode Instrumentation (BCI) via the java_crw_demo library,
-but the instrumentation code is pure Java (no Java native methods used).
-NOTE: Be sure to check out java.lang.instrument for a way to avoid
-native code agents completely.
-</li>
-
-<li>
-<A HREF="gctest">gctest</A>
-<br>
-This is a small agent that does garbage collection counting.
-</li>
-
-<li>
-<A HREF="heapViewer">heapViewer</A>
-<br>
-This is a small agent that does some basic heap inspections.
-</li>
-
-<li>
-<A HREF="heapTracker">heapTracker</A>
-<br>
-This is a small agent that does BCI to capture object creation
-and track them.
-It uses Bytecode Instrumentation (BCI) via the java_crw_demo library.
-</li>
-
-<li>
-<A HREF="waiters">waiters</A>
-<br>
-This is a small agent that gets information about threads
-waiting on monitors.
-</li>
-
-</ul>
-
-
-
-<h2>Agent Support</h2>
-
-<ul>
-
-<li>
-<A HREF="java_crw_demo">java_crw_demo</A>
-<br>
-This is a demo C library that does class file to class file
-transformations or BCI (Bytecode Instrumentation).
-It is used by several of the above agents.
-</li>
-
-
-</ul>
-
-
-
-<h2>Native Library Build Hints</h2>
-
-<p>
-All libraries loaded into java are assumed to be MT-safe (Multi-thread safe).
-This means that multiple threads could be executing the code at the same
-time, and static or global data may need to be placed in critical
-sections. See the Raw Monitor interfaces for more information.
-
-<p>
-All native libraries loaded into the 
-Java Virtual Machine,
-including Agent libraries,
-need to be compiled and built in a compatible way.
-Certain native compilation options or optimizations should be avoided,
-and some are required.
-More information on this options is available in the man pages for
-the various compilers.
-
-<p>
-Some native compiler and linker options can create fatal or 
-erroneous behavior when native agent libraries are operating
-inside the Java Virtual Machine.
-It would take too many words to describe all the possible issues with all
-the native compiler options, optimizations, and settings.
-Here are some recommendations on the basic compiler and linker options
-we recommend:
-
-<ul>
-
-<h3> Solaris </h3>
-
-<li>
-On Solaris, using the Sun Studio 11 C compiler,
-the typical compile and link command lines might look something like:
-<br>
-For 32bit SPARC:
-<br>
-<code><ul>
-cc -xO2 -mt -xregs=no%appl -xmemalign=4s -xarch=v8 -KPIC -c <i>*.c</i>
-<br>
-cc -mt -xarch=v8 -z defs -ztext -G -o <i>libXXX.so *.o</i> -lc
-</code></ul>
-<br>
-For 64bit SPARC:
-<br>
-<code><ul>
-cc -xO2 -mt -xregs=no%appl -xarch=v9 -KPIC -c <i>*.c</i>
-<br>
-cc -mt -xarch=v9 -z defs -ztext -G -o <i>libXXX.so *.o</i> -lc
-</code></ul>
-<br>
-For X86:
-<br>
-<code><ul>
-cc -xO2 -mt -xregs=no%frameptr -KPIC -c <i>*.c</i>
-<br>
-cc -mt -z defs -ztext -G -o <i>libXXX.so *.o</i> -lc
-</code></ul>
-<br>
-For AMD64:
-<br>
-<code><ul>
-cc -xO2 -mt -xregs=no%frameptr -xarch=amd64 -KPIC -c <i>*.c</i>
-<br>
-cc -mt -xarch=amd64 -z defs -ztext -G -o <i>libXXX.so *.o</i> -lc
-</code></ul>
-<br>
-</li>
-
-<li>
-Architecture/File Format: 
-For SPARC 32bit use <code>-xarch=v8</code>, 
-for SPARC 64bit use <code>-xarch=v9</code>, 
-for X86 (32-bit) 
-<i>
-leave the option off or use <code>-xarch=generic</code>
-</i>,
-and for AMD64 (64bit) use <code>-xarch=amd64</code>
-with both C and C++.
-<br>
-This is to be specific as to the architecture and the file format
-of the .o files (and ultimately of the .so). 
-</li>
-
-<li>
-MT-Safe, Position Independent: Use <code>-KPIC -mt</code> 
-with both C and C++.
-</li>
-
-<li>
-Register usage: For SPARC (both 32bit and 64bit) use 
-<code>-xregs=no%appl</code> and for X86 and AMD64 use <code>-xregs=no%frameptr</code>
-with both C and C++.
-</li>
-
-<li>
-Alignment: For SPARC 32bit use -xmemalign=4s and for SPARC 64bit do NOT use <code>-xmemalign=4</code>
-with both C and C++.
-</li>
-
-<li>
-Dependencies: Use <code>ldd -r <i>LibraryName</i></code>.
-<br>
-After the shared library has been built, the utility
-<code>ldd</code> can be used to verify that all dependent libraries 
-have been satisfied, and all externs can be found.
-If <code>ldd</code> says anything is missing, it is very likely that the JVM will also
-be unable to load this library.
-This usually means that you missed some <code>-l<i>name</i></code>
-options when building the library, or perhaps forgot a <code>-R path</code>
-option that tells the library where to look for libraries at runtime.
-</li>
-
-<h3> Linux </h3>
-
-<li>
-On Linux, using the gcc version 3.2, 
-the typical compile and link command lines might look something like:
-<br>
-For X86:
-<br>
-<code><ul>
-gcc -O2 -fPIC -pthread -DLINUX -c <i>*.c</i>
-<br>
-gcc -z defs -static-libgcc -shared -o <i>libXXX.so *.o</i> -lc
-</code></ul>
-<br>
-For AMD64:
-<br>
-<code><ul>
-gcc -O2 -fPIC -pthread -DLINUX -D_LP64=1 -c <i>*.c</i>
-<br>
-gcc -z defs -static-libgcc -shared -o <i>libXXX.so *.o</i> -lc
-</code></ul>
-<br>
-</li>
-
-<li>
-MT-Safe, Position Independent: 
-Use <code>-fPIC -pthread</code>.
-</li>
-
-<li>
-Agent Demo Code: Needs -DLINUX
-</li>
-
-<li>
-Register Usage: Use <code>-fno-omit-frame-pointer</code>.
-<br>
-It is important that these libraries have frame pointer register usage, see the above comments on the Solaris 
-<code>-xregs=no%frameptr</code>
-option.
-</li>
-
-<li>
-Library: Use -static-libgcc.
-<br>
-When building the shared library (-shared option), this option
-allows for maximum portability of the library between different
-flavors of Linux.
-The problem we have seen with Linux is that we cannot depend
-on a compatible shared gcc library existing on all the versions of
-Linux we can run on.
-By doing this static link, the version script becomes more
-important, making sure you don't expose any extern symbols
-you didn't intend to.
-</li>
-
-<li>
-Dependencies: Use <code>ldd -r <i>LibraryName</i></code>.
-<br>
-Provides the same checking as Solaris (see above).
-</li>
-
-<h3> Windows </h3>
-
-<li>
-On Windows and using the Microsoft C++ Compiler Visual Studio .NET 2003,
-the typical compile and link command lines might look something like:
-<br>
-For X86:
-<br>
-<code><ul>
-cl /O1 /MD /D _STATIC_CPPLIB /c <i>*.c</i>
-<br>
-link /dll /opt:REF /out:<i>XXX.dll *.obj</i>
-</code></ul>
-<br>
-For AMD64:
-<br>
-<code><ul>
-cl /O1 /MD /D _STATIC_CPPLIB /c <i>*.c</i>
-<br>
-link /dll /opt:REF /out:<i>XXX.dll *.obj</i>
-</code></ul>
-<br>
-</li>
-
-<li>
-Library: Use <code>/opt:REF </code> when building the dll.
-</li>
-
-<li>
-MS DLL Runtime: Use the <code>/MD /D _STATIC_CPPLIB</code> option.
-<br>
-This causes your dll to become dependent on just MSVCR*.DLL.
-The option /D _STATIC_CPPLIB prevents you from becoming dependent on the
-C++ library MSVCP*.DLL.
-This is what we use in the JDK, but there are probably many combinations
-that you could safely use, unfortunately there are many combinations
-of runtimes that will not work. 
-Check the Microsoft site on proper use of runtimes.
-</li>
-
-<li>
-Dependencies: Use VC++ <code>dumpbin /exports</code> and the VC++ "Dependency Walker".
-<br>
-Provides dependency information similar to <code>ldd</code>.
-</li>
-
-</ul>
-
-
-<h2>For More Information</h2>
-
-<p>
-Remember, the complete source to all these agents is contained in the JDK
-installations at demo/jvmti.
-
-<p>
-For more detailed information on JVM TI, refer to 
-<A HREF="http://java.sun.com/j2se/latest/docs/guide/jvmti">
-http://java.sun.com/j2se/latest/docs/guide/jvmti.</A>
- 
-<p>
-More information on using JNI and building native libraries refer to:
-<A HREF="http://java.sun.com/j2se/latest/docs/guide/jni">
-http://java.sun.com/j2se/latest/docs/guide/jni</A>.
-
-<p>
-Additional information can also be found by doing a search on "jvmti" at
-<A HREF="http://java.sun.com/j2se">http://java.sun.com/j2se</A>.
-Various technical articles are also available through this website.
-And don't forget the 
-Java Tutorials at 
-<A HREF="http://docs.oracle.com/javase/tutorial">http://docs.oracle.com/javase/tutorial</A>
-for getting a quick start on all the various interfaces.
-
-<h2>Comments and Feedback</h2>
-
-<p>
-Comments regarding JVM TI or on any of these demonstrations should be
-sent through 
-<A HREF="http://java.sun.com/mail">http://java.sun.com/mail/</A>
-
-
-
-</html>
--- a/jdk/src/demo/share/jvmti/java_crw_demo/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-#
-# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-java_crw_demo Library
-
-The library java_crw_demo is a small C library that is used by HPROF
-and other agent libraries to do some very basic bytecode 
-insertion (BCI) of class files.  This is not an agent 
-library but a general purpose library that can be used to do some 
-very limited bytecode insertion.
-
-In the demo sources, look for the use of java_crw_demo.h and
-the C function java_crw_demo().  The java_crw_demo library is provided 
-as part of the JRE.
-
-The basic BCI that this library does includes:
-
-    * On entry to the java.lang.Object init method (signature "()V"), 
-      a invokestatic call to tclass.obj_init_method(object); is inserted. 
-
-    * On any newarray type opcode, immediately following it, the array 
-      object is duplicated on the stack and an invokestatic call to
-      tclass.newarray_method(object); is inserted. 
-
-    * On entry to all methods, a invokestatic call to 
-      tclass.call_method(cnum,mnum); is inserted. The agent can map the 
-      two integers (cnum,mnum) to a method in a class, the cnum is the 
-      number provided to the java_crw_demo library when the classfile was 
-      modified.
-
-    * On return from any method (any return opcode), a invokestatic call to
-      tclass.return_method(cnum,mnum); is inserted.  
-
-Some methods are not modified at all, init methods and finalize methods 
-whose length is 1 will not be modified.  Classes that are designated 
-"system" will not have their clinit methods modified. In addition, the 
-method java.lang.Thread.currentThread() is not modified.
-
-No methods or fields will be added to any class, however new constant 
-pool entries will be added at the end of the original constant pool table.
-The exception, line, and local variable tables for each method is adjusted 
-for the modification. The bytecodes are compressed to use smaller offsets 
-and the fewest 'wide' opcodes. 
-
-All attempts are made to minimize the number of bytecodes at each insertion 
-site, however, classes with N return opcodes or N newarray opcodes will get 
-N insertions.  And only the necessary modification dictated by the input 
-arguments to java_crw_demo are actually made.
-
--- a/jdk/src/demo/share/jvmti/java_crw_demo/java_crw_demo.c	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2535 +0,0 @@
-/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/* Class reader writer (java_crw_demo) for instrumenting bytecodes */
-
-/*
- * As long as the callbacks allow for it and the class number is unique,
- *     this code is completely re-entrant and any number of classfile
- *     injections can happen at the same time.
- *
- *     The current logic requires a unique number for this class instance
- *     or (jclass,jobject loader) pair, this is done via the ClassIndex
- *     in hprof, which is passed in as the 'unsigned cnum' to java_crw_demo().
- *     It's up to the user of this interface if it wants to use this
- *     feature.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* Get Java and class file and bytecode information. */
-
-#include <jni.h>
-
-#include "classfile_constants.h"
-
-
-/* Include our own interface for cross check */
-
-#include "java_crw_demo.h"
-
-/* Macros over error functions to capture line numbers */
-
-/* Fatal error used in all builds. */
-
-/* Use THIS_FILE when it is available. */
-#ifndef THIS_FILE
-    #define THIS_FILE "java_crw.demo.c" /* Never use __FILE__ */
-#endif
-
-#define CRW_FATAL(ci, message) fatal_error(ci, message, THIS_FILE, __LINE__)
-
-#if defined(DEBUG) || !defined(NDEBUG)
-
-  /* This assert macro is only used in the debug builds. */
-  #define CRW_ASSERT(ci, cond) \
-        ((cond)?(void)0:assert_error(ci, #cond, THIS_FILE, __LINE__))
-
-#else
-
-  #define CRW_ASSERT(ci, cond)
-
-#endif
-
-#define CRW_ASSERT_MI(mi) CRW_ASSERT((mi)?(mi)->ci:NULL,(mi)!=NULL)
-
-#define CRW_ASSERT_CI(ci) CRW_ASSERT(ci, ( (ci) != NULL && \
-                         (ci)->input_position <= (ci)->input_len && \
-                         (ci)->output_position <= (ci)->output_len) )
-
-#define BUFSIZE 256
-
-#ifdef _WIN32
-#define snprintf(buffer, count, format, ...) _snprintf_s(buffer, count, _TRUNCATE, format, ##__VA_ARGS__)
-#endif
-
-/* Typedefs for various integral numbers, just for code clarity */
-
-typedef unsigned       ClassOpcode;             /* One opcode */
-typedef unsigned char  ByteCode;                /* One byte from bytecodes */
-typedef int            ByteOffset;              /* Byte offset */
-typedef int            ClassConstant;           /* Constant pool kind */
-typedef long           CrwPosition;             /* Position in class image */
-typedef unsigned short CrwCpoolIndex;           /* Index into constant pool */
-
-/* Misc support macros */
-
-/* Given the position of an opcode, find the next 4byte boundary position */
-#define NEXT_4BYTE_BOUNDARY(opcode_pos) (((opcode_pos)+4) & (~3))
-
-#define LARGEST_INJECTION               (12*3) /* 3 injections at same site */
-#define MAXIMUM_NEW_CPOOL_ENTRIES       64 /* don't add more than 32 entries */
-
-/* Constant Pool Entry (internal table that mirrors pool in file image) */
-
-typedef struct {
-    const char *        ptr;            /* Pointer to any string */
-    unsigned short      len;            /* Length of string */
-    unsigned int        index1;         /* 1st 16 bit index or 32bit value. */
-    unsigned int        index2;         /* 2nd 16 bit index or 32bit value. */
-    ClassConstant       tag;            /* Tag or kind of entry. */
-} CrwConstantPoolEntry;
-
-struct MethodImage;
-
-/* Class file image storage structure */
-
-typedef struct CrwClassImage {
-
-    /* Unique class number for this class */
-    unsigned                    number;
-
-    /* Name of class, given or gotten out of class image */
-    const char *                name;
-
-    /* Input and Output class images tracking */
-    const unsigned char *       input;
-    unsigned char *             output;
-    CrwPosition                 input_len;
-    CrwPosition                 output_len;
-    CrwPosition                 input_position;
-    CrwPosition                 output_position;
-
-    /* Mirrored constant pool */
-    CrwConstantPoolEntry *      cpool;
-    CrwCpoolIndex               cpool_max_elements;             /* Max count */
-    CrwCpoolIndex               cpool_count_plus_one;
-
-    /* Input flags about class (e.g. is it a system class) */
-    int                         system_class;
-
-    /* Class access flags gotten from file. */
-    unsigned                    access_flags;
-
-    /* Names of classes and methods. */
-    char* tclass_name;          /* Name of class that has tracker methods. */
-    char* tclass_sig;           /* Signature of class */
-    char* call_name;            /* Method name to call at offset 0 */
-    char* call_sig;             /* Signature of this method */
-    char* return_name;          /* Method name to call before any return */
-    char* return_sig;           /* Signature of this method */
-    char* obj_init_name;        /* Method name to call in Object <init> */
-    char* obj_init_sig;         /* Signature of this method */
-    char* newarray_name;        /* Method name to call after newarray opcodes */
-    char* newarray_sig;         /* Signature of this method */
-
-    /* Constant pool index values for new entries */
-    CrwCpoolIndex               tracker_class_index;
-    CrwCpoolIndex               object_init_tracker_index;
-    CrwCpoolIndex               newarray_tracker_index;
-    CrwCpoolIndex               call_tracker_index;
-    CrwCpoolIndex               return_tracker_index;
-    CrwCpoolIndex               class_number_index; /* Class number in pool */
-
-    /* Count of injections made into this class */
-    int                         injection_count;
-
-    /* This class must be the java.lang.Object class */
-    jboolean                    is_object_class;
-
-    /* This class must be the java.lang.Thread class */
-    jboolean                    is_thread_class;
-
-    /* Callback functions */
-    FatalErrorHandler           fatal_error_handler;
-    MethodNumberRegister        mnum_callback;
-
-    /* Table of method names and descr's */
-    int                         method_count;
-    const char **               method_name;
-    const char **               method_descr;
-    struct MethodImage *        current_mi;
-
-} CrwClassImage;
-
-/* Injection bytecodes (holds injected bytecodes for each code position) */
-
-typedef struct {
-    ByteCode *  code;
-    ByteOffset  len;
-} Injection;
-
-/* Method transformation data (allocated/freed as each method is processed) */
-
-typedef struct MethodImage {
-
-    /* Back reference to Class image data. */
-    CrwClassImage *     ci;
-
-    /* Unique method number for this class. */
-    unsigned            number;
-
-    /* Method name and descr */
-    const char *        name;
-    const char *        descr;
-
-    /* Map of input bytecode offsets to output bytecode offsets */
-    ByteOffset *        map;
-
-    /* Bytecode injections for each input bytecode offset */
-    Injection *         injections;
-
-    /* Widening setting for each input bytecode offset */
-    signed char *       widening;
-
-    /* Length of original input bytecodes, and new bytecodes. */
-    ByteOffset          code_len;
-    ByteOffset          new_code_len;
-
-    /* Location in input where bytecodes are located. */
-    CrwPosition         start_of_input_bytecodes;
-
-    /* Original max_stack and new max stack */
-    unsigned            max_stack;
-    unsigned            new_max_stack;
-
-    jboolean            object_init_method;
-    jboolean            skip_call_return_sites;
-
-    /* Method access flags gotten from file. */
-    unsigned            access_flags;
-
-} MethodImage;
-
-/* ----------------------------------------------------------------- */
-/* General support functions (memory and error handling) */
-
-static void
-fatal_error(CrwClassImage *ci, const char *message, const char *file, int line)
-{
-    if ( ci != NULL && ci->fatal_error_handler != NULL ) {
-        (*ci->fatal_error_handler)(message, file, line);
-    } else {
-        /* Normal operation should NEVER reach here */
-        /* NO CRW FATAL ERROR HANDLER! */
-        (void)fprintf(stderr, "CRW: %s [%s:%d]\n", message, file, line);
-    }
-    abort();
-}
-
-#if defined(DEBUG) || !defined(NDEBUG)
-static void
-assert_error(CrwClassImage *ci, const char *condition,
-                 const char *file, int line)
-{
-    char buf[512];
-    MethodImage *mi;
-    ByteOffset byte_code_offset;
-
-    mi = ci->current_mi;
-    if ( mi != NULL ) {
-        byte_code_offset = (ByteOffset)(mi->ci->input_position - mi->start_of_input_bytecodes);
-    } else {
-        byte_code_offset=-1;
-    }
-
-    (void)sprintf(buf,
-                "CRW ASSERTION FAILURE: %s (%s:%s:%d)",
-                condition,
-                ci->name==NULL?"?":ci->name,
-                (mi==NULL||mi->name==NULL)?"?":mi->name,
-                byte_code_offset);
-    fatal_error(ci, buf, file, line);
-}
-#endif
-
-static void *
-allocate(CrwClassImage *ci, int nbytes)
-{
-    void * ptr;
-
-    if ( nbytes <= 0 ) {
-        CRW_FATAL(ci, "Cannot allocate <= 0 bytes");
-    }
-    ptr = malloc(nbytes);
-    if ( ptr == NULL ) {
-        CRW_FATAL(ci, "Ran out of malloc memory");
-    }
-    return ptr;
-}
-
-static void *
-reallocate(CrwClassImage *ci, void *optr, int nbytes)
-{
-    void * ptr;
-
-    if ( optr == NULL ) {
-        CRW_FATAL(ci, "Cannot deallocate NULL");
-    }
-    if ( nbytes <= 0 ) {
-        CRW_FATAL(ci, "Cannot reallocate <= 0 bytes");
-    }
-    ptr = realloc(optr, nbytes);
-    if ( ptr == NULL ) {
-        CRW_FATAL(ci, "Ran out of malloc memory");
-    }
-    return ptr;
-}
-
-static void *
-allocate_clean(CrwClassImage *ci, int nbytes)
-{
-    void * ptr;
-
-    if ( nbytes <= 0 ) {
-        CRW_FATAL(ci, "Cannot allocate <= 0 bytes");
-    }
-    ptr = calloc(nbytes, 1);
-    if ( ptr == NULL ) {
-        CRW_FATAL(ci, "Ran out of malloc memory");
-    }
-    return ptr;
-}
-
-static const char *
-duplicate(CrwClassImage *ci, const char *str, int len)
-{
-    char *copy;
-
-    copy = (char*)allocate(ci, len+1);
-    (void)memcpy(copy, str, len);
-    copy[len] = 0;
-    return (const char *)copy;
-}
-
-static void
-deallocate(CrwClassImage *ci, void *ptr)
-{
-    if ( ptr == NULL ) {
-        CRW_FATAL(ci, "Cannot deallocate NULL");
-    }
-    (void)free(ptr);
-}
-
-/* ----------------------------------------------------------------- */
-/* Functions for reading/writing bytes to/from the class images */
-
-static unsigned
-readU1(CrwClassImage *ci)
-{
-    CRW_ASSERT_CI(ci);
-    return ((unsigned)(ci->input[ci->input_position++])) & 0xFF;
-}
-
-static unsigned
-readU2(CrwClassImage *ci)
-{
-    unsigned res;
-
-    res = readU1(ci);
-    return (res << 8) + readU1(ci);
-}
-
-static signed short
-readS2(CrwClassImage *ci)
-{
-    unsigned res;
-
-    res = readU1(ci);
-    return ((res << 8) + readU1(ci)) & 0xFFFF;
-}
-
-static unsigned
-readU4(CrwClassImage *ci)
-{
-    unsigned res;
-
-    res = readU2(ci);
-    return (res << 16) + readU2(ci);
-}
-
-static void
-writeU1(CrwClassImage *ci, unsigned val)  /* Only writes out lower 8 bits */
-{
-    CRW_ASSERT_CI(ci);
-    if ( ci->output != NULL ) {
-        ci->output[ci->output_position++] = val & 0xFF;
-    }
-}
-
-static void
-writeU2(CrwClassImage *ci, unsigned val)
-{
-    writeU1(ci, val >> 8);
-    writeU1(ci, val);
-}
-
-static void
-writeU4(CrwClassImage *ci, unsigned val)
-{
-    writeU2(ci, val >> 16);
-    writeU2(ci, val);
-}
-
-static unsigned
-copyU1(CrwClassImage *ci)
-{
-    unsigned value;
-
-    value = readU1(ci);
-    writeU1(ci, value);
-    return value;
-}
-
-static unsigned
-copyU2(CrwClassImage *ci)
-{
-    unsigned value;
-
-    value = readU2(ci);
-    writeU2(ci, value);
-    return value;
-}
-
-static unsigned
-copyU4(CrwClassImage *ci)
-{
-    unsigned value;
-
-    value = readU4(ci);
-    writeU4(ci, value);
-    return value;
-}
-
-static void
-copy(CrwClassImage *ci, unsigned count)
-{
-    CRW_ASSERT_CI(ci);
-    if ( ci->output != NULL ) {
-        (void)memcpy(ci->output+ci->output_position,
-                     ci->input+ci->input_position, count);
-        ci->output_position += count;
-    }
-    ci->input_position += count;
-    CRW_ASSERT_CI(ci);
-}
-
-static void
-skip(CrwClassImage *ci, unsigned count)
-{
-    CRW_ASSERT_CI(ci);
-    ci->input_position += count;
-}
-
-static void
-read_bytes(CrwClassImage *ci, void *bytes, unsigned count)
-{
-    CRW_ASSERT_CI(ci);
-    CRW_ASSERT(ci, bytes!=NULL);
-    (void)memcpy(bytes, ci->input+ci->input_position, count);
-    ci->input_position += count;
-}
-
-static void
-write_bytes(CrwClassImage *ci, void *bytes, unsigned count)
-{
-    CRW_ASSERT_CI(ci);
-    CRW_ASSERT(ci, bytes!=NULL);
-    if ( ci->output != NULL ) {
-        (void)memcpy(ci->output+ci->output_position, bytes, count);
-        ci->output_position += count;
-    }
-}
-
-static void
-random_writeU2(CrwClassImage *ci, CrwPosition pos, unsigned val)
-{
-    CrwPosition save_position;
-
-    CRW_ASSERT_CI(ci);
-    save_position = ci->output_position;
-    ci->output_position = pos;
-    writeU2(ci, val);
-    ci->output_position = save_position;
-}
-
-static void
-random_writeU4(CrwClassImage *ci, CrwPosition pos, unsigned val)
-{
-    CrwPosition save_position;
-
-    CRW_ASSERT_CI(ci);
-    save_position = ci->output_position;
-    ci->output_position = pos;
-    writeU4(ci, val);
-    ci->output_position = save_position;
-}
-
-/* ----------------------------------------------------------------- */
-/* Constant Pool handling functions. */
-
-static void
-fillin_cpool_entry(CrwClassImage *ci, CrwCpoolIndex i,
-                   ClassConstant tag,
-                   unsigned int index1, unsigned int index2,
-                   const char *ptr, int len)
-{
-    CRW_ASSERT_CI(ci);
-    CRW_ASSERT(ci, i > 0 && i < ci->cpool_count_plus_one);
-    ci->cpool[i].tag    = tag;
-    ci->cpool[i].index1 = index1;
-    ci->cpool[i].index2 = index2;
-    ci->cpool[i].ptr    = ptr;
-    ci->cpool[i].len    = (unsigned short)len;
-}
-
-static CrwCpoolIndex
-add_new_cpool_entry(CrwClassImage *ci, ClassConstant tag,
-                    unsigned int index1, unsigned int index2,
-                    const char *str, int len)
-{
-    CrwCpoolIndex i;
-    char *utf8 = NULL;
-
-    CRW_ASSERT_CI(ci);
-    i = ci->cpool_count_plus_one++;
-
-    /* NOTE: This implementation does not automatically expand the
-     *       constant pool table beyond the expected number needed
-     *       to handle this particular CrwTrackerInterface injections.
-     *       See MAXIMUM_NEW_CPOOL_ENTRIES
-     */
-    CRW_ASSERT(ci,  ci->cpool_count_plus_one < ci->cpool_max_elements );
-
-    writeU1(ci, tag);
-    switch (tag) {
-        case JVM_CONSTANT_Class:
-            writeU2(ci, index1);
-            break;
-        case JVM_CONSTANT_String:
-            writeU2(ci, index1);
-            break;
-        case JVM_CONSTANT_Fieldref:
-        case JVM_CONSTANT_Methodref:
-        case JVM_CONSTANT_InterfaceMethodref:
-        case JVM_CONSTANT_Integer:
-        case JVM_CONSTANT_Float:
-        case JVM_CONSTANT_NameAndType:
-            writeU2(ci, index1);
-            writeU2(ci, index2);
-            break;
-        case JVM_CONSTANT_Long:
-        case JVM_CONSTANT_Double:
-            writeU4(ci, index1);
-            writeU4(ci, index2);
-            ci->cpool_count_plus_one++;
-            CRW_ASSERT(ci,  ci->cpool_count_plus_one < ci->cpool_max_elements );
-            break;
-        case JVM_CONSTANT_Utf8:
-            CRW_ASSERT(ci, len==(len & 0xFFFF));
-            writeU2(ci, len);
-            write_bytes(ci, (void*)str, len);
-            utf8 = (char*)duplicate(ci, str, len);
-            break;
-        default:
-            CRW_FATAL(ci, "Unknown constant");
-            break;
-    }
-    fillin_cpool_entry(ci, i, tag, index1, index2, (const char *)utf8, len);
-    CRW_ASSERT(ci, i > 0 && i < ci->cpool_count_plus_one);
-    return i;
-}
-
-static CrwCpoolIndex
-add_new_class_cpool_entry(CrwClassImage *ci, const char *class_name)
-{
-    CrwCpoolIndex name_index;
-    CrwCpoolIndex class_index;
-    int           len;
-
-    CRW_ASSERT_CI(ci);
-    CRW_ASSERT(ci, class_name!=NULL);
-
-    len = (int)strlen(class_name);
-    name_index = add_new_cpool_entry(ci, JVM_CONSTANT_Utf8, len, 0,
-                        class_name, len);
-    class_index = add_new_cpool_entry(ci, JVM_CONSTANT_Class, name_index, 0,
-                        NULL, 0);
-    return class_index;
-}
-
-static CrwCpoolIndex
-add_new_method_cpool_entry(CrwClassImage *ci, CrwCpoolIndex class_index,
-                     const char *name, const char *descr)
-{
-    CrwCpoolIndex name_index;
-    CrwCpoolIndex descr_index;
-    CrwCpoolIndex name_type_index;
-    int len;
-
-    CRW_ASSERT_CI(ci);
-    CRW_ASSERT(ci, name!=NULL);
-    CRW_ASSERT(ci, descr!=NULL);
-    len = (int)strlen(name);
-    name_index =
-        add_new_cpool_entry(ci, JVM_CONSTANT_Utf8, len, 0, name, len);
-    len = (int)strlen(descr);
-    descr_index =
-        add_new_cpool_entry(ci, JVM_CONSTANT_Utf8, len, 0, descr, len);
-    name_type_index =
-        add_new_cpool_entry(ci, JVM_CONSTANT_NameAndType,
-                                name_index, descr_index, NULL, 0);
-    return add_new_cpool_entry(ci, JVM_CONSTANT_Methodref,
-                                class_index, name_type_index, NULL, 0);
-}
-
-static CrwConstantPoolEntry
-cpool_entry(CrwClassImage *ci, CrwCpoolIndex c_index)
-{
-    CRW_ASSERT_CI(ci);
-    CRW_ASSERT(ci, c_index > 0 && c_index < ci->cpool_count_plus_one);
-    return ci->cpool[c_index];
-}
-
-static void
-cpool_setup(CrwClassImage *ci)
-{
-    CrwCpoolIndex i;
-    CrwPosition cpool_output_position;
-    int count_plus_one;
-
-    CRW_ASSERT_CI(ci);
-    cpool_output_position = ci->output_position;
-    count_plus_one = copyU2(ci);
-    CRW_ASSERT(ci, count_plus_one>1);
-    ci->cpool_max_elements = count_plus_one+MAXIMUM_NEW_CPOOL_ENTRIES;
-    ci->cpool = (CrwConstantPoolEntry*)allocate_clean(ci,
-                (int)((ci->cpool_max_elements)*sizeof(CrwConstantPoolEntry)));
-    ci->cpool_count_plus_one = (CrwCpoolIndex)count_plus_one;
-
-    /* Index zero not in class file */
-    for (i = 1; i < count_plus_one; ++i) {
-        CrwCpoolIndex   ipos;
-        ClassConstant   tag;
-        unsigned int    index1;
-        unsigned int    index2;
-        unsigned        len;
-        char *          utf8;
-        char message[BUFSIZE];
-
-        ipos    = i;
-        index1  = 0;
-        index2  = 0;
-        len     = 0;
-        utf8    = NULL;
-
-        tag = copyU1(ci);
-        switch (tag) {
-            case JVM_CONSTANT_Class:
-                index1 = copyU2(ci);
-                break;
-            case JVM_CONSTANT_String:
-                index1 = copyU2(ci);
-                break;
-            case JVM_CONSTANT_Fieldref:
-            case JVM_CONSTANT_Methodref:
-            case JVM_CONSTANT_InterfaceMethodref:
-            case JVM_CONSTANT_Integer:
-            case JVM_CONSTANT_Float:
-            case JVM_CONSTANT_NameAndType:
-                index1 = copyU2(ci);
-                index2 = copyU2(ci);
-                break;
-            case JVM_CONSTANT_Long:
-            case JVM_CONSTANT_Double:
-                index1 = copyU4(ci);
-                index2 = copyU4(ci);
-                ++i;  /* // these take two CP entries - duh! */
-                break;
-            case JVM_CONSTANT_Utf8:
-                len     = copyU2(ci);
-                index1  = (unsigned short)len;
-                utf8    = (char*)allocate(ci, len+1);
-                read_bytes(ci, (void*)utf8, len);
-                utf8[len] = 0;
-                write_bytes(ci, (void*)utf8, len);
-                break;
-            case JVM_CONSTANT_MethodType:
-                index1 = copyU2(ci);
-                break;
-            case JVM_CONSTANT_MethodHandle:
-                index1 = copyU1(ci);
-                index2 = copyU2(ci);
-                break;
-            case JVM_CONSTANT_InvokeDynamic:
-                index1 = copyU2(ci);
-                index2 = copyU2(ci);
-                break;
-            default:
-                snprintf(message, BUFSIZE, "Unknown tag: %d, at ipos %hu", tag, ipos);
-                CRW_FATAL(ci, message);
-                break;
-        }
-        fillin_cpool_entry(ci, ipos, tag, index1, index2, (const char *)utf8, len);
-    }
-
-    if (ci->call_name != NULL || ci->return_name != NULL) {
-        if ( ci->number != (ci->number & 0x7FFF) ) {
-            ci->class_number_index =
-                add_new_cpool_entry(ci, JVM_CONSTANT_Integer,
-                    (ci->number>>16) & 0xFFFF, ci->number & 0xFFFF, NULL, 0);
-        }
-    }
-
-    if (  ci->tclass_name != NULL ) {
-        ci->tracker_class_index =
-                add_new_class_cpool_entry(ci, ci->tclass_name);
-    }
-    if (ci->obj_init_name != NULL) {
-        ci->object_init_tracker_index = add_new_method_cpool_entry(ci,
-                    ci->tracker_class_index,
-                    ci->obj_init_name,
-                    ci->obj_init_sig);
-    }
-    if (ci->newarray_name != NULL) {
-        ci->newarray_tracker_index = add_new_method_cpool_entry(ci,
-                    ci->tracker_class_index,
-                    ci->newarray_name,
-                    ci->newarray_sig);
-    }
-    if (ci->call_name != NULL) {
-        ci->call_tracker_index = add_new_method_cpool_entry(ci,
-                    ci->tracker_class_index,
-                    ci->call_name,
-                    ci->call_sig);
-    }
-    if (ci->return_name != NULL) {
-        ci->return_tracker_index = add_new_method_cpool_entry(ci,
-                    ci->tracker_class_index,
-                    ci->return_name,
-                    ci->return_sig);
-    }
-
-    random_writeU2(ci, cpool_output_position, ci->cpool_count_plus_one);
-}
-
-/* ----------------------------------------------------------------- */
-/* Functions that create the bytecodes to inject */
-
-static ByteOffset
-push_pool_constant_bytecodes(ByteCode *bytecodes, CrwCpoolIndex index)
-{
-    ByteOffset nbytes = 0;
-
-    if ( index == (index&0x7F) ) {
-        bytecodes[nbytes++] = (ByteCode)JVM_OPC_ldc;
-    } else {
-        bytecodes[nbytes++] = (ByteCode)JVM_OPC_ldc_w;
-        bytecodes[nbytes++] = (ByteCode)((index >> 8) & 0xFF);
-    }
-    bytecodes[nbytes++] = (ByteCode)(index & 0xFF);
-    return nbytes;
-}
-
-static ByteOffset
-push_short_constant_bytecodes(ByteCode *bytecodes, unsigned number)
-{
-    ByteOffset nbytes = 0;
-
-    if ( number <= 5 ) {
-        bytecodes[nbytes++] = (ByteCode)(JVM_OPC_iconst_0+number);
-    } else if ( number == (number&0x7F) ) {
-        bytecodes[nbytes++] = (ByteCode)JVM_OPC_bipush;
-        bytecodes[nbytes++] = (ByteCode)(number & 0xFF);
-    } else {
-        bytecodes[nbytes++] = (ByteCode)JVM_OPC_sipush;
-        bytecodes[nbytes++] = (ByteCode)((number >> 8) & 0xFF);
-        bytecodes[nbytes++] = (ByteCode)(number & 0xFF);
-    }
-    return nbytes;
-}
-
-static ByteOffset
-injection_template(MethodImage *mi, ByteCode *bytecodes, ByteOffset max_nbytes,
-                        CrwCpoolIndex method_index)
-{
-    CrwClassImage *     ci;
-    ByteOffset nbytes = 0;
-    unsigned max_stack;
-    int add_dup;
-    int add_aload;
-    int push_cnum;
-    int push_mnum;
-
-    ci = mi->ci;
-
-    CRW_ASSERT(ci, bytecodes!=NULL);
-
-    if ( method_index == 0 )  {
-        return 0;
-    }
-
-    if ( method_index == ci->newarray_tracker_index) {
-        max_stack       = mi->max_stack + 1;
-        add_dup         = JNI_TRUE;
-        add_aload       = JNI_FALSE;
-        push_cnum       = JNI_FALSE;
-        push_mnum       = JNI_FALSE;
-    } else if ( method_index == ci->object_init_tracker_index) {
-        max_stack       = mi->max_stack + 1;
-        add_dup         = JNI_FALSE;
-        add_aload       = JNI_TRUE;
-        push_cnum       = JNI_FALSE;
-        push_mnum       = JNI_FALSE;
-    } else {
-        max_stack       = mi->max_stack + 2;
-        add_dup         = JNI_FALSE;
-        add_aload       = JNI_FALSE;
-        push_cnum       = JNI_TRUE;
-        push_mnum       = JNI_TRUE;
-    }
-
-    if ( add_dup ) {
-        bytecodes[nbytes++] = (ByteCode)JVM_OPC_dup;
-    }
-    if ( add_aload ) {
-        bytecodes[nbytes++] = (ByteCode)JVM_OPC_aload_0;
-    }
-    if ( push_cnum ) {
-        if ( ci->number == (ci->number & 0x7FFF) ) {
-            nbytes += push_short_constant_bytecodes(bytecodes+nbytes,
-                                                ci->number);
-        } else {
-            CRW_ASSERT(ci, ci->class_number_index!=0);
-            nbytes += push_pool_constant_bytecodes(bytecodes+nbytes,
-                                                ci->class_number_index);
-        }
-    }
-    if ( push_mnum ) {
-        nbytes += push_short_constant_bytecodes(bytecodes+nbytes,
-                                            mi->number);
-    }
-    bytecodes[nbytes++] = (ByteCode)JVM_OPC_invokestatic;
-    bytecodes[nbytes++] = (ByteCode)(method_index >> 8);
-    bytecodes[nbytes++] = (ByteCode)method_index;
-    bytecodes[nbytes]   = 0;
-    CRW_ASSERT(ci, nbytes<max_nbytes);
-
-    /* Make sure the new max_stack is appropriate */
-    if ( max_stack > mi->new_max_stack ) {
-        mi->new_max_stack = max_stack;
-    }
-    return nbytes;
-}
-
-/* Called to create injection code at entry to a method */
-static ByteOffset
-entry_injection_code(MethodImage *mi, ByteCode *bytecodes, ByteOffset len)
-{
-    CrwClassImage *     ci;
-    ByteOffset nbytes = 0;
-
-    CRW_ASSERT_MI(mi);
-
-    ci = mi->ci;
-
-    if ( mi->object_init_method ) {
-        nbytes = injection_template(mi,
-                            bytecodes, len, ci->object_init_tracker_index);
-    }
-    if ( !mi->skip_call_return_sites ) {
-        nbytes += injection_template(mi,
-                    bytecodes+nbytes, len-nbytes, ci->call_tracker_index);
-    }
-    return nbytes;
-}
-
-/* Called to create injection code before an opcode */
-static ByteOffset
-before_injection_code(MethodImage *mi, ClassOpcode opcode,
-                      ByteCode *bytecodes, ByteOffset len)
-{
-    ByteOffset nbytes = 0;
-
-
-    CRW_ASSERT_MI(mi);
-    switch ( opcode ) {
-        case JVM_OPC_return:
-        case JVM_OPC_ireturn:
-        case JVM_OPC_lreturn:
-        case JVM_OPC_freturn:
-        case JVM_OPC_dreturn:
-        case JVM_OPC_areturn:
-            if ( !mi->skip_call_return_sites ) {
-                nbytes = injection_template(mi,
-                            bytecodes, len, mi->ci->return_tracker_index);
-            }
-            break;
-        default:
-            break;
-    }
-    return nbytes;
-}
-
-/* Called to create injection code after an opcode */
-static ByteOffset
-after_injection_code(MethodImage *mi, ClassOpcode opcode,
-                     ByteCode *bytecodes, ByteOffset len)
-{
-    CrwClassImage* ci;
-    ByteOffset nbytes;
-
-    ci = mi->ci;
-    nbytes = 0;
-
-    CRW_ASSERT_MI(mi);
-    switch ( opcode ) {
-        case JVM_OPC_new:
-            /* Can't inject here cannot pass around uninitialized object */
-            break;
-        case JVM_OPC_newarray:
-        case JVM_OPC_anewarray:
-        case JVM_OPC_multianewarray:
-            nbytes = injection_template(mi,
-                                bytecodes, len, ci->newarray_tracker_index);
-            break;
-        default:
-            break;
-    }
-    return nbytes;
-}
-
-/* Actually inject the bytecodes */
-static void
-inject_bytecodes(MethodImage *mi, ByteOffset at,
-                 ByteCode *bytecodes, ByteOffset len)
-{
-    Injection injection;
-    CrwClassImage *ci;
-
-    ci = mi->ci;
-    CRW_ASSERT_MI(mi);
-    CRW_ASSERT(ci, at <= mi->code_len);
-
-    injection = mi->injections[at];
-
-    CRW_ASSERT(ci, len <= LARGEST_INJECTION/2);
-    CRW_ASSERT(ci, injection.len+len <= LARGEST_INJECTION);
-
-    /* Either start an injection area or concatenate to what is there */
-    if ( injection.code == NULL ) {
-        CRW_ASSERT(ci, injection.len==0);
-        injection.code = (ByteCode *)allocate_clean(ci, LARGEST_INJECTION+1);
-    }
-
-    (void)memcpy(injection.code+injection.len, bytecodes, len);
-    injection.len += len;
-    injection.code[injection.len] = 0;
-    mi->injections[at] = injection;
-    ci->injection_count++;
-}
-
-/* ----------------------------------------------------------------- */
-/* Method handling functions */
-
-static MethodImage *
-method_init(CrwClassImage *ci, unsigned mnum, ByteOffset code_len)
-{
-    MethodImage *       mi;
-    ByteOffset          i;
-
-    mi                  = (MethodImage*)allocate_clean(ci, (int)sizeof(MethodImage));
-    mi->ci              = ci;
-    mi->name            = ci->method_name[mnum];
-    mi->descr           = ci->method_descr[mnum];
-    mi->code_len        = code_len;
-    mi->map             = (ByteOffset*)allocate_clean(ci,
-                                (int)((code_len+1)*sizeof(ByteOffset)));
-    for(i=0; i<=code_len; i++) {
-        mi->map[i] = i;
-    }
-    mi->widening        = (signed char*)allocate_clean(ci, code_len+1);
-    mi->injections      = (Injection *)allocate_clean(ci,
-                                (int)((code_len+1)*sizeof(Injection)));
-    mi->number          = mnum;
-    ci->current_mi      = mi;
-    return mi;
-}
-
-static void
-method_term(MethodImage *mi)
-{
-    CrwClassImage *ci;
-
-    ci = mi->ci;
-    CRW_ASSERT_MI(mi);
-    if ( mi->map != NULL ) {
-        deallocate(ci, (void*)mi->map);
-        mi->map = NULL;
-    }
-    if ( mi->widening != NULL ) {
-        deallocate(ci, (void*)mi->widening);
-        mi->widening = NULL;
-    }
-    if ( mi->injections != NULL ) {
-        ByteOffset i;
-        for(i=0; i<= mi->code_len; i++) {
-            if ( mi->injections[i].code != NULL ) {
-                deallocate(ci, (void*)mi->injections[i].code);
-                mi->injections[i].code = NULL;
-            }
-        }
-        deallocate(ci, (void*)mi->injections);
-        mi->injections = NULL;
-    }
-    ci->current_mi = NULL;
-    deallocate(ci, (void*)mi);
-}
-
-static ByteOffset
-input_code_offset(MethodImage *mi)
-{
-    CRW_ASSERT_MI(mi);
-    return (ByteOffset)(mi->ci->input_position - mi->start_of_input_bytecodes);
-}
-
-static void
-rewind_to_beginning_of_input_bytecodes(MethodImage *mi)
-{
-    CRW_ASSERT_MI(mi);
-    mi->ci->input_position = mi->start_of_input_bytecodes;
-}
-
-/* Starting at original byte position 'at', add 'offset' to it's new
- *   location. This may be a negative value.
- *   NOTE: That this map is not the new bytecode location of the opcode
- *         but the new bytecode location that should be used when
- *         a goto or jump instruction was targeting the old bytecode
- *         location.
- */
-static void
-adjust_map(MethodImage *mi, ByteOffset at, ByteOffset offset)
-{
-    ByteOffset i;
-
-    CRW_ASSERT_MI(mi);
-    for (i = at; i <= mi->code_len; ++i) {
-        mi->map[i] += offset;
-    }
-}
-
-static void
-widen(MethodImage *mi, ByteOffset at, ByteOffset len)
-{
-    int delta;
-
-    CRW_ASSERT(mi->ci, at <= mi->code_len);
-    delta = len - mi->widening[at];
-    /* Adjust everything from the current input location by delta */
-    adjust_map(mi, input_code_offset(mi), delta);
-    /* Mark at beginning of instruction */
-    mi->widening[at] = (signed char)len;
-}
-
-static void
-verify_opc_wide(CrwClassImage *ci, ClassOpcode wopcode)
-{
-    switch (wopcode) {
-        case JVM_OPC_aload: case JVM_OPC_astore:
-        case JVM_OPC_fload: case JVM_OPC_fstore:
-        case JVM_OPC_iload: case JVM_OPC_istore:
-        case JVM_OPC_lload: case JVM_OPC_lstore:
-        case JVM_OPC_dload: case JVM_OPC_dstore:
-        case JVM_OPC_ret:   case JVM_OPC_iinc:
-            break;
-        default:
-            CRW_FATAL(ci, "Invalid opcode supplied to wide opcode");
-            break;
-    }
-}
-
-static unsigned
-opcode_length(CrwClassImage *ci, ClassOpcode opcode)
-{
-    /* Define array that holds length of an opcode */
-    static unsigned char _opcode_length[JVM_OPC_MAX+1] =
-                          JVM_OPCODE_LENGTH_INITIALIZER;
-
-    if ( opcode > JVM_OPC_MAX ) {
-        CRW_FATAL(ci, "Invalid opcode supplied to opcode_length()");
-    }
-    return _opcode_length[opcode];
-}
-
-/* Walk one instruction and inject instrumentation */
-static void
-inject_for_opcode(MethodImage *mi)
-{
-    CrwClassImage *  ci;
-    ClassOpcode      opcode;
-    int              pos;
-
-    CRW_ASSERT_MI(mi);
-    ci = mi->ci;
-    pos = input_code_offset(mi);
-    opcode = readU1(ci);
-
-    if (opcode == JVM_OPC_wide) {
-        ClassOpcode     wopcode;
-
-        wopcode = readU1(ci);
-        /* lvIndex not used */
-        (void)readU2(ci);
-        verify_opc_wide(ci, wopcode);
-        if ( wopcode==JVM_OPC_iinc ) {
-            (void)readU1(ci);
-            (void)readU1(ci);
-        }
-    } else {
-
-        ByteCode        bytecodes[LARGEST_INJECTION+1];
-        int             header;
-        int             instr_len;
-        int             low;
-        int             high;
-        int             npairs;
-        ByteOffset      len;
-
-        /* Get bytecodes to inject before this opcode */
-        len = before_injection_code(mi, opcode, bytecodes, (int)sizeof(bytecodes));
-        if ( len > 0 ) {
-            inject_bytecodes(mi, pos, bytecodes, len);
-            /* Adjust map after processing this opcode */
-        }
-
-        /* Process this opcode */
-        switch (opcode) {
-            case JVM_OPC_tableswitch:
-                header = NEXT_4BYTE_BOUNDARY(pos);
-                skip(ci, header - (pos+1));
-                (void)readU4(ci);
-                low = readU4(ci);
-                high = readU4(ci);
-                skip(ci, (high+1-low) * 4);
-                break;
-            case JVM_OPC_lookupswitch:
-                header = NEXT_4BYTE_BOUNDARY(pos);
-                skip(ci, header - (pos+1));
-                (void)readU4(ci);
-                npairs = readU4(ci);
-                skip(ci, npairs * 8);
-                break;
-            default:
-                instr_len = opcode_length(ci, opcode);
-                skip(ci, instr_len-1);
-                break;
-        }
-
-        /* Get position after this opcode is processed */
-        pos = input_code_offset(mi);
-
-        /* Adjust for any before_injection_code() */
-        if ( len > 0 ) {
-            /* Adjust everything past this opcode.
-             *   Why past it? Because we want any jumps to this bytecode loc
-             *   to go to the injected code, not where the opcode
-             *   was moved too.
-             *   Consider a 'return' opcode that is jumped too.
-             *   NOTE: This may not be correct in all cases, but will
-             *         when we are only dealing with non-variable opcodes
-             *         like the return opcodes. Be careful if the
-             *         before_injection_code() changes to include other
-             *         opcodes that have variable length.
-             */
-            adjust_map(mi, pos, len);
-        }
-
-        /* Get bytecodes to inject after this opcode */
-        len = after_injection_code(mi, opcode, bytecodes, (int)sizeof(bytecodes));
-        if ( len > 0 ) {
-            inject_bytecodes(mi, pos, bytecodes, len);
-
-            /* Adjust for any after_injection_code() */
-            adjust_map(mi, pos, len);
-        }
-
-    }
-}
-
-/* Map original bytecode location to it's new location. (See adjust_map()). */
-static ByteOffset
-method_code_map(MethodImage *mi, ByteOffset pos)
-{
-    CRW_ASSERT_MI(mi);
-    CRW_ASSERT(mi->ci, pos <= mi->code_len);
-    return mi->map[pos];
-}
-
-static int
-adjust_instruction(MethodImage *mi)
-{
-    CrwClassImage *     ci;
-    ClassOpcode         opcode;
-    int                 pos;
-    int                 new_pos;
-
-    CRW_ASSERT_MI(mi);
-    ci = mi->ci;
-    pos = input_code_offset(mi);
-    new_pos = method_code_map(mi,pos);
-
-    opcode = readU1(ci);
-
-    if (opcode == JVM_OPC_wide) {
-        ClassOpcode wopcode;
-
-        wopcode = readU1(ci);
-        /* lvIndex not used */
-        (void)readU2(ci);
-        verify_opc_wide(ci, wopcode);
-        if ( wopcode==JVM_OPC_iinc ) {
-            (void)readU1(ci);
-            (void)readU1(ci);
-        }
-    } else {
-
-        int widened;
-        int header;
-        int newHeader;
-        int low;
-        int high;
-        int new_pad;
-        int old_pad;
-        int delta;
-        int new_delta;
-        int delta_pad;
-        int npairs;
-        int instr_len;
-
-        switch (opcode) {
-
-        case JVM_OPC_tableswitch:
-            widened     = mi->widening[pos];
-            header      = NEXT_4BYTE_BOUNDARY(pos);
-            newHeader   = NEXT_4BYTE_BOUNDARY(new_pos);
-
-            skip(ci, header - (pos+1));
-
-            delta       = readU4(ci);
-            low         = readU4(ci);
-            high        = readU4(ci);
-            skip(ci, (high+1-low) * 4);
-            new_pad     = newHeader - new_pos;
-            old_pad     = header - pos;
-            delta_pad   = new_pad - old_pad;
-            if (widened != delta_pad) {
-                widen(mi, pos, delta_pad);
-                return 0;
-            }
-            break;
-
-        case JVM_OPC_lookupswitch:
-            widened     = mi->widening[pos];
-            header      = NEXT_4BYTE_BOUNDARY(pos);
-            newHeader   = NEXT_4BYTE_BOUNDARY(new_pos);
-
-            skip(ci, header - (pos+1));
-
-            delta       = readU4(ci);
-            npairs      = readU4(ci);
-            skip(ci, npairs * 8);
-            new_pad     = newHeader - new_pos;
-            old_pad     = header - pos;
-            delta_pad   = new_pad - old_pad;
-            if (widened != delta_pad) {
-                widen(mi, pos, delta_pad);
-                return 0;
-            }
-            break;
-
-        case JVM_OPC_jsr: case JVM_OPC_goto:
-        case JVM_OPC_ifeq: case JVM_OPC_ifge: case JVM_OPC_ifgt:
-        case JVM_OPC_ifle: case JVM_OPC_iflt: case JVM_OPC_ifne:
-        case JVM_OPC_if_icmpeq: case JVM_OPC_if_icmpne: case JVM_OPC_if_icmpge:
-        case JVM_OPC_if_icmpgt: case JVM_OPC_if_icmple: case JVM_OPC_if_icmplt:
-        case JVM_OPC_if_acmpeq: case JVM_OPC_if_acmpne:
-        case JVM_OPC_ifnull: case JVM_OPC_ifnonnull:
-            widened     = mi->widening[pos];
-            delta       = readS2(ci);
-            if (widened == 0) {
-                new_delta = method_code_map(mi,pos+delta) - new_pos;
-                if ((new_delta < -32768) || (new_delta > 32767)) {
-                    switch (opcode) {
-                        case JVM_OPC_jsr: case JVM_OPC_goto:
-                            widen(mi, pos, 2);
-                            break;
-                        default:
-                            widen(mi, pos, 5);
-                            break;
-                    }
-                    return 0;
-                }
-            }
-            break;
-
-        case JVM_OPC_jsr_w:
-        case JVM_OPC_goto_w:
-            (void)readU4(ci);
-            break;
-
-        default:
-            instr_len = opcode_length(ci, opcode);
-            skip(ci, instr_len-1);
-            break;
-        }
-    }
-    return 1;
-}
-
-static void
-write_instruction(MethodImage *mi)
-{
-    CrwClassImage *     ci;
-    ClassOpcode         opcode;
-    ByteOffset          new_code_len;
-    int                 pos;
-    int                 new_pos;
-
-    CRW_ASSERT_MI(mi);
-    ci = mi->ci;
-    pos = input_code_offset(mi);
-    new_pos = method_code_map(mi,pos);
-    new_code_len = mi->injections[pos].len;
-    if (new_code_len > 0) {
-        write_bytes(ci, (void*)mi->injections[pos].code, new_code_len);
-    }
-
-    opcode = readU1(ci);
-    if (opcode == JVM_OPC_wide) {
-        ClassOpcode     wopcode;
-
-        writeU1(ci, opcode);
-
-        wopcode = copyU1(ci);
-        /* lvIndex not used */
-        (void)copyU2(ci);
-        verify_opc_wide(ci, wopcode);
-        if ( wopcode==JVM_OPC_iinc ) {
-            (void)copyU1(ci);
-            (void)copyU1(ci);
-        }
-    } else {
-
-        ClassOpcode new_opcode;
-        int             header;
-        int             newHeader;
-        int             low;
-        int             high;
-        int             i;
-        int             npairs;
-        int             widened;
-        int             instr_len;
-        int             delta;
-        int             new_delta;
-
-        switch (opcode) {
-
-            case JVM_OPC_tableswitch:
-                header = NEXT_4BYTE_BOUNDARY(pos);
-                newHeader = NEXT_4BYTE_BOUNDARY(new_pos);
-
-                skip(ci, header - (pos+1));
-
-                delta = readU4(ci);
-                new_delta = method_code_map(mi,pos+delta) - new_pos;
-                low = readU4(ci);
-                high = readU4(ci);
-
-                writeU1(ci, opcode);
-                for (i = new_pos+1; i < newHeader; ++i) {
-                    writeU1(ci, 0);
-                }
-                writeU4(ci, new_delta);
-                writeU4(ci, low);
-                writeU4(ci, high);
-
-                for (i = low; i <= high; ++i) {
-                    delta = readU4(ci);
-                    new_delta = method_code_map(mi,pos+delta) - new_pos;
-                    writeU4(ci, new_delta);
-                }
-                break;
-
-            case JVM_OPC_lookupswitch:
-                header = NEXT_4BYTE_BOUNDARY(pos);
-                newHeader = NEXT_4BYTE_BOUNDARY(new_pos);
-
-                skip(ci, header - (pos+1));
-
-                delta = readU4(ci);
-                new_delta = method_code_map(mi,pos+delta) - new_pos;
-                npairs = readU4(ci);
-                writeU1(ci, opcode);
-                for (i = new_pos+1; i < newHeader; ++i) {
-                    writeU1(ci, 0);
-                }
-                writeU4(ci, new_delta);
-                writeU4(ci, npairs);
-                for (i = 0; i< npairs; ++i) {
-                    unsigned match = readU4(ci);
-                    delta = readU4(ci);
-                    new_delta = method_code_map(mi,pos+delta) - new_pos;
-                    writeU4(ci, match);
-                    writeU4(ci, new_delta);
-                }
-                break;
-
-            case JVM_OPC_jsr: case JVM_OPC_goto:
-            case JVM_OPC_ifeq: case JVM_OPC_ifge: case JVM_OPC_ifgt:
-            case JVM_OPC_ifle: case JVM_OPC_iflt: case JVM_OPC_ifne:
-            case JVM_OPC_if_icmpeq: case JVM_OPC_if_icmpne: case JVM_OPC_if_icmpge:
-            case JVM_OPC_if_icmpgt: case JVM_OPC_if_icmple: case JVM_OPC_if_icmplt:
-            case JVM_OPC_if_acmpeq: case JVM_OPC_if_acmpne:
-            case JVM_OPC_ifnull: case JVM_OPC_ifnonnull:
-                widened = mi->widening[pos];
-                delta = readS2(ci);
-                new_delta = method_code_map(mi,pos+delta) - new_pos;
-                new_opcode = opcode;
-                if (widened == 0) {
-                    writeU1(ci, opcode);
-                    writeU2(ci, new_delta);
-                } else if (widened == 2) {
-                    switch (opcode) {
-                        case JVM_OPC_jsr:
-                            new_opcode = JVM_OPC_jsr_w;
-                            break;
-                        case JVM_OPC_goto:
-                            new_opcode = JVM_OPC_goto_w;
-                            break;
-                        default:
-                            CRW_FATAL(ci, "unexpected opcode");
-                            break;
-                    }
-                    writeU1(ci, new_opcode);
-                    writeU4(ci, new_delta);
-                } else if (widened == 5) {
-                    switch (opcode) {
-                        case JVM_OPC_ifeq:
-                            new_opcode = JVM_OPC_ifne;
-                            break;
-                        case JVM_OPC_ifge:
-                            new_opcode = JVM_OPC_iflt;
-                            break;
-                        case JVM_OPC_ifgt:
-                            new_opcode = JVM_OPC_ifle;
-                            break;
-                        case JVM_OPC_ifle:
-                            new_opcode = JVM_OPC_ifgt;
-                            break;
-                        case JVM_OPC_iflt:
-                            new_opcode = JVM_OPC_ifge;
-                            break;
-                        case JVM_OPC_ifne:
-                            new_opcode = JVM_OPC_ifeq;
-                            break;
-                        case JVM_OPC_if_icmpeq:
-                            new_opcode = JVM_OPC_if_icmpne;
-                            break;
-                        case JVM_OPC_if_icmpne:
-                            new_opcode = JVM_OPC_if_icmpeq;
-                            break;
-                        case JVM_OPC_if_icmpge:
-                            new_opcode = JVM_OPC_if_icmplt;
-                            break;
-                        case JVM_OPC_if_icmpgt:
-                            new_opcode = JVM_OPC_if_icmple;
-                            break;
-                        case JVM_OPC_if_icmple:
-                            new_opcode = JVM_OPC_if_icmpgt;
-                            break;
-                        case JVM_OPC_if_icmplt:
-                            new_opcode = JVM_OPC_if_icmpge;
-                            break;
-                        case JVM_OPC_if_acmpeq:
-                            new_opcode = JVM_OPC_if_acmpne;
-                            break;
-                        case JVM_OPC_if_acmpne:
-                            new_opcode = JVM_OPC_if_acmpeq;
-                            break;
-                        case JVM_OPC_ifnull:
-                            new_opcode = JVM_OPC_ifnonnull;
-                            break;
-                        case JVM_OPC_ifnonnull:
-                            new_opcode = JVM_OPC_ifnull;
-                            break;
-                        default:
-                            CRW_FATAL(ci, "Unexpected opcode");
-                        break;
-                    }
-                    writeU1(ci, new_opcode);    /* write inverse branch */
-                    writeU2(ci, 3 + 5);         /* beyond if and goto_w */
-                    writeU1(ci, JVM_OPC_goto_w);    /* add a goto_w */
-                    writeU4(ci, new_delta-3); /* write new and wide delta */
-                } else {
-                    CRW_FATAL(ci, "Unexpected widening");
-                }
-                break;
-
-            case JVM_OPC_jsr_w:
-            case JVM_OPC_goto_w:
-                delta = readU4(ci);
-                new_delta = method_code_map(mi,pos+delta) - new_pos;
-                writeU1(ci, opcode);
-                writeU4(ci, new_delta);
-                break;
-
-            default:
-                instr_len = opcode_length(ci, opcode);
-                writeU1(ci, opcode);
-                copy(ci, instr_len-1);
-                break;
-        }
-    }
-}
-
-static void
-method_inject_and_write_code(MethodImage *mi)
-{
-    ByteCode bytecodes[LARGEST_INJECTION+1];
-    ByteOffset   len;
-
-    CRW_ASSERT_MI(mi);
-
-    /* Do injections */
-    rewind_to_beginning_of_input_bytecodes(mi);
-    len = entry_injection_code(mi, bytecodes, (int)sizeof(bytecodes));
-    if ( len > 0 ) {
-        int pos;
-
-        pos = 0;
-        inject_bytecodes(mi, pos, bytecodes, len);
-        /* Adjust pos 0 to map to new pos 0, you never want to
-         *  jump into this entry code injection. So the new pos 0
-         *  will be past this entry_injection_code().
-         */
-        adjust_map(mi, pos, len); /* Inject before behavior */
-    }
-    while (input_code_offset(mi) < mi->code_len) {
-        inject_for_opcode(mi);
-    }
-
-    /* Adjust instructions */
-    rewind_to_beginning_of_input_bytecodes(mi);
-    while (input_code_offset(mi) < mi->code_len) {
-        if (!adjust_instruction(mi)) {
-            rewind_to_beginning_of_input_bytecodes(mi);
-        }
-    }
-
-    /* Write new instructions */
-    rewind_to_beginning_of_input_bytecodes(mi);
-    while (input_code_offset(mi) < mi->code_len) {
-        write_instruction(mi);
-    }
-}
-
-static void
-copy_attribute(CrwClassImage *ci)
-{
-    int len;
-
-    (void)copyU2(ci);
-    len = copyU4(ci);
-    copy(ci, len);
-}
-
-static void
-copy_attributes(CrwClassImage *ci)
-{
-    unsigned i;
-    unsigned count;
-
-    count = copyU2(ci);
-    for (i = 0; i < count; ++i) {
-        copy_attribute(ci);
-    }
-}
-
-static void
-copy_all_fields(CrwClassImage *ci)
-{
-    unsigned i;
-    unsigned count;
-
-    count = copyU2(ci);
-    for (i = 0; i < count; ++i) {
-        /* access, name, descriptor */
-        copy(ci, 6);
-        copy_attributes(ci);
-    }
-}
-
-static void
-write_line_table(MethodImage *mi)
-{
-    unsigned             i;
-    unsigned             count;
-    CrwClassImage *      ci;
-
-    CRW_ASSERT_MI(mi);
-    ci = mi->ci;
-    (void)copyU4(ci);
-    count = copyU2(ci);
-    for(i=0; i<count; i++) {
-        ByteOffset start_pc;
-        ByteOffset new_start_pc;
-
-        start_pc = readU2(ci);
-
-        if ( start_pc == 0 ) {
-            new_start_pc = 0; /* Don't skip entry injection code. */
-        } else {
-            new_start_pc = method_code_map(mi, start_pc);
-        }
-
-        writeU2(ci, new_start_pc);
-        (void)copyU2(ci);
-    }
-}
-
-/* Used for LocalVariableTable and LocalVariableTypeTable attributes */
-static void
-write_var_table(MethodImage *mi)
-{
-    unsigned             i;
-    unsigned             count;
-    CrwClassImage *      ci;
-
-    CRW_ASSERT_MI(mi);
-    ci = mi->ci;
-    (void)copyU4(ci);
-    count = copyU2(ci);
-    for(i=0; i<count; i++) {
-        ByteOffset start_pc;
-        ByteOffset new_start_pc;
-        ByteOffset length;
-        ByteOffset new_length;
-        ByteOffset end_pc;
-        ByteOffset new_end_pc;
-
-        start_pc        = readU2(ci);
-        length          = readU2(ci);
-
-        if ( start_pc == 0 ) {
-            new_start_pc = 0; /* Don't skip entry injection code. */
-        } else {
-            new_start_pc = method_code_map(mi, start_pc);
-        }
-        end_pc          = start_pc + length;
-        new_end_pc      = method_code_map(mi, end_pc);
-        new_length      = new_end_pc - new_start_pc;
-
-        writeU2(ci, new_start_pc);
-        writeU2(ci, new_length);
-        (void)copyU2(ci);
-        (void)copyU2(ci);
-        (void)copyU2(ci);
-    }
-}
-
-/* The uoffset field is u2 or u4 depending on the code_len.
- *   Note that the code_len is likely changing, so be careful here.
- */
-static unsigned
-readUoffset(MethodImage *mi)
-{
-    if ( mi->code_len > 65535 ) {
-        return readU4(mi->ci);
-    }
-    return readU2(mi->ci);
-}
-
-static void
-writeUoffset(MethodImage *mi, unsigned val)
-{
-    if ( mi->new_code_len > 65535 ) {
-        writeU4(mi->ci, val);
-    }
-    writeU2(mi->ci, val);
-}
-
-static unsigned
-copyUoffset(MethodImage *mi)
-{
-    unsigned uoffset;
-
-    uoffset = readUoffset(mi);
-    writeUoffset(mi, uoffset);
-    return uoffset;
-}
-
-/* Copy over verification_type_info structure */
-static void
-copy_verification_types(MethodImage *mi, int ntypes)
-{
-    /* If there were ntypes, we just copy that over, no changes */
-    if ( ntypes > 0 ) {
-        int j;
-
-        for ( j = 0 ; j < ntypes ; j++ ) {
-            unsigned tag;
-
-            tag = copyU1(mi->ci);
-            switch ( tag ) {
-                case JVM_ITEM_Object:
-                    (void)copyU2(mi->ci); /* Constant pool entry */
-                    break;
-                case JVM_ITEM_Uninitialized:
-                    /* Code offset for 'new' opcode is for this object */
-                    writeUoffset(mi, method_code_map(mi, readUoffset(mi)));
-                    break;
-            }
-        }
-    }
-}
-
-/* Process the StackMapTable attribute. We didn't add any basic blocks
- *   so the frame count remains the same but we may need to process the
- *   frame types due to offset changes putting things out of range.
- */
-static void
-write_stackmap_table(MethodImage *mi)
-{
-    CrwClassImage *ci;
-    CrwPosition    save_position;
-    ByteOffset     last_pc;
-    ByteOffset     last_new_pc;
-    unsigned       i;
-    unsigned       attr_len;
-    unsigned       new_attr_len;
-    unsigned       count;
-    unsigned       delta_adj;
-
-    CRW_ASSERT_MI(mi);
-    ci = mi->ci;
-
-    /* Save the position of the attribute length so we can fix it later */
-    save_position = ci->output_position;
-    attr_len      = copyU4(ci);
-    count         = copyUoffset(mi);  /* uoffset: number_of_entries */
-    if ( count == 0 ) {
-        CRW_ASSERT(ci, attr_len==2);
-        return;
-    }
-
-    /* Process entire stackmap */
-    last_pc     = 0;
-    last_new_pc = 0;
-    delta_adj   = 0;
-    for ( i = 0 ; i < count ; i++ ) {
-        ByteOffset new_pc=0;    /* new pc in instrumented code */
-        unsigned   ft;        /* frame_type */
-        int        delta=0;     /* pc delta */
-        int        new_delta=0; /* new pc delta */
-
-        ft = readU1(ci);
-        if ( ft <= 63 ) {
-            /* Frame Type: same_frame ([0,63]) */
-            unsigned   new_ft;    /* new frame_type */
-
-            delta     = (delta_adj + ft);
-            new_pc    = method_code_map(mi, last_pc + delta);
-            new_delta = new_pc - last_new_pc;
-            new_ft    = (new_delta - delta_adj);
-            if ( new_ft > 63 ) {
-                /* Change to same_frame_extended (251) */
-                new_ft = 251;
-                writeU1(ci, new_ft);
-                writeUoffset(mi, (new_delta - delta_adj));
-            } else {
-                writeU1(ci, new_ft);
-            }
-        } else if ( ft >= 64 && ft <= 127 ) {
-            /* Frame Type: same_locals_1_stack_item_frame ([64,127]) */
-            unsigned   new_ft;    /* new frame_type */
-
-            delta     = (delta_adj + ft - 64);
-            new_pc    = method_code_map(mi, last_pc + delta);
-            new_delta = new_pc - last_new_pc;
-            if ( (new_delta - delta_adj) > 63 ) {
-                /* Change to same_locals_1_stack_item_frame_extended (247) */
-                new_ft = 247;
-                writeU1(ci, new_ft);
-                writeUoffset(mi, (new_delta - delta_adj));
-            } else {
-                new_ft = (new_delta - delta_adj) + 64;
-                writeU1(ci, new_ft);
-            }
-            copy_verification_types(mi, 1);
-        } else if ( ft >= 128 && ft <= 246 ) {
-            /* Frame Type: reserved_for_future_use ([128,246]) */
-            CRW_FATAL(ci, "Unknown frame type in StackMapTable attribute");
-        } else if ( ft == 247 ) {
-            /* Frame Type: same_locals_1_stack_item_frame_extended (247) */
-            delta     = (delta_adj + readUoffset(mi));
-            new_pc    = method_code_map(mi, last_pc + delta);
-            new_delta = new_pc - last_new_pc;
-            writeU1(ci, ft);
-            writeUoffset(mi, (new_delta - delta_adj));
-            copy_verification_types(mi, 1);
-        } else if ( ft >= 248 && ft <= 250 ) {
-            /* Frame Type: chop_frame ([248,250]) */
-            delta     = (delta_adj + readUoffset(mi));
-            new_pc    = method_code_map(mi, last_pc + delta);
-            new_delta = new_pc - last_new_pc;
-            writeU1(ci, ft);
-            writeUoffset(mi, (new_delta - delta_adj));
-        } else if ( ft == 251 ) {
-            /* Frame Type: same_frame_extended (251) */
-            delta     = (delta_adj + readUoffset(mi));
-            new_pc    = method_code_map(mi, last_pc + delta);
-            new_delta = new_pc - last_new_pc;
-            writeU1(ci, ft);
-            writeUoffset(mi, (new_delta - delta_adj));
-        } else if ( ft >= 252 && ft <= 254 ) {
-            /* Frame Type: append_frame ([252,254]) */
-            delta     = (delta_adj + readUoffset(mi));
-            new_pc    = method_code_map(mi, last_pc + delta);
-            new_delta = new_pc - last_new_pc;
-            writeU1(ci, ft);
-            writeUoffset(mi, (new_delta - delta_adj));
-            copy_verification_types(mi, (ft - 251));
-        } else if ( ft == 255 ) {
-            unsigned   ntypes;
-
-            /* Frame Type: full_frame (255) */
-            delta     = (delta_adj + readUoffset(mi));
-            new_pc    = method_code_map(mi, last_pc + delta);
-            new_delta = new_pc - last_new_pc;
-            writeU1(ci, ft);
-            writeUoffset(mi, (new_delta - delta_adj));
-            ntypes    = copyU2(ci); /* ulocalvar */
-            copy_verification_types(mi, ntypes);
-            ntypes    = copyU2(ci); /* ustack */
-            copy_verification_types(mi, ntypes);
-        }
-
-        /* Update last_pc and last_new_pc (save on calls to method_code_map) */
-        CRW_ASSERT(ci, delta >= 0);
-        CRW_ASSERT(ci, new_delta >= 0);
-        last_pc    += delta;
-        last_new_pc = new_pc;
-        CRW_ASSERT(ci, last_pc <= mi->code_len);
-        CRW_ASSERT(ci, last_new_pc <= mi->new_code_len);
-
-        /* Delta adjustment, all deltas are -1 now in attribute */
-        delta_adj = 1;
-    }
-
-    /* Update the attribute length */
-    new_attr_len = ci->output_position - (save_position + 4);
-    CRW_ASSERT(ci, new_attr_len >= attr_len);
-    random_writeU4(ci, save_position, new_attr_len);
-}
-
-/* Process the CLDC StackMap attribute. We didn't add any basic blocks
- *   so the frame count remains the same but we may need to process the
- *   frame types due to offset changes putting things out of range.
- */
-static void
-write_cldc_stackmap_table(MethodImage *mi)
-{
-    CrwClassImage *ci;
-    CrwPosition    save_position;
-    unsigned       i;
-    unsigned       attr_len;
-    unsigned       new_attr_len;
-    unsigned       count;
-
-    CRW_ASSERT_MI(mi);
-    ci = mi->ci;
-
-    /* Save the position of the attribute length so we can fix it later */
-    save_position = ci->output_position;
-    attr_len      = copyU4(ci);
-    count         = copyUoffset(mi);  /* uoffset: number_of_entries */
-    if ( count == 0 ) {
-        CRW_ASSERT(ci, attr_len==2);
-        return;
-    }
-
-    /* Process entire stackmap */
-    for ( i = 0 ; i < count ; i++ ) {
-        unsigned   ntypes;
-
-        writeUoffset(mi, method_code_map(mi, readUoffset(mi)));
-        ntypes    = copyU2(ci); /* ulocalvar */
-        copy_verification_types(mi, ntypes);
-        ntypes    = copyU2(ci); /* ustack */
-        copy_verification_types(mi, ntypes);
-    }
-
-    /* Update the attribute length */
-    new_attr_len = ci->output_position - (save_position + 4);
-    CRW_ASSERT(ci, new_attr_len >= attr_len);
-    random_writeU4(ci, save_position, new_attr_len);
-}
-
-static void
-method_write_exception_table(MethodImage *mi)
-{
-    unsigned            i;
-    unsigned            count;
-    CrwClassImage *     ci;
-
-    CRW_ASSERT_MI(mi);
-    ci = mi->ci;
-    count = copyU2(ci);
-    for(i=0; i<count; i++) {
-        ByteOffset start_pc;
-        ByteOffset new_start_pc;
-        ByteOffset end_pc;
-        ByteOffset new_end_pc;
-        ByteOffset handler_pc;
-        ByteOffset new_handler_pc;
-
-        start_pc        = readU2(ci);
-        end_pc          = readU2(ci);
-        handler_pc      = readU2(ci);
-
-        new_start_pc    = method_code_map(mi, start_pc);
-        new_end_pc      = method_code_map(mi, end_pc);
-        new_handler_pc  = method_code_map(mi, handler_pc);
-
-        writeU2(ci, new_start_pc);
-        writeU2(ci, new_end_pc);
-        writeU2(ci, new_handler_pc);
-        (void)copyU2(ci);
-    }
-}
-
-static int
-attribute_match(CrwClassImage *ci, CrwCpoolIndex name_index, const char *name)
-{
-    CrwConstantPoolEntry cs;
-    int                  len;
-
-    CRW_ASSERT_CI(ci);
-    CRW_ASSERT(ci, name!=NULL);
-    len = (int)strlen(name);
-    cs = cpool_entry(ci, name_index);
-    if ( cs.len==len && strncmp(cs.ptr, name, len)==0) {
-       return 1;
-    }
-    return 0;
-}
-
-static void
-method_write_code_attribute(MethodImage *mi)
-{
-    CrwClassImage *     ci;
-    CrwCpoolIndex       name_index;
-
-    CRW_ASSERT_MI(mi);
-    ci = mi->ci;
-    name_index = copyU2(ci);
-    if ( attribute_match(ci, name_index, "LineNumberTable") ) {
-        write_line_table(mi);
-    } else if ( attribute_match(ci, name_index, "LocalVariableTable") ) {
-        write_var_table(mi);
-    } else if ( attribute_match(ci, name_index, "LocalVariableTypeTable") ) {
-        write_var_table(mi); /* Exact same format as the LocalVariableTable */
-    } else if ( attribute_match(ci, name_index, "StackMapTable") ) {
-        write_stackmap_table(mi);
-    } else if ( attribute_match(ci, name_index, "StackMap") ) {
-        write_cldc_stackmap_table(mi);
-    } else {
-        unsigned len;
-        len = copyU4(ci);
-        copy(ci, len);
-    }
-}
-
-static int
-is_init_method(const char *name)
-{
-    if ( name!=NULL && strcmp(name,"<init>")==0 ) {
-        return JNI_TRUE;
-    }
-    return JNI_FALSE;
-}
-
-static int
-is_clinit_method(const char *name)
-{
-    if ( name!=NULL && strcmp(name,"<clinit>")==0 ) {
-        return JNI_TRUE;
-    }
-    return JNI_FALSE;
-}
-
-static int
-is_finalize_method(const char *name)
-{
-    if ( name!=NULL && strcmp(name,"finalize")==0 ) {
-        return JNI_TRUE;
-    }
-    return JNI_FALSE;
-}
-
-static int
-skip_method(CrwClassImage *ci, const char *name,
-                unsigned access_flags, ByteOffset code_len,
-                int system_class, jboolean *pskip_call_return_sites)
-{
-    *pskip_call_return_sites = JNI_FALSE;
-    if ( system_class ) {
-        if ( code_len == 1 && is_init_method(name) ) {
-            return JNI_TRUE;
-        } else if ( code_len == 1 && is_finalize_method(name) ) {
-            return JNI_TRUE;
-        } else if ( is_clinit_method(name) ) {
-            return JNI_TRUE;
-        } else if ( ci->is_thread_class && strcmp(name,"currentThread")==0 ) {
-            return JNI_TRUE;
-        }
-        /*
-        if ( access_flags & JVM_ACC_PRIVATE ) {
-            *pskip_call_return_sites = JNI_TRUE;
-        }
-        */
-    }
-    return JNI_FALSE;
-}
-
-/* Process all code attributes */
-static void
-method_write_bytecodes(CrwClassImage *ci, unsigned mnum, unsigned access_flags)
-{
-    CrwPosition         output_attr_len_position;
-    CrwPosition         output_max_stack_position;
-    CrwPosition         output_code_len_position;
-    CrwPosition         start_of_output_bytecodes;
-    unsigned            i;
-    unsigned            attr_len;
-    unsigned            max_stack;
-    ByteOffset          code_len;
-    unsigned            attr_count;
-    unsigned            new_attr_len;
-    MethodImage *       mi;
-    jboolean            object_init_method;
-    jboolean            skip_call_return_sites;
-
-    CRW_ASSERT_CI(ci);
-
-    /* Attribute Length */
-    output_attr_len_position = ci->output_position;
-    attr_len = copyU4(ci);
-
-    /* Max Stack */
-    output_max_stack_position = ci->output_position;
-    max_stack = copyU2(ci);
-
-    /* Max Locals */
-    (void)copyU2(ci);
-
-    /* Code Length */
-    output_code_len_position = ci->output_position;
-    code_len = copyU4(ci);
-    start_of_output_bytecodes = ci->output_position;
-
-    /* Some methods should not be instrumented */
-    object_init_method = JNI_FALSE;
-    skip_call_return_sites = JNI_FALSE;
-    if ( ci->is_object_class &&
-         is_init_method(ci->method_name[mnum]) &&
-         strcmp(ci->method_descr[mnum],"()V")==0 ) {
-        object_init_method = JNI_TRUE;
-        skip_call_return_sites = JNI_TRUE;
-    } else if ( skip_method(ci, ci->method_name[mnum], access_flags,
-                code_len, ci->system_class, &skip_call_return_sites) ) {
-        /* Copy remainder minus already copied, the U2 max_stack,
-         *   U2 max_locals, and U4 code_length fields have already
-         *   been processed.
-         */
-        copy(ci, attr_len - (2+2+4));
-        return;
-    }
-
-    /* Start Injection */
-    mi = method_init(ci, mnum, code_len);
-    mi->object_init_method = object_init_method;
-    mi->access_flags = access_flags;
-    mi->skip_call_return_sites = skip_call_return_sites;
-
-    /* Save the current position as the start of the input bytecodes */
-    mi->start_of_input_bytecodes = ci->input_position;
-
-    /* The max stack may increase */
-    mi->max_stack = max_stack;
-    mi->new_max_stack = max_stack;
-
-    /* Adjust all code offsets */
-    method_inject_and_write_code(mi);
-
-    /* Fix up code length (save new_code_len for later attribute processing) */
-    mi->new_code_len = (int)(ci->output_position - start_of_output_bytecodes);
-    random_writeU4(ci, output_code_len_position, mi->new_code_len);
-
-    /* Fixup max stack */
-    CRW_ASSERT(ci, mi->new_max_stack <= 0xFFFF);
-    random_writeU2(ci, output_max_stack_position, mi->new_max_stack);
-
-    /* Copy exception table */
-    method_write_exception_table(mi);
-
-    /* Copy code attributes (needs mi->new_code_len) */
-    attr_count = copyU2(ci);
-    for (i = 0; i < attr_count; ++i) {
-        method_write_code_attribute(mi);
-    }
-
-    /* Fix up attribute length */
-    new_attr_len = (int)(ci->output_position - (output_attr_len_position + 4));
-    random_writeU4(ci, output_attr_len_position, new_attr_len);
-
-    /* Free method data */
-    method_term(mi);
-    mi = NULL;
-
-}
-
-static void
-method_write(CrwClassImage *ci, unsigned mnum)
-{
-    unsigned            i;
-    unsigned            access_flags;
-    CrwCpoolIndex       name_index;
-    CrwCpoolIndex       descr_index;
-    unsigned            attr_count;
-
-    access_flags = copyU2(ci);
-    name_index = copyU2(ci);
-    ci->method_name[mnum] = cpool_entry(ci, name_index).ptr;
-    descr_index = copyU2(ci);
-    ci->method_descr[mnum] = cpool_entry(ci, descr_index).ptr;
-    attr_count = copyU2(ci);
-
-    for (i = 0; i < attr_count; ++i) {
-        CrwCpoolIndex name_index;
-
-        name_index = copyU2(ci);
-        if ( attribute_match(ci, name_index, "Code") ) {
-            method_write_bytecodes(ci, mnum, access_flags);
-        } else {
-            unsigned len;
-            len = copyU4(ci);
-            copy(ci, len);
-        }
-    }
-}
-
-static void
-method_write_all(CrwClassImage *ci)
-{
-    unsigned i;
-    unsigned count;
-
-    count = copyU2(ci);
-    ci->method_count = count;
-    if ( count > 0 ) {
-        ci->method_name = (const char **)allocate_clean(ci, count*(int)sizeof(const char*));
-        ci->method_descr = (const char **)allocate_clean(ci, count*(int)sizeof(const char*));
-    }
-
-    for (i = 0; i < count; ++i) {
-        method_write(ci, i);
-    }
-
-    if ( ci->mnum_callback != NULL ) {
-        (*(ci->mnum_callback))(ci->number, ci->method_name, ci->method_descr,
-                         count);
-    }
-}
-
-/* ------------------------------------------------------------------- */
-/* Cleanup function. */
-
-static void
-cleanup(CrwClassImage *ci)
-{
-    CRW_ASSERT_CI(ci);
-    if ( ci->name != NULL ) {
-        deallocate(ci, (void*)ci->name);
-        ci->name = NULL;
-    }
-    if ( ci->method_name != NULL ) {
-        deallocate(ci, (void*)ci->method_name);
-        ci->method_name = NULL;
-    }
-    if ( ci->method_descr != NULL ) {
-        deallocate(ci, (void*)ci->method_descr);
-        ci->method_descr = NULL;
-    }
-    if ( ci->cpool != NULL ) {
-        CrwCpoolIndex i;
-        for(i=0; i<ci->cpool_count_plus_one; i++) {
-            if ( ci->cpool[i].ptr != NULL ) {
-                deallocate(ci, (void*)(ci->cpool[i].ptr));
-                ci->cpool[i].ptr = NULL;
-            }
-        }
-        deallocate(ci, (void*)ci->cpool);
-        ci->cpool = NULL;
-    }
-}
-
-static jboolean
-skip_class(unsigned access_flags)
-{
-    if ( access_flags & JVM_ACC_INTERFACE ) {
-        return JNI_TRUE;
-    }
-    return JNI_FALSE;
-}
-
-static long
-inject_class(struct CrwClassImage *ci,
-                 int system_class,
-                 char* tclass_name,
-                 char* tclass_sig,
-                 char* call_name,
-                 char* call_sig,
-                 char* return_name,
-                 char* return_sig,
-                 char* obj_init_name,
-                 char* obj_init_sig,
-                 char* newarray_name,
-                 char* newarray_sig,
-                 unsigned char *buf,
-                 long buf_len)
-{
-    CrwConstantPoolEntry        cs;
-    CrwCpoolIndex               this_class;
-    CrwCpoolIndex               super_class;
-    unsigned                    magic;
-    unsigned                    classfileMajorVersion;
-    unsigned                    classfileMinorVersion;
-    unsigned                    interface_count;
-
-    CRW_ASSERT_CI(ci);
-    CRW_ASSERT(ci, buf!=NULL);
-    CRW_ASSERT(ci, buf_len!=0);
-
-    CRW_ASSERT(ci, strchr(tclass_name,'.')==NULL); /* internal qualified name */
-
-    ci->injection_count         = 0;
-    ci->system_class            = system_class;
-    ci->tclass_name             = tclass_name;
-    ci->tclass_sig              = tclass_sig;
-    ci->call_name               = call_name;
-    ci->call_sig                = call_sig;
-    ci->return_name             = return_name;
-    ci->return_sig              = return_sig;
-    ci->obj_init_name           = obj_init_name;
-    ci->obj_init_sig            = obj_init_sig;
-    ci->newarray_name           = newarray_name;
-    ci->newarray_sig            = newarray_sig;
-    ci->output                  = buf;
-    ci->output_len              = buf_len;
-
-    magic = copyU4(ci);
-    CRW_ASSERT(ci, magic==0xCAFEBABE);
-    if ( magic != 0xCAFEBABE ) {
-        return (long)0;
-    }
-
-    /* minor version number not used */
-    classfileMinorVersion = copyU2(ci);
-    /* major version number not used */
-    classfileMajorVersion = copyU2(ci);
-    CRW_ASSERT(ci,  (classfileMajorVersion <= JVM_CLASSFILE_MAJOR_VERSION) ||
-                   ((classfileMajorVersion == JVM_CLASSFILE_MAJOR_VERSION) &&
-                    (classfileMinorVersion <= JVM_CLASSFILE_MINOR_VERSION)));
-
-    cpool_setup(ci);
-
-    ci->access_flags        = copyU2(ci);
-    if ( skip_class(ci->access_flags) ) {
-        return (long)0;
-    }
-
-    this_class          = copyU2(ci);
-
-    cs = cpool_entry(ci, (CrwCpoolIndex)(cpool_entry(ci, this_class).index1));
-    if ( ci->name == NULL ) {
-        ci->name = duplicate(ci, cs.ptr, cs.len);
-        CRW_ASSERT(ci, strchr(ci->name,'.')==NULL); /* internal qualified name */
-    }
-    CRW_ASSERT(ci, (int)strlen(ci->name)==cs.len && strncmp(ci->name, cs.ptr, cs.len)==0);
-
-    super_class         = copyU2(ci);
-    if ( super_class == 0 ) {
-        ci->is_object_class = JNI_TRUE;
-        CRW_ASSERT(ci, strcmp(ci->name,"java/lang/Object")==0);
-    }
-
-    interface_count     = copyU2(ci);
-    copy(ci, interface_count * 2);
-
-    copy_all_fields(ci);
-
-    method_write_all(ci);
-
-    if ( ci->injection_count == 0 ) {
-        return (long)0;
-    }
-
-    copy_attributes(ci);
-
-    return (long)ci->output_position;
-}
-
-/* ------------------------------------------------------------------- */
-/* Exported interfaces */
-
-JNIEXPORT void JNICALL
-java_crw_demo(unsigned class_number,
-         const char *name,
-         const unsigned char *file_image,
-         long file_len,
-         int system_class,
-         char* tclass_name,     /* Name of class that has tracker methods. */
-         char* tclass_sig,      /* Signature of tclass */
-         char* call_name,       /* Method name to call at offset 0 */
-         char* call_sig,        /* Signature of this method */
-         char* return_name,     /* Method name to call before any return */
-         char* return_sig,      /* Signature of this method */
-         char* obj_init_name,   /* Method name to call in Object <init> */
-         char* obj_init_sig,    /* Signature of this method */
-         char* newarray_name,   /* Method name to call after newarray opcodes */
-         char* newarray_sig,    /* Signature of this method */
-         unsigned char **pnew_file_image,
-         long *pnew_file_len,
-         FatalErrorHandler fatal_error_handler,
-         MethodNumberRegister mnum_callback)
-{
-    CrwClassImage ci;
-    long          max_length;
-    long          new_length;
-    void         *new_image;
-    int           len;
-
-    /* Initial setup of the CrwClassImage structure */
-    (void)memset(&ci, 0, (int)sizeof(CrwClassImage));
-    ci.fatal_error_handler = fatal_error_handler;
-    ci.mnum_callback       = mnum_callback;
-
-    /* Do some interface error checks */
-    if ( pnew_file_image==NULL ) {
-        CRW_FATAL(&ci, "pnew_file_image==NULL");
-    }
-    if ( pnew_file_len==NULL ) {
-        CRW_FATAL(&ci, "pnew_file_len==NULL");
-    }
-
-    /* No file length means do nothing */
-    *pnew_file_image = NULL;
-    *pnew_file_len = 0;
-    if ( file_len==0 ) {
-        return;
-    }
-
-    /* Do some more interface error checks */
-    if ( file_image == NULL ) {
-        CRW_FATAL(&ci, "file_image == NULL");
-    }
-    if ( file_len < 0 ) {
-        CRW_FATAL(&ci, "file_len < 0");
-    }
-    if ( system_class != 0 && system_class != 1 ) {
-        CRW_FATAL(&ci, "system_class is not 0 or 1");
-    }
-    if ( tclass_name == NULL ) {
-        CRW_FATAL(&ci, "tclass_name == NULL");
-    }
-    if ( tclass_sig == NULL || tclass_sig[0]!='L' ) {
-        CRW_FATAL(&ci, "tclass_sig is not a valid class signature");
-    }
-    len = (int)strlen(tclass_sig);
-    if ( tclass_sig[len-1]!=';' ) {
-        CRW_FATAL(&ci, "tclass_sig is not a valid class signature");
-    }
-    if ( call_name != NULL ) {
-        if ( call_sig == NULL || strcmp(call_sig, "(II)V") != 0 ) {
-            CRW_FATAL(&ci, "call_sig is not (II)V");
-        }
-    }
-    if ( return_name != NULL ) {
-        if ( return_sig == NULL || strcmp(return_sig, "(II)V") != 0 ) {
-            CRW_FATAL(&ci, "return_sig is not (II)V");
-        }
-    }
-    if ( obj_init_name != NULL ) {
-        if ( obj_init_sig == NULL || strcmp(obj_init_sig, "(Ljava/lang/Object;)V") != 0 ) {
-            CRW_FATAL(&ci, "obj_init_sig is not (Ljava/lang/Object;)V");
-        }
-    }
-    if ( newarray_name != NULL ) {
-        if ( newarray_sig == NULL || strcmp(newarray_sig, "(Ljava/lang/Object;)V") != 0 ) {
-            CRW_FATAL(&ci, "newarray_sig is not (Ljava/lang/Object;)V");
-        }
-    }
-
-    /* Finish setup the CrwClassImage structure */
-    ci.is_thread_class = JNI_FALSE;
-    if ( name != NULL ) {
-        CRW_ASSERT(&ci, strchr(name,'.')==NULL); /* internal qualified name */
-
-        ci.name = duplicate(&ci, name, (int)strlen(name));
-        if ( strcmp(name, "java/lang/Thread")==0 ) {
-            ci.is_thread_class = JNI_TRUE;
-        }
-    }
-    ci.number = class_number;
-    ci.input = file_image;
-    ci.input_len = file_len;
-
-    /* Do the injection */
-    max_length = file_len*2 + 512; /* Twice as big + 512 */
-    new_image = allocate(&ci, (int)max_length);
-    new_length = inject_class(&ci,
-                                 system_class,
-                                 tclass_name,
-                                 tclass_sig,
-                                 call_name,
-                                 call_sig,
-                                 return_name,
-                                 return_sig,
-                                 obj_init_name,
-                                 obj_init_sig,
-                                 newarray_name,
-                                 newarray_sig,
-                                 new_image,
-                                 max_length);
-
-    /* Dispose or shrink the space to be returned. */
-    if ( new_length == 0 ) {
-        deallocate(&ci, (void*)new_image);
-        new_image = NULL;
-    } else {
-        new_image = (void*)reallocate(&ci, (void*)new_image, (int)new_length);
-    }
-
-    /* Return the new class image */
-    *pnew_file_image = (unsigned char *)new_image;
-    *pnew_file_len = (long)new_length;
-
-    /* Cleanup before we leave. */
-    cleanup(&ci);
-}
-
-/* Return the classname for this class which is inside the classfile image. */
-JNIEXPORT char * JNICALL
-java_crw_demo_classname(const unsigned char *file_image, long file_len,
-        FatalErrorHandler fatal_error_handler)
-{
-    CrwClassImage               ci;
-    CrwConstantPoolEntry        cs;
-    CrwCpoolIndex               this_class;
-    unsigned                    magic;
-    char *                      name;
-
-    name = NULL;
-
-    if ( file_len==0 || file_image==NULL ) {
-        return name;
-    }
-
-    /* The only fields we need filled in are the image pointer and the error
-     *    handler.
-     *    By not adding an output buffer pointer, no output is created.
-     */
-    (void)memset(&ci, 0, (int)sizeof(CrwClassImage));
-    ci.input     = file_image;
-    ci.input_len = file_len;
-    ci.fatal_error_handler = fatal_error_handler;
-
-    /* Read out the bytes from the classfile image */
-
-    magic = readU4(&ci); /* magic number */
-    CRW_ASSERT(&ci, magic==0xCAFEBABE);
-    if ( magic != 0xCAFEBABE ) {
-        return name;
-    }
-    (void)readU2(&ci); /* minor version number */
-    (void)readU2(&ci); /* major version number */
-
-    /* Read in constant pool. Since no output setup, writes are NOP's */
-    cpool_setup(&ci);
-
-    (void)readU2(&ci); /* access flags */
-    this_class = readU2(&ci); /* 'this' class */
-
-    /* Get 'this' constant pool entry */
-    cs = cpool_entry(&ci, (CrwCpoolIndex)(cpool_entry(&ci, this_class).index1));
-
-    /* Duplicate the name */
-    name = (char *)duplicate(&ci, cs.ptr, cs.len);
-
-    /* Cleanup before we leave. */
-    cleanup(&ci);
-
-    /* Return malloc space */
-    return name;
-}
--- a/jdk/src/demo/share/jvmti/java_crw_demo/java_crw_demo.h	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#ifndef JAVA_CRW_DEMO_H
-#define JAVA_CRW_DEMO_H
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* This callback is used to notify the caller of a fatal error. */
-
-typedef void (*FatalErrorHandler)(const char*message, const char*file, int line);
-
-/* This callback is used to return the method information for a class.
- *   Since the information was already read here, it was useful to
- *   return it here, with no JVMTI phase restrictions.
- *   If the class file does represent a "class" and it has methods, then
- *   this callback will be called with the class number and pointers to
- *   the array of names, array of signatures, and the count of methods.
- */
-
-typedef void (*MethodNumberRegister)(unsigned, const char**, const char**, int);
-
-/* Class file reader/writer interface. Basic input is a classfile image
- *     and details about what to inject. The output is a new classfile image
- *     that was allocated with malloc(), and should be freed by the caller.
- */
-
-/* Names of external symbols to look for. These are the names that we
- *   try and lookup in the shared library. On Windows 2000, the naming
- *   convention is to prefix a "_" and suffix a "@N" where N is 4 times
- *   the number or arguments supplied.It has 19 args, so 76 = 19*4.
- *   On Windows 2003, Linux, and Solaris, the first name will be
- *   found, on Windows 2000 a second try should find the second name.
- *
- *   WARNING: If You change the JavaCrwDemo typedef, you MUST change
- *            multiple things in this file, including this name.
- */
-
-#define JAVA_CRW_DEMO_SYMBOLS { "java_crw_demo", "_java_crw_demo@76" }
-
-/* Typedef needed for type casting in dynamic access situations. */
-
-typedef void (JNICALL *JavaCrwDemo)(
-         unsigned class_number,
-         const char *name,
-         const unsigned char *file_image,
-         long file_len,
-         int system_class,
-         char* tclass_name,
-         char* tclass_sig,
-         char* call_name,
-         char* call_sig,
-         char* return_name,
-         char* return_sig,
-         char* obj_init_name,
-         char* obj_init_sig,
-         char* newarray_name,
-         char* newarray_sig,
-         unsigned char **pnew_file_image,
-         long *pnew_file_len,
-         FatalErrorHandler fatal_error_handler,
-         MethodNumberRegister mnum_callback
-);
-
-/* Function export (should match typedef above) */
-
-JNIEXPORT void JNICALL java_crw_demo(
-
-         unsigned class_number, /* Caller assigned class number for class */
-
-         const char *name,      /* Internal class name, e.g. java/lang/Object */
-                                /*   (Do not use "java.lang.Object" format) */
-
-         const unsigned char
-           *file_image,         /* Pointer to classfile image for this class */
-
-         long file_len,         /* Length of the classfile in bytes */
-
-         int system_class,      /* Set to 1 if this is a system class */
-                                /*   (prevents injections into empty */
-                                /*   <clinit>, finalize, and <init> methods) */
-
-         char* tclass_name,     /* Class that has methods we will call at */
-                                /*   the injection sites (tclass) */
-
-         char* tclass_sig,      /* Signature of tclass */
-                                /*  (Must be "L" + tclass_name + ";") */
-
-         char* call_name,       /* Method name in tclass to call at offset 0 */
-                                /*   for every method */
-
-         char* call_sig,        /* Signature of this call_name method */
-                                /*  (Must be "(II)V") */
-
-         char* return_name,     /* Method name in tclass to call at all */
-                                /*  return opcodes in every method */
-
-         char* return_sig,      /* Signature of this return_name method */
-                                /*  (Must be "(II)V") */
-
-         char* obj_init_name,   /* Method name in tclass to call first thing */
-                                /*   when injecting java.lang.Object.<init> */
-
-         char* obj_init_sig,    /* Signature of this obj_init_name method */
-                                /*  (Must be "(Ljava/lang/Object;)V") */
-
-         char* newarray_name,   /* Method name in tclass to call after every */
-                                /*   newarray opcode in every method */
-
-         char* newarray_sig,    /* Signature of this method */
-                                /*  (Must be "(Ljava/lang/Object;II)V") */
-
-         unsigned char
-           **pnew_file_image,   /* Returns a pointer to new classfile image */
-
-         long *pnew_file_len,   /* Returns the length of the new image */
-
-         FatalErrorHandler
-           fatal_error_handler, /* Pointer to function to call on any */
-                                /*  fatal error. NULL sends error to stderr */
-
-         MethodNumberRegister
-           mnum_callback        /* Pointer to function that gets called */
-                                /*   with all details on methods in this */
-                                /*   class. NULL means skip this call. */
-
-           );
-
-
-/* External to read the class name out of a class file .
- *
- *   WARNING: If You change the typedef, you MUST change
- *            multiple things in this file, including this name.
- */
-
-#define JAVA_CRW_DEMO_CLASSNAME_SYMBOLS \
-         { "java_crw_demo_classname", "_java_crw_demo_classname@12" }
-
-/* Typedef needed for type casting in dynamic access situations. */
-
-typedef char * (JNICALL *JavaCrwDemoClassname)(
-         const unsigned char *file_image,
-         long file_len,
-         FatalErrorHandler fatal_error_handler);
-
-JNIEXPORT char * JNICALL java_crw_demo_classname(
-         const unsigned char *file_image,
-         long file_len,
-         FatalErrorHandler fatal_error_handler);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif /* __cplusplus */
-
-#endif
--- a/jdk/src/demo/share/jvmti/java_crw_demo/sample.makefile.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +0,0 @@
-#
-# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-########################################################################
-#
-# Sample GNU Makefile for building
-#
-#  Example uses:    
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
-#       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
-#       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
-#
-########################################################################
-
-# Source lists
-LIBNAME=java_crw_demo
-SOURCES=java_crw_demo.c
-
-# Solaris Studio C Compiler Version 12.4
-ifeq ($(OSNAME), solaris)
-    # Sun Solaris Compiler options needed
-    COMMON_FLAGS=-mt -KPIC
-    # Options that help find errors
-    COMMON_FLAGS+= -Xa -v -xc99=%none
-    # Check LIBARCH for any special compiler options
-    LIBARCH=$(shell uname -p)
-    ifeq ($(LIBARCH), sparc)
-        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
-    endif
-    ifeq ($(LIBARCH), sparcv9)
-        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
-    endif
-    ifeq ($(OPT), true)
-        CFLAGS=-xO2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS)
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-z defs -ztext
-    # Libraries we are dependent on
-    LIBRARIES=-lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -G -o $@
-endif
-
-# Linux GNU C Compiler
-ifeq ($(OSNAME), linux)
-    # GNU Compiler options needed to build it
-    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
-    # Options that help find errors
-    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
-    ifeq ($(OPT), true)
-        CFLAGS=-O2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
-    # Libraries we are dependent on
-    LIBRARIES=-lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -shared -o $@
-endif
-
-# Windows Microsoft C/C++ Optimizing Compiler Version 12
-ifeq ($(OSNAME), win32)
-    CC=cl
-    # Compiler options needed to build it
-    COMMON_FLAGS=-Gy -DWIN32
-    # Options that help find errors
-    COMMON_FLAGS+=-W0 -WX
-    ifeq ($(OPT), true)
-        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
-    else
-        CFLAGS= -Od -Zi $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.obj)
-    # Library name and options needed to build it
-    LIBRARY=$(LIBNAME).dll
-    LDFLAGS=
-    # Libraries we are dependent on
-    LIBRARIES=
-    # Building a shared library
-    LINK_SHARED=link -dll -out:$@
-endif
-
-# Common -I options
-CFLAGS += -I.
-CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
-
-# Default rule (build both native library and jar file)
-all: $(LIBRARY)
-
-# Build native library
-$(LIBRARY): $(OBJECTS)
-	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
-
-# Cleanup the built bits
-clean:
-	rm -f -r classes
-	rm -f $(LIBRARY) $(OBJECTS)
-
-# Compilation rule only needed on Windows
-ifeq ($(OSNAME), win32)
-%.obj: %.c
-	$(COMPILE.c) $<
-endif
-
--- a/jdk/src/demo/share/jvmti/minst/Minst.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-
-/* Java class to hold static methods which will be called in byte code
- *    injections of all class files.
- */
-
-public class Minst {
-
-    /* Master switch that activates methods. */
-
-    private static int engaged = 0;
-
-    /* At the very beginning of every method, a call to method_entry()
-     *     is injected.
-     */
-
-    public static void method_entry(int cnum, int mnum) {
-        Class<Minst> x = Minst.class;
-        synchronized ( x ) {
-            if ( engaged > 0 ) {
-                engaged = 0;
-                String className = "Unknown";
-                String methodName = "Unknown";
-                Exception exp = new Exception();
-                StackTraceElement[] stack = exp.getStackTrace();
-                if (stack.length > 1) {
-                    StackTraceElement location = stack[1];
-                    className = location.getClassName();
-                    methodName = location.getMethodName();
-                }
-                System.out.println("Reached method entry: " +
-                     className + "." + methodName + "()");
-                engaged++;
-            }
-        }
-    }
-
-}
--- a/jdk/src/demo/share/jvmti/minst/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-minst
-
-This agent library can be used to inject code at method calls.
-It uses the same java_crw_demo library used by HPROF to do BCI on all 
-or selected classfiles loaded into the Virtual Machine.  
-The class Minst.java can be customized to do whatever you wish,
-within reason of course, and does not call native methods directly.
-
-You can use this agent library as follows:
-
-    java -agentlib:minst ...
-
-To get help on the available options try:
-
-    java -agentlib:minst=help
-
-See ${JAVA_HOME}/demo/jvmti/index.html for help running and building agents.
-
--- a/jdk/src/demo/share/jvmti/minst/minst.c	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,481 +0,0 @@
-/*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include "stdlib.h"
-
-#include "minst.h"
-#include "java_crw_demo.h"
-
-
-/* ------------------------------------------------------------------- */
-/* Some constant maximum sizes */
-
-#define MAX_TOKEN_LENGTH        80
-#define MAX_METHOD_NAME_LENGTH  256
-
-/* Some constant names that tie to Java class/method names.
- *    We assume the Java class whose static methods we will be calling
- *    looks like:
- *
- * public class Minst {
- *     private static int engaged;
- *     private static native void _method_entry(Object thr, int cnum, int mnum);
- *     public static void method_entry(int cnum, int mnum)
- *     {
- *         ...
- *     }
- * }
- *
- */
-
-#define MINST_class        Minst            /* Name of class we are using */
-#define MINST_entry        method_entry    /* Name of java entry method */
-#define MINST_engaged      engaged         /* Name of java static field */
-
-/* C macros to create strings from tokens */
-#define _STRING(s) #s
-#define STRING(s) _STRING(s)
-
-/* ------------------------------------------------------------------- */
-
-/* Global agent data structure */
-
-typedef struct {
-    /* JVMTI Environment */
-    jvmtiEnv      *jvmti;
-    jboolean       vm_is_dead;
-    jboolean       vm_is_started;
-    /* Data access Lock */
-    jrawMonitorID  lock;
-    /* Options */
-    char           *include;
-    char           *exclude;
-    /* Class Count/ID */
-    jint            ccount;
-} GlobalAgentData;
-
-static GlobalAgentData *gdata;
-
-/* Enter a critical section by doing a JVMTI Raw Monitor Enter */
-static void
-enter_critical_section(jvmtiEnv *jvmti)
-{
-    jvmtiError error;
-
-    error = (*jvmti)->RawMonitorEnter(jvmti, gdata->lock);
-    check_jvmti_error(jvmti, error, "Cannot enter with raw monitor");
-}
-
-/* Exit a critical section by doing a JVMTI Raw Monitor Exit */
-static void
-exit_critical_section(jvmtiEnv *jvmti)
-{
-    jvmtiError error;
-
-    error = (*jvmti)->RawMonitorExit(jvmti, gdata->lock);
-    check_jvmti_error(jvmti, error, "Cannot exit with raw monitor");
-}
-
-/* Callback for JVMTI_EVENT_VM_START */
-static void JNICALL
-cbVMStart(jvmtiEnv *jvmti, JNIEnv *env)
-{
-    enter_critical_section(jvmti); {
-        /* Indicate VM has started */
-        gdata->vm_is_started = JNI_TRUE;
-    } exit_critical_section(jvmti);
-}
-
-/* Callback for JVMTI_EVENT_VM_INIT */
-static void JNICALL
-cbVMInit(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    enter_critical_section(jvmti); {
-        jclass   klass;
-        jfieldID field;
-
-        /* Register Natives for class whose methods we use */
-        klass = (*env)->FindClass(env, STRING(MINST_class));
-        if ( klass == NULL ) {
-            fatal_error("ERROR: JNI: Cannot find %s with FindClass\n",
-                        STRING(MINST_class));
-        }
-
-        /* Engage calls. */
-        field = (*env)->GetStaticFieldID(env, klass, STRING(MINST_engaged), "I");
-        if ( field == NULL ) {
-            fatal_error("ERROR: JNI: Cannot get field from %s\n",
-                        STRING(MINST_class));
-        }
-        (*env)->SetStaticIntField(env, klass, field, 1);
-    } exit_critical_section(jvmti);
-}
-
-/* Callback for JVMTI_EVENT_VM_DEATH */
-static void JNICALL
-cbVMDeath(jvmtiEnv *jvmti, JNIEnv *env)
-{
-    enter_critical_section(jvmti); {
-        jclass   klass;
-        jfieldID field;
-
-        /* The VM has died. */
-        stdout_message("VMDeath\n");
-
-        /* Disengage calls in MINST_class. */
-        klass = (*env)->FindClass(env, STRING(MINST_class));
-        if ( klass == NULL ) {
-            fatal_error("ERROR: JNI: Cannot find %s with FindClass\n",
-                        STRING(MINST_class));
-        }
-        field = (*env)->GetStaticFieldID(env, klass, STRING(MINST_engaged), "I");
-        if ( field == NULL ) {
-            fatal_error("ERROR: JNI: Cannot get field from %s\n",
-                        STRING(MINST_class));
-        }
-        (*env)->SetStaticIntField(env, klass, field, -1);
-
-        /* The critical section here is important to hold back the VM death
-         *    until all other callbacks have completed.
-         */
-
-        /* Since this critical section could be holding up other threads
-         *   in other event callbacks, we need to indicate that the VM is
-         *   dead so that the other callbacks can short circuit their work.
-         *   We don't expect any further events after VmDeath but we do need
-         *   to be careful that existing threads might be in our own agent
-         *   callback code.
-         */
-        gdata->vm_is_dead = JNI_TRUE;
-
-    } exit_critical_section(jvmti);
-
-}
-
-/* Callback for JVMTI_EVENT_CLASS_FILE_LOAD_HOOK */
-static void JNICALL
-cbClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv* env,
-                jclass class_being_redefined, jobject loader,
-                const char* name, jobject protection_domain,
-                jint class_data_len, const unsigned char* class_data,
-                jint* new_class_data_len, unsigned char** new_class_data)
-{
-    enter_critical_section(jvmti); {
-        /* It's possible we get here right after VmDeath event, be careful */
-        if ( !gdata->vm_is_dead ) {
-
-            const char *classname;
-
-            /* Name could be NULL */
-            if ( name == NULL ) {
-                classname = java_crw_demo_classname(class_data, class_data_len,
-                        NULL);
-                if ( classname == NULL ) {
-                    fatal_error("ERROR: No classname inside classfile\n");
-                }
-            } else {
-                classname = strdup(name);
-                if ( classname == NULL ) {
-                    fatal_error("ERROR: Out of malloc memory\n");
-                }
-            }
-
-            *new_class_data_len = 0;
-            *new_class_data     = NULL;
-
-            /* The tracker class itself? */
-            if ( interested((char*)classname, "", gdata->include, gdata->exclude)
-                  &&  strcmp(classname, STRING(MINST_class)) != 0 ) {
-                jint           cnum;
-                int            system_class;
-                unsigned char *new_image;
-                long           new_length;
-
-                /* Get unique number for every class file image loaded */
-                cnum = gdata->ccount++;
-
-                /* Is it a system class? If the class load is before VmStart
-                 *   then we will consider it a system class that should
-                 *   be treated carefully. (See java_crw_demo)
-                 */
-                system_class = 0;
-                if ( !gdata->vm_is_started ) {
-                    system_class = 1;
-                }
-
-                new_image = NULL;
-                new_length = 0;
-
-                /* Call the class file reader/write demo code */
-                java_crw_demo(cnum,
-                    classname,
-                    class_data,
-                    class_data_len,
-                    system_class,
-                    STRING(MINST_class), "L" STRING(MINST_class) ";",
-                    STRING(MINST_entry), "(II)V",
-                    NULL, NULL,
-                    NULL, NULL,
-                    NULL, NULL,
-                    &new_image,
-                    &new_length,
-                    NULL,
-                    NULL);
-
-                /* If we got back a new class image, return it back as "the"
-                 *   new class image. This must be JVMTI Allocate space.
-                 */
-                if ( new_length > 0 ) {
-                    unsigned char *jvmti_space;
-
-                    jvmti_space = (unsigned char *)allocate(jvmti, (jint)new_length);
-                    (void)memcpy((void*)jvmti_space, (void*)new_image, (int)new_length);
-                    *new_class_data_len = (jint)new_length;
-                    *new_class_data     = jvmti_space; /* VM will deallocate */
-                }
-
-                /* Always free up the space we get from java_crw_demo() */
-                if ( new_image != NULL ) {
-                    (void)free((void*)new_image); /* Free malloc() space with free() */
-                }
-            }
-            (void)free((void*)classname);
-        }
-    } exit_critical_section(jvmti);
-}
-
-/* Parse the options for this minst agent */
-static void
-parse_agent_options(char *options)
-{
-    char token[MAX_TOKEN_LENGTH];
-    char *next;
-
-    /* Parse options and set flags in gdata */
-    if ( options==NULL ) {
-        return;
-    }
-
-    /* Get the first token from the options string. */
-    next = get_token(options, ",=", token, sizeof(token));
-
-    /* While not at the end of the options string, process this option. */
-    while ( next != NULL ) {
-        if ( strcmp(token,"help")==0 ) {
-            stdout_message("The minst JVMTI demo agent\n");
-            stdout_message("\n");
-            stdout_message(" java -agent:minst[=options] ...\n");
-            stdout_message("\n");
-            stdout_message("The options are comma separated:\n");
-            stdout_message("\t help\t\t\t Print help information\n");
-            stdout_message("\t include=item\t\t Only these classes/methods\n");
-            stdout_message("\t exclude=item\t\t Exclude these classes/methods\n");
-            stdout_message("\n");
-            stdout_message("item\t Qualified class and/or method names\n");
-            stdout_message("\t\t e.g. (*.<init>;Foobar.method;sun.*)\n");
-            stdout_message("\n");
-            exit(0);
-        } else if ( strcmp(token,"include")==0 ) {
-            int   used;
-            int   maxlen;
-
-            maxlen = MAX_METHOD_NAME_LENGTH;
-            if ( gdata->include == NULL ) {
-                gdata->include = (char*)calloc(maxlen+1, 1);
-                used = 0;
-            } else {
-                used  = (int)strlen(gdata->include);
-                gdata->include[used++] = ',';
-                gdata->include[used] = 0;
-                gdata->include = (char*)
-                             realloc((void*)gdata->include, used+maxlen+1);
-            }
-            if ( gdata->include == NULL ) {
-                fatal_error("ERROR: Out of malloc memory\n");
-            }
-            /* Add this item to the list */
-            next = get_token(next, ",=", gdata->include+used, maxlen);
-            /* Check for token scan error */
-            if ( next==NULL ) {
-                fatal_error("ERROR: include option error\n");
-            }
-        } else if ( strcmp(token,"exclude")==0 ) {
-            int   used;
-            int   maxlen;
-
-            maxlen = MAX_METHOD_NAME_LENGTH;
-            if ( gdata->exclude == NULL ) {
-                gdata->exclude = (char*)calloc(maxlen+1, 1);
-                used = 0;
-            } else {
-                used  = (int)strlen(gdata->exclude);
-                gdata->exclude[used++] = ',';
-                gdata->exclude[used] = 0;
-                gdata->exclude = (char*)
-                             realloc((void*)gdata->exclude, used+maxlen+1);
-            }
-            if ( gdata->exclude == NULL ) {
-                fatal_error("ERROR: Out of malloc memory\n");
-            }
-            /* Add this item to the list */
-            next = get_token(next, ",=", gdata->exclude+used, maxlen);
-            /* Check for token scan error */
-            if ( next==NULL ) {
-                fatal_error("ERROR: exclude option error\n");
-            }
-        } else if ( token[0]!=0 ) {
-            /* We got a non-empty token and we don't know what it is. */
-            fatal_error("ERROR: Unknown option: %s\n", token);
-        }
-        /* Get the next token (returns NULL if there are no more) */
-        next = get_token(next, ",=", token, sizeof(token));
-    }
-}
-
-/* Agent_OnLoad: This is called immediately after the shared library is
- *   loaded. This is the first code executed.
- */
-JNIEXPORT jint JNICALL
-DEF_Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
-{
-    static GlobalAgentData data;
-    jvmtiEnv              *jvmti;
-    jvmtiError             error;
-    jint                   res;
-    jvmtiCapabilities      capabilities;
-    jvmtiEventCallbacks    callbacks;
-
-    /* Setup initial global agent data area
-     *   Use of static/extern data should be handled carefully here.
-     *   We need to make sure that we are able to cleanup after ourselves
-     *     so anything allocated in this library needs to be freed in
-     *     the Agent_OnUnload() function.
-     */
-    (void)memset((void*)&data, 0, sizeof(data));
-    gdata = &data;
-
-    /* First thing we need to do is get the jvmtiEnv* or JVMTI environment */
-    res = (*vm)->GetEnv(vm, (void **)&jvmti, JVMTI_VERSION_1);
-    if (res != JNI_OK) {
-        /* This means that the VM was unable to obtain this version of the
-         *   JVMTI interface, this is a fatal error.
-         */
-        fatal_error("ERROR: Unable to access JVMTI Version 1 (0x%x),"
-                " is your JDK a 5.0 or newer version?"
-                " JNIEnv's GetEnv() returned %d\n",
-               JVMTI_VERSION_1, res);
-    }
-
-    /* Here we save the jvmtiEnv* for Agent_OnUnload(). */
-    gdata->jvmti = jvmti;
-
-    /* Parse any options supplied on java command line */
-    parse_agent_options(options);
-
-    /* Immediately after getting the jvmtiEnv* we need to ask for the
-     *   capabilities this agent will need. In this case we need to make
-     *   sure that we can get all class load hooks.
-     */
-    (void)memset(&capabilities,0, sizeof(capabilities));
-    capabilities.can_generate_all_class_hook_events  = 1;
-    error = (*jvmti)->AddCapabilities(jvmti, &capabilities);
-    check_jvmti_error(jvmti, error, "Unable to get necessary JVMTI capabilities.");
-
-    /* Next we need to provide the pointers to the callback functions to
-     *   to this jvmtiEnv*
-     */
-    (void)memset(&callbacks,0, sizeof(callbacks));
-    /* JVMTI_EVENT_VM_START */
-    callbacks.VMStart           = &cbVMStart;
-    /* JVMTI_EVENT_VM_INIT */
-    callbacks.VMInit           = &cbVMInit;
-    /* JVMTI_EVENT_VM_DEATH */
-    callbacks.VMDeath           = &cbVMDeath;
-    /* JVMTI_EVENT_CLASS_FILE_LOAD_HOOK */
-    callbacks.ClassFileLoadHook = &cbClassFileLoadHook;
-    error = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, (jint)sizeof(callbacks));
-    check_jvmti_error(jvmti, error, "Cannot set jvmti callbacks");
-
-    /* At first the only initial events we are interested in are VM
-     *   initialization, VM death, and Class File Loads.
-     *   Once the VM is initialized we will request more events.
-     */
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_VM_START, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_VM_INIT, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_VM_DEATH, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-
-    /* Here we create a raw monitor for our use in this agent to
-     *   protect critical sections of code.
-     */
-    error = (*jvmti)->CreateRawMonitor(jvmti, "agent data", &(gdata->lock));
-    check_jvmti_error(jvmti, error, "Cannot create raw monitor");
-
-    /* Add demo jar file to boot classpath */
-    add_demo_jar_to_bootclasspath(jvmti, "minst");
-
-    /* We return JNI_OK to signify success */
-    return JNI_OK;
-}
-
-/* Agent_OnUnload: This is called immediately before the shared library is
- *   unloaded. This is the last code executed.
- */
-JNIEXPORT void JNICALL
-DEF_Agent_OnUnload(JavaVM *vm)
-{
-    /* Make sure all malloc/calloc/strdup space is freed */
-    if ( gdata->include != NULL ) {
-        (void)free((void*)gdata->include);
-        gdata->include = NULL;
-    }
-    if ( gdata->exclude != NULL ) {
-        (void)free((void*)gdata->exclude);
-        gdata->exclude = NULL;
-    }
-}
--- a/jdk/src/demo/share/jvmti/minst/minst.h	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/* Primary minst #include file, should be included by most if not
- *    all minst source files. Gives access to the global data structure
- *    and all global macros.
- */
-
-#ifndef MINST_H
-#define MINST_H
-
-/* Standard C functions used throughout. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stddef.h>
-#include <stdarg.h>
-
-/* General JVM/Java functions, types and macros. */
-
-#include <sys/types.h>
-#include "jni.h"
-#include "jvmti.h"
-
-/* Utility functions */
-
-#include "agent_util.h"
-
-#endif
--- a/jdk/src/demo/share/jvmti/minst/sample.makefile.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-#
-# Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-########################################################################
-#
-# Sample GNU Makefile for building JVMTI Demo minst
-#
-#  Example uses:    
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
-#       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
-#       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
-#
-########################################################################
-
-# Source lists
-LIBNAME=minst
-SOURCES=minst.c ../agent_util/agent_util.c
-JAVA_SOURCES=Minst.java
-
-# Name of jar file that needs to be created
-JARFILE=minst.jar
-
-# Solaris Studio C Compiler Version 12.4
-ifeq ($(OSNAME), solaris)
-    # Sun Solaris Compiler options needed
-    COMMON_FLAGS=-mt -KPIC
-    # Options that help find errors
-    COMMON_FLAGS+= -Xa -v -xc99=%none
-    # Check LIBARCH for any special compiler options
-    LIBARCH=$(shell uname -p)
-    ifeq ($(LIBARCH), sparc)
-        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
-    endif
-    ifeq ($(LIBARCH), sparcv9)
-        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
-    endif
-    ifeq ($(OPT), true)
-        CFLAGS=-xO2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS)
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-z defs -ztext
-    # Libraries we are dependent on
-    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -G -o $@
-endif
-
-# Linux GNU C Compiler
-ifeq ($(OSNAME), linux)
-    # GNU Compiler options needed to build it
-    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
-    # Options that help find errors
-    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
-    ifeq ($(OPT), true)
-        CFLAGS=-O2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
-    # Libraries we are dependent on
-    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -shared -o $@
-endif
-
-# Windows Microsoft C/C++ Optimizing Compiler Version 12
-ifeq ($(OSNAME), win32)
-    CC=cl
-    # Compiler options needed to build it
-    COMMON_FLAGS=-Gy -DWIN32
-    # Options that help find errors
-    COMMON_FLAGS+=-W0 -WX
-    ifeq ($(OPT), true)
-        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
-    else
-        CFLAGS= -Od -Zi $(COMMON_FLAGS) 
-    endif
-    # Add in java_crw_demo obj file on windows (easier)
-    SOURCES+=../java_crw_demo/java_crw_demo.c
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.obj)
-    # Library name and options needed to build it
-    LIBRARY=$(LIBNAME).dll
-    LDFLAGS=
-    # Libraries we are dependent on
-    LIBRARIES=$(JDK)/
-    # Building a shared library
-    LINK_SHARED=link -dll -out:$@
-endif
-
-# Common -I options
-CFLAGS += -I.
-CFLAGS += -I../agent_util
-CFLAGS += -I../java_crw_demo
-CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
-
-# Default rule (build both native library and jar file)
-all: $(LIBRARY) $(JARFILE)
-
-# Build native library
-$(LIBRARY): $(OBJECTS)
-	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
-
-# Build jar file
-$(JARFILE): $(JAVA_SOURCES)
-	rm -f -r classes
-	mkdir -p classes
-	$(JDK)/bin/javac -d classes $(JAVA_SOURCES)
-	(cd classes; $(JDK)/bin/jar cf ../$@ *)
-
-# Cleanup the built bits
-clean:
-	rm -f -r classes
-	rm -f $(LIBRARY) $(JARFILE) $(OBJECTS)
-
-# Simple tester
-test: all
-	LD_LIBRARY_PATH=. $(JDK)/bin/java -agentlib:$(LIBNAME) -Xbootclasspath/a:./$(JARFILE) -version
-
-# Compilation rule only needed on Windows
-ifeq ($(OSNAME), win32)
-%.obj: %.c
-	$(COMPILE.c) $<
-endif
-
--- a/jdk/src/demo/share/jvmti/mtrace/Mtrace.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-
-/* Java class to hold static methods which will be called in byte code
- *    injections of all class files.
- */
-
-public class Mtrace {
-
-    /* Master switch that activates methods. */
-
-    private static int engaged = 0;
-
-    /* At the very beginning of every method, a call to method_entry()
-     *     is injected.
-     */
-
-    private static native void _method_entry(Object thr, int cnum, int mnum);
-    public static void method_entry(int cnum, int mnum)
-    {
-        if ( engaged != 0 ) {
-            _method_entry(Thread.currentThread(), cnum, mnum);
-        }
-    }
-
-    /* Before any of the return bytecodes, a call to method_exit()
-     *     is injected.
-     */
-
-    private static native void _method_exit(Object thr, int cnum, int mnum);
-    public static void method_exit(int cnum, int mnum)
-    {
-        if ( engaged != 0 ) {
-            _method_exit(Thread.currentThread(), cnum, mnum);
-        }
-    }
-
-}
--- a/jdk/src/demo/share/jvmti/mtrace/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-#
-# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-mtrace
-
-This agent library can be used to track method call and return counts.
-It uses the same java_crw_demo library used by HPROF to do BCI on all or
-selected classfiles loaded into the Virtual Machine.  It will print out a 
-sorted list of the most heavily used classes (as determined by the number 
-of method calls into the class) and also include the call and return counts 
-for all methods that are called.  
-
-You can use this agent library as follows:
-
-    java -Xbootclasspath/a:mtrace.jar -agentlib:mtrace ...
-
-To get help on the available options try:
-
-    java -agentlib:mtrace=help
-
-See ${JAVA_HOME}/demo/jvmti/index.html for help running and building agents.
-
--- a/jdk/src/demo/share/jvmti/mtrace/mtrace.c	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,833 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include "stdlib.h"
-
-#include "mtrace.h"
-#include "java_crw_demo.h"
-
-
-/* ------------------------------------------------------------------- */
-/* Some constant maximum sizes */
-
-#define MAX_TOKEN_LENGTH        16
-#define MAX_THREAD_NAME_LENGTH  512
-#define MAX_METHOD_NAME_LENGTH  1024
-
-/* Some constant names that tie to Java class/method names.
- *    We assume the Java class whose static methods we will be calling
- *    looks like:
- *
- * public class Mtrace {
- *     private static int engaged;
- *     private static native void _method_entry(Object thr, int cnum, int mnum);
- *     public static void method_entry(int cnum, int mnum)
- *     {
- *         if ( engaged != 0 ) {
- *             _method_entry(Thread.currentThread(), cnum, mnum);
- *         }
- *     }
- *     private static native void _method_exit(Object thr, int cnum, int mnum);
- *     public static void method_exit(int cnum, int mnum)
- *     {
- *         if ( engaged != 0 ) {
- *             _method_exit(Thread.currentThread(), cnum, mnum);
- *         }
- *     }
- * }
- *
- *    The engaged field allows us to inject all classes (even system classes)
- *    and delay the actual calls to the native code until the VM has reached
- *    a safe time to call native methods (Past the JVMTI VM_START event).
- *
- */
-
-#define MTRACE_class        Mtrace          /* Name of class we are using */
-#define MTRACE_entry        method_entry    /* Name of java entry method */
-#define MTRACE_exit         method_exit     /* Name of java exit method */
-#define MTRACE_native_entry _method_entry   /* Name of java entry native */
-#define MTRACE_native_exit  _method_exit    /* Name of java exit native */
-#define MTRACE_engaged      engaged         /* Name of java static field */
-
-/* C macros to create strings from tokens */
-#define _STRING(s) #s
-#define STRING(s) _STRING(s)
-
-/* ------------------------------------------------------------------- */
-
-/* Data structure to hold method and class information in agent */
-
-typedef struct MethodInfo {
-    const char *name;          /* Method name */
-    const char *signature;     /* Method signature */
-    int         calls;         /* Method call count */
-    int         returns;       /* Method return count */
-} MethodInfo;
-
-typedef struct ClassInfo {
-    const char *name;          /* Class name */
-    int         mcount;        /* Method count */
-    MethodInfo *methods;       /* Method information */
-    int         calls;         /* Method call count for this class */
-} ClassInfo;
-
-/* Global agent data structure */
-
-typedef struct {
-    /* JVMTI Environment */
-    jvmtiEnv      *jvmti;
-    jboolean       vm_is_dead;
-    jboolean       vm_is_started;
-    /* Data access Lock */
-    jrawMonitorID  lock;
-    /* Options */
-    char           *include;
-    char           *exclude;
-    int             max_count;
-    /* ClassInfo Table */
-    ClassInfo      *classes;
-    jint            ccount;
-} GlobalAgentData;
-
-static GlobalAgentData *gdata;
-
-/* Enter a critical section by doing a JVMTI Raw Monitor Enter */
-static void
-enter_critical_section(jvmtiEnv *jvmti)
-{
-    jvmtiError error;
-
-    error = (*jvmti)->RawMonitorEnter(jvmti, gdata->lock);
-    check_jvmti_error(jvmti, error, "Cannot enter with raw monitor");
-}
-
-/* Exit a critical section by doing a JVMTI Raw Monitor Exit */
-static void
-exit_critical_section(jvmtiEnv *jvmti)
-{
-    jvmtiError error;
-
-    error = (*jvmti)->RawMonitorExit(jvmti, gdata->lock);
-    check_jvmti_error(jvmti, error, "Cannot exit with raw monitor");
-}
-
-/* Get a name for a jthread */
-static void
-get_thread_name(jvmtiEnv *jvmti, jthread thread, char *tname, int maxlen)
-{
-    jvmtiThreadInfo info;
-    jvmtiError      error;
-
-    /* Make sure the stack variables are garbage free */
-    (void)memset(&info,0, sizeof(info));
-
-    /* Assume the name is unknown for now */
-    (void)strcpy(tname, "Unknown");
-
-    /* Get the thread information, which includes the name */
-    error = (*jvmti)->GetThreadInfo(jvmti, thread, &info);
-    check_jvmti_error(jvmti, error, "Cannot get thread info");
-
-    /* The thread might not have a name, be careful here. */
-    if ( info.name != NULL ) {
-        int len;
-
-        /* Copy the thread name into tname if it will fit */
-        len = (int)strlen(info.name);
-        if ( len < maxlen ) {
-            (void)strcpy(tname, info.name);
-        }
-
-        /* Every string allocated by JVMTI needs to be freed */
-        deallocate(jvmti, (void*)info.name);
-    }
-}
-
-/* Qsort class compare routine */
-static int
-class_compar(const void *e1, const void *e2)
-{
-    ClassInfo *c1 = (ClassInfo*)e1;
-    ClassInfo *c2 = (ClassInfo*)e2;
-    if ( c1->calls > c2->calls ) return  1;
-    if ( c1->calls < c2->calls ) return -1;
-    return 0;
-}
-
-/* Qsort method compare routine */
-static int
-method_compar(const void *e1, const void *e2)
-{
-    MethodInfo *m1 = (MethodInfo*)e1;
-    MethodInfo *m2 = (MethodInfo*)e2;
-    if ( m1->calls > m2->calls ) return  1;
-    if ( m1->calls < m2->calls ) return -1;
-    return 0;
-}
-
-/* Callback from java_crw_demo() that gives us mnum mappings */
-static void
-mnum_callbacks(unsigned cnum, const char **names, const char**sigs, int mcount)
-{
-    ClassInfo  *cp;
-    int         mnum;
-
-    if ( cnum >= (unsigned)gdata->ccount ) {
-        fatal_error("ERROR: Class number out of range\n");
-    }
-    if ( mcount == 0 ) {
-        return;
-    }
-
-    cp           = gdata->classes + (int)cnum;
-    cp->calls    = 0;
-    cp->mcount   = mcount;
-    cp->methods  = (MethodInfo*)calloc(mcount, sizeof(MethodInfo));
-    if ( cp->methods == NULL ) {
-        fatal_error("ERROR: Out of malloc memory\n");
-    }
-
-    for ( mnum = 0 ; mnum < mcount ; mnum++ ) {
-        MethodInfo *mp;
-
-        mp            = cp->methods + mnum;
-        mp->name      = (const char *)strdup(names[mnum]);
-        if ( mp->name == NULL ) {
-            fatal_error("ERROR: Out of malloc memory\n");
-        }
-        mp->signature = (const char *)strdup(sigs[mnum]);
-        if ( mp->signature == NULL ) {
-            fatal_error("ERROR: Out of malloc memory\n");
-        }
-    }
-}
-
-/* Java Native Method for entry */
-static void
-MTRACE_native_entry(JNIEnv *env, jclass klass, jobject thread, jint cnum, jint mnum)
-{
-    enter_critical_section(gdata->jvmti); {
-        /* It's possible we get here right after VmDeath event, be careful */
-        if ( !gdata->vm_is_dead ) {
-            ClassInfo  *cp;
-            MethodInfo *mp;
-
-            if ( cnum >= gdata->ccount ) {
-                fatal_error("ERROR: Class number out of range\n");
-            }
-            cp = gdata->classes + cnum;
-            if ( mnum >= cp->mcount ) {
-                fatal_error("ERROR: Method number out of range\n");
-            }
-            mp = cp->methods + mnum;
-            if ( interested((char*)cp->name, (char*)mp->name,
-                            gdata->include, gdata->exclude)  ) {
-                mp->calls++;
-                cp->calls++;
-            }
-        }
-    } exit_critical_section(gdata->jvmti);
-}
-
-/* Java Native Method for exit */
-static void
-MTRACE_native_exit(JNIEnv *env, jclass klass, jobject thread, jint cnum, jint mnum)
-{
-    enter_critical_section(gdata->jvmti); {
-        /* It's possible we get here right after VmDeath event, be careful */
-        if ( !gdata->vm_is_dead ) {
-            ClassInfo  *cp;
-            MethodInfo *mp;
-
-            if ( cnum >= gdata->ccount ) {
-                fatal_error("ERROR: Class number out of range\n");
-            }
-            cp = gdata->classes + cnum;
-            if ( mnum >= cp->mcount ) {
-                fatal_error("ERROR: Method number out of range\n");
-            }
-            mp = cp->methods + mnum;
-            if ( interested((char*)cp->name, (char*)mp->name,
-                            gdata->include, gdata->exclude)  ) {
-                mp->returns++;
-            }
-        }
-    } exit_critical_section(gdata->jvmti);
-}
-
-/* Callback for JVMTI_EVENT_VM_START */
-static void JNICALL
-cbVMStart(jvmtiEnv *jvmti, JNIEnv *env)
-{
-    enter_critical_section(jvmti); {
-        jclass   klass;
-        jfieldID field;
-        int      rc;
-
-        /* Java Native Methods for class */
-        static JNINativeMethod registry[2] = {
-            {STRING(MTRACE_native_entry), "(Ljava/lang/Object;II)V",
-                (void*)&MTRACE_native_entry},
-            {STRING(MTRACE_native_exit),  "(Ljava/lang/Object;II)V",
-                (void*)&MTRACE_native_exit}
-        };
-
-        /* The VM has started. */
-        stdout_message("VMStart\n");
-
-        /* Register Natives for class whose methods we use */
-        klass = (*env)->FindClass(env, STRING(MTRACE_class));
-        if ( klass == NULL ) {
-            fatal_error("ERROR: JNI: Cannot find %s with FindClass\n",
-                        STRING(MTRACE_class));
-        }
-        rc = (*env)->RegisterNatives(env, klass, registry, 2);
-        if ( rc != 0 ) {
-            fatal_error("ERROR: JNI: Cannot register native methods for %s\n",
-                        STRING(MTRACE_class));
-        }
-
-        /* Engage calls. */
-        field = (*env)->GetStaticFieldID(env, klass, STRING(MTRACE_engaged), "I");
-        if ( field == NULL ) {
-            fatal_error("ERROR: JNI: Cannot get field from %s\n",
-                        STRING(MTRACE_class));
-        }
-        (*env)->SetStaticIntField(env, klass, field, 1);
-
-        /* Indicate VM has started */
-        gdata->vm_is_started = JNI_TRUE;
-
-    } exit_critical_section(jvmti);
-}
-
-/* Callback for JVMTI_EVENT_VM_INIT */
-static void JNICALL
-cbVMInit(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    enter_critical_section(jvmti); {
-        char  tname[MAX_THREAD_NAME_LENGTH];
-        static jvmtiEvent events[] =
-                { JVMTI_EVENT_THREAD_START, JVMTI_EVENT_THREAD_END };
-        int        i;
-
-        /* The VM has started. */
-        get_thread_name(jvmti, thread, tname, sizeof(tname));
-        stdout_message("VMInit %s\n", tname);
-
-        /* The VM is now initialized, at this time we make our requests
-         *   for additional events.
-         */
-
-        for( i=0; i < (int)(sizeof(events)/sizeof(jvmtiEvent)); i++) {
-            jvmtiError error;
-
-            /* Setup event  notification modes */
-            error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                                  events[i], (jthread)NULL);
-            check_jvmti_error(jvmti, error, "Cannot set event notification");
-        }
-
-    } exit_critical_section(jvmti);
-}
-
-/* Callback for JVMTI_EVENT_VM_DEATH */
-static void JNICALL
-cbVMDeath(jvmtiEnv *jvmti, JNIEnv *env)
-{
-    enter_critical_section(jvmti); {
-        jclass   klass;
-        jfieldID field;
-
-        /* The VM has died. */
-        stdout_message("VMDeath\n");
-
-        /* Disengage calls in MTRACE_class. */
-        klass = (*env)->FindClass(env, STRING(MTRACE_class));
-        if ( klass == NULL ) {
-            fatal_error("ERROR: JNI: Cannot find %s with FindClass\n",
-                        STRING(MTRACE_class));
-        }
-        field = (*env)->GetStaticFieldID(env, klass, STRING(MTRACE_engaged), "I");
-        if ( field == NULL ) {
-            fatal_error("ERROR: JNI: Cannot get field from %s\n",
-                        STRING(MTRACE_class));
-        }
-        (*env)->SetStaticIntField(env, klass, field, 0);
-
-        /* The critical section here is important to hold back the VM death
-         *    until all other callbacks have completed.
-         */
-
-        /* Since this critical section could be holding up other threads
-         *   in other event callbacks, we need to indicate that the VM is
-         *   dead so that the other callbacks can short circuit their work.
-         *   We don't expect any further events after VmDeath but we do need
-         *   to be careful that existing threads might be in our own agent
-         *   callback code.
-         */
-        gdata->vm_is_dead = JNI_TRUE;
-
-        /* Dump out stats */
-        stdout_message("Begin Class Stats\n");
-        if ( gdata->ccount > 0 ) {
-            int cnum;
-
-            /* Sort table (in place) by number of method calls into class. */
-            /*  Note: Do not use this table after this qsort! */
-            qsort(gdata->classes, gdata->ccount, sizeof(ClassInfo),
-                        &class_compar);
-
-            /* Dump out gdata->max_count most called classes */
-            for ( cnum=gdata->ccount-1 ;
-                  cnum >= 0 && cnum >= gdata->ccount - gdata->max_count;
-                  cnum-- ) {
-                ClassInfo *cp;
-                int        mnum;
-
-                cp = gdata->classes + cnum;
-                stdout_message("Class %s %d calls\n", cp->name, cp->calls);
-                if ( cp->calls==0 ) continue;
-
-                /* Sort method table (in place) by number of method calls. */
-                /*  Note: Do not use this table after this qsort! */
-                qsort(cp->methods, cp->mcount, sizeof(MethodInfo),
-                            &method_compar);
-                for ( mnum=cp->mcount-1 ; mnum >= 0 ; mnum-- ) {
-                    MethodInfo *mp;
-
-                    mp = cp->methods + mnum;
-                    if ( mp->calls==0 ) continue;
-                    stdout_message("\tMethod %s %s %d calls %d returns\n",
-                        mp->name, mp->signature, mp->calls, mp->returns);
-                }
-            }
-        }
-        stdout_message("End Class Stats\n");
-        (void)fflush(stdout);
-
-    } exit_critical_section(jvmti);
-
-}
-
-/* Callback for JVMTI_EVENT_THREAD_START */
-static void JNICALL
-cbThreadStart(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    enter_critical_section(jvmti); {
-        /* It's possible we get here right after VmDeath event, be careful */
-        if ( !gdata->vm_is_dead ) {
-            char  tname[MAX_THREAD_NAME_LENGTH];
-
-            get_thread_name(jvmti, thread, tname, sizeof(tname));
-            stdout_message("ThreadStart %s\n", tname);
-        }
-    } exit_critical_section(jvmti);
-}
-
-/* Callback for JVMTI_EVENT_THREAD_END */
-static void JNICALL
-cbThreadEnd(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    enter_critical_section(jvmti); {
-        /* It's possible we get here right after VmDeath event, be careful */
-        if ( !gdata->vm_is_dead ) {
-            char  tname[MAX_THREAD_NAME_LENGTH];
-
-            get_thread_name(jvmti, thread, tname, sizeof(tname));
-            stdout_message("ThreadEnd %s\n", tname);
-        }
-    } exit_critical_section(jvmti);
-}
-
-/* Callback for JVMTI_EVENT_CLASS_FILE_LOAD_HOOK */
-static void JNICALL
-cbClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv* env,
-                jclass class_being_redefined, jobject loader,
-                const char* name, jobject protection_domain,
-                jint class_data_len, const unsigned char* class_data,
-                jint* new_class_data_len, unsigned char** new_class_data)
-{
-    enter_critical_section(jvmti); {
-        /* It's possible we get here right after VmDeath event, be careful */
-        if ( !gdata->vm_is_dead ) {
-
-            const char *classname;
-
-            /* Name could be NULL */
-            if ( name == NULL ) {
-                classname = java_crw_demo_classname(class_data, class_data_len,
-                        NULL);
-                if ( classname == NULL ) {
-                    fatal_error("ERROR: No classname inside classfile\n");
-                }
-            } else {
-                classname = strdup(name);
-                if ( classname == NULL ) {
-                    fatal_error("ERROR: Out of malloc memory\n");
-                }
-            }
-
-            *new_class_data_len = 0;
-            *new_class_data     = NULL;
-
-            /* The tracker class itself? */
-            if ( interested((char*)classname, "", gdata->include, gdata->exclude)
-                  &&  strcmp(classname, STRING(MTRACE_class)) != 0 ) {
-                jint           cnum;
-                int            system_class;
-                unsigned char *new_image;
-                long           new_length;
-                ClassInfo     *cp;
-
-                /* Get unique number for every class file image loaded */
-                cnum = gdata->ccount++;
-
-                /* Save away class information */
-                if ( gdata->classes == NULL ) {
-                    gdata->classes = (ClassInfo*)malloc(
-                                gdata->ccount*sizeof(ClassInfo));
-                } else {
-                    gdata->classes = (ClassInfo*)
-                                realloc((void*)gdata->classes,
-                                gdata->ccount*sizeof(ClassInfo));
-                }
-                if ( gdata->classes == NULL ) {
-                    fatal_error("ERROR: Out of malloc memory\n");
-                }
-                cp           = gdata->classes + cnum;
-                cp->name     = (const char *)strdup(classname);
-                if ( cp->name == NULL ) {
-                    fatal_error("ERROR: Out of malloc memory\n");
-                }
-                cp->calls    = 0;
-                cp->mcount   = 0;
-                cp->methods  = NULL;
-
-                /* Is it a system class? If the class load is before VmStart
-                 *   then we will consider it a system class that should
-                 *   be treated carefully. (See java_crw_demo)
-                 */
-                system_class = 0;
-                if ( !gdata->vm_is_started ) {
-                    system_class = 1;
-                }
-
-                new_image = NULL;
-                new_length = 0;
-
-                /* Call the class file reader/write demo code */
-                java_crw_demo(cnum,
-                    classname,
-                    class_data,
-                    class_data_len,
-                    system_class,
-                    STRING(MTRACE_class), "L" STRING(MTRACE_class) ";",
-                    STRING(MTRACE_entry), "(II)V",
-                    STRING(MTRACE_exit), "(II)V",
-                    NULL, NULL,
-                    NULL, NULL,
-                    &new_image,
-                    &new_length,
-                    NULL,
-                    &mnum_callbacks);
-
-                /* If we got back a new class image, return it back as "the"
-                 *   new class image. This must be JVMTI Allocate space.
-                 */
-                if ( new_length > 0 ) {
-                    unsigned char *jvmti_space;
-
-                    jvmti_space = (unsigned char *)allocate(jvmti, (jint)new_length);
-                    (void)memcpy((void*)jvmti_space, (void*)new_image, (int)new_length);
-                    *new_class_data_len = (jint)new_length;
-                    *new_class_data     = jvmti_space; /* VM will deallocate */
-                }
-
-                /* Always free up the space we get from java_crw_demo() */
-                if ( new_image != NULL ) {
-                    (void)free((void*)new_image); /* Free malloc() space with free() */
-                }
-            }
-            (void)free((void*)classname);
-        }
-    } exit_critical_section(jvmti);
-}
-
-/* Parse the options for this mtrace agent */
-static void
-parse_agent_options(char *options)
-{
-    char token[MAX_TOKEN_LENGTH];
-    char *next;
-
-    gdata->max_count = 10; /* Default max=n */
-
-    /* Parse options and set flags in gdata */
-    if ( options==NULL ) {
-        return;
-    }
-
-    /* Get the first token from the options string. */
-    next = get_token(options, ",=", token, sizeof(token));
-
-    /* While not at the end of the options string, process this option. */
-    while ( next != NULL ) {
-        if ( strcmp(token,"help")==0 ) {
-            stdout_message("The mtrace JVMTI demo agent\n");
-            stdout_message("\n");
-            stdout_message(" java -agent:mtrace[=options] ...\n");
-            stdout_message("\n");
-            stdout_message("The options are comma separated:\n");
-            stdout_message("\t help\t\t\t Print help information\n");
-            stdout_message("\t max=n\t\t Only list top n classes\n");
-            stdout_message("\t include=item\t\t Only these classes/methods\n");
-            stdout_message("\t exclude=item\t\t Exclude these classes/methods\n");
-            stdout_message("\n");
-            stdout_message("item\t Qualified class and/or method names\n");
-            stdout_message("\t\t e.g. (*.<init>;Foobar.method;sun.*)\n");
-            stdout_message("\n");
-            exit(0);
-        } else if ( strcmp(token,"max")==0 ) {
-            char number[MAX_TOKEN_LENGTH];
-
-            /* Get the numeric option */
-            next = get_token(next, ",=", number, (int)sizeof(number));
-            /* Check for token scan error */
-            if ( next==NULL ) {
-                fatal_error("ERROR: max=n option error\n");
-            }
-            /* Save numeric value */
-            gdata->max_count = atoi(number);
-        } else if ( strcmp(token,"include")==0 ) {
-            int   used;
-            int   maxlen;
-
-            maxlen = MAX_METHOD_NAME_LENGTH;
-            if ( gdata->include == NULL ) {
-                gdata->include = (char*)calloc(maxlen+1, 1);
-                used = 0;
-            } else {
-                used  = (int)strlen(gdata->include);
-                gdata->include[used++] = ',';
-                gdata->include[used] = 0;
-                gdata->include = (char*)
-                             realloc((void*)gdata->include, used+maxlen+1);
-            }
-            if ( gdata->include == NULL ) {
-                fatal_error("ERROR: Out of malloc memory\n");
-            }
-            /* Add this item to the list */
-            next = get_token(next, ",=", gdata->include+used, maxlen);
-            /* Check for token scan error */
-            if ( next==NULL ) {
-                fatal_error("ERROR: include option error\n");
-            }
-        } else if ( strcmp(token,"exclude")==0 ) {
-            int   used;
-            int   maxlen;
-
-            maxlen = MAX_METHOD_NAME_LENGTH;
-            if ( gdata->exclude == NULL ) {
-                gdata->exclude = (char*)calloc(maxlen+1, 1);
-                used = 0;
-            } else {
-                used  = (int)strlen(gdata->exclude);
-                gdata->exclude[used++] = ',';
-                gdata->exclude[used] = 0;
-                gdata->exclude = (char*)
-                             realloc((void*)gdata->exclude, used+maxlen+1);
-            }
-            if ( gdata->exclude == NULL ) {
-                fatal_error("ERROR: Out of malloc memory\n");
-            }
-            /* Add this item to the list */
-            next = get_token(next, ",=", gdata->exclude+used, maxlen);
-            /* Check for token scan error */
-            if ( next==NULL ) {
-                fatal_error("ERROR: exclude option error\n");
-            }
-        } else if ( token[0]!=0 ) {
-            /* We got a non-empty token and we don't know what it is. */
-            fatal_error("ERROR: Unknown option: %s\n", token);
-        }
-        /* Get the next token (returns NULL if there are no more) */
-        next = get_token(next, ",=", token, sizeof(token));
-    }
-}
-
-/* Agent_OnLoad: This is called immediately after the shared library is
- *   loaded. This is the first code executed.
- */
-JNIEXPORT jint JNICALL
-DEF_Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
-{
-    static GlobalAgentData data;
-    jvmtiEnv              *jvmti;
-    jvmtiError             error;
-    jint                   res;
-    jvmtiCapabilities      capabilities;
-    jvmtiEventCallbacks    callbacks;
-
-    /* Setup initial global agent data area
-     *   Use of static/extern data should be handled carefully here.
-     *   We need to make sure that we are able to cleanup after ourselves
-     *     so anything allocated in this library needs to be freed in
-     *     the Agent_OnUnload() function.
-     */
-    (void)memset((void*)&data, 0, sizeof(data));
-    gdata = &data;
-
-    /* First thing we need to do is get the jvmtiEnv* or JVMTI environment */
-    res = (*vm)->GetEnv(vm, (void **)&jvmti, JVMTI_VERSION_1);
-    if (res != JNI_OK) {
-        /* This means that the VM was unable to obtain this version of the
-         *   JVMTI interface, this is a fatal error.
-         */
-        fatal_error("ERROR: Unable to access JVMTI Version 1 (0x%x),"
-                " is your JDK a 5.0 or newer version?"
-                " JNIEnv's GetEnv() returned %d\n",
-               JVMTI_VERSION_1, res);
-    }
-
-    /* Here we save the jvmtiEnv* for Agent_OnUnload(). */
-    gdata->jvmti = jvmti;
-
-    /* Parse any options supplied on java command line */
-    parse_agent_options(options);
-
-    /* Immediately after getting the jvmtiEnv* we need to ask for the
-     *   capabilities this agent will need. In this case we need to make
-     *   sure that we can get all class load hooks.
-     */
-    (void)memset(&capabilities,0, sizeof(capabilities));
-    capabilities.can_generate_all_class_hook_events  = 1;
-    error = (*jvmti)->AddCapabilities(jvmti, &capabilities);
-    check_jvmti_error(jvmti, error, "Unable to get necessary JVMTI capabilities.");
-
-    /* Next we need to provide the pointers to the callback functions to
-     *   to this jvmtiEnv*
-     */
-    (void)memset(&callbacks,0, sizeof(callbacks));
-    /* JVMTI_EVENT_VM_START */
-    callbacks.VMStart           = &cbVMStart;
-    /* JVMTI_EVENT_VM_INIT */
-    callbacks.VMInit            = &cbVMInit;
-    /* JVMTI_EVENT_VM_DEATH */
-    callbacks.VMDeath           = &cbVMDeath;
-    /* JVMTI_EVENT_CLASS_FILE_LOAD_HOOK */
-    callbacks.ClassFileLoadHook = &cbClassFileLoadHook;
-    /* JVMTI_EVENT_THREAD_START */
-    callbacks.ThreadStart       = &cbThreadStart;
-    /* JVMTI_EVENT_THREAD_END */
-    callbacks.ThreadEnd         = &cbThreadEnd;
-    error = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, (jint)sizeof(callbacks));
-    check_jvmti_error(jvmti, error, "Cannot set jvmti callbacks");
-
-    /* At first the only initial events we are interested in are VM
-     *   initialization, VM death, and Class File Loads.
-     *   Once the VM is initialized we will request more events.
-     */
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_VM_START, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_VM_INIT, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_VM_DEATH, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-    error = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                          JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, (jthread)NULL);
-    check_jvmti_error(jvmti, error, "Cannot set event notification");
-
-    /* Here we create a raw monitor for our use in this agent to
-     *   protect critical sections of code.
-     */
-    error = (*jvmti)->CreateRawMonitor(jvmti, "agent data", &(gdata->lock));
-    check_jvmti_error(jvmti, error, "Cannot create raw monitor");
-
-    /* Add demo jar file to boot classpath */
-    add_demo_jar_to_bootclasspath(jvmti, "mtrace");
-
-    /* We return JNI_OK to signify success */
-    return JNI_OK;
-}
-
-/* Agent_OnUnload: This is called immediately before the shared library is
- *   unloaded. This is the last code executed.
- */
-JNIEXPORT void JNICALL
-DEF_Agent_OnUnload(JavaVM *vm)
-{
-    /* Make sure all malloc/calloc/strdup space is freed */
-    if ( gdata->include != NULL ) {
-        (void)free((void*)gdata->include);
-        gdata->include = NULL;
-    }
-    if ( gdata->exclude != NULL ) {
-        (void)free((void*)gdata->exclude);
-        gdata->exclude = NULL;
-    }
-    if ( gdata->classes != NULL ) {
-        int cnum;
-
-        for ( cnum = 0 ; cnum < gdata->ccount ; cnum++ ) {
-            ClassInfo *cp;
-
-            cp = gdata->classes + cnum;
-            (void)free((void*)cp->name);
-            if ( cp->mcount > 0 ) {
-                int mnum;
-
-                for ( mnum = 0 ; mnum < cp->mcount ; mnum++ ) {
-                    MethodInfo *mp;
-
-                    mp = cp->methods + mnum;
-                    (void)free((void*)mp->name);
-                    (void)free((void*)mp->signature);
-                }
-                (void)free((void*)cp->methods);
-            }
-        }
-        (void)free((void*)gdata->classes);
-        gdata->classes = NULL;
-    }
-}
--- a/jdk/src/demo/share/jvmti/mtrace/mtrace.h	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/* Primary mtrace #include file, should be included by most if not
- *    all mtrace source files. Gives access to the global data structure
- *    and all global macros.
- */
-
-#ifndef MTRACE_H
-#define MTRACE_H
-
-/* Standard C functions used throughout. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stddef.h>
-#include <stdarg.h>
-
-/* General JVM/Java functions, types and macros. */
-
-#include <sys/types.h>
-#include "jni.h"
-#include "jvmti.h"
-
-/* Utility functions */
-
-#include "agent_util.h"
-
-#endif
--- a/jdk/src/demo/share/jvmti/mtrace/sample.makefile.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-#
-# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-########################################################################
-#
-# Sample GNU Makefile for building JVMTI Demo mtrace
-#
-#  Example uses:    
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
-#       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
-#       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
-#
-########################################################################
-
-# Source lists
-LIBNAME=mtrace
-SOURCES=mtrace.c ../agent_util/agent_util.c
-JAVA_SOURCES=Mtrace.java
-
-# Name of jar file that needs to be created
-JARFILE=mtrace.jar
-
-# Solaris Studio C Compiler Version 12.4
-ifeq ($(OSNAME), solaris)
-    # Sun Solaris Compiler options needed
-    COMMON_FLAGS=-mt -KPIC
-    # Options that help find errors
-    COMMON_FLAGS+= -Xa -v -xc99=%none
-    # Check LIBARCH for any special compiler options
-    LIBARCH=$(shell uname -p)
-    ifeq ($(LIBARCH), sparc)
-        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
-    endif
-    ifeq ($(LIBARCH), sparcv9)
-        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
-    endif
-    ifeq ($(OPT), true)
-        CFLAGS=-xO2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS)
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-z defs -ztext
-    # Libraries we are dependent on
-    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -G -o $@
-endif
-
-# Linux GNU C Compiler
-ifeq ($(OSNAME), linux)
-    # GNU Compiler options needed to build it
-    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
-    # Options that help find errors
-    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
-    ifeq ($(OPT), true)
-        CFLAGS=-O2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
-    # Libraries we are dependent on
-    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -shared -o $@
-endif
-
-# Windows Microsoft C/C++ Optimizing Compiler Version 12
-ifeq ($(OSNAME), win32)
-    CC=cl
-    # Compiler options needed to build it
-    COMMON_FLAGS=-Gy -DWIN32
-    # Options that help find errors
-    COMMON_FLAGS+=-W0 -WX
-    ifeq ($(OPT), true)
-        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
-    else
-        CFLAGS= -Od -Zi $(COMMON_FLAGS) 
-    endif
-    # Add in java_crw_demo obj file on windows (easier)
-    SOURCES+=../java_crw_demo/java_crw_demo.c
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.obj)
-    # Library name and options needed to build it
-    LIBRARY=$(LIBNAME).dll
-    LDFLAGS=
-    # Libraries we are dependent on
-    LIBRARIES=$(JDK)/
-    # Building a shared library
-    LINK_SHARED=link -dll -out:$@
-endif
-
-# Common -I options
-CFLAGS += -I.
-CFLAGS += -I../agent_util
-CFLAGS += -I../java_crw_demo
-CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
-
-# Default rule (build both native library and jar file)
-all: $(LIBRARY) $(JARFILE)
-
-# Build native library
-$(LIBRARY): $(OBJECTS)
-	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
-
-# Build jar file
-$(JARFILE): $(JAVA_SOURCES)
-	rm -f -r classes
-	mkdir -p classes
-	$(JDK)/bin/javac -d classes $(JAVA_SOURCES)
-	(cd classes; $(JDK)/bin/jar cf ../$@ *)
-
-# Cleanup the built bits
-clean:
-	rm -f -r classes
-	rm -f $(LIBRARY) $(JARFILE) $(OBJECTS)
-
-# Simple tester
-test: all
-	LD_LIBRARY_PATH=. $(JDK)/bin/java -agentlib:$(LIBNAME) -Xbootclasspath/a:./$(JARFILE) -version
-
-# Compilation rule only needed on Windows
-ifeq ($(OSNAME), win32)
-%.obj: %.c
-	$(COMPILE.c) $<
-endif
-
--- a/jdk/src/demo/share/jvmti/versionCheck/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-#
-# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-versionCheck
-
-This agent library just makes some simple calls and checks 
-the version of the interface being used to build the agent, 
-with that supplied by the VM at runtime.
-
-You can use this agent library as follows:
-
-    java -agentlib:versionCheck ...
-
-See ${JAVA_HOME}/demo/jvmti/index.html for help running and building agents.
-
--- a/jdk/src/demo/share/jvmti/versionCheck/sample.makefile.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-#
-# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-########################################################################
-#
-# Sample GNU Makefile for building JVMTI Demo versionCheck
-#
-#  Example uses:    
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
-#       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
-#       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
-#
-########################################################################
-
-# Source lists
-LIBNAME=versionCheck
-SOURCES=versionCheck.c ../agent_util/agent_util.c
-
-# Solaris Studio C Compiler Version 12.4
-ifeq ($(OSNAME), solaris)
-    # Sun Solaris Compiler options needed
-    COMMON_FLAGS=-mt -KPIC
-    # Options that help find errors
-    COMMON_FLAGS+= -Xa -v -xc99=%none
-    # Check LIBARCH for any special compiler options
-    LIBARCH=$(shell uname -p)
-    ifeq ($(LIBARCH), sparc)
-        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
-    endif
-    ifeq ($(LIBARCH), sparcv9)
-        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
-    endif
-    ifeq ($(OPT), true)
-        CFLAGS=-xO2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS)
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-z defs -ztext
-    # Libraries we are dependent on
-    LIBRARIES= -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -G -o $@
-endif
-
-# Linux GNU C Compiler
-ifeq ($(OSNAME), linux)
-    # GNU Compiler options needed to build it
-    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
-    # Options that help find errors
-    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
-    ifeq ($(OPT), true)
-        CFLAGS=-O2 $(COMMON_FLAGS) 
-    else
-        CFLAGS=-g $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
-    # Libraries we are dependent on
-    LIBRARIES=-lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.c) -shared -o $@
-endif
-
-# Windows Microsoft C/C++ Optimizing Compiler Version 12
-ifeq ($(OSNAME), win32)
-    CC=cl
-    # Compiler options needed to build it
-    COMMON_FLAGS=-Gy -DWIN32
-    # Options that help find errors
-    COMMON_FLAGS+=-W0 -WX
-    ifeq ($(OPT), true)
-        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
-    else
-        CFLAGS= -Od -Zi $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.c=%.obj)
-    # Library name and options needed to build it
-    LIBRARY=$(LIBNAME).dll
-    LDFLAGS=
-    # Libraries we are dependent on
-    LIBRARIES=
-    # Building a shared library
-    LINK_SHARED=link -dll -out:$@
-endif
-
-# Common -I options
-CFLAGS += -I.
-CFLAGS += -I../agent_util
-CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
-
-# Default rule
-all: $(LIBRARY)
-
-# Build native library
-$(LIBRARY): $(OBJECTS)
-	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
-
-# Cleanup the built bits
-clean:
-	rm -f $(LIBRARY) $(OBJECTS)
-
-# Simple tester
-test: all
-	LD_LIBRARY_PATH=`pwd` $(JDK)/bin/java -agentlib:$(LIBNAME) -version
-
-# Compilation rule only needed on Windows
-ifeq ($(OSNAME), win32)
-%.obj: %.c
-	$(COMPILE.c) $<
-endif
-
--- a/jdk/src/demo/share/jvmti/versionCheck/versionCheck.c	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "jni.h"
-#include "jvmti.h"
-
-#include "agent_util.h"
-
-/* Create major.minor.micro version string */
-static void
-version_check(jint cver, jint rver)
-{
-    jint cmajor, cminor, cmicro;
-    jint rmajor, rminor, rmicro;
-
-    cmajor = (cver & JVMTI_VERSION_MASK_MAJOR) >> JVMTI_VERSION_SHIFT_MAJOR;
-    cminor = (cver & JVMTI_VERSION_MASK_MINOR) >> JVMTI_VERSION_SHIFT_MINOR;
-    cmicro = (cver & JVMTI_VERSION_MASK_MICRO) >> JVMTI_VERSION_SHIFT_MICRO;
-    rmajor = (rver & JVMTI_VERSION_MASK_MAJOR) >> JVMTI_VERSION_SHIFT_MAJOR;
-    rminor = (rver & JVMTI_VERSION_MASK_MINOR) >> JVMTI_VERSION_SHIFT_MINOR;
-    rmicro = (rver & JVMTI_VERSION_MASK_MICRO) >> JVMTI_VERSION_SHIFT_MICRO;
-    stdout_message("Compile Time JVMTI Version: %d.%d.%d (0x%08x)\n",
-                        cmajor, cminor, cmicro, cver);
-    stdout_message("Run Time JVMTI Version: %d.%d.%d (0x%08x)\n",
-                        rmajor, rminor, rmicro, rver);
-    if ( (cmajor > rmajor) || (cmajor == rmajor && cminor > rminor) ) {
-        fatal_error(
-            "ERROR: Compile Time JVMTI and Run Time JVMTI are incompatible\n");
-    }
-}
-
-/* Callback for JVMTI_EVENT_VM_INIT */
-static void JNICALL
-vm_init(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    jvmtiError err;
-    jint       runtime_version;
-
-    /* The exact JVMTI version doesn't have to match, however this
-     *  code demonstrates how you can check that the JVMTI version seen
-     *  in the jvmti.h include file matches that being supplied at runtime
-     *  by the VM.
-     */
-    err = (*jvmti)->GetVersionNumber(jvmti, &runtime_version);
-    check_jvmti_error(jvmti, err, "get version number");
-    version_check(JVMTI_VERSION, runtime_version);
-}
-
-/* Agent_OnLoad() is called first, we prepare for a VM_INIT event here. */
-JNIEXPORT jint JNICALL
-DEF_Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
-{
-    jint                rc;
-    jvmtiError          err;
-    jvmtiEventCallbacks callbacks;
-    jvmtiEnv           *jvmti;
-
-    /* Get JVMTI environment */
-    rc = (*vm)->GetEnv(vm, (void **)&jvmti, JVMTI_VERSION);
-    if (rc != JNI_OK) {
-        fatal_error("ERROR: Unable to create jvmtiEnv, GetEnv failed, error=%d\n", rc);
-        return -1;
-    }
-
-    /* Set callbacks and enable event notifications */
-    memset(&callbacks, 0, sizeof(callbacks));
-    callbacks.VMInit                  = &vm_init;
-    err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, sizeof(callbacks));
-    check_jvmti_error(jvmti, err, "set event callbacks");
-    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
-                        JVMTI_EVENT_VM_INIT, NULL);
-    check_jvmti_error(jvmti, err, "set event notify");
-    return 0;
-}
-
-/* Agent_OnUnload() is called last */
-JNIEXPORT void JNICALL
-DEF_Agent_OnUnload(JavaVM *vm)
-{
-}
--- a/jdk/src/demo/share/jvmti/waiters/Agent.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,225 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stddef.h>
-
-#include "jni.h"
-#include "jvmti.h"
-
-#include "agent_util.h"
-
-#include "Monitor.hpp"
-#include "Thread.hpp"
-#include "Agent.hpp"
-
-/* Implementation of the Agent class */
-
-/* Given a jvmtiEnv* and jthread, find the Thread instance */
-Thread *
-Agent::get_thread(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    jvmtiError err;
-    Thread    *t;
-
-    /* This should always be in the Thread Local Storage */
-    t = NULL;
-    err = jvmti->GetThreadLocalStorage(thread, (void**)&t);
-    check_jvmti_error(jvmti, err, "get thread local storage");
-    if ( t == NULL ) {
-        /* This jthread has never been seen before? */
-        stdout_message("WARNING: Never before seen jthread?\n");
-        t = new Thread(jvmti, env, thread);
-        err = jvmti->SetThreadLocalStorage(thread, (const void*)t);
-        check_jvmti_error(jvmti, err, "set thread local storage");
-    }
-    return t;
-}
-
-/* Given a jvmtiEnv* and jobject, find the Monitor instance or create one */
-Monitor *
-Agent::get_monitor(jvmtiEnv *jvmti, JNIEnv *env, jobject object)
-{
-    jvmtiError err;
-    Monitor   *m;
-    jlong      tag;
-
-    m   = NULL;
-    tag = (jlong)0;
-    err = jvmti->GetTag(object, &tag);
-    check_jvmti_error(jvmti, err, "get tag");
-    /*LINTED*/
-    m = (Monitor *)(void *)(ptrdiff_t)tag;
-    if ( m == NULL ) {
-        m = new Monitor(jvmti, env, object);
-        /* Save monitor on list */
-        if (monitor_count == monitor_list_size) {
-            monitor_list_size += monitor_list_grow_size;
-            monitor_list = (Monitor**)realloc((void*)monitor_list,
-                (monitor_list_size)*(int)sizeof(Monitor*));
-        }
-        monitor_list[monitor_count] = m;
-        m->set_slot(monitor_count);
-        monitor_count++;
-        /*LINTED*/
-        tag = (jlong)(ptrdiff_t)(void *)m;
-        err = jvmti->SetTag(object, tag);
-        check_jvmti_error(jvmti, err, "set tag");
-    }
-    return m;
-}
-
-/* VM initialization and VM death calls to Agent */
-Agent::Agent(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    stdout_message("Agent created..\n");
-    stdout_message("VMInit...\n");
-    /* Start monitor list */
-    monitor_count = 0;
-    monitor_list_size = initial_monitor_list_size;
-    monitor_list = (Monitor**)
-        malloc(monitor_list_size*(int)sizeof(Monitor*));
-}
-
-Agent::~Agent()
-{
-    stdout_message("Agent reclaimed..\n");
-}
-
-void Agent::vm_death(jvmtiEnv *jvmti, JNIEnv *env)
-{
-    /* Delete all Monitors we allocated */
-    for ( int i = 0; i < (int)monitor_count; i++ ) {
-        delete monitor_list[i];
-    }
-    free(monitor_list);
-    /* Print death message */
-    stdout_message("VMDeath...\n");
-}
-
-/* Thread start event, setup a new thread */
-void Agent::thread_start(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    jvmtiError err;
-    Thread    *t;
-
-    /* Allocate a new Thread instance, put it in the Thread Local
-     *    Storage for easy access later.
-     */
-    t = new Thread(jvmti, env, thread);
-    err = jvmti->SetThreadLocalStorage(thread, (const void*)t);
-    check_jvmti_error(jvmti, err, "set thread local storage");
-}
-
-
-/* Thread end event, we need to reclaim the space */
-void Agent::thread_end(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    jvmtiError err;
-    Thread    *t;
-
-    /* Find the thread */
-    t = get_thread(jvmti, env, thread);
-
-    /* Clear out the Thread Local Storage */
-    err = jvmti->SetThreadLocalStorage(thread, (const void*)NULL);
-    check_jvmti_error(jvmti, err, "set thread local storage");
-
-    /* Reclaim the C++ object space */
-    delete t;
-}
-
-/* Monitor contention begins for a thread. */
-void Agent::monitor_contended_enter(jvmtiEnv* jvmti, JNIEnv *env,
-             jthread thread, jobject object)
-{
-    get_monitor(jvmti, env, object)->contended();
-    get_thread(jvmti, env, thread)->
-                monitor_contended_enter(jvmti, env, thread, object);
-}
-
-/* Monitor contention ends for a thread. */
-void Agent::monitor_contended_entered(jvmtiEnv* jvmti, JNIEnv *env,
-               jthread thread, jobject object)
-{
-    /* Do nothing for now */
-}
-
-/* Monitor wait begins for a thread. */
-void Agent::monitor_wait(jvmtiEnv* jvmti, JNIEnv *env,
-             jthread thread, jobject object, jlong timeout)
-{
-    get_monitor(jvmti, env, object)->waited();
-    get_thread(jvmti, env, thread)->
-                monitor_wait(jvmti, env, thread, object, timeout);
-}
-
-/* Monitor wait ends for a thread. */
-void Agent::monitor_waited(jvmtiEnv* jvmti, JNIEnv *env,
-               jthread thread, jobject object, jboolean timed_out)
-{
-    if ( timed_out ) {
-        get_monitor(jvmti, env, object)->timeout();
-    }
-    get_thread(jvmti, env, thread)->
-                monitor_waited(jvmti, env, thread, object, timed_out);
-}
-
-/* A tagged object has been freed */
-void Agent::object_free(jvmtiEnv* jvmti, jlong tag)
-{
-    /* We just cast the tag to a C++ pointer and delete it.
-     *   we know it can only be a Monitor *.
-     */
-    Monitor   *m;
-    /*LINTED*/
-    m = (Monitor *)(ptrdiff_t)tag;
-    if (monitor_count > 1) {
-        /* Move the last element to this Monitor's slot */
-        int slot = m->get_slot();
-        Monitor *last = monitor_list[monitor_count-1];
-        monitor_list[slot] = last;
-        last->set_slot(slot);
-    }
-    monitor_count--;
-    delete m;
-}
--- a/jdk/src/demo/share/jvmti/waiters/Agent.hpp	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/* C++ Agent class */
-
-class Agent {
-
-  private:
-    enum {
-      initial_monitor_list_size = 64,
-      monitor_list_grow_size = 16
-    };
-    Monitor     **monitor_list;
-    unsigned      monitor_list_size;
-    unsigned      monitor_count;
-    Thread *get_thread(jvmtiEnv *jvmti, JNIEnv *env, jthread thread);
-    Monitor *get_monitor(jvmtiEnv *jvmti, JNIEnv *env, jobject object);
-
-  public:
-    Agent(jvmtiEnv *jvmti, JNIEnv *env, jthread thread);
-    ~Agent();
-    void vm_death(jvmtiEnv *jvmti, JNIEnv *env);
-    void thread_start(jvmtiEnv *jvmti, JNIEnv *env, jthread thread);
-    void thread_end(jvmtiEnv *jvmti, JNIEnv *env, jthread thread);
-    void monitor_contended_enter(jvmtiEnv* jvmti, JNIEnv *env,
-                   jthread thread, jobject object);
-    void monitor_contended_entered(jvmtiEnv* jvmti, JNIEnv *env,
-                   jthread thread, jobject object);
-    void monitor_wait(jvmtiEnv* jvmti, JNIEnv *env,
-                   jthread thread, jobject object, jlong timeout);
-    void monitor_waited(jvmtiEnv* jvmti, JNIEnv *env,
-                   jthread thread, jobject object, jboolean timed_out);
-    void object_free(jvmtiEnv* jvmti, jlong tag);
-
-};
--- a/jdk/src/demo/share/jvmti/waiters/Monitor.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "jni.h"
-#include "jvmti.h"
-
-#include "agent_util.h"
-
-#include "Monitor.hpp"
-
-/* Implementation of the Monitor class */
-
-Monitor::Monitor(jvmtiEnv *jvmti, JNIEnv *env, jobject object)
-{
-    jvmtiError err;
-    jclass     klass;
-    char      *signature;
-
-    /* Clear counters */
-    contends  = 0;
-    waits     = 0;
-    timeouts  = 0;
-
-    /* Get the class name for this monitor object */
-    (void)strcpy(name, "Unknown");
-    klass = env->GetObjectClass(object);
-    if ( klass == NULL ) {
-        fatal_error("ERROR: Cannot find jclass from jobject\n");
-    }
-    err = jvmti->GetClassSignature(klass, &signature, NULL);
-    check_jvmti_error(jvmti, err, "get class signature");
-    if ( signature != NULL ) {
-        (void)strncpy(name, signature, (int)sizeof(name)-1);
-        deallocate(jvmti, signature);
-    }
-}
-
-Monitor::~Monitor()
-{
-    stdout_message("Monitor %s summary: %d contends, %d waits, %d timeouts\n",
-        name, contends, waits, timeouts);
-}
-
-int Monitor::get_slot()
-{
-    return slot;
-}
-
-void Monitor::set_slot(int aslot)
-{
-    slot = aslot;
-}
-
-void Monitor::contended()
-{
-    contends++;
-}
-
-void Monitor::waited()
-{
-    waits++;
-}
-
-void Monitor::timeout()
-{
-    timeouts++;
-}
--- a/jdk/src/demo/share/jvmti/waiters/Monitor.hpp	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-#ifdef STATIC_BUILD
-#define Monitor WaiterMonitor
-#endif
-
-
-/* C++ Monitor class */
-
-class Monitor {
-
-  private:
-    char     name[64];
-    int      slot;
-    unsigned contends;
-    unsigned waits;
-    unsigned timeouts;
-
-  public:
-    Monitor(jvmtiEnv *jvmti, JNIEnv *env, jobject object);
-    ~Monitor();
-    int get_slot();
-    void set_slot(int i);
-    void contended();
-    void waited();
-    void timeout();
-
-};
--- a/jdk/src/demo/share/jvmti/waiters/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-#
-# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-waiters
-
-This agent library can be used to track threads that wait on monitors.
-This agent is written in C++.
-
-You can use this agent library as follows:
-
-    java -agentlib:waiters ...
-
-To get help on the available options try:
-
-    java -agentlib:waiters=help
-
-See ${JAVA_HOME}/demo/jvmti/index.html for help running and building agents.
-
--- a/jdk/src/demo/share/jvmti/waiters/Thread.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-#ifdef STATIC_BUILD
-#define Thread WaiterThread
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "jni.h"
-#include "jvmti.h"
-
-#include "agent_util.h"
-
-#include "Thread.hpp"
-
-/* Implementation of the Thread class */
-
-Thread::Thread(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-{
-    jvmtiError      err;
-    jvmtiThreadInfo info;
-
-    /* Get and save the name of the thread */
-    info.name = NULL;
-    (void)strcpy(name, "Unknown");
-    err = jvmti->GetThreadInfo(thread, &info);
-    check_jvmti_error(jvmti, err, "get thread info");
-    if ( info.name != NULL ) {
-        (void)strncpy(name, info.name, (int)sizeof(name)-1);
-        name[(int)sizeof(name)-1] = 0;
-        deallocate(jvmti, info.name);
-    }
-
-    /* Clear thread counters */
-    contends = 0;
-    waits    = 0;
-    timeouts = 0;
-}
-
-Thread::~Thread()
-{
-    /* Send out summary message */
-    stdout_message("Thread %s summary: %d waits plus %d contended\n",
-        name, waits, contends);
-}
-
-void Thread::monitor_contended_enter(jvmtiEnv* jvmti, JNIEnv *env,
-             jthread thread, jobject object)
-{
-    contends++;
-}
-
-void Thread::monitor_wait(jvmtiEnv* jvmti, JNIEnv *env,
-               jthread thread, jobject object, jlong timeout)
-{
-    waits++;
-}
-
-void Thread::monitor_waited(jvmtiEnv* jvmti, JNIEnv *env,
-               jthread thread, jobject object, jboolean timed_out)
-{
-    if ( timed_out ) {
-        timeouts++;
-    }
-}
--- a/jdk/src/demo/share/jvmti/waiters/Thread.hpp	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/* C++ Thread class */
-
-class Thread {
-
-  private:
-    char     name[64];
-    unsigned contends;
-    unsigned waits;
-    unsigned timeouts;
-
-  public:
-    Thread(jvmtiEnv *jvmti, JNIEnv *env, jthread thread);
-    ~Thread();
-    void monitor_contended_enter(jvmtiEnv* jvmti, JNIEnv *env,
-                   jthread thread, jobject object);
-    void monitor_wait(jvmtiEnv* jvmti, JNIEnv *env,
-                   jthread thread, jobject object, jlong timeout);
-    void monitor_waited(jvmtiEnv* jvmti, JNIEnv *env,
-                   jthread thread, jobject object, jboolean timed_out);
-
-};
--- a/jdk/src/demo/share/jvmti/waiters/sample.makefile.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-#
-# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-########################################################################
-#
-# Sample GNU Makefile for building JVMTI Demo waiters
-#
-#  Example uses:    
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
-#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
-#       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
-#       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
-#
-########################################################################
-
-# Source lists
-LIBNAME=waiters
-SOURCES=waiters.cpp Agent.cpp Thread.cpp Monitor.cpp ../agent_util/agent_util.c
-
-# Solaris Sun C Compiler Version 5.5
-ifeq ($(OSNAME), solaris)
-    # Tell gnumake which compilers to use
-    CC=cc
-    CXX=CC
-    # Sun Solaris Compiler options needed
-    COMMON_FLAGS=-mt -KPIC
-    # Check LIBARCH for any special compiler options
-    LIBARCH=$(shell uname -p)
-    ifeq ($(LIBARCH), sparc)
-        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
-    endif
-    ifeq ($(LIBARCH), sparcv9)
-        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
-    endif
-    ifeq ($(OPT), true)
-        CXXFLAGS=-xO2 $(COMMON_FLAGS) 
-    else
-        CXXFLAGS=-g $(COMMON_FLAGS)
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.cpp=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-z defs -ztext
-    # Libraries we are dependent on
-    LIBRARIES= -lc
-    # Building a shared library
-    LINK_SHARED=$(LINK.cc) -G -o $@
-endif
-
-# Linux GNU C Compiler
-ifeq ($(OSNAME), linux)
-    # GNU Compiler options needed to build it
-    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
-    # Options that help find errors
-    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
-    ifeq ($(OPT), true)
-        CXXFLAGS=-O2 $(COMMON_FLAGS) 
-    else
-        CXXFLAGS=-g $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.cpp=%.o)
-    # Library name and options needed to build it
-    LIBRARY=lib$(LIBNAME).so
-    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
-    # Libraries we are dependent on
-    LIBRARIES=
-    # Building a shared library
-    LINK_SHARED=$(LINK.cc) -shared -o $@
-endif
-
-# Windows Microsoft C/C++ Optimizing Compiler Version 12
-ifeq ($(OSNAME), win32)
-    CC=cl
-    # Compiler options needed to build it
-    COMMON_FLAGS=-Gy -DWIN32
-    # Options that help find errors
-    COMMON_FLAGS+=-W0 -WX
-    ifeq ($(OPT), true)
-        CXXFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
-    else
-        CXXFLAGS= -Od -Zi $(COMMON_FLAGS) 
-    endif
-    # Object files needed to create library
-    OBJECTS=$(SOURCES:%.cpp=%.obj)
-    # Library name and options needed to build it
-    LIBRARY=$(LIBNAME).dll
-    LDFLAGS=
-    # Libraries we are dependent on
-    LIBRARIES=
-    # Building a shared library
-    LINK_SHARED=link -dll -out:$@
-endif
-
-# Common -I options
-CXXFLAGS += -I.
-CXXFLAGS += -I../agent_util
-CXXFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
-
-# Default rule
-all: $(LIBRARY)
-
-# Build native library
-$(LIBRARY): $(OBJECTS)
-	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
-
-# Cleanup the built bits
-clean:
-	rm -f $(LIBRARY) $(OBJECTS)
-
-# Simple tester
-test: all
-	LD_LIBRARY_PATH=`pwd` $(JDK)/bin/java -agentlib:$(LIBNAME) -version
-
-# Compilation rule only needed on Windows
-ifeq ($(OSNAME), win32)
-%.obj: %.cpp
-	$(COMPILE.cc) $<
-endif
-
--- a/jdk/src/demo/share/jvmti/waiters/waiters.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,295 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/* Example of using JVMTI events:
- *      JVMTI_EVENT_VM_INIT
- *      JVMTI_EVENT_VM_DEATH
- *      JVMTI_EVENT_THREAD_START
- *      JVMTI_EVENT_THREAD_END
- *      JVMTI_EVENT_MONITOR_CONTENDED_ENTER
- *      JVMTI_EVENT_MONITOR_WAIT
- *      JVMTI_EVENT_MONITOR_WAITED
- *      JVMTI_EVENT_OBJECT_FREE
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "jni.h"
-#include "jvmti.h"
-
-#include "agent_util.h"
-
-#include "Monitor.hpp"
-#include "Thread.hpp"
-#include "Agent.hpp"
-
-static jrawMonitorID vm_death_lock;
-static jboolean      vm_death_active;
-
-/* Given a jvmtiEnv*, return the C++ Agent class instance */
-static Agent *
-get_agent(jvmtiEnv *jvmti)
-{
-    jvmtiError err;
-    Agent     *agent;
-
-    agent = NULL;
-    err = jvmti->GetEnvironmentLocalStorage((void**)&agent);
-    check_jvmti_error(jvmti, err, "get env local storage");
-    if ( agent == NULL ) {
-        /* This should never happen, but we should check */
-        fatal_error("ERROR: GetEnvironmentLocalStorage() returned NULL");
-    }
-    return agent;
-}
-
-/* Enter raw monitor */
-static void
-menter(jvmtiEnv *jvmti, jrawMonitorID rmon)
-{
-    jvmtiError err;
-
-    err = jvmti->RawMonitorEnter(rmon);
-    check_jvmti_error(jvmti, err, "raw monitor enter");
-}
-
-/* Exit raw monitor */
-static void
-mexit(jvmtiEnv *jvmti, jrawMonitorID rmon)
-{
-    jvmtiError err;
-
-    err = jvmti->RawMonitorExit(rmon);
-    check_jvmti_error(jvmti, err, "raw monitor exit");
-}
-
-
-/* All callbacks need to be extern "C" */
-extern "C" {
-    static void JNICALL
-    vm_init(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-    {
-        jvmtiError err;
-        Agent     *agent;
-
-        /* Create raw monitor to protect against threads running after death */
-        err = jvmti->CreateRawMonitor("Waiters vm_death lock", &vm_death_lock);
-        check_jvmti_error(jvmti, err, "create raw monitor");
-        vm_death_active = JNI_FALSE;
-
-        /* Create an Agent instance, set JVMTI Local Storage */
-        agent = new Agent(jvmti, env, thread);
-        err = jvmti->SetEnvironmentLocalStorage((const void*)agent);
-        check_jvmti_error(jvmti, err, "set env local storage");
-
-        /* Enable all other events we want */
-        err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
-                        JVMTI_EVENT_VM_DEATH, NULL);
-        check_jvmti_error(jvmti, err, "set event notify");
-        err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
-                        JVMTI_EVENT_THREAD_START, NULL);
-        check_jvmti_error(jvmti, err, "set event notify");
-        err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
-                        JVMTI_EVENT_THREAD_END, NULL);
-        check_jvmti_error(jvmti, err, "set event notify");
-        err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
-                        JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL);
-        check_jvmti_error(jvmti, err, "set event notify");
-        err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
-                        JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL);
-        check_jvmti_error(jvmti, err, "set event notify");
-        err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
-                        JVMTI_EVENT_MONITOR_WAIT, NULL);
-        check_jvmti_error(jvmti, err, "set event notify");
-        err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
-                        JVMTI_EVENT_MONITOR_WAITED, NULL);
-        check_jvmti_error(jvmti, err, "set event notify");
-        err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
-                        JVMTI_EVENT_OBJECT_FREE, NULL);
-        check_jvmti_error(jvmti, err, "set event notify");
-    }
-    static void JNICALL
-    vm_death(jvmtiEnv *jvmti, JNIEnv *env)
-    {
-        jvmtiError err;
-        Agent     *agent;
-
-        /* Block all callbacks */
-        menter(jvmti, vm_death_lock); {
-            /* Set flag for other callbacks */
-            vm_death_active = JNI_TRUE;
-
-            /* Inform Agent instance of VM_DEATH */
-            agent = get_agent(jvmti);
-            agent->vm_death(jvmti, env);
-
-            /* Reclaim space of Agent */
-            err = jvmti->SetEnvironmentLocalStorage((const void*)NULL);
-            check_jvmti_error(jvmti, err, "set env local storage");
-            delete agent;
-        } mexit(jvmti, vm_death_lock);
-
-    }
-    static void JNICALL
-    thread_start(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-    {
-        menter(jvmti, vm_death_lock); {
-            if ( !vm_death_active ) {
-                get_agent(jvmti)->thread_start(jvmti, env, thread);
-            }
-        } mexit(jvmti, vm_death_lock);
-    }
-    static void JNICALL
-    thread_end(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
-    {
-        menter(jvmti, vm_death_lock); {
-            if ( !vm_death_active ) {
-                get_agent(jvmti)->thread_end(jvmti, env, thread);
-            }
-        } mexit(jvmti, vm_death_lock);
-    }
-    static void JNICALL
-    monitor_contended_enter(jvmtiEnv* jvmti, JNIEnv *env,
-                 jthread thread, jobject object)
-    {
-        menter(jvmti, vm_death_lock); {
-            if ( !vm_death_active ) {
-                get_agent(jvmti)->monitor_contended_enter(jvmti, env,
-                                                          thread, object);
-            }
-        } mexit(jvmti, vm_death_lock);
-    }
-    static void JNICALL
-    monitor_contended_entered(jvmtiEnv* jvmti, JNIEnv *env,
-                   jthread thread, jobject object)
-    {
-        menter(jvmti, vm_death_lock); {
-            if ( !vm_death_active ) {
-                get_agent(jvmti)->monitor_contended_entered(jvmti, env,
-                                                            thread, object);
-            }
-        } mexit(jvmti, vm_death_lock);
-    }
-    static void JNICALL
-    monitor_wait(jvmtiEnv* jvmti, JNIEnv *env,
-                 jthread thread, jobject object, jlong timeout)
-    {
-        menter(jvmti, vm_death_lock); {
-            if ( !vm_death_active ) {
-                get_agent(jvmti)->monitor_wait(jvmti, env, thread,
-                                               object, timeout);
-            }
-        } mexit(jvmti, vm_death_lock);
-    }
-    static void JNICALL
-    monitor_waited(jvmtiEnv* jvmti, JNIEnv *env,
-                   jthread thread, jobject object, jboolean timed_out)
-    {
-        menter(jvmti, vm_death_lock); {
-            if ( !vm_death_active ) {
-                get_agent(jvmti)->monitor_waited(jvmti, env, thread,
-                                                 object, timed_out);
-            }
-        } mexit(jvmti, vm_death_lock);
-    }
-    static void JNICALL
-    object_free(jvmtiEnv* jvmti, jlong tag)
-    {
-        menter(jvmti, vm_death_lock); {
-            if ( !vm_death_active ) {
-                get_agent(jvmti)->object_free(jvmti, tag);
-            }
-        } mexit(jvmti, vm_death_lock);
-    }
-
-    /* Agent_OnLoad() is called first, we prepare for a VM_INIT event here. */
-    JNIEXPORT jint JNICALL
-    DEF_Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
-    {
-        jvmtiEnv           *jvmti;
-        jint                rc;
-        jvmtiError          err;
-        jvmtiCapabilities   capabilities;
-        jvmtiEventCallbacks callbacks;
-
-        /* Get JVMTI environment */
-        rc = vm->GetEnv((void **)&jvmti, JVMTI_VERSION);
-        if (rc != JNI_OK) {
-            fatal_error("ERROR: Unable to create jvmtiEnv, GetEnv failed, error=%d\n", rc);
-            return -1;
-        }
-
-        /* Get/Add JVMTI capabilities */
-        (void)memset(&capabilities, 0, sizeof(capabilities));
-        capabilities.can_generate_monitor_events        = 1;
-        capabilities.can_get_monitor_info               = 1;
-        capabilities.can_tag_objects                    = 1;
-        capabilities.can_generate_object_free_events    = 1;
-        err = jvmti->AddCapabilities(&capabilities);
-        check_jvmti_error(jvmti, err, "add capabilities");
-
-        /* Set all callbacks and enable VM_INIT event notification */
-        memset(&callbacks, 0, sizeof(callbacks));
-        callbacks.VMInit                  = &vm_init;
-        callbacks.VMDeath                 = &vm_death;
-        callbacks.ThreadStart             = &thread_start;
-        callbacks.ThreadEnd               = &thread_end;
-        callbacks.MonitorContendedEnter   = &monitor_contended_enter;
-        callbacks.MonitorContendedEntered = &monitor_contended_entered;
-        callbacks.MonitorWait             = &monitor_wait;
-        callbacks.MonitorWaited           = &monitor_waited;
-        callbacks.ObjectFree              = &object_free;
-        err = jvmti->SetEventCallbacks(&callbacks, (jint)sizeof(callbacks));
-        check_jvmti_error(jvmti, err, "set event callbacks");
-        err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
-                        JVMTI_EVENT_VM_INIT, NULL);
-        check_jvmti_error(jvmti, err, "set event notify");
-        return 0;
-    }
-
-    /* Agent_OnUnload() is called last */
-    JNIEXPORT void JNICALL
-    DEF_Agent_OnUnload(JavaVM *vm)
-    {
-    }
-
-} /* of extern "C" */
--- a/jdk/src/demo/share/management/FullThreadDump/Deadlock.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- */
-
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.BrokenBarrierException;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import java.io.IOException;
-
-/**
- * This Deadlock class demonstrates the capability of performing
- * deadlock detection programmatically within the application using
- * the java.lang.management API.
- *
- * See ThreadMonitor.java for the use of java.lang.management.ThreadMXBean
- * API.
- */
-public class Deadlock {
-    public static void main(String[] argv) {
-        new Deadlock();
-
-        // Now find deadlock
-        ThreadMonitor monitor = new ThreadMonitor();
-        boolean found = false;
-        while (!found) {
-            found = monitor.findDeadlock();
-            try {
-                Thread.sleep(500);
-            } catch (InterruptedException e) {
-                System.exit(1);
-            }
-        }
-
-        System.out.println("\nPress <Enter> to exit this Deadlock program.\n");
-        waitForEnterPressed();
-    }
-
-
-    private CyclicBarrier barrier = new CyclicBarrier(6);
-    public Deadlock() {
-        DeadlockThread[] dThreads = new DeadlockThread[6];
-
-        Monitor a = new Monitor("a");
-        Monitor b = new Monitor("b");
-        Monitor c = new Monitor("c");
-        dThreads[0] = new DeadlockThread("MThread-1", a, b);
-        dThreads[1] = new DeadlockThread("MThread-2", b, c);
-        dThreads[2] = new DeadlockThread("MThread-3", c, a);
-
-        Lock d = new ReentrantLock();
-        Lock e = new ReentrantLock();
-        Lock f = new ReentrantLock();
-
-        dThreads[3] = new DeadlockThread("SThread-4", d, e);
-        dThreads[4] = new DeadlockThread("SThread-5", e, f);
-        dThreads[5] = new DeadlockThread("SThread-6", f, d);
-
-        // make them daemon threads so that the test will exit
-        for (int i = 0; i < 6; i++) {
-            dThreads[i].setDaemon(true);
-            dThreads[i].start();
-        }
-    }
-
-    class DeadlockThread extends Thread {
-        private Lock lock1 = null;
-        private Lock lock2 = null;
-        private Monitor mon1 = null;
-        private Monitor mon2 = null;
-        private boolean useSync;
-
-        DeadlockThread(String name, Lock lock1, Lock lock2) {
-            super(name);
-            this.lock1 = lock1;
-            this.lock2 = lock2;
-            this.useSync = true;
-        }
-        DeadlockThread(String name, Monitor mon1, Monitor mon2) {
-            super(name);
-            this.mon1 = mon1;
-            this.mon2 = mon2;
-            this.useSync = false;
-        }
-        @Override
-        public void run() {
-            if (useSync) {
-                syncLock();
-            } else {
-                monitorLock();
-            }
-        }
-        private void syncLock() {
-            lock1.lock();
-            try {
-                try {
-                    barrier.await();
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                    System.exit(1);
-                } catch (BrokenBarrierException e) {
-                    e.printStackTrace();
-                    System.exit(1);
-                }
-                goSyncDeadlock();
-            } finally {
-                lock1.unlock();
-            }
-        }
-        private void goSyncDeadlock() {
-            try {
-                barrier.await();
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-                System.exit(1);
-            } catch (BrokenBarrierException e) {
-                e.printStackTrace();
-                System.exit(1);
-            }
-            lock2.lock();
-            throw new RuntimeException("should not reach here.");
-        }
-        private void monitorLock() {
-            synchronized (mon1) {
-                try {
-                    barrier.await();
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                    System.exit(1);
-                } catch (BrokenBarrierException e) {
-                    e.printStackTrace();
-                    System.exit(1);
-                }
-                goMonitorDeadlock();
-            }
-        }
-        private void goMonitorDeadlock() {
-            try {
-                barrier.await();
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-                System.exit(1);
-            } catch (BrokenBarrierException e) {
-                e.printStackTrace();
-                System.exit(1);
-            }
-            synchronized (mon2) {
-                throw new RuntimeException(getName() + " should not reach here.");
-            }
-        }
-    }
-
-    class Monitor {
-        String name;
-        Monitor(String name) {
-            this.name = name;
-        }
-    }
-
-    private static void waitForEnterPressed() {
-        try {
-            boolean done = false;
-            while (!done) {
-                char ch = (char) System.in.read();
-                if (ch<0||ch=='\n') {
-                    done = true;
-                }
-            }
-        }
-        catch (IOException e) {
-            e.printStackTrace();
-            System.exit(0);
-        }
-    }
-}
--- a/jdk/src/demo/share/management/FullThreadDump/FullThreadDump.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- */
-
-import javax.management.*;
-import javax.management.remote.*;
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-/**
- * This FullThreadDump class demonstrates the capability to get
- * a full thread dump and also detect deadlock remotely.
- */
-public class FullThreadDump {
-    private MBeanServerConnection server;
-    private JMXConnector jmxc;
-    public FullThreadDump(String hostname, int port) {
-        System.out.println("Connecting to " + hostname + ":" + port);
-
-        // Create an RMI connector client and connect it to
-        // the RMI connector server
-        String urlPath = "/jndi/rmi://" + hostname + ":" + port + "/jmxrmi";
-        connect(urlPath);
-   }
-
-   public void dump() {
-        try {
-            ThreadMonitor monitor = new ThreadMonitor(server);
-            monitor.threadDump();
-            if (!monitor.findDeadlock()) {
-                System.out.println("No deadlock found.");
-            }
-        } catch (IOException e) {
-            System.err.println("\nCommunication error: " + e.getMessage());
-            System.exit(1);
-        }
-    }
-
-    /**
-     * Connect to a JMX agent of a given URL.
-     */
-    private void connect(String urlPath) {
-        try {
-            JMXServiceURL url = new JMXServiceURL("rmi", "", 0, urlPath);
-            this.jmxc = JMXConnectorFactory.connect(url);
-            this.server = jmxc.getMBeanServerConnection();
-        } catch (MalformedURLException e) {
-            // should not reach here
-        } catch (IOException e) {
-            System.err.println("\nCommunication error: " + e.getMessage());
-            System.exit(1);
-        }
-    }
-
-    public static void main(String[] args) {
-        if (args.length != 1) {
-            usage();
-        }
-
-        String[] arg2 = args[0].split(":");
-        if (arg2.length != 2) {
-            usage();
-        }
-        String hostname = arg2[0];
-        int port = -1;
-        try {
-            port = Integer.parseInt(arg2[1]);
-        } catch (NumberFormatException x) {
-            usage();
-        }
-        if (port < 0) {
-            usage();
-        }
-
-        // get full thread dump and perform deadlock detection
-        FullThreadDump ftd = new FullThreadDump(hostname, port);
-        ftd.dump();
-    }
-
-    private static void usage() {
-        System.out.println("Usage: java FullThreadDump <hostname>:<port>");
-    }
-}
--- a/jdk/src/demo/share/management/FullThreadDump/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-FullThreadDump demonstrates the use of the java.lang.management API 
-to print the full thread dump.  JDK 6 defines a new API to dump
-the information about monitors and java.util.concurrent ownable
-synchronizers.
-
-This demo also illustrates how to monitor JDK 5 and JDK 6 VMs with
-two versions of APIs.
-
-It contains two parts: 
-a) Local monitoring within the application
-b) Remote monitoring by connecting to a JMX agent with a JMX service URL:
-      service:jmx:rmi:///jndi/rmi://<hostName>:<portNum>/jmxrmi
-   where <hostName> is the hostname and <portNum> is the port number
-   to which the JMX agent will be connected.
-
-To run the demo
----------------
-a) Local Monitoring
-
-   java -cp <JDK_HOME>/demo/management/FullThreadDump/FullThreadDump.jar Deadlock
-
-   This will dump the stack trace and then detect deadlocks locally
-   within the application.
-
-b) Remote Monitoring
-
-  (1) Start the Deadlock application (or any other application) 
-      with the JMX agent as follows:
-   
-      java -Dcom.sun.management.jmxremote.port=1090
-           -Dcom.sun.management.jmxremote.ssl=false
-           -Dcom.sun.management.jmxremote.authenticate=false
-           -cp <JDK_HOME>/demo/management/FullThreadDump/FullThreadDump.jar
-           Deadlock
-
-      This instruction uses the Sun's built-in support to enable a JMX agent.
-      You can programmatically start a JMX agent with the RMI connector
-      using javax.management.remote API.  See the javadoc and examples for 
-      javax.management.remote API for details.
-
-  (2) Run FullThreadDump 
-
-      java -jar <JDK_HOME>/demo/management/FullThreadDump/FullThreadDump.jar \
-	  localhost:1090
-
-      This will dump the stack trace and then print out the deadlocked threads.
-      
-These instructions assume that this installation's version of the java
-command is in your path.  If it isn't, then you should either
-specify the complete path to the java command or update your
-PATH environment variable as described in the installation
-instructions for the Java(TM) SDK.
--- a/jdk/src/demo/share/management/FullThreadDump/ThreadMonitor.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,266 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- */
-
-import static java.lang.management.ManagementFactory.*;
-import java.lang.management.ThreadMXBean;
-import java.lang.management.ThreadInfo;
-import java.lang.management.LockInfo;
-import java.lang.management.MonitorInfo;
-import javax.management.*;
-import java.io.*;
-
-/**
- * Example of using the java.lang.management API to dump stack trace
- * and to perform deadlock detection.
- *
- * @author  Mandy Chung
- */
-public class ThreadMonitor {
-    private MBeanServerConnection server;
-    private ThreadMXBean tmbean;
-    private ObjectName objname;
-
-    // default - JDK 6+ VM
-    private String findDeadlocksMethodName = "findDeadlockedThreads";
-    private boolean canDumpLocks = true;
-
-    /**
-     * Constructs a ThreadMonitor object to get thread information
-     * in a remote JVM.
-     */
-    public ThreadMonitor(MBeanServerConnection server) throws IOException {
-       this.server = server;
-       this.tmbean = newPlatformMXBeanProxy(server,
-                                            THREAD_MXBEAN_NAME,
-                                            ThreadMXBean.class);
-       try {
-           objname = new ObjectName(THREAD_MXBEAN_NAME);
-        } catch (MalformedObjectNameException e) {
-            // should not reach here
-            InternalError ie = new InternalError(e.getMessage());
-            ie.initCause(e);
-            throw ie;
-       }
-       parseMBeanInfo();
-    }
-
-    /**
-     * Constructs a ThreadMonitor object to get thread information
-     * in the local JVM.
-     */
-    public ThreadMonitor() {
-        this.tmbean = getThreadMXBean();
-    }
-
-    /**
-     * Prints the thread dump information to System.out.
-     */
-    public void threadDump() {
-        if (canDumpLocks) {
-            if (tmbean.isObjectMonitorUsageSupported() &&
-                tmbean.isSynchronizerUsageSupported()) {
-                // Print lock info if both object monitor usage
-                // and synchronizer usage are supported.
-                // This sample code can be modified to handle if
-                // either monitor usage or synchronizer usage is supported.
-                dumpThreadInfoWithLocks();
-            }
-        } else {
-            dumpThreadInfo();
-        }
-    }
-
-    private void dumpThreadInfo() {
-       System.out.println("Full Java thread dump");
-       long[] tids = tmbean.getAllThreadIds();
-       ThreadInfo[] tinfos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
-       for (ThreadInfo ti : tinfos) {
-           printThreadInfo(ti);
-       }
-    }
-
-    /**
-     * Prints the thread dump information with locks info to System.out.
-     */
-    private void dumpThreadInfoWithLocks() {
-       System.out.println("Full Java thread dump with locks info");
-
-       ThreadInfo[] tinfos = tmbean.dumpAllThreads(true, true);
-       for (ThreadInfo ti : tinfos) {
-           printThreadInfo(ti);
-           LockInfo[] syncs = ti.getLockedSynchronizers();
-           printLockInfo(syncs);
-       }
-       System.out.println();
-    }
-
-    private static String INDENT = "    ";
-
-    private void printThreadInfo(ThreadInfo ti) {
-       // print thread information
-       printThread(ti);
-
-       // print stack trace with locks
-       StackTraceElement[] stacktrace = ti.getStackTrace();
-       MonitorInfo[] monitors = ti.getLockedMonitors();
-       for (int i = 0; i < stacktrace.length; i++) {
-           StackTraceElement ste = stacktrace[i];
-           System.out.println(INDENT + "at " + ste.toString());
-           for (MonitorInfo mi : monitors) {
-               if (mi.getLockedStackDepth() == i) {
-                   System.out.println(INDENT + "  - locked " + mi);
-               }
-           }
-       }
-       System.out.println();
-    }
-
-    private void printThread(ThreadInfo ti) {
-       StringBuilder sb = new StringBuilder("\"" + ti.getThreadName() + "\"" +
-                                            " Id=" + ti.getThreadId() +
-                                            " in " + ti.getThreadState());
-       if (ti.getLockName() != null) {
-           sb.append(" on lock=" + ti.getLockName());
-       }
-       if (ti.isSuspended()) {
-           sb.append(" (suspended)");
-       }
-       if (ti.isInNative()) {
-           sb.append(" (running in native)");
-       }
-       System.out.println(sb.toString());
-       if (ti.getLockOwnerName() != null) {
-            System.out.println(INDENT + " owned by " + ti.getLockOwnerName() +
-                               " Id=" + ti.getLockOwnerId());
-       }
-    }
-
-    private void printMonitorInfo(ThreadInfo ti) {
-       MonitorInfo[] monitors = ti.getLockedMonitors();
-       System.out.println(INDENT + "Locked monitors: count = " + monitors.length);
-       for (MonitorInfo mi : monitors) {
-           System.out.println(INDENT + "  - " + mi + " locked at ");
-           System.out.println(INDENT + "      " + mi.getLockedStackDepth() +
-                              " " + mi.getLockedStackFrame());
-       }
-    }
-
-    private void printLockInfo(LockInfo[] locks) {
-       System.out.println(INDENT + "Locked synchronizers: count = " + locks.length);
-       for (LockInfo li : locks) {
-           System.out.println(INDENT + "  - " + li);
-       }
-       System.out.println();
-    }
-
-    /**
-     * Checks if any threads are deadlocked. If any, print
-     * the thread dump information.
-     */
-    public boolean findDeadlock() {
-       long[] tids;
-       if (findDeadlocksMethodName.equals("findDeadlockedThreads") &&
-               tmbean.isSynchronizerUsageSupported()) {
-           tids = tmbean.findDeadlockedThreads();
-           if (tids == null) {
-               return false;
-           }
-
-           System.out.println("Deadlock found :-");
-           ThreadInfo[] infos = tmbean.getThreadInfo(tids, true, true);
-           for (ThreadInfo ti : infos) {
-               printThreadInfo(ti);
-               printMonitorInfo(ti);
-               printLockInfo(ti.getLockedSynchronizers());
-               System.out.println();
-           }
-       } else {
-           tids = tmbean.findMonitorDeadlockedThreads();
-           if (tids == null) {
-               return false;
-           }
-           ThreadInfo[] infos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
-           for (ThreadInfo ti : infos) {
-               // print thread information
-               printThreadInfo(ti);
-           }
-       }
-
-       return true;
-    }
-
-
-    private void parseMBeanInfo() throws IOException {
-        try {
-            MBeanOperationInfo[] mopis = server.getMBeanInfo(objname).getOperations();
-
-            // look for findDeadlockedThreads operations;
-            boolean found = false;
-            for (MBeanOperationInfo op : mopis) {
-                if (op.getName().equals(findDeadlocksMethodName)) {
-                    found = true;
-                    break;
-                }
-            }
-            if (!found) {
-                // if findDeadlockedThreads operation doesn't exist,
-                // the target VM is running on JDK 5 and details about
-                // synchronizers and locks cannot be dumped.
-                findDeadlocksMethodName = "findMonitorDeadlockedThreads";
-                canDumpLocks = false;
-            }
-        } catch (IntrospectionException e) {
-            InternalError ie = new InternalError(e.getMessage());
-            ie.initCause(e);
-            throw ie;
-        } catch (InstanceNotFoundException e) {
-            InternalError ie = new InternalError(e.getMessage());
-            ie.initCause(e);
-            throw ie;
-        } catch (ReflectionException e) {
-            InternalError ie = new InternalError(e.getMessage());
-            ie.initCause(e);
-            throw ie;
-        }
-    }
-}
--- a/jdk/src/demo/share/management/JTop/JTop.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,427 +0,0 @@
-/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- *
- * Example of using the java.lang.management API to sort threads
- * by CPU usage.
- *
- * JTop class can be run as a standalone application.
- * It first establishs a connection to a target VM specified
- * by the given hostname and port number where the JMX agent
- * to be connected.  It then polls for the thread information
- * and the CPU consumption of each thread to display every 2
- * seconds.
- *
- * It is also used by JTopPlugin which is a JConsolePlugin
- * that can be used with JConsole (see README.txt). The JTop
- * GUI will be added as a JConsole tab by the JTop plugin.
- *
- * @see com.sun.tools.jconsole.JConsolePlugin
- *
- * @author Mandy Chung
- */
-import java.lang.management.*;
-import javax.management.*;
-import javax.management.remote.*;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.TreeMap;
-import java.util.concurrent.ExecutionException;
-import java.text.NumberFormat;
-import java.net.MalformedURLException;
-import static java.lang.management.ManagementFactory.*;
-
-import java.awt.*;
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.table.*;
-
-/**
- * JTop is a JPanel to display thread's name, CPU time, and its state
- * in a table.
- */
-public class JTop extends JPanel {
-
-    private static class StatusBar extends JPanel {
-        private static final long serialVersionUID = -6483392381797633018L;
-        private final JLabel statusText;
-
-        public StatusBar(boolean defaultVisible) {
-            super(new GridLayout(1, 1));
-            statusText = new JLabel();
-            statusText.setVisible(defaultVisible);
-            add(statusText);
-        }
-
-        @Override
-        public Dimension getMaximumSize() {
-            Dimension maximum = super.getMaximumSize();
-            Dimension minimum = getMinimumSize();
-            return new Dimension(maximum.width, minimum.height);
-        }
-
-        public void setMessage(String text) {
-            statusText.setText(text);
-            statusText.setVisible(true);
-        }
-    }
-    private static final long serialVersionUID = -1499762160973870696L;
-    private MBeanServerConnection server;
-    private ThreadMXBean tmbean;
-    private MyTableModel tmodel;
-    private final StatusBar statusBar;
-    public JTop() {
-        super(new GridBagLayout());
-
-        tmodel = new MyTableModel();
-        JTable table = new JTable(tmodel);
-        table.setPreferredScrollableViewportSize(new Dimension(500, 300));
-
-        // Set the renderer to format Double
-        table.setDefaultRenderer(Double.class, new DoubleRenderer());
-        // Add some space
-        table.setIntercellSpacing(new Dimension(6,3));
-        table.setRowHeight(table.getRowHeight() + 4);
-
-        // Create the scroll pane and add the table to it.
-        JScrollPane scrollPane = new JScrollPane(table);
-
-        // Add the scroll pane to this panel.
-        GridBagConstraints c1 = new GridBagConstraints();
-        c1.fill = GridBagConstraints.BOTH;
-        c1.gridy = 0;
-        c1.gridx = 0;
-        c1.weightx = 1;
-        c1.weighty = 1;
-        add(scrollPane, c1);
-
-        statusBar = new StatusBar(false);
-        GridBagConstraints c2 = new GridBagConstraints();
-        c2.fill = GridBagConstraints.HORIZONTAL;
-        c2.gridy = 1;
-        c2.gridx = 0;
-        c2.weightx = 1.0;
-        c2.weighty = 0.0;
-        add(statusBar, c2);
-    }
-
-    // Set the MBeanServerConnection object for communicating
-    // with the target VM
-    public void setMBeanServerConnection(MBeanServerConnection mbs) {
-        this.server = mbs;
-        try {
-            this.tmbean = newPlatformMXBeanProxy(server,
-                                                 THREAD_MXBEAN_NAME,
-                                                 ThreadMXBean.class);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        if (!tmbean.isThreadCpuTimeSupported()) {
-            statusBar.setMessage("Monitored VM does not support thread CPU time measurement");
-        } else {
-            try {
-                tmbean.setThreadCpuTimeEnabled(true);
-            } catch (SecurityException e) {
-                statusBar.setMessage("Monitored VM does not have permission for enabling thread cpu time measurement");
-            }
-        }
-    }
-
-    class MyTableModel extends AbstractTableModel {
-        private static final long serialVersionUID = -7877310288576779514L;
-        private String[] columnNames = {"ThreadName",
-                                        "CPU(sec)",
-                                        "State"};
-        // List of all threads. The key of each entry is the CPU time
-        // and its value is the ThreadInfo object with no stack trace.
-        private List<Map.Entry<Long, ThreadInfo>> threadList =
-            Collections.emptyList();
-
-        public MyTableModel() {
-        }
-
-        @Override
-        public int getColumnCount() {
-            return columnNames.length;
-        }
-
-        @Override
-        public int getRowCount() {
-            return threadList.size();
-        }
-
-        @Override
-        public String getColumnName(int col) {
-            return columnNames[col];
-        }
-
-        @Override
-        public Object getValueAt(int row, int col) {
-            Map.Entry<Long, ThreadInfo> me = threadList.get(row);
-            switch (col) {
-                case 0 :
-                    // Column 0 shows the thread name
-                    return me.getValue().getThreadName();
-                case 1 :
-                    // Column 1 shows the CPU usage
-                    long ns = me.getKey().longValue();
-                    double sec = ns / 1000000000;
-                    return new Double(sec);
-                case 2 :
-                    // Column 2 shows the thread state
-                    return me.getValue().getThreadState();
-                default:
-                    return null;
-            }
-        }
-
-        @Override
-        public Class<?> getColumnClass(int c) {
-            return getValueAt(0, c).getClass();
-        }
-
-        void setThreadList(List<Map.Entry<Long, ThreadInfo>> list) {
-            threadList = list;
-        }
-    }
-
-    /**
-     * Get the thread list with CPU consumption and the ThreadInfo
-     * for each thread sorted by the CPU time.
-     */
-    private List<Map.Entry<Long, ThreadInfo>> getThreadList() {
-        // Get all threads and their ThreadInfo objects
-        // with no stack trace
-        long[] tids = tmbean.getAllThreadIds();
-        ThreadInfo[] tinfos = tmbean.getThreadInfo(tids);
-
-        // build a map with key = CPU time and value = ThreadInfo
-        SortedMap<Long, ThreadInfo> map = new TreeMap<Long, ThreadInfo>();
-        for (int i = 0; i < tids.length; i++) {
-            long cpuTime = tmbean.getThreadCpuTime(tids[i]);
-            // filter out threads that have been terminated
-            if (cpuTime != -1 && tinfos[i] != null) {
-                map.put(new Long(cpuTime), tinfos[i]);
-            }
-        }
-
-        // build the thread list and sort it with CPU time
-        // in decreasing order
-        Set<Map.Entry<Long, ThreadInfo>> set = map.entrySet();
-        List<Map.Entry<Long, ThreadInfo>> list =
-            new ArrayList<Map.Entry<Long, ThreadInfo>>(set);
-        Collections.reverse(list);
-        return list;
-    }
-
-
-    /**
-     * Format Double with 4 fraction digits
-     */
-    class DoubleRenderer extends DefaultTableCellRenderer {
-        private static final long serialVersionUID = 1704639497162584382L;
-        NumberFormat formatter;
-        public DoubleRenderer() {
-            super();
-            setHorizontalAlignment(JLabel.RIGHT);
-        }
-
-        @Override
-        public void setValue(Object value) {
-            if (formatter==null) {
-                formatter = NumberFormat.getInstance();
-                formatter.setMinimumFractionDigits(4);
-            }
-            setText((value == null) ? "" : formatter.format(value));
-        }
-    }
-
-    // SwingWorker responsible for updating the GUI
-    //
-    // It first gets the thread and CPU usage information as a
-    // background task done by a worker thread so that
-    // it will not block the event dispatcher thread.
-    //
-    // When the worker thread finishes, the event dispatcher
-    // thread will invoke the done() method which will update
-    // the UI.
-    class Worker extends SwingWorker<List<Map.Entry<Long, ThreadInfo>>,Object> {
-        private MyTableModel tmodel;
-        Worker(MyTableModel tmodel) {
-            this.tmodel = tmodel;
-        }
-
-        // Get the current thread info and CPU time
-        @Override
-        public List<Map.Entry<Long, ThreadInfo>> doInBackground() {
-            return getThreadList();
-        }
-
-        // fire table data changed to trigger GUI update
-        // when doInBackground() is finished
-        @Override
-        protected void done() {
-            try {
-                // Set table model with the new thread list
-                tmodel.setThreadList(get());
-                // refresh the table model
-                tmodel.fireTableDataChanged();
-            } catch (InterruptedException e) {
-            } catch (ExecutionException e) {
-            }
-        }
-    }
-
-    // Return a new SwingWorker for UI update
-    public SwingWorker<?,?> newSwingWorker() {
-        return new Worker(tmodel);
-    }
-
-    public static void main(String[] args) throws Exception {
-        // Validate the input arguments
-        if (args.length != 1) {
-            usage();
-        }
-
-        String[] arg2 = args[0].split(":");
-        if (arg2.length != 2) {
-            usage();
-        }
-        String hostname = arg2[0];
-        int port = -1;
-        try {
-            port = Integer.parseInt(arg2[1]);
-        } catch (NumberFormatException x) {
-            usage();
-        }
-        if (port < 0) {
-            usage();
-        }
-
-        // Create the JTop Panel
-        final JTop jtop = new JTop();
-        // Set up the MBeanServerConnection to the target VM
-        MBeanServerConnection server = connect(hostname, port);
-        jtop.setMBeanServerConnection(server);
-
-        // A timer task to update GUI per each interval
-        TimerTask timerTask = new TimerTask() {
-            @Override
-            public void run() {
-                // Schedule the SwingWorker to update the GUI
-                jtop.newSwingWorker().execute();
-            }
-        };
-
-        // Create the standalone window with JTop panel
-        // by the event dispatcher thread
-        SwingUtilities.invokeAndWait(new Runnable() {
-            @Override
-            public void run() {
-                createAndShowGUI(jtop);
-            }
-        });
-
-        // refresh every 2 seconds
-        Timer timer = new Timer("JTop Sampling thread");
-        timer.schedule(timerTask, 0, 2000);
-
-    }
-
-    // Establish a connection with the remote application
-    //
-    // You can modify the urlPath to the address of the JMX agent
-    // of your application if it has a different URL.
-    //
-    // You can also modify the following code to take
-    // username and password for client authentication.
-    private static MBeanServerConnection connect(String hostname, int port) {
-        // Create an RMI connector client and connect it to
-        // the RMI connector server
-        String urlPath = "/jndi/rmi://" + hostname + ":" + port + "/jmxrmi";
-        MBeanServerConnection server = null;
-        try {
-            JMXServiceURL url = new JMXServiceURL("rmi", "", 0, urlPath);
-            JMXConnector jmxc = JMXConnectorFactory.connect(url);
-            server = jmxc.getMBeanServerConnection();
-        } catch (MalformedURLException e) {
-            // should not reach here
-        } catch (IOException e) {
-            System.err.println("\nCommunication error: " + e.getMessage());
-            System.exit(1);
-        }
-        return server;
-    }
-
-    private static void usage() {
-        System.out.println("Usage: java JTop <hostname>:<port>");
-        System.exit(1);
-    }
-    /**
-     * Create the GUI and show it.  For thread safety,
-     * this method should be invoked from the
-     * event-dispatching thread.
-     */
-    private static void createAndShowGUI(JPanel jtop) {
-        // Create and set up the window.
-        JFrame frame = new JFrame("JTop");
-        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
-
-        // Create and set up the content pane.
-        JComponent contentPane = (JComponent) frame.getContentPane();
-        contentPane.add(jtop, BorderLayout.CENTER);
-        contentPane.setOpaque(true); //content panes must be opaque
-        contentPane.setBorder(new EmptyBorder(12, 12, 12, 12));
-        frame.setContentPane(contentPane);
-
-        // Display the window.
-        frame.pack();
-        frame.setVisible(true);
-    }
-
-}
--- a/jdk/src/demo/share/management/JTop/JTopPlugin.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- *
- * Example of a JConsole Plugin.  This loads JTop as a JConsole tab.
- *
- * @author Mandy Chung
- */
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import javax.swing.JPanel;
-import javax.swing.SwingWorker;
-
-import com.sun.tools.jconsole.JConsoleContext;
-import com.sun.tools.jconsole.JConsoleContext.ConnectionState;
-import com.sun.tools.jconsole.JConsolePlugin;
-
-/**
- * JTopPlugin is a subclass to com.sun.tools.jconsole.JConsolePlugin
- *
- * JTopPlugin is loaded and instantiated by JConsole.  One instance
- * is created for each window that JConsole creates. It listens to
- * the connected property change so that it will update JTop with
- * the valid MBeanServerConnection object.  JTop is a JPanel object
- * displaying the thread and its CPU usage information.
- */
-public class JTopPlugin extends JConsolePlugin implements PropertyChangeListener
-{
-    private JTop jtop = null;
-    private Map<String, JPanel> tabs = null;
-
-    public JTopPlugin() {
-        // register itself as a listener
-        addContextPropertyChangeListener(this);
-    }
-
-    /*
-     * Returns a JTop tab to be added in JConsole.
-     */
-    @Override
-    public synchronized Map<String, JPanel> getTabs() {
-        if (tabs == null) {
-            jtop = new JTop();
-            jtop.setMBeanServerConnection(
-                getContext().getMBeanServerConnection());
-            // use LinkedHashMap if you want a predictable order
-            // of the tabs to be added in JConsole
-            tabs = new LinkedHashMap<String, JPanel>();
-            tabs.put("JTop", jtop);
-        }
-        return tabs;
-    }
-
-    /*
-     * Returns a SwingWorker which is responsible for updating the JTop tab.
-     */
-    @Override
-    public SwingWorker<?,?> newSwingWorker() {
-        return jtop.newSwingWorker();
-    }
-
-    // You can implement the dispose() method if you need to release
-    // any resource when the plugin instance is disposed when the JConsole
-    // window is closed.
-    //
-    // public void dispose() {
-    // }
-
-    /*
-     * Property listener to reset the MBeanServerConnection
-     * at reconnection time.
-     */
-    @Override
-    public void propertyChange(PropertyChangeEvent ev) {
-        String prop = ev.getPropertyName();
-        if (prop == JConsoleContext.CONNECTION_STATE_PROPERTY) {
-            ConnectionState newState = (ConnectionState)ev.getNewValue();
-            // JConsole supports disconnection and reconnection
-            // The MBeanServerConnection will become invalid when
-            // disconnected. Need to use the new MBeanServerConnection object
-            // created at reconnection time.
-            if (newState == ConnectionState.CONNECTED && jtop != null) {
-                jtop.setMBeanServerConnection(
-                    getContext().getMBeanServerConnection());
-            }
-        }
-    }
-}
--- a/jdk/src/demo/share/management/JTop/META-INF/services/com.sun.tools.jconsole.JConsolePlugin	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-JTopPlugin
--- a/jdk/src/demo/share/management/JTop/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-JTop monitors the CPU usage of all threads in a remote application
-which has remote management enabled.  JTop demonstrates the use of 
-the java.lang.management API to obtain the CPU consumption for 
-each thread.
-
-JTop is also a JConsole Plugin.  See below for details.
-
-JTop Standalone GUI
-===================
-
-JTop first establishes a connection to a JMX agent in a remote
-application with a JMX service URL:
-   service:jmx:rmi:///jndi/rmi://<hostName>:<portNum>/jmxrmi
-
-where <hostName> is the hostname and <portNum> is the port number
-to which the JMX agent will be connected.
-
-To run the demo
----------------
-(1) Start the application with the JMX agent - here's an example of 
-    how the Java2D is started
-   
-      java -Dcom.sun.management.jmxremote.port=1090
-           -Dcom.sun.management.jmxremote.ssl=false
-           -Dcom.sun.management.jmxremote.authenticate=false
-           -jar <JDK_HOME>/demo/jfc/Java2D/Java2Demo.jar
-
-    This instruction uses the Sun's built-in support to enable a JMX agent
-    with a JMX service URL as described above.
-    You can programmatically start a JMX agent with the RMI connector
-    using javax.management.remote API.  See the javadoc and examples for 
-    javax.management.remote API for details.
-
-(2) Run JTop on a different machine:
-
-      java -jar <JDK_HOME>/demo/management/JTop/JTop.jar <hostname>:1090
-
-    where <hostname> is where the Java2Demo.jar runs in step (1).
-
-These instructions assume that this installation's version of the java
-command is in your path.  If it isn't, then you should either
-specify the complete path to the java command or update your
-PATH environment variable as described in the installation
-instructions for the Java(TM) SDK.
-
-JTop JConsole Plugin
-====================
-
-JTop is a JConsole Plugin which adds a "JTop" tab to JConsole.
-
-To run JConsole with the JTop plugin 
-------------------------------------
-    jconsole -pluginpath <JDK_HOME>/demo/management/JTop/JTop.jar
-
-
-To compile
-----------
-    javac -classpath <JDK_HOME>/lib/jconsole.jar JTopPlugin.java
- 
-com.sun.tools.jconsole API is in jconsole.jar which is needed
-in the classpath for compilation.
--- a/jdk/src/demo/share/management/MemoryMonitor/MemoryMonitor.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,491 +0,0 @@
-/*
- * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- */
-
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.image.BufferedImage;
-import java.awt.geom.Line2D;
-import java.awt.geom.Rectangle2D;
-import java.util.Date;
-import javax.swing.*;
-import javax.swing.border.EtchedBorder;
-import javax.swing.border.TitledBorder;
-import java.lang.management.*;
-/**
- * Demo code which plots the memory usage by all memory pools.
- * The memory usage is sampled at some time interval using
- * java.lang.management API. This demo code is modified based
- * java2d MemoryMonitor demo.
- */
-public class MemoryMonitor extends JPanel {
-
-    private static final long serialVersionUID = -3463003810776195761L;
-    static JCheckBox dateStampCB = new JCheckBox("Output Date Stamp");
-    public Surface surf;
-    JPanel controls;
-    boolean doControls;
-    JTextField tf;
-    // Get memory pools.
-    static java.util.List<MemoryPoolMXBean> mpools =
-        ManagementFactory.getMemoryPoolMXBeans();
-    // Total number of memory pools.
-    static int numPools = mpools.size();
-
-    public MemoryMonitor() {
-        setLayout(new BorderLayout());
-        setBorder(new TitledBorder(new EtchedBorder(), "Memory Monitor"));
-        add(surf = new Surface());
-        controls = new JPanel();
-        controls.setPreferredSize(new Dimension(135,80));
-        Font font = new Font("serif", Font.PLAIN, 10);
-        JLabel label = new JLabel("Sample Rate");
-        label.setFont(font);
-        label.setForeground(Color.red);
-        controls.add(label);
-        tf = new JTextField("1000");
-        tf.setPreferredSize(new Dimension(45,20));
-        controls.add(tf);
-        controls.add(label = new JLabel("ms"));
-        label.setFont(font);
-        label.setForeground(Color.red);
-        controls.add(dateStampCB);
-        dateStampCB.setFont(font);
-        addMouseListener(new MouseAdapter() {
-            @Override
-            public void mouseClicked(MouseEvent e) {
-               removeAll();
-               if ((doControls = !doControls)) {
-                   surf.stop();
-                   add(controls);
-               } else {
-                   try {
-                       surf.sleepAmount = Long.parseLong(tf.getText().trim());
-                   } catch (Exception ex) {}
-                   surf.start();
-                   add(surf);
-               }
-               validate();
-               repaint();
-            }
-        });
-    }
-
-
-    public class Surface extends JPanel implements Runnable {
-
-        public Thread thread;
-        public long sleepAmount = 1000;
-        public int  usageHistCount = 20000;
-        private int w, h;
-        private BufferedImage bimg;
-        private Graphics2D big;
-        private Font font = new Font("Times New Roman", Font.PLAIN, 11);
-        private int columnInc;
-        private float usedMem[][];
-        private float usedMemMax[]; // Used when max pool size is undefined
-        private int ptNum[];
-        private int ascent, descent;
-        private Rectangle graphOutlineRect = new Rectangle();
-        private Rectangle2D mfRect = new Rectangle2D.Float();
-        private Rectangle2D muRect = new Rectangle2D.Float();
-        private Line2D graphLine = new Line2D.Float();
-        private Color graphColor = new Color(46, 139, 87);
-        private Color mfColor = new Color(0, 100, 0);
-        private String usedStr;
-
-
-        public Surface() {
-            setBackground(Color.black);
-            addMouseListener(new MouseAdapter() {
-                @Override
-                public void mouseClicked(MouseEvent e) {
-                    if (thread == null) start(); else stop();
-                }
-            });
-            usedMem = new float[numPools][];
-            usedMemMax = new float[numPools];
-            for (int i = 0; i < numPools; i++) {
-                usedMemMax[i] = 1024f * 1024f ;
-            }
-            ptNum = new int[numPools];
-        }
-
-        @Override
-        public Dimension getMinimumSize() {
-            return getPreferredSize();
-        }
-
-        @Override
-        public Dimension getMaximumSize() {
-            return getPreferredSize();
-        }
-
-        @Override
-        public Dimension getPreferredSize() {
-            return new Dimension(135,80);
-        }
-
-
-        @Override
-        public void paint(Graphics g) {
-
-            if (big == null) {
-                return;
-            }
-
-            big.setBackground(getBackground());
-            big.clearRect(0,0,w,h);
-
-
-            h = h / ((numPools + numPools%2) / 2);
-            w = w / 2;
-
-            int k=0; // index of memory pool.
-            for (int i=0; i < 2;i++) {
-               for (int j=0; j < (numPools + numPools%2)/ 2; j++) {
-                 plotMemoryUsage(w*i,h*j,w,h,k);
-                 if (++k >= numPools) {
-                    i = 3;
-                    j = (numPools + numPools%2)/ 2;
-                    break;
-                 }
-               }
-            }
-            g.drawImage(bimg, 0, 0, this);
-        }
-
-        public void plotMemoryUsage(int x1, int y1, int x2, int y2, int npool) {
-
-            MemoryPoolMXBean mp = mpools.get(npool);
-            float usedMemory =  mp.getUsage().getUsed();
-            float totalMemory =  mp.getUsage().getMax();
-            if (totalMemory < 0) { // Max is undefined for this pool
-                if (usedMemory > usedMemMax[npool]) {
-                    usedMemMax[npool] = usedMemory;
-                }
-                totalMemory = usedMemMax[npool];
-            }
-
-            // .. Draw allocated and used strings ..
-            big.setColor(Color.green);
-
-            // Print Max memory allocated for this memory pool.
-            big.drawString(String.valueOf((int)totalMemory/1024) + "K Max ", x1+4.0f, (float) y1 + ascent+0.5f);
-            big.setColor(Color.yellow);
-
-            // Print the memory pool name.
-            big.drawString(mp.getName(),  x1+x2/2, (float) y1 + ascent+0.5f);
-
-            // Print the memory used by this memory pool.
-            usedStr = String.valueOf((int)usedMemory/1024)
-                + "K used";
-            big.setColor(Color.green);
-            big.drawString(usedStr, x1+4, y1+y2-descent);
-
-            // Calculate remaining size
-            float ssH = ascent + descent;
-            float remainingHeight = y2 - (ssH*2) - 0.5f;
-            float blockHeight = remainingHeight/10;
-            float blockWidth = 20.0f;
-            float remainingWidth = x2 - blockWidth - 10;
-
-            // .. Memory Free ..
-            big.setColor(mfColor);
-            int MemUsage = (int) (((totalMemory - usedMemory) / totalMemory) * 10);
-            int i = 0;
-            for ( ; i < MemUsage ; i++) {
-                mfRect.setRect(x1+5,(float) y1+ssH+i*blockHeight,
-                                blockWidth, blockHeight-1);
-                big.fill(mfRect);
-            }
-
-            // .. Memory Used ..
-            big.setColor(Color.green);
-            for ( ; i < 10; i++)  {
-                muRect.setRect(x1+5,(float) y1 + ssH+i*blockHeight,
-                                blockWidth, blockHeight-1);
-                big.fill(muRect);
-            }
-
-            // .. Draw History Graph ..
-            if (remainingWidth <= 30) remainingWidth = (float)30;
-            if (remainingHeight <= ssH) remainingHeight = ssH;
-            big.setColor(graphColor);
-            int graphX = x1+30;
-            int graphY = y1 + (int) ssH;
-            int graphW = (int) remainingWidth;
-            int graphH = (int) remainingHeight;
-
-            graphOutlineRect.setRect(graphX, graphY, graphW, graphH);
-            big.draw(graphOutlineRect);
-
-            int graphRow = graphH/10;
-
-            // .. Draw row ..
-            for (int j = graphY; j <= graphH+graphY; j += graphRow) {
-                graphLine.setLine(graphX,j,graphX+graphW,j);
-                big.draw(graphLine);
-            }
-
-            // .. Draw animated column movement ..
-            int graphColumn = graphW/15;
-
-            if (columnInc == 0) {
-                columnInc = graphColumn;
-            }
-
-            for (int j = graphX+columnInc; j < graphW+graphX; j+=graphColumn) {
-                graphLine.setLine(j,graphY,j,graphY+graphH);
-                big.draw(graphLine);
-            }
-
-            --columnInc;
-
-            // Plot memory usage by this memory pool.
-            if (usedMem[npool] == null) {
-                usedMem[npool] = new float[usageHistCount];
-                ptNum[npool] = 0;
-            }
-
-            // save memory usage history.
-            usedMem[npool][ptNum[npool]] = usedMemory;
-
-            big.setColor(Color.yellow);
-
-            int w1; // width of memory usage history.
-            if (ptNum[npool] > graphW) {
-                w1 = graphW;
-            } else {
-                w1 = ptNum[npool];
-            }
-
-
-            for (int j=graphX+graphW-w1, k=ptNum[npool]-w1; k < ptNum[npool];
-                                                                k++, j++) {
-                 if (k != 0) {
-                     if (usedMem[npool][k] != usedMem[npool][k-1]) {
-                         int h1 = (int)(graphY + graphH * ((totalMemory -usedMem[npool][k-1])/totalMemory));
-                         int h2 = (int)(graphY + graphH * ((totalMemory -usedMem[npool][k])/totalMemory));
-                         big.drawLine(j-1, h1, j, h2);
-                     } else {
-                         int h1 = (int)(graphY + graphH * ((totalMemory -usedMem[npool][k])/totalMemory));
-                         big.fillRect(j, h1, 1, 1);
-                     }
-                 }
-            }
-            if (ptNum[npool]+2 == usedMem[npool].length) {
-                // throw out oldest point
-                for (int j = 1;j < ptNum[npool]; j++) {
-                     usedMem[npool][j-1] = usedMem[npool][j];
-                }
-                --ptNum[npool];
-            } else {
-                ptNum[npool]++;
-            }
-        }
-
-
-        public void start() {
-            thread = new Thread(this);
-            thread.setPriority(Thread.MIN_PRIORITY);
-            thread.setName("MemoryMonitor");
-            thread.start();
-        }
-
-
-        public synchronized void stop() {
-            thread = null;
-            notify();
-        }
-
-        @Override
-        public void run() {
-
-            Thread me = Thread.currentThread();
-
-            while (thread == me && !isShowing() || getSize().width == 0) {
-                try {
-                    Thread.sleep(500);
-                } catch (InterruptedException e) { return; }
-            }
-
-            while (thread == me && isShowing()) {
-                Dimension d = getSize();
-                if (d.width != w || d.height != h) {
-                    w = d.width;
-                    h = d.height;
-                    bimg = (BufferedImage) createImage(w, h);
-                    big = bimg.createGraphics();
-                    big.setFont(font);
-                    FontMetrics fm = big.getFontMetrics(font);
-                    ascent = fm.getAscent();
-                    descent = fm.getDescent();
-                }
-                repaint();
-                try {
-                    Thread.sleep(sleepAmount);
-                } catch (InterruptedException e) { break; }
-                if (MemoryMonitor.dateStampCB.isSelected()) {
-                     System.out.println(new Date().toString() + " " + usedStr);
-                }
-            }
-            thread = null;
-        }
-    }
-
-
-    // Test thread to consume memory
-    static class Memeater extends ClassLoader implements Runnable {
-        Object y[];
-        public Memeater() {}
-        @Override
-        public void run() {
-            y = new Object[10000000];
-            int k =0;
-            while(true) {
-                 if (k == 5000000) k=0;
-                 y[k++] = new Object();
-                 try {
-                     Thread.sleep(20);
-                 } catch (Exception x){}
-
-                 // to consume perm gen storage
-                 try {
-                     // the classes are small so we load 10 at a time
-                     for (int i=0; i<10; i++) {
-                        loadNext();
-                     }
-                 } catch (ClassNotFoundException x) {
-                   // ignore exception
-                 }
-
-           }
-
-        }
-
-        Class<?> loadNext() throws ClassNotFoundException {
-
-            // public class TestNNNNNN extends java.lang.Object{
-            // public TestNNNNNN();
-            //   Code:
-            //    0:    aload_0
-            //    1:    invokespecial   #1; //Method java/lang/Object."<init>":()V
-            //    4:    return
-            // }
-
-            int begin[] = {
-                0xca, 0xfe, 0xba, 0xbe, 0x00, 0x00, 0x00, 0x30,
-                0x00, 0x0a, 0x0a, 0x00, 0x03, 0x00, 0x07, 0x07,
-                0x00, 0x08, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06,
-                0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00,
-                0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x04, 0x43,
-                0x6f, 0x64, 0x65, 0x0c, 0x00, 0x04, 0x00, 0x05,
-                0x01, 0x00, 0x0a, 0x54, 0x65, 0x73, 0x74 };
-
-            int end [] = {
-                0x01, 0x00, 0x10,
-                0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e,
-                0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74,
-                0x00, 0x21, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
-                0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x04,
-                0x00, 0x05, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00,
-                0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
-                0x00, 0x05, 0x2a, 0xb7, 0x00, 0x01, 0xb1, 0x00,
-                0x00, 0x00, 0x00, 0x00, 0x00 };
-
-
-            // TestNNNNNN
-
-            String name = "Test" + Integer.toString(count++);
-
-            byte value[];
-            try {
-                value = name.substring(4).getBytes("UTF-8");
-            } catch (java.io.UnsupportedEncodingException x) {
-                throw new Error();
-            }
-
-            // construct class file
-
-            int len = begin.length + value.length + end.length;
-            byte b[] = new byte[len];
-            int pos=0;
-            for (int i: begin) {
-                b[pos++] = (byte) i;
-            }
-            for (byte v: value) {
-                b[pos++] = v;
-            }
-            for (int e: end) {
-                b[pos++] = (byte) e;
-            }
-
-            return defineClass(name, b, 0, b.length);
-
-        }
-        static int count = 100000;
-
-    }
-
-    public static void main(String s[]) {
-        final MemoryMonitor demo = new MemoryMonitor();
-        WindowListener l = new WindowAdapter() {
-            @Override
-            public void windowClosing(WindowEvent e) {System.exit(0);}
-            @Override
-            public void windowDeiconified(WindowEvent e) { demo.surf.start(); }
-            @Override
-            public void windowIconified(WindowEvent e) { demo.surf.stop(); }
-        };
-        JFrame f = new JFrame("MemoryMonitor");
-        f.addWindowListener(l);
-        f.getContentPane().add("Center", demo);
-        f.pack();
-        f.setSize(new Dimension(400,500));
-        f.setVisible(true);
-        demo.surf.start();
-        Thread thr = new Thread(new Memeater());
-        thr.start();
-    }
-
-}
--- a/jdk/src/demo/share/management/MemoryMonitor/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-#
-# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-MemoryMonitor demonstrates the use of the java.lang.management API 
-in observing the memory usage of all memory pools consumed by
-the application.
-
-This simple demo program queries the memory usage of each memory pool
-and plots the memory usage history graph.
-
-To run the MemoryMonitor demo
-
-   java -jar <JDK_HOME>/demo/management/MemoryMonitor/MemoryMonitor.jar 
-
-These instructions assume that this installation's version of the java
-command is in your path.  If it isn't, then you should either
-specify the complete path to the java command or update your
-PATH environment variable as described in the installation
-instructions for the Java(TM) SDK.
-
--- a/jdk/src/demo/share/management/VerboseGC/PrintGCStat.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- */
-
-import static java.lang.management.ManagementFactory.*;
-import java.lang.management.*;
-import javax.management.*;
-import java.io.*;
-import java.util.*;
-
-/**
- * Example of using the java.lang.management API to monitor
- * the memory usage and garbage collection statistics.
- *
- * @author  Mandy Chung
- */
-public class PrintGCStat {
-    private RuntimeMXBean rmbean;
-    private MemoryMXBean mmbean;
-    private List<MemoryPoolMXBean> pools;
-    private List<GarbageCollectorMXBean> gcmbeans;
-
-    /**
-     * Constructs a PrintGCStat object to monitor a remote JVM.
-     */
-    public PrintGCStat(MBeanServerConnection server) throws IOException {
-        // Create the platform mxbean proxies
-        this.rmbean = newPlatformMXBeanProxy(server,
-                                             RUNTIME_MXBEAN_NAME,
-                                             RuntimeMXBean.class);
-        this.mmbean = newPlatformMXBeanProxy(server,
-                                             MEMORY_MXBEAN_NAME,
-                                             MemoryMXBean.class);
-        ObjectName poolName = null;
-        ObjectName gcName = null;
-        try {
-            poolName = new ObjectName(MEMORY_POOL_MXBEAN_DOMAIN_TYPE+",*");
-            gcName = new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE+",*");
-        } catch (MalformedObjectNameException e) {
-            // should not reach here
-            assert(false);
-        }
-
-        Set<ObjectName> mbeans = server.queryNames(poolName, null);
-        if (mbeans != null) {
-            pools = new ArrayList<MemoryPoolMXBean>();
-            for (ObjectName objName : mbeans) {
-                MemoryPoolMXBean p =
-                    newPlatformMXBeanProxy(server,
-                                           objName.getCanonicalName(),
-                                           MemoryPoolMXBean.class);
-                pools.add(p);
-            }
-        }
-
-        mbeans = server.queryNames(gcName, null);
-        if (mbeans != null) {
-            gcmbeans = new ArrayList<GarbageCollectorMXBean>();
-            for (ObjectName objName : mbeans) {
-                GarbageCollectorMXBean gc =
-                    newPlatformMXBeanProxy(server,
-                                           objName.getCanonicalName(),
-                                           GarbageCollectorMXBean.class);
-                gcmbeans.add(gc);
-            }
-        }
-    }
-
-    /**
-     * Constructs a PrintGCStat object to monitor the local JVM.
-     */
-    public PrintGCStat() {
-        // Obtain the platform mxbean instances for the running JVM.
-        this.rmbean = getRuntimeMXBean();
-        this.mmbean = getMemoryMXBean();
-        this.pools = getMemoryPoolMXBeans();
-        this.gcmbeans = getGarbageCollectorMXBeans();
-    }
-
-    /**
-     * Prints the verbose GC log to System.out to list the memory usage
-     * of all memory pools as well as the GC statistics.
-     */
-    public void printVerboseGc() {
-        System.out.println("Uptime: " + formatMillis(rmbean.getUptime()));
-        System.out.println("Heap usage: " + mmbean.getHeapMemoryUsage());
-        System.out.println("Non-Heap memory usage: " + mmbean.getNonHeapMemoryUsage());
-        for (GarbageCollectorMXBean gc : gcmbeans) {
-            System.out.print(" [" + gc.getName() + ": ");
-            System.out.print("Count=" + gc.getCollectionCount());
-            System.out.print(" GCTime=" + formatMillis(gc.getCollectionTime()));
-            System.out.print("]");
-        }
-        System.out.println();
-        for (MemoryPoolMXBean p : pools) {
-            System.out.print("  [" + p.getName() + ":");
-            MemoryUsage u = p.getUsage();
-            System.out.print(" Used=" + formatBytes(u.getUsed()));
-            System.out.print(" Committed=" + formatBytes(u.getCommitted()));
-            System.out.println("]");
-        }
-    }
-
-    private String formatMillis(long ms) {
-        return String.format("%.4fsec", ms / (double) 1000);
-    }
-    private String formatBytes(long bytes) {
-        long kb = bytes;
-        if (bytes > 0) {
-            kb = bytes / 1024;
-        }
-        return kb + "K";
-    }
-}
--- a/jdk/src/demo/share/management/VerboseGC/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-VerboseGC demonstrates the use of the java.lang.management API to 
-print the garbage collection statistics and memory usage remotely 
-by connecting to a JMX agent with a JMX service URL:
-      service:jmx:rmi:///jndi/rmi://<hostName>:<portNum>/jmxrmi
-where <hostName> is the hostname and <portNum> is the port number
-to which the JMX agent will be connected.
-
-To run the VerboseGC demo
-
-(1) Start the application with the JMX agent - here's an example of 
-    how the Java2D is started
-
-    java -Dcom.sun.management.jmxremote.port=1090
-         -Dcom.sun.management.jmxremote.ssl=false
-         -Dcom.sun.management.jmxremote.authenticate=false
-         -jar <JDK_HOME>/demo/jfc/Java2D/Java2Demo.jar
-
-    This instruction uses the Sun's built-in support to enable a JMX agent.
-    You can programmatically start a JMX agent with the RMI connector
-    using javax.management.remote API.  See the javadoc and examples for
-    javax.management.remote API for details.
-
-(2) Run VerboseGC
-   
-      java -jar <JDK_HOME>/demo/management/VerboseGC/VerboseGC.jar localhost:1090
-
-These instructions assume that this installation's version of the java
-command is in your path.  If it isn't, then you should either
-specify the complete path to the java command or update your
-PATH environment variable as described in the installation
-instructions for the Java(TM) SDK.
--- a/jdk/src/demo/share/management/VerboseGC/VerboseGC.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- */
-
-import javax.management.*;
-import javax.management.remote.*;
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-/**
- * This VerboseGC class demonstrates the capability to get
- * the garbage collection statistics and memory usage remotely.
- */
-public class VerboseGC {
-    private MBeanServerConnection server;
-    private JMXConnector jmxc;
-    public VerboseGC(String hostname, int port) {
-        System.out.println("Connecting to " + hostname + ":" + port);
-
-        // Create an RMI connector client and connect it to
-        // the RMI connector server
-        String urlPath = "/jndi/rmi://" + hostname + ":" + port + "/jmxrmi";
-        connect(urlPath);
-   }
-
-   public void dump(long interval, long samples) {
-        try {
-            PrintGCStat pstat = new PrintGCStat(server);
-            for (int i = 0; i < samples; i++) {
-                pstat.printVerboseGc();
-                try {
-                    Thread.sleep(interval);
-                } catch (InterruptedException e) {
-                    System.exit(1);
-                }
-            }
-        } catch (IOException e) {
-            System.err.println("\nCommunication error: " + e.getMessage());
-            System.exit(1);
-        }
-    }
-
-    /**
-     * Connect to a JMX agent of a given URL.
-     */
-    private void connect(String urlPath) {
-        try {
-            JMXServiceURL url = new JMXServiceURL("rmi", "", 0, urlPath);
-            this.jmxc = JMXConnectorFactory.connect(url);
-            this.server = jmxc.getMBeanServerConnection();
-        } catch (MalformedURLException e) {
-            // should not reach here
-        } catch (IOException e) {
-            System.err.println("\nCommunication error: " + e.getMessage());
-            System.exit(1);
-        }
-    }
-
-    public static void main(String[] args) {
-        if (args.length < 1) {
-            usage();
-        }
-
-        String hostname = "";
-        int port = -1;
-        long interval = 5000; // default is 5 second interval
-        long mins = 5;
-        for (String arg: args) {
-            if (arg.startsWith("-")) {
-                if (arg.equals("-h") ||
-                    arg.equals("-help") ||
-                    arg.equals("-?")) {
-                    usage();
-                } else if (arg.startsWith("-interval=")) {
-                    try {
-                        interval = Integer.parseInt(arg.substring(10)) * 1000;
-                    } catch (NumberFormatException ex) {
-                        usage();
-                    }
-                } else if (arg.startsWith("-duration=")) {
-                    try {
-                        mins = Integer.parseInt(arg.substring(10));
-                    } catch (NumberFormatException ex) {
-                        usage();
-                    }
-                } else {
-                    // Unknown switch
-                    System.err.println("Unrecognized option: " + arg);
-                    usage();
-                }
-            } else {
-                String[] arg2 = arg.split(":");
-                if (arg2.length != 2) {
-                    usage();
-                }
-                hostname = arg2[0];
-                try {
-                    port = Integer.parseInt(arg2[1]);
-                } catch (NumberFormatException x) {
-                    usage();
-                }
-                if (port < 0) {
-                    usage();
-                }
-            }
-        }
-
-        // get full thread dump and perform deadlock detection
-        VerboseGC vgc = new VerboseGC(hostname, port);
-        long samples = (mins * 60 * 1000) / interval;
-        vgc.dump(interval, samples);
-
-    }
-
-    private static void usage() {
-        System.out.print("Usage: java VerboseGC <hostname>:<port> ");
-        System.out.println(" [-interval=seconds] [-duration=minutes]");
-    }
-}
--- a/jdk/src/demo/share/management/index.html	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-<html>
-<head> <title>java.lang.management Demonstration Code</title> </head>
-
-
-<h1>java.lang.management Demonstration Code</h1>
-
-<ul>
-
-<li>
-<A HREF="FullThreadDump">FullThreadDump</A>
-<br>
-Shows how to get thread dumps and look for deadlocks.
-</li>
-
-<li>
-<A HREF="VerboseGC">VerboseGC</A>
-<br>
-Shows how you can find out about Garbage Collection in the VM.
-</li>
-
-<li>
-<A HREF="MemoryMonitor">MemoryMonitor</A>
-<br>
-Shows how you can find out the memory usage in the VM.
-</li>
-
-<li>
-<A HREF="JTop">JTop</A>
-<br>
-Shows how you can find out the threads with top CPU usage.
-</li>
-
-
-</ul>
-
-
-
-<h2>Comments and Feedback</h2>
-
-<p>
-Comments regarding java.lang.management API or on any of these 
-demonstrations should be sent through 
-<A HREF="http://java.sun.com/mail">http://java.sun.com/mail/</A>
-
-
-</html>
--- a/jdk/src/demo/share/scripting/jconsole-plugin/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-What is this demo about?
-
-This is "script shell" plugin for jconsole  - the monitoring and management 
-client tool shipped with JRE. This plugin adds "Script Shell" tab to jconsole.
-This serves as a demo for jconsole plugin API (com.sun.tools.jconsole) as well 
-as a demo for scripting API (javax.script) for the Java platform.
-
-Script console is an interactive read-eval-print interface that can be used
-used to execute advanced monitoring and management queries. By default,
-JavaScript is used as the scripting language. The scripting language can be 
-changed using the system property com.sun.demo.jconsole.console.language. To 
-use other scripting languages, you need to specify the corresponding engine
-jar file in pluginpath along with this plugin's jar file.
-
-The following 3 global variables are exposed to the script engine:
-
-    window      javax.swing.JPanel
-    engine      javax.script.ScriptEngine
-    plugin      com.sun.tools.jconsole.JConsolePlugin
-
-If you use JavaScript, there are many useful global functions defined in 
-./src/resources/jconsole.js. This is built into the script plugin jar file. 
-In addition, you can add other global functions and global variables by 
-defining those in ~/jconsole.js (or jconsole.<ext> where <ext> is the file 
-extension for your scripting language of choice under your home directory).
-
-How do I compile script console plugin?
-
-You can use the Java based build tool "ant" (http://ant.apache.org) to build 
-this plugin. To build using ant, please use the following command in the
-current directory:
-
-    ant
-
-How do I use script console plugin?
-
-To start jconsole with this plugin, please use the following command
-
-    jconsole -pluginpath jconsole-plugin.jar
-
-How do I load my own script files in script console?
-
-If you use JavaScript (the default), then there is a global function called
-"load" to load any script file from your file system. In script console
-prompt, enter the following:
-
-    load(<script-file-path>);
-
-where <script-file-path> is the path of your script file to load. If you don't 
-specify the file path, then the load function shows file dialog box to choose 
-the script file to load.
-
-How do I get help on script global functions?
-
-If you use JavaScript (the default), then there is a global function called
-"help" that prints one-line help messages on global functions. In script
-console prompt, enter the following:
-
-    help(); 
-
-Where are the sample JavaScript files?
-
-./src/scripts directory contains JavaScript files that can be loaded into
-script console.
--- a/jdk/src/demo/share/scripting/jconsole-plugin/build.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-
-<!-- 
-  This is ant (http://ant.apache.org) build script to build the jconsole 
-  script console plugin.
--->
- 
-<project name="JConsole Script Shell Plugin" default="all" basedir=".">
-
-  <!-- property definitions -->
-  <property name="app.name" value="jconsole-plugin"/>
-  <property name="src.dir"  value="src"/>  
-  <property name="jconsole.jar.dir"  value="${java.home}/../lib"/>
-  <property name="build.dir"  value="."/>
-  <property name="dist.jar" value="${build.dir}/${app.name}.jar"/>
-  <property name="classes.dir"  value="${build.dir}/classes"/>
-  <property name="resources.dir"  value="${classes.dir}/resources"/>
-
-
-  <!-- make directories required -->
-  <target name="prepare">
-    <mkdir dir="${classes.dir}"/>
-  </target>
-
-  <target name="clean">
-     <delete file="${dist.jar}"/>
-     <delete dir="${classes.dir}"/>
-  </target>
-
-  <!-- we need jconsole.jar in CLASSPATH to build -->
-  <path id="javac.classpath">
-    <pathelement path="${jconsole.jar.dir}/jconsole.jar" />
-  </path>
-
-  <target name="compile" depends="prepare" description="compiles the sources">
-    <javac srcdir="${src.dir}"
-           destdir="${classes.dir}"
-           debug="on" deprecation="on">
-      <classpath refid="javac.classpath" />
-    </javac>
-    <copy todir="${classes.dir}/META-INF/services">
-      <fileset dir="${src.dir}/META-INF/services"/>
-    </copy>
-    <copy todir="${resources.dir}">
-      <fileset dir="${src.dir}/resources"/>
-    </copy>
-  </target>
-
-  <target name="all" depends="compile" description="buile deployment bundle">
-    <jar jarfile="${dist.jar}"
-         basedir="${classes.dir}"/>
-  </target>
-
-</project>
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/META-INF/services/com.sun.tools.jconsole.JConsolePlugin	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-com.sun.demo.scripting.jconsole.ScriptJConsolePlugin
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/EditableAtEndDocument.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.demo.scripting.jconsole;
-
-import javax.swing.text.*;
-
-/** This class implements a special type of document in which edits
- * can only be performed at the end, from "mark" to the end of the
- * document. This is used in ScriptShellPanel class as document for editor.
- */
-public class EditableAtEndDocument extends PlainDocument {
-
-    private static final long serialVersionUID = 5358116444851502167L;
-    private int mark;
-
-    @Override
-    public void insertString(int offset, String text, AttributeSet a)
-        throws BadLocationException {
-        int len = getLength();
-        super.insertString(len, text, a);
-    }
-
-    @Override
-    public void remove(int offs, int len) throws BadLocationException {
-        int start = offs;
-        int end = offs + len;
-
-        int markStart = mark;
-        int markEnd = getLength();
-
-        if ((end < markStart) || (start > markEnd)) {
-            // no overlap
-            return;
-        }
-
-        // Determine interval intersection
-        int cutStart = Math.max(start, markStart);
-        int cutEnd = Math.min(end, markEnd);
-        super.remove(cutStart, cutEnd - cutStart);
-    }
-
-    public void setMark() {
-        mark = getLength();
-    }
-
-    public String getMarkedText() throws BadLocationException {
-        return getText(mark, getLength() - mark);
-    }
-
-    /** Used to reset the contents of this document */
-    public void clear() {
-        try {
-            super.remove(0, getLength());
-            setMark();
-        } catch (BadLocationException e) {
-        }
-    }
-}
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/ScriptJConsolePlugin.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,224 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.demo.scripting.jconsole;
-
-import com.sun.tools.jconsole.*;
-import java.io.*;
-import java.util.concurrent.CountDownLatch;
-import javax.script.*;
-import javax.swing.*;
-import java.util.*;
-
-/**
- * This is script console plugin. This class uses javax.script API to create
- * interactive read-eval-print script shell within the jconsole GUI.
- */
-public class ScriptJConsolePlugin extends JConsolePlugin
-                     implements ScriptShellPanel.CommandProcessor {
-    // Panel for our tab
-    private volatile ScriptShellPanel window;
-    // Tabs that we add to jconsole GUI
-    private Map<String, JPanel> tabs;
-
-    // Script engine that evaluates scripts
-    private volatile ScriptEngine engine;
-
-    // script engine initialization occurs in background.
-    // This latch is used to coorrdinate engine init and eval.
-    private CountDownLatch engineReady = new CountDownLatch(1);
-
-    // File extension used for scripts of chosen language.
-    // For eg. ".js" for JavaScript, ".bsh" for BeanShell.
-    private String extension;
-
-    // Prompt to print in the read-eval-print loop. This is
-    // derived from the script file extension.
-    private volatile String prompt;
-
-    /**
-     * Constructor to create this plugin
-     */
-    public ScriptJConsolePlugin() {
-    }
-
-    @Override public Map<String, JPanel> getTabs() {
-        // create ScriptEngine
-        createScriptEngine();
-
-        // create panel for tab
-        window = new ScriptShellPanel(this);
-
-        // add tab to tabs map
-        tabs = new HashMap<String, JPanel>();
-        tabs.put("Script Shell", window);
-
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                // initialize the script engine
-                initScriptEngine();
-                engineReady.countDown();
-            }
-        }).start();
-        return tabs;
-    }
-
-    @Override public SwingWorker<?,?> newSwingWorker() {
-        return null;
-    }
-
-    @Override public void dispose() {
-        window.dispose();
-    }
-
-    @Override
-    public String getPrompt() {
-        return prompt;
-    }
-
-    @Override
-    public String executeCommand(String cmd) {
-        String res;
-        try {
-           engineReady.await();
-           Object tmp = engine.eval(cmd);
-           res = (tmp == null)? null : tmp.toString();
-        } catch (InterruptedException ie) {
-           res = ie.getMessage();
-        } catch (ScriptException se) {
-           res = se.getMessage();
-        }
-        return res;
-    }
-
-    //-- Internals only below this point
-    private void createScriptEngine() {
-        ScriptEngineManager manager = new ScriptEngineManager();
-        String language = getScriptLanguage();
-        engine = manager.getEngineByName(language);
-        if (engine == null) {
-            throw new RuntimeException("cannot load " + language + " engine");
-        }
-        extension = engine.getFactory().getExtensions().get(0);
-        prompt = extension + ">";
-        engine.setBindings(createBindings(), ScriptContext.ENGINE_SCOPE);
-    }
-
-    // Name of the System property used to select scripting language
-    private static final String LANGUAGE_KEY = "com.sun.demo.jconsole.console.language";
-
-    private String getScriptLanguage() {
-        // check whether explicit System property is set
-        String lang = System.getProperty(LANGUAGE_KEY);
-        if (lang == null) {
-            // default is JavaScript
-            lang = "JavaScript";
-        }
-        return lang;
-    }
-
-    // create Bindings that is backed by a synchronized HashMap
-    private Bindings createBindings() {
-        Map<String, Object> map =
-                Collections.synchronizedMap(new HashMap<String, Object>());
-        return new SimpleBindings(map);
-    }
-
-    // create and initialize script engine
-    private void initScriptEngine() {
-        // set pre-defined global variables
-        setGlobals();
-        // load pre-defined initialization file
-        loadInitFile();
-        // load current user's initialization file
-        loadUserInitFile();
-    }
-
-    // set pre-defined global variables for script
-    private void setGlobals() {
-        engine.put("engine", engine);
-        engine.put("window", window);
-        engine.put("plugin", this);
-    }
-
-    // load initial script file (jconsole.<extension>)
-    private void loadInitFile() {
-        String oldFilename = (String) engine.get(ScriptEngine.FILENAME);
-        engine.put(ScriptEngine.FILENAME, "<built-in jconsole." + extension + ">");
-        try {
-            Class<? extends ScriptJConsolePlugin> myClass = this.getClass();
-            InputStream stream = myClass.getResourceAsStream("/resources/jconsole." +
-                                       extension);
-            if (stream != null) {
-                engine.eval(new InputStreamReader(new BufferedInputStream(stream)));
-            }
-        } catch (Exception exp) {
-            exp.printStackTrace();
-            // FIXME: What else I can do here??
-        } finally {
-            engine.put(ScriptEngine.FILENAME, oldFilename);
-        }
-    }
-
-    // load user's initial script file (~/jconsole.<extension>)
-    private void loadUserInitFile() {
-        String oldFilename = (String) engine.get(ScriptEngine.FILENAME);
-        String home = System.getProperty("user.home");
-        if (home == null) {
-            // no user.home?? should not happen??
-            return;
-        }
-        String fileName = home + File.separator + "jconsole." + extension;
-        if (! (new File(fileName).exists())) {
-            // user does not have ~/jconsole.<extension>
-            return;
-        }
-        engine.put(ScriptEngine.FILENAME, fileName);
-        try {
-            engine.eval(new FileReader(fileName));
-        } catch (Exception exp) {
-            exp.printStackTrace();
-            // FIXME: What else I can do here??
-        } finally {
-            engine.put(ScriptEngine.FILENAME, oldFilename);
-        }
-    }
-}
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/ScriptShellPanel.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.demo.scripting.jconsole;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.text.*;
-
-
-/**
- * A JPanel subclass containing a scrollable text area displaying the
- * jconsole's script console.
- */
-
-public class ScriptShellPanel extends JPanel {
-
-    private static final long serialVersionUID = 4116273141148726319L;
-
-    // interface to evaluate script command and script prompt
-    interface CommandProcessor {
-        // execute given String as script and return the result
-        public String executeCommand(String cmd);
-        // get prompt used for interactive read-eval-loop
-        public String getPrompt();
-    }
-
-    // my script command processor
-    private CommandProcessor commandProcessor;
-    // editor component for command editing
-    private JTextComponent editor;
-
-    private final ExecutorService commandExecutor =
-            Executors.newSingleThreadExecutor();
-
-    // document management
-    private boolean updating;
-
-    public ScriptShellPanel(CommandProcessor cmdProc) {
-        setLayout(new BorderLayout());
-        this.commandProcessor = cmdProc;
-        this.editor = new JTextArea();
-        editor.setDocument(new EditableAtEndDocument());
-        JScrollPane scroller = new JScrollPane();
-        scroller.getViewport().add(editor);
-        add(scroller, BorderLayout.CENTER);
-
-        editor.getDocument().addDocumentListener(new DocumentListener() {
-            @Override
-            public void changedUpdate(DocumentEvent e) {
-            }
-
-            @Override
-            public void insertUpdate(DocumentEvent e) {
-                if (updating) return;
-                beginUpdate();
-                editor.setCaretPosition(editor.getDocument().getLength());
-                if (insertContains(e, '\n')) {
-                    String cmd = getMarkedText();
-                    // Handle multi-line input
-                    if ((cmd.length() == 0) ||
-                        (cmd.charAt(cmd.length() - 1) != '\\')) {
-                        // Trim "\\n" combinations
-                        final String cmd1 = trimContinuations(cmd);
-                        commandExecutor.execute(new Runnable() {
-                            @Override
-                            public void run() {
-                                final String result = executeCommand(cmd1);
-
-                                SwingUtilities.invokeLater(new Runnable() {
-                                    @Override
-                                    public void run() {
-                                        if (result != null) {
-                                            print(result + "\n");
-                                        }
-                                        printPrompt();
-                                        setMark();
-                                        endUpdate();
-                                    }
-                                });
-                            }
-                        });
-                    } else {
-                        endUpdate();
-                    }
-                } else {
-                    endUpdate();
-                }
-            }
-
-            @Override
-            public void removeUpdate(DocumentEvent e) {
-            }
-        });
-
-        // This is a bit of a hack but is probably better than relying on
-        // the JEditorPane to update the caret's position precisely the
-        // size of the insertion
-        editor.addCaretListener(new CaretListener() {
-            @Override
-            public void caretUpdate(CaretEvent e) {
-                int len = editor.getDocument().getLength();
-                if (e.getDot() > len) {
-                    editor.setCaretPosition(len);
-                }
-            }
-        });
-
-        Box hbox = Box.createHorizontalBox();
-        hbox.add(Box.createGlue());
-        JButton button = new JButton("Clear"); // FIXME: i18n?
-        button.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                clear();
-            }
-        });
-        hbox.add(button);
-        hbox.add(Box.createGlue());
-        add(hbox, BorderLayout.SOUTH);
-
-        clear();
-    }
-
-    public void dispose() {
-        commandExecutor.shutdown();
-    }
-
-    @Override
-    public void requestFocus() {
-        editor.requestFocus();
-    }
-
-    public void clear() {
-        clear(true);
-    }
-
-    public void clear(boolean prompt) {
-        EditableAtEndDocument d = (EditableAtEndDocument) editor.getDocument();
-        d.clear();
-        if (prompt) printPrompt();
-        setMark();
-        editor.requestFocus();
-    }
-
-    public void setMark() {
-        ((EditableAtEndDocument) editor.getDocument()).setMark();
-    }
-
-    public String getMarkedText() {
-        try {
-            String s = ((EditableAtEndDocument) editor.getDocument()).getMarkedText();
-            int i = s.length();
-            while ((i > 0) && (s.charAt(i - 1) == '\n')) {
-                i--;
-            }
-            return s.substring(0, i);
-        } catch (BadLocationException e) {
-            e.printStackTrace();
-            return null;
-        }
-    }
-
-    public void print(String s) {
-        Document d = editor.getDocument();
-        try {
-            d.insertString(d.getLength(), s, null);
-        } catch (BadLocationException e) {
-            e.printStackTrace();
-        }
-    }
-
-
-    //
-    // Internals only below this point
-    //
-
-    private String executeCommand(String cmd) {
-        return commandProcessor.executeCommand(cmd);
-    }
-
-    private String getPrompt() {
-        return commandProcessor.getPrompt();
-    }
-
-    private void beginUpdate() {
-        editor.setEditable(false);
-        updating = true;
-    }
-
-    private void endUpdate() {
-        editor.setEditable(true);
-        updating = false;
-    }
-
-    private void printPrompt() {
-        print(getPrompt());
-    }
-
-    private boolean insertContains(DocumentEvent e, char c) {
-        String s = null;
-        try {
-            s = editor.getText(e.getOffset(), e.getLength());
-            for (int i = 0; i < e.getLength(); i++) {
-                if (s.charAt(i) == c) {
-                    return true;
-                }
-            }
-        } catch (BadLocationException ex) {
-            ex.printStackTrace();
-        }
-        return false;
-    }
-
-    private String trimContinuations(String text) {
-        int i;
-        while ((i = text.indexOf("\\\n")) >= 0) {
-            text = text.substring(0, i) + text.substring(i+1, text.length());
-        }
-        return text;
-    }
-}
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/resources/jconsole.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,891 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- *  list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- *  this list of conditions and the following disclaimer in the documentation
- *  and/or other materials provided with the distribution.
- *
- * Neither the name of Oracle nor the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
-
-// This function depends on the pre-defined variable
-// "plugin" of type com.sun.tools.jconsole.JConsolePlugin
-
-function jcontext() {
-    return plugin.getContext();
-}
-jcontext.docString = "returns JConsoleContext for the current jconsole plugin";
-
-function mbeanConnection() {
-    return jcontext().getMBeanServerConnection();
-}
-mbeanConnection.docString = "returns current MBeanServer connection";
-
-// check if there is a build in sync function, define one if missing
-if (typeof sync === "undefined") {
-    var sync = function(func, obj) {
-        if (arguments.length < 1 || arguments.length > 2 ) {
-            throw "sync(function [,object]) parameter count mismatch";
-        }
-
-        var syncobj = (arguments.length == 2 ? obj : this);
-
-        if (!syncobj._syncLock) {
-            syncobj._syncLock = new Lock();
-        }
-
-        return function() {
-            syncobj._syncLock.lock();
-            try {
-                func.apply(null, arguments);
-            } finally {
-                syncobj._syncLock.unlock();
-            }
-        };
-    };
-    sync.docString = "synchronize a function, optionally on an object";
-}
-
-/**
- * Prints one liner help message for each function exposed here
- * Note that this function depends on docString meta-data for
- * each function
- */
-function help() {
-    var i;
-    for (i in this) {
-        var func = this[i];
-        if (typeof(func) == "function" &&
-           ("docString" in func)) {
-            echo(i + " - " + func["docString"]);
-        }
-    }
-}
-help.docString = "prints help message for global functions";
-
-function connectionState() {
-    return jcontext().connectionState;
-}
-connectionState.docString = "return connection state of the current jcontext";
-
-/**
- * Returns a platform MXBean proxy for given MXBean name and interface class
- */
-function newPlatformMXBeanProxy(name, intf) {
-    var factory = java.lang.management.ManagementFactory;
-    return factory.newPlatformMXBeanProxy(mbeanConnection(), name, intf);
-}
-newPlatformMXBeanProxy.docString = "returns a proxy for a platform MXBean";
-
-/**
- * Wraps a string to ObjectName if needed.
- */
-function objectName(objName) {
-    var ObjectName = Packages.javax.management.ObjectName;
-    if (objName instanceof ObjectName) {
-        return objName;
-    } else {
-        return new ObjectName(objName);
-    }
-}
-objectName.docString = "creates JMX ObjectName for a given String";
-
-
-/**
- * Creates a new (M&M) Attribute object
- *
- * @param name name of the attribute
- * @param value value of the attribute
- */
-function attribute(name, value) {
-    var Attribute = Packages.javax.management.Attribute;
-    return new Attribute(name, value);
-}
-attribute.docString = "returns a new JMX Attribute using name and value given";
-
-/**
- * Returns MBeanInfo for given ObjectName. Strings are accepted.
- */
-function mbeanInfo(objName) {
-    objName = objectName(objName);
-    return mbeanConnection().getMBeanInfo(objName);
-}
-mbeanInfo.docString = "returns MBeanInfo of a given ObjectName";
-
-/**
- * Returns ObjectInstance for a given ObjectName.
- */
-function objectInstance(objName) {
-    objName = objectName(objName);
-    return mbeanConnection().objectInstance(objectName);
-}
-objectInstance.docString = "returns ObjectInstance for a given ObjectName";
-
-/**
- * Queries with given ObjectName and QueryExp.
- * QueryExp may be null.
- *
- * @return set of ObjectNames.
- */
-function queryNames(objName, query) {
-    objName = objectName(objName);
-    if (query == undefined) query = null;
-    return mbeanConnection().queryNames(objName, query);
-}
-queryNames.docString = "returns QueryNames using given ObjectName and optional query";
-
-
-/**
- * Queries with given ObjectName and QueryExp.
- * QueryExp may be null.
- *
- * @return set of ObjectInstances.
- */
-function queryMBeans(objName, query) {
-    objName = objectName(objName);
-    if (query == undefined) query = null;
-    return mbeanConnection().queryMBeans(objName, query);
-}
-queryMBeans.docString = "return MBeans using given ObjectName and optional query";
-
-// wraps a script array as java.lang.Object[]
-function objectArray(array) {
-    return Java.to(array, "java.lang.Object[]");
-}
-
-// wraps a script (string) array as java.lang.String[]
-function stringArray(array) {
-    return Java.to(array, "java.lang.String[]");
-}
-
-// script array to Java List
-function toAttrList(array) {
-    var AttributeList = Packages.javax.management.AttributeList;
-    if (array instanceof AttributeList) {
-        return array;
-    }
-    var list = new AttributeList(array.length);
-    for (var index = 0; index < array.length; index++) {
-        list.add(array[index]);
-    }
-    return list;
-}
-
-// Java Collection (Iterable) to script array
-function toArray(collection) {
-    if (collection instanceof Array) {
-        return collection;
-    }
-    var itr = collection.iterator();
-    var array = new Array();
-    while (itr.hasNext()) {
-        array[array.length] = itr.next();
-    }
-    return array;
-}
-
-// gets MBean attributes
-function getMBeanAttributes(objName, attributeNames) {
-    objName = objectName(objName);
-    return mbeanConnection().getAttributes(objName,stringArray(attributeNames));
-}
-getMBeanAttributes.docString = "returns specified Attributes of given ObjectName";
-
-// gets MBean attribute
-function getMBeanAttribute(objName, attrName) {
-    objName = objectName(objName);
-    return mbeanConnection().getAttribute(objName, attrName);
-}
-getMBeanAttribute.docString = "returns a single Attribute of given ObjectName";
-
-
-// sets MBean attributes
-function setMBeanAttributes(objName, attrList) {
-    objName = objectName(objName);
-    attrList = toAttrList(attrList);
-    return mbeanConnection().setAttributes(objName, attrList);
-}
-setMBeanAttributes.docString = "sets specified Attributes of given ObjectName";
-
-// sets MBean attribute
-function setMBeanAttribute(objName, attrName, attrValue) {
-    var Attribute = Packages.javax.management.Attribute;
-    objName = objectName(objName);
-    mbeanConnection().setAttribute(objName, new Attribute(attrName, attrValue));
-}
-setMBeanAttribute.docString = "sets a single Attribute of given ObjectName";
-
-
-// invokes an operation on given MBean
-function invokeMBean(objName, operation, params, signature) {
-    objName = objectName(objName);
-    params = objectArray(params);
-    signature = stringArray(signature);
-    return mbeanConnection().invoke(objName, operation, params, signature);
-}
-invokeMBean.docString = "invokes MBean operation on given ObjectName";
-
-/**
- * Wraps a MBean specified by ObjectName as a convenient
- * script object -- so that setting/getting MBean attributes
- * and invoking MBean method can be done with natural syntax.
- *
- * @param objName ObjectName of the MBean
- * @param async asynchornous mode [optional, default is false]
- * @return script wrapper for MBean
- *
- * With async mode, all field, operation access is async. Results
- * will be of type FutureTask. When you need value, call 'get' on it.
- */
-function mbean(objName, async) {
-    var index;
-
-    objName = objectName(objName);
-    var info = mbeanInfo(objName);
-    var attrs = info.attributes;
-    var attrMap = new Object;
-    for (index in attrs) {
-        attrMap[attrs[index].name] = attrs[index];
-    }
-    var opers = info.operations;
-    var operMap = new Object;
-    for (index in opers) {
-        operMap[opers[index].name] = opers[index];
-    }
-
-    function isAttribute(name) {
-        return name in attrMap;
-    }
-
-    function isOperation(name) {
-        return name in operMap;
-    }
-
-    return new JSAdapter() {
-        __has__: function (name) {
-            return isAttribute(name) || isOperation(name);
-        },
-        __get__: function (name) {
-            if (isAttribute(name)) {
-                if (async) {
-                    return getMBeanAttribute.future(objName, name); 
-                } else {
-                    return getMBeanAttribute(objName, name); 
-                }
-            } else {
-                return undefined;
-            }
-        },
-        __call__: function(name) {
-            if (isOperation(name)) {
-                var oper = operMap[name];
-
-                var params = [];
-                for (var j = 1; j < arguments.length; j++) {
-                    params[j-1]= arguments[j];
-                }
-
-                var sigs = oper.signature;
-
-                var sigNames = new Array(sigs.length);
-                for (var index in sigs) {
-                    sigNames[index] = sigs[index].getType();
-                }
-
-                if (async) {
-                    return invokeMBean.future(objName, name, params, sigNames);
-                } else {
-                    return invokeMBean(objName, name, params, sigNames);
-                }
-            } else {
-                return undefined;
-            }
-        },
-        __put__: function (name, value) {
-            if (isAttribute(name)) {
-                if (async) {
-                    setMBeanAttribute.future(objName, name, value);
-                } else {
-                    setMBeanAttribute(objName, name, value);
-                }
-            } else {
-                return undefined;
-            }
-        }
-    };
-}
-mbean.docString = "returns a conveninent script wrapper for a MBean of given ObjectName";
-
-/**
- * load and evaluate script file. If no script file is
- * specified, file dialog is shown to choose the script.
- *
- * @param file script file name [optional]
- * @return value returned from evaluating script
- */
-function load(file) {
-    if (file == undefined || file == null) {
-        // file not specified, show file dialog to choose
-        file = fileDialog();
-    }
-    if (file == null) return;
-
-    var reader = new java.io.FileReader(file);
-    var oldFilename = engine.get(engine.FILENAME);
-    engine.put(engine.FILENAME, file);
-    try {
-        engine.eval(reader);
-    } finally {
-        engine.put(engine.FILENAME, oldFilename);
-    }
-    reader.close();
-}
-load.docString = "loads a script file and evaluates it";
-
-/**
- * Concurrency utilities for JavaScript. These are based on
- * java.lang and java.util.concurrent API. The following functions 
- * provide a simpler API for scripts. Instead of directly using java.lang
- * and java.util.concurrent classes, scripts can use functions and
- * objects exported from here. 
- */
-
-/**
- * Wrapper for java.lang.Object.wait
- *
- * can be called only within a sync method
- */
-function wait(object) {
-    var objClazz = java.lang.Class.forName('java.lang.Object');
-    var waitMethod = objClazz.getMethod('wait', null);
-    waitMethod.invoke(object, null);
-}
-wait.docString = "convenient wrapper for java.lang.Object.wait method";
-
-
-/**
- * Wrapper for java.lang.Object.notify
- *
- * can be called only within a sync method
- */
-function notify(object) {
-    var objClazz = java.lang.Class.forName('java.lang.Object');
-    var notifyMethod = objClazz.getMethod('notify', null);
-    notifyMethod.invoke(object, null);
-}
-notify.docString = "convenient wrapper for java.lang.Object.notify method";
-
-
-/**
- * Wrapper for java.lang.Object.notifyAll
- *
- * can be called only within a sync method
- */
-function notifyAll(object)  {
-    var objClazz = java.lang.Class.forName('java.lang.Object');
-    var notifyAllMethod = objClazz.getMethod('notifyAll', null);
-    notifyAllMethod.invoke(object, null);
-}
-notifyAll.docString = "convenient wrapper for java.lang.Object.notifyAll method";
-
-
-/**
- * Creates a java.lang.Runnable from a given script
- * function.
- */
-Function.prototype.runnable = function() {
-    var args = arguments;
-    var func = this;
-    return new java.lang.Runnable() {
-        run: function() {
-            func.apply(null, args);
-        }
-    }
-}
-
-/**
- * Executes the function on a new Java Thread.
- */
-Function.prototype.thread = function() {
-    var t = new java.lang.Thread(this.runnable.apply(this, arguments));
-    t.start();
-    return t;
-}
-
-/**
- * Executes the function on a new Java daemon Thread.
- */
-Function.prototype.daemon = function() {
-    var t = new java.lang.Thread(this.runnable.apply(this, arguments));
-    t.setDaemon(true);
-    t.start();
-    return t;
-}
-
-/**
- * Creates a java.util.concurrent.Callable from a given script
- * function.
- */
-Function.prototype.callable = function() {
-    var args = arguments;
-    var func = this;
-    return new java.util.concurrent.Callable() {
-          call: function() { return func.apply(null, args); }
-    }
-}
-
-/**
- * Registers the script function so that it will be called exit.
- */
-Function.prototype.atexit = function () {
-    var args = arguments;
-    java.lang.Runtime.getRuntime().addShutdownHook(
-         new java.lang.Thread(this.runnable.apply(this, args)));
-}
-
-/**
- * Executes the function asynchronously.  
- *
- * @return a java.util.concurrent.FutureTask
- */
-Function.prototype.future = (function() {
-    // default executor for future
-    var juc = java.util.concurrent;
-    var theExecutor = juc.Executors.newSingleThreadExecutor();
-    // clean-up the default executor at exit
-    (function() { theExecutor.shutdown(); }).atexit();
-    return function() {
-        return theExecutor.submit(this.callable.apply(this, arguments));
-    }
-})();
-
-// shortcut for j.u.c lock classes
-var Lock = java.util.concurrent.locks.ReentrantLock;
-var RWLock = java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- * Executes a function after acquiring given lock. On return,
- * (normal or exceptional), lock is released.
- *
- * @param lock lock that is locked and unlocked
- */
-Function.prototype.sync = function (lock) {
-    if (arguments.length == 0) {
-        throw "lock is missing";
-    }
-    var res = new Array(arguments.length - 1);
-    for (var i = 0; i < res.length; i++) {
-        res[i] = arguments[i + 1];
-    }
-    lock.lock();
-    try {
-        this.apply(null, res);
-    } finally {
-        lock.unlock();
-    }
-};
-
-/**
- * Causes current thread to sleep for specified
- * number of milliseconds
- *
- * @param interval in milliseconds
- */
-function sleep(interval) {
-    java.lang.Thread.sleep(interval);
-}
-sleep.docString = "wrapper for java.lang.Thread.sleep method";
-
-/**
- * Schedules a task to be executed once in N milliseconds specified.
- *
- * @param callback function or expression to evaluate
- * @param interval in milliseconds to sleep
- * @return timeout ID (which is nothing but Thread instance)
- */
-function setTimeout(callback, interval) {
-    if (! (callback instanceof Function)) {
-        callback = new Function(callback);
-    }
-
-    // start a new thread that sleeps given time
-    // and calls callback in an infinite loop
-    return (function() {
-         try {
-             sleep(interval);
-         } catch (x) { }
-         callback();
-    }).daemon();
-}
-setTimeout.docString = "calls given callback once after specified interval";
-
-/**
- * Cancels a timeout set earlier.
- * @param tid timeout ID returned from setTimeout
- */
-function clearTimeout(tid) {
-    // we just interrupt the timer thread
-    tid.interrupt();
-}
-clearTimeout.docString = "interrupt a setTimeout timer";
-
-/**
- * Schedules a task to be executed once in
- * every N milliseconds specified.
- *
- * @param callback function or expression to evaluate
- * @param interval in milliseconds to sleep
- * @return timeout ID (which is nothing but Thread instance)
- */
-function setInterval(callback, interval) {
-    if (! (callback instanceof Function)) {
-        callback = new Function(callback);
-    }
-
-    // start a new thread that sleeps given time
-    // and calls callback in an infinite loop
-    return (function() {
-         while (true) {
-             try {
-                 sleep(interval);
-             } catch (x) {
-                 break;
-             }
-             callback();
-         }
-    }).daemon();
-}
-setInterval.docString = "calls given callback every specified interval";
-
-/**
- * Cancels a timeout set earlier.
- * @param tid timeout ID returned from setTimeout
- */
-function clearInterval(tid) {
-    // we just interrupt the timer thread
-    tid.interrupt();
-}
-clearInterval.docString = "interrupt a setInterval timer";
-
-/**
- * Simple access to thread local storage. 
- *
- * Script sample:
- *
- *  __thread.x = 44;
- *  function f() { 
- *      __thread.x = 'hello'; 
- *      print(__thread.x); 
- *  }
- *  f.thread();       // prints 'hello'
- * print(__thread.x); // prints 44 in main thread
- */
-var __thread = (function () {
-    var map = new Object();
-    return new JSAdapter() {
-        __has__: function(name) {
-            return map[name] != undefined;
-        },
-        __get__: function(name) {
-            if (map[name] != undefined) {
-                return map[name].get();
-            } else {
-                return undefined;
-            }
-        },
-        __put__: sync(function(name, value) {
-            if (map[name] == undefined) {
-                var tmp = new java.lang.ThreadLocal();
-                tmp.set(value);
-                map[name] = tmp;
-            } else {
-                map[name].set(value);
-            }
-        }),
-        __delete__: function(name) {
-            if (map[name] != undefined) {
-                map[name].set(null);
-            }            
-        }
-    }
-})();
-
-// user interface utilities
-
-/** 
- * Swing invokeLater - invokes given function in AWT event thread
- */
-Function.prototype.invokeLater = function() {
-    var SwingUtilities = Packages.javax.swing.SwingUtilities;
-    SwingUtilities.invokeLater(this.runnable.apply(this, arguments));
-}
-
-/** 
- * Swing invokeAndWait - invokes given function in AWT event thread
- * and waits for it's completion
- */
-Function.prototype.invokeAndWait = function() {
-    var SwingUtilities = Packages.javax.swing.SwingUtilities;
-    SwingUtilities.invokeAndWait(this.runnable.apply(this, arguments));
-}
-
-/**
- * Am I running in AWT event dispatcher thread?
- */
-function isEventThread() {
-    var SwingUtilities = Packages.javax.swing.SwingUtilities;
-    return SwingUtilities.isEventDispatchThread();
-}
-isEventThread.docString = "returns whether the current thread is GUI thread";
-
-/**
- * Opens a file dialog box 
- *
- * @param curDir current directory [optional]
- * @return absolute path if file selected or else null
- */
-function fileDialog(curDir) {
-    var result;
-    function _fileDialog() {
-        if (curDir == undefined) curDir = undefined;
-        var JFileChooser = Packages.javax.swing.JFileChooser;
-        var dialog = new JFileChooser(curDir);
-        var res = dialog.showOpenDialog(null);
-        if (res == JFileChooser.APPROVE_OPTION) {
-            result = dialog.getSelectedFile().getAbsolutePath();
-        } else {
-           result = null;
-        }
-    }
-
-    if (isEventThread()) {
-        _fileDialog();
-    } else {
-        _fileDialog.invokeAndWait();
-    }
-    return result;
-}
-fileDialog.docString = "show a FileOpen dialog box";
-
-/**
- * Shows a message box
- *
- * @param msg message to be shown
- * @param title title of message box [optional]
- * @param msgType type of message box [constants in JOptionPane]
- */
-function msgBox(msg, title, msgType) {
-   
-    function _msgBox() { 
-        var JOptionPane = Packages.javax.swing.JOptionPane;
-        if (msg === undefined) msg = "undefined";
-        if (msg === null) msg = "null";
-        if (title == undefined) title = msg;
-        if (msgType == undefined) msgType = JOptionPane.INFORMATION_MESSAGE;
-        JOptionPane.showMessageDialog(window, msg, title, msgType);
-    }
-    if (isEventThread()) {
-        _msgBox();
-    } else {
-        _msgBox.invokeAndWait();
-    }
-}
-msgBox.docString = "shows MessageBox to the user";
- 
-/**
- * Shows an information alert box
- *
- * @param msg message to be shown
- * @param title title of message box [optional]
- */   
-function alert(msg, title) {
-    var JOptionPane = Packages.javax.swing.JOptionPane;
-    msgBox(msg, title, JOptionPane.INFORMATION_MESSAGE);
-}
-alert.docString = "shows an alert message box to the user";
-
-/**
- * Shows an error alert box
- *
- * @param msg message to be shown
- * @param title title of message box [optional]
- */
-function error(msg, title) {
-    var JOptionPane = Packages.javax.swing.JOptionPane;
-    msgBox(msg, title, JOptionPane.ERROR_MESSAGE);
-}
-error.docString = "shows an error message box to the user";
-
-
-/**
- * Shows a warning alert box
- *
- * @param msg message to be shown
- * @param title title of message box [optional]
- */
-function warn(msg, title) {
-    var JOptionPane = Packages.javax.swing.JOptionPane;
-    msgBox(msg, title, JOptionPane.WARNING_MESSAGE);
-}
-warn.docString = "shows a warning message box to the user";
-
-
-/**
- * Shows a prompt dialog box
- *
- * @param question question to be asked
- * @param answer default answer suggested [optional]
- * @return answer given by user
- */
-function prompt(question, answer) {
-    var result;
-    function _prompt() {
-        var JOptionPane = Packages.javax.swing.JOptionPane;
-        if (answer == undefined) answer = "";
-        result = JOptionPane.showInputDialog(window, question, answer);
-    }
-    if (isEventThread()) {
-        _prompt();
-    } else {
-        _prompt.invokeAndWait();
-    }
-    return result;
-}
-prompt.docString = "shows a prompt box to the user and returns the answer";
-
-/**
- * Shows a confirmation dialog box
- *
- * @param msg message to be shown
- * @param title title of message box [optional]
- * @return boolean (yes->true, no->false)
- */
-function confirm(msg, title) {
-    var result;
-    var JOptionPane = Packages.javax.swing.JOptionPane;
-    function _confirm() {
-        if (title == undefined) title = msg;
-        var optionType = JOptionPane.YES_NO_OPTION;
-        result = JOptionPane.showConfirmDialog(null, msg, title, optionType);
-    }
-    if (isEventThread()) {
-        _confirm();
-    } else {
-        _confirm.invokeAndWait();
-    }     
-    return result == JOptionPane.YES_OPTION;
-}
-confirm.docString = "shows a confirmation message box to the user";
-
-/**
- * Echoes zero or more arguments supplied to screen.
- * This is print equivalent for GUI.
- *
- * @param zero or more items to echo.
- */
-function echo() {
-    var args = arguments;
-    (function() {
-        var len = args.length;
-        for (var i = 0; i < len; i++) {
-            window.print(args[i]);
-            window.print(" ");
-        }
-        window.print("\n");
-    }).invokeLater();
-}
-echo.docString = "echoes arguments to interactive console screen";
-
-
-/**
- * Clear the screen
- */
-function clear() {
-    (function() { window.clear(false); }).invokeLater();
-}
-clear.docString = "clears interactive console screen";
-
-
-// synonym for clear
-var cls = clear;
-
-
-/**
- * Exit the process after confirmation from user 
- * 
- * @param exitCode return code to OS [optional]
- */
-function exit(exitCode) {
-    if (exitCode == undefined) exitCode = 0;
-    if (confirm("Do you really want to exit?")) {
-        java.lang.System.exit(exitCode);
-    } 
-}
-exit.docString = "exits jconsole";
-
-// synonym to exit
-var quit = exit;
-
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/heapdump.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- * This file defines heapdump function to heap dump
- * in binary format. User can call this function
- * based on events. For example, a timer thread can
- * keep checking heap threshold and depending on 
- * specific expected threshold value, it can call
- * heapdump to dump the keep. File name can contain
- * timestamp so that multiple heapdumps can be generated
- * for the same process.
- */
-
-/**
- * Function to dump heap in binary format.
- *
- * @param file heap dump file name [optional]
- */
-function heapdump(file) {
-    // no file specified, show file open dialog
-    if (file == undefined) {
-        file = fileDialog();
-        // check whether user cancelled the dialog
-        if (file == null) return;
-    }
-
-    /* 
-     * Get HotSpotDiagnostic MBean and wrap it as convenient
-     * script wrapper using 'mbean' function. Instead of using
-     * MBean proxies 'mbean' function creates a script wrapper 
-     * that provides similar convenience but uses explicit 
-     * invocation behind the scene. This implies that mbean 
-     * wrapper would the same for dynamic MBeans as well.
-     */
-    var diagBean = mbean("com.sun.management:type=HotSpotDiagnostic");
-
-    // dump the heap in the file
-    diagBean.dumpHeap(file, true);
-}
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/hello.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- * This is sample JavaScript file that can be loaded into script console.
- * This file prints "hello, world".
- */
-
-echo("hello, world");
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/invoke.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- * This script demonstrates "invokeMBean" function. Instead 
- * of using MXBean proxy or script wrapper object returned by
- * 'mbean' function, this file uses direct invoke on MBean.
- *
- * To use this particular script, load this script file in
- * script console prompt and call resetPeakThreadCount().
-
- */
-
-/**
- * Resets the peak thread count to the current number of live threads.
- *
- */
-function resetPeakThreadCount() {
-    return invokeMBean("java.lang:type=Threading", "resetPeakThreadCount", [], {});    
-}
-
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/jstack.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- * This file defines 'jstack' function to print stack traces of
- * threads.'jstack' function which can be called once or periodically 
- * from a timer thread (calling it periodically would slow down the target
- * application). To call this once, just call 'jstack()' in script
- * console prompt. To call jstack in a timer thread, you can use
- *
- *     var t = setInterval(function () { jstack(print); }, 5000);
- *
- * The above call prints threads in sorted order for every 5 seconds.
- * The print output goes to OS console window from which jconsole was 
- * started. The timer can be cancelled later by clearTimeout() function
- * as shown below:
- * 
- *     clearInterval(t);
- */
-
-
-/**
- * print given ThreadInfo using given printFunc
- */
-function printThreadInfo(ti, printFunc) {
-    printFunc(ti.threadId + " - " + ti.threadName + " - " + ti.threadState);
-    var stackTrace = ti.stackTrace;
-    for (var i in stackTrace) {
-        printFunc("\t" + stackTrace[i]);
-    }
-}
-
-/**
- * print stack traces of all threads. 
- *
- * @param printFunc function called to print [optional]
- * @param maxFrames maximum number of frames to print [optional]
- */
-function jstack(printFunc, maxFrames) {
-    // by default use 'echo' to print. Other choices could be
-    // 'print' or custom function that writes in a text file
-    if (printFunc == undefined) {
-        printFunc = echo;
-    }
-
-    // by default print 25 frames
-    if (maxFrames == undefined) {
-        maxFrames = 25;
-    }
-
-    var tmbean = newPlatformMXBeanProxy(
-        "java.lang:type=Threading",
-        java.lang.management.ThreadMXBean.class);
-
-    var tids = tmbean.allThreadIds;
-    var tinfos = tmbean["getThreadInfo(long[],int)"](tids, maxFrames);
-
-    for (var i in tinfos) {
-        printThreadInfo(tinfos[i], printFunc);
-    }
-}
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/jtop.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- * This code is "ported" from JTop demo. This file defines
- * 'jtop' function. jtop prints threads sorting by CPU time. 
- * jtop can be called once or periodically from a timer thread. 
- * To call this once, just call 'jtop()' in script console prompt. 
- * To call jtop in a timer thread, you can use
- *
- *     var t = setInterval(function () { jtop(print); }, 2000); 
- *
- * The above call prints threads in sorted order for every 2 seconds.
- * The print output goes to OS console window from which jconsole was 
- * started. The timer can be cancelled later by clearTimeout() function
- * as shown below:
- *
- *     clearInterval(t);
- */
-
-/**
- * This function returns a List of Map.Entry objects
- * in which each entry maps cpu time to ThreadInfo.
- */
-function getThreadList() {
-    var tmbean = newPlatformMXBeanProxy(
-        "java.lang:type=Threading",
-        java.lang.management.ThreadMXBean.class);
-
-    if (!tmbean.isThreadCpuTimeSupported()) {
-        return java.util.Collections.EMPTY_LIST;
-    }
-
-    tmbean.setThreadCpuTimeEnabled(true);
-
-    var tids = tmbean.allThreadIds;
-    var tinfos = tmbean["getThreadInfo(long[])"](tids);
-
-    var map = new java.util.TreeMap();
-    for (var i in tids) {
-        var cpuTime = tmbean.getThreadCpuTime(tids[i]);
-        if (cpuTime != -1 && tinfos[i] != null) {
-            map.put(cpuTime, tinfos[i]);
-        }
-    }
-    var list = new java.util.ArrayList(map.entrySet());
-    java.util.Collections.reverse(list);
-    return list;
-}
-
-/**
- * This function prints threads sorted by CPU time.
- *
- * @param printFunc function called back to print [optional]
- *
- * By default, it uses 'echo' function to print in screen.
- * Other choices could be 'print' (prints in console), 'alert'
- * to show message box. Or you can define a function that writes
- * the output to a text file.
- */ 
-function jtop(printFunc) {
-    if (printFunc == undefined) {
-        printFunc = echo;
-    }
-    var list = getThreadList();
-    var itr = list.iterator();
-    printFunc("time - state - name");
-    while (itr.hasNext()) {
-        var entry = itr.next();
-        // time is in nanoseconds - convert to seconds
-        var time = entry.key / 1.0e9;
-        var name = entry.value.threadName;
-        var state = entry.value.threadState;
-        printFunc(time + " - " + state + " - " + name); 
-    }
-}
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/sysprops.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- * This file defines 'sysprops' function to print Java System
- * properties.'sysprops' function which can be called once or periodically 
- * from a timer thread (calling it periodically would slow down the target
- * application). To call this once, just call 'sysprops()' in script
- * console prompt. To call sysprops in a timer thread, you can use
- *
- *     var t = setInterval(function () { sysprops(print); }, 5000);
- *
- * The above call prints threads in sorted order for every 5 seconds.
- * The print output goes to OS console window from which jconsole was 
- * started. The timer can be cancelled later by clearTimeout() function
- * as shown below:
- * 
- *     clearInterval(t);
- */
-
-
-/**
- * Returns System properties as a Map
- */
-function getSystemProps() {
-    var runtimeBean = newPlatformMXBeanProxy(
-                "java.lang:type=Runtime",
-                java.lang.management.RuntimeMXBean.class);
-    return runtimeBean.systemProperties;
-}
-
-/**
- * print System properties
- *
- * @param printFunc function called to print [optional]
- */
-function sysprops(printFunc) {
-    // by default use 'echo' to print. Other choices could be
-    // 'print' or custom function that writes in a text file
-    if (printFunc == undefined) {
-        printFunc = echo;
-    }
-
-    var map = getSystemProps();
-    var keys = map.keySet().iterator();
-    while (keys.hasNext()) {
-        var key = keys.next();
-        var value = map.get(key);
-        printFunc(key + "=" + value);
-    }
-}
--- a/jdk/src/demo/share/scripting/jconsole-plugin/src/scripts/verbose.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- * This script demonstrates "getMBeanAttribute"
- * and "setMBeanAttribute" functions. Instead of using
- * MXBean proxy or script wrapper object returned by
- * 'mbean' function, this file uses direct get/set MBean
- * attribute functions.
- *
- * To use this particular script, load this script file in
- * script console prompt and call verboseGC or verboseClass
- * functions. These functions based on events such as 
- * heap threshold crossing a given limit. i.e., A timer thread
- * can keep checking for threshold event and then turn on
- * verbose:gc or verbose:class based on expected event.
-
- */
-
-/**
- * Get or set verbose GC flag.
- *
- * @param flag verbose mode flag [optional]
- *
- * If flag is not passed verboseGC returns current
- * flag value.
- */
-function verboseGC(flag) {
-    if (flag == undefined) {
-        // no argument passed. interpret this as 'get'
-        return getMBeanAttribute("java.lang:type=Memory", "Verbose");    
-    } else {
-        return setMBeanAttribute("java.lang:type=Memory", "Verbose", flag);
-    }
-}
-
-/**
- * Get or set verbose class flag.
- *
- * @param flag verbose mode flag [optional]
- *
- * If flag is not passed verboseClass returns current
- * flag value.
- */
-function verboseClass(flag) {
-    if (flag == undefined) {
-        // no argument passed. interpret this as 'get'
-        return getMBeanAttribute("java.lang:type=ClassLoading", "Verbose");    
-    } else {
-        return setMBeanAttribute("java.lang:type=ClassLoading", "Verbose", flag);
-    }
-}
--- a/jdk/src/demo/solaris/jni/Poller/Client.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import  java.util.*;
-import  java.net.*;
-import  java.io.*;
-
-public class Client
-{
-  private final static int BYTESPEROP= PollingServer.BYTESPEROP;
-  private final static int PORTNUM   = PollingServer.PORTNUM;
-  private final static int MAXCONN   = PollingServer.MAXCONN;
-
-  private static Socket[] sockArr = new Socket[MAXCONN];
-  private static int totalConn =10;
-  private static int bytesToSend =1024000;
-  private static int connections = 0;
-  private static int sends = 0;
-
-  public static void main (String args[]) {
-
-    String host = "localhost";
-
-    if (args.length < 1 || args.length > 3) {
-      System.out.println("Usage : java Client <num_connects>");
-      System.out.println("      | java Client <num_connects> <server_name>");
-      System.out.println("      | java Client <num_connects> <server_name>" +
-                         " <max_Kbytes>");
-      System.exit(-1);
-    }
-
-    if (args.length >= 1)
-      totalConn = java.lang.Integer.valueOf(args[0]).intValue();
-    if (args.length >= 2)
-      host = args[1];
-    if (args.length == 3)
-      bytesToSend = java.lang.Integer.valueOf(args[2]).intValue() * 1024;
-
-
-    if (totalConn <= 0 || totalConn > MAXCONN) {
-      System.out.println("Connections out of range.  Terminating.");
-      System.exit(-1);
-    }
-
-    System.out.println("Using " + totalConn + " connections for sending " +
-                       bytesToSend + " bytes to " + host);
-
-
-    try {
-      Socket ctrlSock = new Socket (host, PORTNUM);
-      PrintStream ctrlStream =
-        new PrintStream(ctrlSock.getOutputStream());
-      ctrlStream.println(bytesToSend);
-      ctrlStream.println(totalConn);
-
-      while (connections < totalConn ) {
-        sockArr[connections] = new Socket (host, PORTNUM);
-        connections ++;
-      }
-      System.out.println("Connections made : " + connections);
-
-      byte[] buff = new byte[BYTESPEROP];
-      for (int i = 0; i < BYTESPEROP; i++) // just put some junk in!
-        buff[i] = (byte) i;
-
-      Random rand = new Random(5321L);
-      while (sends < bytesToSend/BYTESPEROP) {
-        int idx = java.lang.Math.abs(rand.nextInt()) % totalConn;
-        sockArr[idx].getOutputStream().write(buff,0,BYTESPEROP);
-        sends++;
-      }
-      // Wait for server to say done.
-      int bytes = ctrlSock.getInputStream().read(buff, 0, BYTESPEROP);
-      System.out.println (" Total connections : " + connections +
-                          " Bytes sent : " + sends * BYTESPEROP +
-                          "...Done!");
-    } catch (Exception e) { e.printStackTrace(); }
-  }
-}
--- a/jdk/src/demo/solaris/jni/Poller/LinkedQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
-  File: SLQ.java
-  Originally: LinkedQueue.java
-
-  Originally written by Doug Lea and released into the public domain.
-  This may be used for any purposes whatsoever without acknowledgment.
-  Thanks for the assistance and support of Sun Microsystems Labs,
-  and everyone contributing, testing, and using this code.
-
-  History:
-  Date       Who                What
-  11Jun1998  dl               Create public version
-  25aug1998  dl               added peek
-  10dec1998  dl               added isEmpty
-  10jun1999  bc               modified for isolated use
-*/
-
-// Original was in package EDU.oswego.cs.dl.util.concurrent;
-
-/**
- * A linked list based channel implementation,
- * adapted from the TwoLockQueue class from CPJ.
- * The algorithm avoids contention between puts
- * and takes when the queue is not empty.
- * Normally a put and a take can proceed simultaneously.
- * (Although it does not allow multiple concurrent puts or takes.)
- * This class tends to perform more efficently than
- * other Channel implementations in producer/consumer
- * applications.
- * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
- **/
-
-public class LinkedQueue {
-
-
-  /**
-   * Dummy header node of list. The first actual node, if it exists, is always
-   * at head_.next. After each take, the old first node becomes the head.
-   **/
-  protected LinkedNode head_;
-  protected int count_;
-  /**
-   * Helper monitor for managing access to last node, in case it is also first.
-   * last_ and waitingForTake_ ONLY used with synch on appendMonitor_
-   **/
-  protected final Object lastMonitor_ = new Object();
-
-  /**
-   * The last node of list. Put() appends to list, so modifies last_
-   **/
-  protected LinkedNode last_;
-
-  /**
-   * The number of threads waiting for a take.
-   * Notifications are provided in put only if greater than zero.
-   * The bookkeeping is worth it here since in reasonably balanced
-   * usages, the notifications will hardly ever be necessary, so
-   * the call overhead to notify can be eliminated.
-   **/
-  protected int waitingForTake_ = 0;
-
-  public LinkedQueue() {
-    head_ = new LinkedNode(null);
-    last_ = head_;
-    count_ = 0;
-  }
-
-  /** Main mechanics for put/offer **/
-  protected void insert(Object x) {
-    synchronized(lastMonitor_) {
-      LinkedNode p = new LinkedNode(x);
-      last_.next = p;
-      last_ = p;
-      count_++;
-      if (count_ > 1000 && (count_ % 1000 == 0))
-        System.out.println("In Queue : " + count_);
-      if (waitingForTake_ > 0)
-        lastMonitor_.notify();
-    }
-  }
-
-  /** Main mechanics for take/poll **/
-  protected synchronized Object extract() {
-    Object x = null;
-    LinkedNode first = head_.next;
-    if (first != null) {
-      x = first.value;
-      first.value = null;
-      head_ = first;
-      count_ --;
-    }
-    return x;
-  }
-
-
-  public void put(Object x) throws InterruptedException {
-    if (x == null) throw new IllegalArgumentException();
-    if (Thread.interrupted()) throw new InterruptedException();
-    insert(x);
-  }
-
-  public boolean offer(Object x, long msecs) throws InterruptedException {
-    if (x == null) throw new IllegalArgumentException();
-    if (Thread.interrupted()) throw new InterruptedException();
-    insert(x);
-    return true;
-  }
-
-  public Object take() throws InterruptedException {
-    if (Thread.interrupted()) throw new InterruptedException();
-    // try to extract. If fail, then enter wait-based retry loop
-    Object x = extract();
-    if (x != null)
-      return x;
-    else {
-      synchronized(lastMonitor_) {
-        try {
-          ++waitingForTake_;
-          for (;;) {
-            x = extract();
-            if (x != null) {
-              --waitingForTake_;
-              return x;
-            }
-            else {
-              lastMonitor_.wait();
-            }
-          }
-        }
-        catch(InterruptedException ex) {
-          --waitingForTake_;
-          lastMonitor_.notify();
-          throw ex;
-        }
-      }
-    }
-  }
-
-  public synchronized Object peek() {
-    LinkedNode first = head_.next;
-    if (first != null)
-      return first.value;
-    else
-      return null;
-  }
-
-
-  public synchronized boolean isEmpty() {
-    return head_.next == null;
-  }
-
-  public Object poll(long msecs) throws InterruptedException {
-    if (Thread.interrupted()) throw new InterruptedException();
-    Object x = extract();
-    if (x != null)
-      return x;
-    else {
-      synchronized(lastMonitor_) {
-        try {
-          long waitTime = msecs;
-          long start = (msecs <= 0)? 0 : System.currentTimeMillis();
-          ++waitingForTake_;
-          for (;;) {
-            x = extract();
-            if (x != null || waitTime <= 0) {
-              --waitingForTake_;
-              return x;
-            }
-            else {
-              lastMonitor_.wait(waitTime);
-              waitTime = msecs - (System.currentTimeMillis() - start);
-            }
-          }
-        }
-        catch(InterruptedException ex) {
-          --waitingForTake_;
-          lastMonitor_.notify();
-          throw ex;
-        }
-      }
-    }
-  }
-
-  class LinkedNode {
-    Object value;
-    LinkedNode next = null;
-    LinkedNode(Object x) { value = x; }
-    LinkedNode(Object x, LinkedNode n) { value = x; next = n; }
-  }
-}
--- a/jdk/src/demo/solaris/jni/Poller/Poller.c	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,753 +0,0 @@
-/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/*
- **********************************************************************
- * Poller.c :
- * JNI code for use with Poller.java, principally to take advantage
- * of poll() or /dev/poll multiplexing.
- *
- * One will need Solaris 8 or Solaris 7 with adequate patches to take
- * advantage of the /dev/poll performance enhancements, though any
- * version of Solaris 7 will automatically use the kernel poll()
- * caching.  And poll() will function in 2.5.1 and 2.6 as well, but
- * will not perform well for large numbers of file descriptors.
- *
- * Several assumptions have been made to simplify this code :
- *  1> At most MAX_HANDLES (32) separate pollable entities are currently
- *     supported.
- *  2> Global synchronization from Java is assumed for all init, create
- *     and destroy routines.  Per Object (handle passed in) synchronization
- *     is required for all AddFd, RemoveFd, IsMember, and Wait routines.
- *  3> It is currently up to the user to handle waking up an
- *     existing nativeWait() call to do an addfd or removefd on
- *     that set...could implement that here with an extra pipe, or
- *     with a pair of loopback sockets in Poller.java or user code.
- *     In most cases interruption is not necessary for deletions,
- *     so long as deletions are queued up outside the Poller class
- *     and then executed the next time waitMultiple() returns.
- *  4> /dev/poll performance could be slightly improved by coalescing
- *     adds/removes so that a write() is only done before the ioctl
- *     (DP_POLL), but this complicates exception handling and sees
- *     only modest performance gains so wasn't done.
- *  5> /dev/poll does not report errors on attempts to remove non-
- *     extant fds, but a future bug fix to the /dev/poll device driver
- *     should solve this problem.
- *  6> Could add simpler code for pre-Solaris 7 releases which will
- *     perform slightly better on those OSs.  But again there
- *     are only modest gains to be had from these new code paths,
- *     so they've been omitted here.
- *
- * Compile "cc -G -o <dest_dir>/libpoller.so -I ${JAVA_HOME}/include " \
- * -I ${JAVA_HOME}/include/solaris Poller.c" and place the <dest_dir>
- * in your LD_LIBRARY_PATH
- *
- **********************************************************************
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <poll.h>
-#include <malloc.h>
-#include <fcntl.h>
-
-
-/*
- * Remove "_NOT"s to turn on features
- * Append "_NOT" to turn off features.
- * Use of /dev/poll requires both the include file and kernel driver.
- */
-#define DEBUG_NOT
-#define DEVPOLL_NOT
-
-#ifdef DEVPOLL
-#include <sys/devpoll.h>
-#endif
-
-#include "Poller.h"
-
-#define MAX_HANDLES 32
-
-
-#ifdef DEBUG
-#define DBGMSG(x) printf x
-#define ASSERT(x) {if (!(x)) \
-                   printf("assertion(%s) failed at line : %d\n",#x,__LINE__);}
-#define CHECK_HANDLE(x) check_handle(x)
-#else
-#define DBGMSG(x)
-#define ASSERT(x)
-#define CHECK_HANDLE(x)
-#endif
-
-/*
- * Globals ...protect all with a global synchronization object.
- */
-
-static int Current_handle = 0;
-static int Use_devpoll = 0;
-static int Max_index = 0;
-
-/*
- * Per Poller object data.
- * Must be synchronized on a per Poller object basis.
- */
-
-typedef struct ioevent {
-  int inuse;
-  int devpollfd;
-  int last_index;
-  int total_free;
-  int left_events;
-  int max_index;
-  pollfd_t *pfd;
-} ioevent_t;
-
-static ioevent_t IOE_handles[MAX_HANDLES];
-
-/*
- * Exceptions to be thrown.
- * Note : assuming all illegal argument and NULL pointer checks
- *        have already been done by the Java calling methods.
- */
-static jint throwOutOfMemoryError(JNIEnv *env, const char * cause)
-{
-  (*env)->ThrowNew(env, (*env)->FindClass(env,"java/lang/OutOfMemoryError"),
-                   cause);
-  return -1;
-}
-static jint throwInterruptedIOException(JNIEnv *env, const char * cause)
-{
-  (*env)->ThrowNew(env,
-                   (*env)->FindClass(env,"java/io/InterruptedIOException"),
-                   cause);
-  return -1;
-}
-static jint throwIllegalStateException(JNIEnv *env, const char * cause)
-{
-  (*env)->ThrowNew(env,
-                   (*env)->FindClass(env,"java/lang/IllegalStateException"),
-                   cause);
-  return -1;
-}
-
-#define MEMORY_EXCEPTION(str) throwOutOfMemoryError(env, "Poller:" str)
-#define STATE_EXCEPTION(str)  throwIllegalStateException(env, "Poller:" str)
-#define INTERRUPT_EXCEPTION(str) throwInterruptedIOException(env, \
-                                                             "Poller:" str)
-jint addfd(JNIEnv *, ioevent_t *, jint, jshort);
-jint removefd(JNIEnv *, ioevent_t *, jint);
-
-/*
- * Class Poller
- * Method: nativeInit
- * Signature: ()I
- *
- * Only to be called once, right after this library is loaded,
- * so no need to deal with reentrancy here.
- * Could do as a pragma ini, but that isn't as portable.
- */
-JNIEXPORT jint JNICALL Java_Poller_nativeInit(JNIEnv *env, jclass cls)
-{
-  int testdevpollfd;
-  int i;
-
-#ifdef DEVPOLL
-  /*
-   * See if we can use this much faster method
-   * Note : must have fix for BUGID # 4223353 or OS can crash!
-   */
-  testdevpollfd = open("/dev/poll",O_RDWR);
-  if (testdevpollfd >= 0) {
-    /*
-     * If Solaris 7, we need a patch
-     * Until we know what string to search for, we'll play it
-     * safe and disable this for Solaris 7.
-     */
-
-    if (!strcmp(name.release,"5.7"))
-      {
-        Use_devpoll = 0;
-      }
-    else
-      {
-        Use_devpoll = 1;
-      }
-  }
-
-  DBGMSG(("Use_devpoll=%d\n" ,Use_devpoll));
-  close(testdevpollfd);
-#endif
-
-  /*
-   * For now, we optimize for Solaris 7 if /dev/poll isn't
-   * available, as it is only a small % hit for Solaris < 7.
-   * if ( (Use_devpoll == 0) && !strcmp(name.release,"5.6") )
-   *      Use_sol7opt = 0;
-   */
-  Current_handle = 0;
-  for (i = 0; i < MAX_HANDLES; i++) {
-    IOE_handles[i].devpollfd = -1;
-    IOE_handles[i].pfd = NULL;
-  }
-
-  /*
-   * this tells me the max number of open filedescriptors
-   */
-  Max_index = sysconf(_SC_OPEN_MAX);
-  if (Max_index < 0) {
-    Max_index = 1024;
-  }
-
-  DBGMSG(("got sysconf(_SC_OPEN_MAX)=%d file desc\n",Max_index));
-
-  return 0;
-}
-
-JNIEXPORT jint JNICALL Java_Poller_getNumCPUs(JNIEnv *env, jclass cls)
-{
-  return sysconf(_SC_NPROCESSORS_ONLN);
-}
-
-/*
- * Class:     Poller
- * Method:    nativeCreatePoller
- * Signature: (I)I
- * Note : in the case where /dev/poll doesn't exist,
- *        using more than one poll array could hurt
- *        Solaris 7 performance due to kernel caching.
- */
-
-JNIEXPORT jint JNICALL Java_Poller_nativeCreatePoller
-  (JNIEnv *env, jobject obj, jint maximum_fds)
-{
-  int handle, retval, i;
-  ioevent_t *ioeh;
-
-  if (maximum_fds == -1) {
-    maximum_fds = Max_index;
-  }
-  handle = Current_handle;
-  if (Current_handle >= MAX_HANDLES) {
-    for (i = 0; i < MAX_HANDLES; i++) {
-      if (IOE_handles[i].inuse == 0) {
-        handle = i;
-        break;
-      }
-    }
-    if (handle >= MAX_HANDLES) {
-      return MEMORY_EXCEPTION("CreatePoller - MAX_HANDLES exceeded");
-    }
-  } else {
-    Current_handle++;
-  }
-
-  ioeh = &IOE_handles[handle];
-
-  ioeh->inuse      = 1;
-
-  ioeh->last_index = 0;
-  ioeh->total_free = 0;
-  ioeh->left_events = 0;
-  ioeh->max_index = maximum_fds;
-
-  retval = handle;
-  if (Use_devpoll) {
-    ioeh->devpollfd = open("/dev/poll",O_RDWR);
-    DBGMSG(("Opened /dev/poll, set devpollfd = %d\n",ioeh->devpollfd));
-    if (ioeh->devpollfd < 0) {
-      Current_handle--;
-      return MEMORY_EXCEPTION("CreatePoller - can\'t open /dev/poll");
-    }
-  }
-  ioeh->pfd = malloc(maximum_fds * sizeof(pollfd_t));
-  if (ioeh->pfd == NULL) {
-    Current_handle--;
-    return MEMORY_EXCEPTION("CreatePoller - malloc failure");
-  }
-
-  return retval;
-}
-
-/*
- * Class:     Poller
- * Method:    nativeDestroyPoller
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_Poller_nativeDestroyPoller
-  (JNIEnv *env, jobject obj, jint handle)
-{
-
-  ioevent_t *ioeh;
-
-  if (handle < 0 || handle >= MAX_HANDLES)
-    {
-      STATE_EXCEPTION("DestroyPoller - handle out of range");
-      return;
-    }
-
-  ioeh = &IOE_handles[handle];
-  ioeh->inuse = 0;
-  if (Use_devpoll) {
-    close(ioeh->devpollfd);
-  }
-  free(ioeh->pfd);
-}
-
-#ifdef DEBUG
-static void check_handle(ioevent_t *ioeh)
-{
-  int i,used,unused;
-
-  used=unused=0;
-  for (i = 0; i < ioeh->last_index; i++)
-    {
-      if (ioeh->pfd[i].fd == -1)
-        unused++;
-      else
-        used++;
-    }
-  if (unused != ioeh->total_free)
-    printf("WARNING : found %d free, claimed %d.  Used : %d\n",
-           unused, ioeh->total_free, used);
-}
-#endif
-
-/*
- * Class:     Poller
- * Method:    nativeAddFd
- * Signature: (IIS)I
- *
- * Currently doesn't check to make sure we aren't adding
- * an fd already added (no problem for /dev/poll...just
- * an array waster for poll()).
- */
-JNIEXPORT jint JNICALL Java_Poller_nativeAddFd
-  (JNIEnv *env, jobject obj, jint handle, jint fd, jshort events)
-{
-  int retval;
-  ioevent_t *ioeh;
-
-  if (handle < 0 || handle >= MAX_HANDLES)
-    return STATE_EXCEPTION("AddFd - handle out of range");
-
-  ioeh = &IOE_handles[handle];
-
-  CHECK_HANDLE(ioeh);
-
-  #ifdef DEVPOLL
-  if (Use_devpoll)
-    {
-      int i;
-      pollfd_t pollelt;
-
-      /*
-       * use /dev/poll
-       */
-      pollelt.fd = fd;
-      pollelt.events = events;
-      if ((i = write(ioeh->devpollfd, &pollelt, sizeof(pollfd_t))) !=
-          sizeof(pollfd_t)) {
-        DBGMSG(("write to devpollfd=%d showed %d bytes out of %d\n",
-                ioeh->devpollfd,i,sizeof(pollfd_t)));
-        return STATE_EXCEPTION("AddFd - /dev/poll add failure");
-      }
-    else
-      {
-        retval = fd;
-      }
-    }
-  else
-  #endif
-    { /* no /dev/poll available */
-      retval = addfd(env, ioeh, fd, events);
-    }
-  return retval;
-}
-
-/*
- * Addfd to pollfd array...optimized for Solaris 7
- */
-jint addfd(JNIEnv *env, ioevent_t *ioeh, jint fd, jshort events)
-{
-  int idx;
-
-  if (ioeh->total_free)
-    {
-      /*
-       * Traversing from end because that's where we pad.
-       */
-      ioeh->total_free--;
-      for (idx = ioeh->last_index - 1; idx >= 0; idx--) {
-        if (ioeh->pfd[idx].fd == -1)
-          break;
-      }
-    }
-  else if (ioeh->last_index >= ioeh->max_index)
-    {
-      return MEMORY_EXCEPTION("AddFd - too many fds");
-    }
-  else
-    {
-      int i;
-      int new_total;
-      /*
-       * For Solaris 7, want to add some growth space
-       * and fill extras with fd=-1.  This allows for
-       * kernel poll() implementation to perform optimally.
-       */
-      new_total = ioeh->last_index;
-      new_total += (new_total/10) + 1; /* bump size by 10% */
-      if (new_total > ioeh->max_index)
-        new_total = ioeh->max_index;
-      for (i = ioeh->last_index; i <= new_total; i++)
-        {
-          ioeh->pfd[i].fd = -1;
-        }
-      idx = ioeh->last_index;
-      ioeh->total_free = new_total - ioeh->last_index - 1;
-      DBGMSG(("Just grew from %d to %d in size\n",
-              ioeh->last_index, new_total));
-      ioeh->last_index = new_total;
-    }
-  ASSERT((idx >= 0) && (idx <= ioeh->max_index));
-  ASSERT(ioeh->pfd[idx].fd == -1);
-  ioeh->pfd[idx].fd = fd;
-  ioeh->pfd[idx].events = events;
-  ioeh->pfd[idx].revents = 0;
-
-  CHECK_HANDLE(ioeh);
-
-  return fd;
-}
-
-/*
- * Class:     Poller
- * Method:    nativeRemoveFd
- * Signature: (II)I
- */
-JNIEXPORT jint JNICALL Java_Poller_nativeRemoveFd
-  (JNIEnv *env, jobject obj, jint handle, jint fd)
-{
-  ioevent_t *ioeh;
-
-  if (handle < 0 || handle >= MAX_HANDLES)
-    return STATE_EXCEPTION("RemoveFd - handle out of range");
-
-  ioeh = &IOE_handles[handle];
-
-  #ifdef DEVPOLL
-  if (Use_devpoll)
-    {
-      /*
-       * use /dev/poll - currently no need for locking here.
-       */
-      pollfd_t pollelt;
-
-      pollelt.fd = fd;
-      pollelt.events = POLLREMOVE;
-      if (write(ioeh->devpollfd, &pollelt,
-                sizeof(pollfd_t) ) != sizeof(pollfd_t))
-        {
-          return STATE_EXCEPTION("RemoveFd - /dev/poll failure");
-        }
-    }
-  else
-  #endif DEVPOLL
-    {
-      return removefd(env, ioeh,fd);
-    }
-}
-/*
- * remove from pollfd array...optimize for Solaris 7
- */
-jint removefd(JNIEnv *env, ioevent_t *ioeh, jint fd)
-{
-  int i;
-  int found = 0;
-
-    { /* !Use_devpoll */
-      for (i = 0; i < ioeh->last_index; i++)
-        {
-          if (ioeh->pfd[i].fd == fd)
-            {
-              ioeh->pfd[i].fd = -1;
-              found = 1;
-              break;
-            }
-        }
-      if (!found)
-        {
-          return STATE_EXCEPTION("RemoveFd - no such fd");
-        }
-      ioeh->left_events = 0; /* Have to go back to the kernel */
-      ioeh->total_free++;
-      /*
-       * Shrinking pool if > 33% empty. Just don't do this often!
-       */
-      if ( (ioeh->last_index > 100) &&
-           (ioeh->total_free > (ioeh->last_index / 3)) )
-        {
-          int j;
-          /*
-           * we'll just bite the bullet here, since we're > 33% empty.
-           * walk through and eliminate -1 fd values, shrink total
-           * size to still have ~ 10 fd==-1 values at end.
-           * Start at end (since we pad here) and, when we find fd != -1,
-           * swap with an earlier fd == -1 until we have all -1 values
-           * at the end.
-           */
-          CHECK_HANDLE(ioeh);
-          for (i = ioeh->last_index - 1, j = 0; i > j; i--)
-            {
-              if (ioeh->pfd[i].fd != -1)
-                {
-                  while ( (j < i) && (ioeh->pfd[j].fd != -1) )
-                    j++;
-                  DBGMSG( ("i=%d,j=%d,ioeh->pfd[j].fd=%d\n",
-                           i, j, ioeh->pfd[j].fd) );
-                  if (j < i)
-                      {
-                        ASSERT(ioeh->pfd[j].fd == -1);
-                        ioeh->pfd[j].fd = ioeh->pfd[i].fd;
-                        ioeh->pfd[j].events = ioeh->pfd[i].events;
-                        ioeh->pfd[i].fd = -1;
-                      }
-                }
-            }
-          DBGMSG(("Just shrunk from %d to %d in size\n",
-                  ioeh->last_index, j+11));
-          ioeh->last_index = j + 11; /* last_index always 1 greater */
-          ioeh->total_free = 10;
-          CHECK_HANDLE(ioeh);
-        }
-    } /* !Use_devpoll */
-
-  return 1;
-}
-
-/*
- * Class:     Poller
- * Method:    nativeIsMember
- * Signature: (II)I
- */
-JNIEXPORT jint JNICALL Java_Poller_nativeIsMember
-  (JNIEnv *env, jobject obj, jint handle, jint fd)
-{
-  int found = 0;
-  int i;
-  ioevent_t *ioeh;
-
-  if (handle < 0 || handle >= MAX_HANDLES)
-    return STATE_EXCEPTION("IsMember - handle out of range");
-
-  ioeh = &IOE_handles[handle];
-
-  #ifdef DEVPOLL
-  if (Use_devpoll)
-    {
-      pollfd_t pfd;
-      /*
-       * DEVPOLL ioctl DP_ISPOLLED call to determine if fd is polled.
-       */
-      pfd.fd = fd;
-      pfd.events = 0;
-      pfd.revents = 0;
-      found = ioctl(ioeh->devpollfd, DP_ISPOLLED, &pfd);
-      if (found == -1)
-        {
-          return STATE_EXCEPTION("IsMember - /dev/poll failure");
-        }
-    }
-  else
-  #endif
-    {
-      for (i = 0; i < ioeh->last_index; i++)
-        {
-          if (fd == ioeh->pfd[i].fd)
-            {
-              found = 1;
-              break;
-            }
-        }
-    }
-
-  return found;
-}
-
-/*
- * Class:     Poller
- * Method:    nativeWait
- * Signature: (II[I[SJ)I
- */
-JNIEXPORT jint JNICALL Java_Poller_nativeWait
-  (JNIEnv *env, jobject obj, jint handle, jint maxEvents,
-   jintArray jfds, jshortArray jrevents, jlong timeout)
-{
-  int useEvents, count, idx;
-  short *reventp;
-  jint  *fdp;
-  int   retval;
-  ioevent_t *ioeh;
-  jboolean isCopy1,isCopy2;
-
-  if (handle < 0 || handle >= MAX_HANDLES)
-    return STATE_EXCEPTION("nativeWait - handle out of range");
-
-  ioeh = &IOE_handles[handle];
-
-  if (maxEvents == 0) /* just doing a kernel delay! */
-    {
-      useEvents = poll(NULL,0L,timeout);
-      return 0;
-    }
-
-  #ifdef DEVPOLL
-  if (Use_devpoll)
-    {
-      struct dvpoll dopoll;
-      /*
-       * DEVPOLL ioctl DP_POLL call, reading
-       */
-      dopoll.dp_timeout = timeout;
-      dopoll.dp_nfds=maxEvents;
-      dopoll.dp_fds=ioeh->pfd;
-
-      useEvents = ioctl(ioeh->devpollfd, DP_POLL, &dopoll);
-      while ((useEvents == -1) && (errno == EAGAIN))
-            useEvents = ioctl(ioeh->devpollfd, DP_POLL, &dopoll);
-
-      if (useEvents == -1)
-        {
-          if (errno == EINTR)
-            return INTERRUPT_EXCEPTION("nativeWait - /dev/poll failure EINTR");
-          else
-            return STATE_EXCEPTION("nativeWait - /dev/poll failure");
-        }
-
-      reventp =(*env)->GetShortArrayElements(env,jrevents,&isCopy1);
-      fdp =(*env)->GetIntArrayElements(env,jfds,&isCopy2);
-      for (idx = 0,count = 0; idx < useEvents; idx++)
-        {
-          if (ioeh->pfd[idx].revents)
-            {
-              fdp[count] = ioeh->pfd[idx].fd;
-              reventp[count] = ioeh->pfd[idx].revents;
-              count++;
-            }
-        }
-      if (count < useEvents)
-        return STATE_EXCEPTION("Wait - Corrupted internals");
-
-      if (isCopy1 == JNI_TRUE)
-        (*env)->ReleaseShortArrayElements(env,jrevents,reventp,0);
-      if (isCopy2 == JNI_TRUE)
-        (*env)->ReleaseIntArrayElements(env,jfds,fdp,0);
-    }
-  else
-  #endif
-    { /* !Use_devpoll */
-
-    /* no leftovers=>go to kernel */
-      if (ioeh->left_events == 0)
-        {
-          useEvents = poll(ioeh->pfd,ioeh->last_index, timeout);
-          while ((useEvents == -1) && (errno == EAGAIN))
-            useEvents = poll(ioeh->pfd,ioeh->last_index, timeout);
-          if (useEvents == -1)
-            {
-              if (errno == EINTR)
-                return INTERRUPT_EXCEPTION("Wait - poll() failure EINTR-" \
-                                           "IO interrupted.");
-              else if (errno == EINVAL)
-                return STATE_EXCEPTION("Wait - poll() failure EINVAL-" \
-                                       "invalid args (is fdlim cur < max?)");
-              else
-                return STATE_EXCEPTION("Wait - poll() failure");
-            }
-          ioeh->left_events = useEvents;
-          DBGMSG(("waitnative : poll returns : %d\n",useEvents));
-        }
-      else
-        {  /* left over from last call */
-          useEvents = ioeh->left_events;
-        }
-
-      if (useEvents > maxEvents)
-        {
-          useEvents = maxEvents;
-        }
-
-      ioeh->left_events -= useEvents; /* left to process */
-
-      DBGMSG(("waitnative : left %d, use %d, max %d\n",ioeh->left_events,
-              useEvents,maxEvents));
-
-      if (useEvents > 0)
-        {
-          reventp =(*env)->GetShortArrayElements(env,jrevents,&isCopy1);
-          fdp =(*env)->GetIntArrayElements(env,jfds,&isCopy2);
-          for (idx = 0,count = 0; (idx < ioeh->last_index) &&
-                 (count < useEvents); idx++)
-            {
-              if (ioeh->pfd[idx].revents)
-                {
-                  fdp[count] = ioeh->pfd[idx].fd;
-                  reventp[count] = ioeh->pfd[idx].revents;
-                  /* in case of leftover for next walk */
-                  ioeh->pfd[idx].revents = 0;
-                  count++;
-                }
-            }
-          if (count < useEvents)
-            {
-              ioeh->left_events = 0;
-              return STATE_EXCEPTION("Wait - Corrupted internals");
-            }
-          if (isCopy1 == JNI_TRUE)
-            (*env)->ReleaseShortArrayElements(env,jrevents,reventp,0);
-          if (isCopy2 == JNI_TRUE)
-            (*env)->ReleaseIntArrayElements(env,jfds,fdp,0);
-        }
-    } /* !Use_devpoll */
-
-  return useEvents;
-}
--- a/jdk/src/demo/solaris/jni/Poller/Poller.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,335 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.lang.reflect.*;
-import java.io.*;
-import java.net.*;
-
-/**
- * This class is provided for access to the underlying poll(2)
- * or /dev/poll kernel interfaces.  This may be needed for
- * multiplexing IO when an application cannot afford to have
- * a thread block on each outstanding IO request.
- *
- * It currently supports the same basic functionality as the
- * C poll(2) API, although for efficiency we needed to avoid
- * passing the entire pollfd array for every call.  See man
- * pages for poll(2) for info on C API and event types.
- *
- *
- * @author  Bruce Chapman
- * @see     java.io.FileDescriptor
- * @see     java.net.Socket
- * @see     attached README.txt
- * @since   1.2
- */
-
-public class Poller {
-  /**
-   * Solaris POLL event types.
-   */
-  public final static short POLLERR  = 0x08;
-  public final static short POLLHUP  = 0x10;
-  public final static short POLLNVAL = 0x20;
-  public final static short POLLIN   = 1;
-  public final static short POLLPRI  = 2;
-  public final static short POLLOUT  = 4;
-  public final static short POLLRDNORM = 0x40;
-  public final static short POLLWRNORM = POLLOUT ;
-  public final static short POLLRDBAND = 0x80;
-  public final static short POLLWRBAND = 0x100;
-  public final static short POLLNORM   = POLLRDNORM;
-
-  /*
-   * This global synchronization object must be used for all
-   * creation or destruction of Poller objects.
-   */
-  private final static Object globalSync = new Object();
-
-  /*
-   * The handle for a Poller Object...is used in the JNI C code
-   * where all the associated data is kept.
-   */
-  private int handle;
-
-  /**
-   * Constructs an instance of a <code>Poller</code> object.
-   * Native code uses sysconf(_SC_OPEN_MAX) to determine how
-   * many fd/skt objects this Poller object can contain.
-   */
-  public Poller() throws Exception {
-    synchronized(globalSync) {
-      this.handle = nativeCreatePoller(-1);
-    }
-  }
-
-  /**
-   * Constructs an instance of a <code>Poller</code> object.
-   * @param  maxFd the maximum number of FileDescriptors/Sockets
-   *         this Poller object can contain.
-   */
-  public Poller(int maxFd) throws Exception {
-    synchronized(globalSync) {
-      this.handle = nativeCreatePoller(maxFd);
-    }
-  }
-
-  /**
-   * Needed to clean up at the JNI C level when object is GCd.
-   */
-  protected void finalize() throws Throwable {
-    synchronized(globalSync) {
-      nativeDestroyPoller(handle);
-      super.finalize();
-    }
-  }
-
-  /**
-   * Since we can't guarantee WHEN finalize is called, we may
-   * recycle on our own.
-   * @param  maxFd the maximum number of FileDescriptors/Sockets
-   *         this Poller object can contain.
-   */
-  public void reset(int maxFd) throws Exception {
-    synchronized(globalSync) {
-      nativeDestroyPoller(handle);
-      this.handle = nativeCreatePoller(maxFd);
-    }
-  }
-  /**
-   * Since we can't guarantee WHEN finalize is called, we may
-   * recycle on our own.
-   */
-  public void reset() throws Exception {
-    synchronized(globalSync) {
-      nativeDestroyPoller(handle);
-      this.handle = nativeCreatePoller(-1);
-    }
-  }
-
-  /**
-   * Add FileDescriptor to the set handled by this Poller object.
-   *
-   * @param  fdObj the FileDescriptor, Socket, or ServerSocket to add.
-   * @param  event the bitmask of events we are interested in.
-   * @return the OS level fd associated with this IO Object
-   *          (which is what waitMultiple() stores in fds[])
-   */
-  public synchronized int add(Object fdObj, short event) throws Exception {
-    return nativeAddFd(handle,findfd(fdObj), event);
-  }
-
-  /**
-   * Remove FileDescriptor from the set handled by this Poller object.
-   *
-   * Must be called before the fd/skt is closed.
-   * @param fdObj the FileDescriptor, Socket, or ServerSocket to remove.
-   * @return true if removal succeeded.
-   */
-  public synchronized boolean remove(Object fdObj) throws Exception {
-    return (nativeRemoveFd(handle,findfd(fdObj)) == 1);
-  }
-  /**
-   * Check if fd or socket is already in the set handled by this Poller object
-   *
-   * @param fdObj the FileDescriptor or [Server]Socket to check.
-   * @return true if fd/skt is in the set for this Poller object.
-   */
-  public synchronized boolean isMember(Object fdObj) throws Exception {
-    return (nativeIsMember(handle,findfd(fdObj)) == 1);
-  }
-  /**
-   * Wait on Multiple IO Objects.
-   *
-   * @param maxRet    the maximum number of fds[] and revents[] to return.
-   * @param fds[]     (return) an array of ints in which to store fds with
-   *                  available data upon a successful non-timeout return.
-   *                  fds.length must be >= maxRet
-   * @param revents[] (return) the actual events available on the
-   *                  same-indexed fds[] (i.e. fds[0] has events revents[0])
-   *                  revents.length must be >= maxRet
-   *
-   * Note : both above arrays are "dense," i.e. only fds[] with events
-   *        available are returned.
-   *
-   * @param timeout   the maximum number of milliseconds to wait for
-   *                  events before timing out.
-   * @return          the number of fds with triggered events.
-   *
-   * Note : convenience methods exist for skipping the timeout parameter
-   *        or the maxRet parameter (in the case of no maxRet, fds.length
-   *        must equal revents.length)
-   *
-   * obj.waitMultiple(null,null,timeout) can be used for pausing the LWP
-   * (much more reliable and scalable than Thread.sleep() or Object.wait())
-   */
-  public synchronized int waitMultiple(int maxRet, int[] fds,short[] revents,
-                                       long timeout) throws Exception
-    {
-      if ((revents == null) || (fds == null)) {
-        if (maxRet > 0) {
-          throw new NullPointerException("fds or revents is null");
-        }
-      } else if ( (maxRet < 0) ||
-                  (maxRet > revents.length) || (maxRet > fds.length) ) {
-        throw new IllegalArgumentException("maxRet out of range");
-      }
-
-      int ret = nativeWait(handle, maxRet, fds, revents, timeout);
-      if (ret < 0) {
-        throw new InterruptedIOException();
-      }
-      return ret;
-    }
-
-  /**
-   * Wait on Multiple IO Objects (no timeout).
-   * A convenience method for waiting indefinitely on IO events
-   *
-   * @see Poller#waitMultiple
-   *
-   */
-  public int waitMultiple(int maxRet, int[] fds, short[] revents)
-    throws Exception
-    {
-      return waitMultiple(maxRet, fds, revents,-1L); // already synchronized
-    }
-
-  /**
-   * Wait on Multiple IO Objects (no maxRet).
-   * A convenience method for waiting on IO events when the fds
-   * and revents arrays are the same length and that specifies the
-   * maximum number of return events.
-   *
-   * @see Poller#waitMultiple
-   *
-   */
-  public synchronized int waitMultiple(int[] fds, short[] revents,
-                                       long timeout) throws Exception
-    {
-      if ((revents == null) && (fds == null)) {
-        return nativeWait(handle,0,null,null,timeout);
-      } else if ((revents == null) || (fds == null)) {
-        throw new NullPointerException("revents or fds is null");
-      } else if (fds.length == revents.length) {
-        return nativeWait(handle, fds.length, fds, revents, timeout);
-      }
-      throw new IllegalArgumentException("fds.length != revents.length");
-    }
-
-
-  /**
-   * Wait on Multiple IO Objects (no maxRet/timeout).
-   * A convenience method for waiting on IO events when the fds
-   * and revents arrays are the same length and that specifies the
-   * maximum number of return events, and when waiting indefinitely
-   * for IO events to occur.
-   *
-   * @see Poller#waitMultiple
-   *
-   */
-  public int waitMultiple(int[] fds, short[] revents)
-    throws Exception
-    {
-      if ((revents == null) || (fds == null)) {
-        throw new NullPointerException("fds or revents is null");
-      } else if (fds.length == revents.length) {
-        return waitMultiple(revents.length,fds,revents,-1L); // already sync
-      }
-      throw new IllegalArgumentException("fds.length != revents.length");
-    }
-
-  // Utility - get (int) fd from FileDescriptor or [Server]Socket objects.
-
-  private int findfd(Object fdObj) throws Exception {
-    Class cl;
-    Field f;
-    Object val, implVal;
-
-    if ((fdObj instanceof java.net.Socket) ||
-        (fdObj instanceof java.net.ServerSocket)) {
-      cl = fdObj.getClass();
-      f = cl.getDeclaredField("impl");
-      f.setAccessible(true);
-      val = f.get(fdObj);
-      cl = f.getType();
-      f = cl.getDeclaredField("fd");
-      f.setAccessible(true);
-      implVal = f.get(val);
-      cl = f.getType();
-      f = cl.getDeclaredField("fd");
-      f.setAccessible(true);
-      return  ((Integer) f.get(implVal)).intValue();
-    } else if ( fdObj instanceof java.io.FileDescriptor ) {
-      cl = fdObj.getClass();
-      f = cl.getDeclaredField("fd");
-      f.setAccessible(true);
-      return  ((Integer) f.get(fdObj)).intValue();
-    }
-    else {
-      throw new IllegalArgumentException("Illegal Object type.");
-    }
-  }
-
-  // Actual NATIVE calls
-
-  private static native int  nativeInit();
-  private native int  nativeCreatePoller(int maxFd) throws Exception;
-  private native void nativeDestroyPoller(int handle) throws Exception;
-  private native int  nativeAddFd(int handle, int fd, short events)
-    throws Exception;
-  private native int  nativeRemoveFd(int handle, int fd) throws Exception;
-  private native int  nativeRemoveIndex(int handle, int index)
-    throws Exception;
-  private native int  nativeIsMember(int handle, int fd) throws Exception;
-  private native int  nativeWait(int handle, int maxRet, int[] fds,
-                                        short[] events, long timeout)
-    throws Exception;
-  /**
-   * Get number of active CPUs in this machine
-   * to determine proper level of concurrency.
-   */
-  public static native int  getNumCPUs();
-
-  static {
-      System.loadLibrary("poller");
-      nativeInit();
-  }
-}
--- a/jdk/src/demo/solaris/jni/Poller/PollingServer.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,265 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.net.*;
-import java.lang.Byte;
-
-/**
- * Simple Java "server" using the Poller class
- * to multiplex on incoming connections.  Note
- * that handoff of events, via linked Q is not
- * actually be a performance booster here, since
- * the processing of events is cheaper than
- * the overhead in scheduling/executing them.
- * Although this demo does allow for concurrency
- * in handling connections, it uses a rather
- * primitive "gang scheduling" policy to keep
- * the code simpler.
- */
-
-public class PollingServer
-{
-  public final static int MAXCONN    = 10000;
-  public final static int PORTNUM    = 4444;
-  public final static int BYTESPEROP = 10;
-
-  /**
-   * This synchronization object protects access to certain
-   * data (bytesRead,eventsToProcess) by concurrent Consumer threads.
-   */
-  private final static Object eventSync = new Object();
-
-  private static InputStream[] instr = new InputStream[MAXCONN];
-  private static int[] mapping = new int[65535];
-  private static LinkedQueue linkedQ = new LinkedQueue();
-  private static int bytesRead = 0;
-  private static int bytesToRead;
-  private static int eventsToProcess=0;
-
-  public PollingServer(int concurrency) {
-    Socket[] sockArr = new Socket[MAXCONN];
-    long timestart, timestop;
-    short[] revents = new short[MAXCONN];
-    int[] fds = new int[MAXCONN];
-    int bytes;
-    Poller Mux;
-    int serverFd;
-    int totalConn=0;
-    int connects=0;
-
-    System.out.println ("Serv: Initializing port " + PORTNUM);
-    try {
-
-      ServerSocket skMain = new ServerSocket (PORTNUM);
-      /*
-       * Create the Poller object Mux, allow for up to MAXCONN
-       * sockets/filedescriptors to be polled.
-       */
-      Mux = new Poller(MAXCONN);
-      serverFd = Mux.add(skMain, Poller.POLLIN);
-
-      Socket ctrlSock = skMain.accept();
-
-      BufferedReader ctrlReader =
-        new BufferedReader(new InputStreamReader(ctrlSock.getInputStream()));
-      String ctrlString = ctrlReader.readLine();
-      bytesToRead = Integer.valueOf(ctrlString).intValue();
-      ctrlString = ctrlReader.readLine();
-      totalConn = Integer.valueOf(ctrlString).intValue();
-
-      System.out.println("Receiving " + bytesToRead + " bytes from " +
-                         totalConn + " client connections");
-
-      timestart = System.currentTimeMillis();
-
-      /*
-       * Start the consumer threads to read data.
-       */
-      for (int consumerThread = 0;
-           consumerThread < concurrency; consumerThread++ ) {
-        new Consumer(consumerThread).start();
-      }
-
-      /*
-       * Take connections, read Data
-       */
-      int numEvents=0;
-
-      while ( bytesRead < bytesToRead ) {
-
-        int loopWaits=0;
-        while (eventsToProcess > 0) {
-          synchronized (eventSync) {
-            loopWaits++;
-            if (eventsToProcess <= 0) break;
-            try { eventSync.wait(); } catch (Exception e) {e.printStackTrace();};
-          }
-        }
-        if (loopWaits > 1)
-          System.out.println("Done waiting...loops = " + loopWaits +
-                             " events " + numEvents +
-                             " bytes read : " + bytesRead );
-
-        if (bytesRead >= bytesToRead) break; // may be done!
-
-        /*
-         * Wait for events
-         */
-        numEvents = Mux.waitMultiple(100, fds, revents);
-        synchronized (eventSync) {
-          eventsToProcess = numEvents;
-        }
-        /*
-         * Process all the events we got from Mux.waitMultiple
-         */
-        int cnt = 0;
-        while ( (cnt < numEvents) && (bytesRead < bytesToRead) ) {
-          int fd = fds[cnt];
-
-          if (revents[cnt] == Poller.POLLIN) {
-            if (fd == serverFd) {
-              /*
-               * New connection coming in on the ServerSocket
-               * Add the socket to the Mux, keep track of mapping
-               * the fdval returned by Mux.add to the connection.
-               */
-              sockArr[connects] = skMain.accept();
-              instr[connects] = sockArr[connects].getInputStream();
-              int fdval = Mux.add(sockArr[connects], Poller.POLLIN);
-              mapping[fdval] = connects;
-              synchronized(eventSync) {
-                eventsToProcess--; // just processed this one!
-              }
-              connects++;
-            } else {
-              /*
-               * We've got data from this client connection.
-               * Put it on the queue for the consumer threads to process.
-               */
-              linkedQ.put(new Integer(fd));
-            }
-          } else {
-            System.out.println("Got revents[" + cnt + "] == " + revents[cnt]);
-          }
-          cnt++;
-        }
-      }
-      timestop = System.currentTimeMillis();
-      System.out.println("Time for all reads (" + totalConn +
-                         " sockets) : " + (timestop-timestart));
-
-      // Tell the client it can now go away
-      byte[] buff = new byte[BYTESPEROP];
-      ctrlSock.getOutputStream().write(buff,0,BYTESPEROP);
-
-      // Tell the cunsumer threads they can exit.
-      for (int cThread = 0; cThread < concurrency; cThread++ ) {
-        linkedQ.put(new Integer(-1));
-      }
-    } catch (Exception exc) { exc.printStackTrace(); }
-  }
-
-  /*
-   * main ... just check if a concurrency was specified
-   */
-  public static void main (String args[])
-  {
-    int concurrency;
-
-    if (args.length == 1)
-      concurrency = java.lang.Integer.valueOf(args[0]).intValue();
-    else
-      concurrency = Poller.getNumCPUs() + 1;
-    PollingServer server = new PollingServer(concurrency);
-  }
-
-  /*
-   * This class is for handling the Client data.
-   * The PollingServer spawns off a number of these based upon
-   * the number of CPUs (or concurrency argument).
-   * Each just loops grabbing events off the queue and
-   * processing them.
-   */
-  class Consumer extends Thread {
-    private int threadNumber;
-    public Consumer(int i) { threadNumber = i; }
-
-    public void run() {
-      byte[] buff = new byte[BYTESPEROP];
-      int bytes = 0;
-
-      InputStream instream;
-      while (bytesRead < bytesToRead) {
-        try {
-          Integer Fd = (Integer) linkedQ.take();
-          int fd = Fd.intValue();
-          if (fd == -1) break; /* got told we could exit */
-
-          /*
-           * We have to map the fd value returned from waitMultiple
-           * to the actual input stream associated with that fd.
-           * Take a look at how the Mux.add() was done to see how
-           * we stored that.
-           */
-          int map = mapping[fd];
-          instream = instr[map];
-          bytes = instream.read(buff,0,BYTESPEROP);
-        } catch (Exception e) { System.out.println(e.toString()); }
-
-        if (bytes > 0) {
-          /*
-           * Any real server would do some synchronized and some
-           * unsynchronized work on behalf of the client, and
-           * most likely send some data back...but this is a
-           * gross oversimplification.
-           */
-          synchronized(eventSync) {
-            bytesRead += bytes;
-            eventsToProcess--;
-            if (eventsToProcess <= 0) {
-              eventSync.notify();
-            }
-          }
-        }
-      }
-    }
-  }
-}
--- a/jdk/src/demo/solaris/jni/Poller/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-README.txt
-
-
-This Poller class demonstrates access to poll(2) functionality in Java.
-
-Requires Solaris production (native threads) JDK 1.2 or later, currently
-the C code compiles only on Solaris (SPARC and Intel).
-
-Poller.java is the class, Poller.c is the supporting JNI code.
-
-PollingServer.java is a sample application which uses the Poller class
-to multiplex sockets.
-
-SimpleServer.java is the functional equivalent that does not multiplex
-but uses a single thread to handle each client connection.
-
-Client.java is a sample application to drive against either server.
-
-To build the Poller class and client/server demo :
- javac PollingServer.java Client.java
- javah Poller
- cc -G -o libpoller.so -I ${JAVA_HOME}/include -I ${JAVA_HOME}/include/solaris\
-  Poller.c
-
-You will need to set the environment variable LD_LIBRARY_PATH to search
-the directory containing libpoller.so.
-
-To use client/server, bump up your fd limit to handle the connections you
-want (need root access to go beyond 1024).  For info on changing your file
-descriptor limit, type "man limit".  If you are using Solaris 2.6
-or later, a regression in loopback read() performance may hit you at low
-numbers of connections, so run the client on another machine.
-
-BASICs of Poller class usage :
- run "javadoc Poller" or see Poller.java for more details.
-
-{
-    Poller Mux = new Poller(65535); // allow it to contain 64K IO objects
-    
-    int fd1 = Mux.add(socket1, Poller.POLLIN);
-    ...
-    int fdN = Mux.add(socketN, Poller.POLLIN);
-
-    int[] fds = new int[100];
-    short[] revents = new revents[100];
-
-    int numEvents = Mux.waitMultiple(100, fds, revents, timeout);
-
-    for (int i = 0; i < numEvents; i++) {
-       /*
-        * Probably need more sophisticated mapping scheme than this!
-	*/
-        if (fds[i] == fd1) {
-	    System.out.println("Got data on socket1");
-	    socket1.getInputStream().read(byteArray);
-	    // Do something based upon state of fd1 connection
-	}
-	...
-    }
-}
-
-Poller class implementation notes :
-
-  Currently all add(),remove(),isMember(), and waitMultiple() methods
-are synchronized for each Poller object.  If one thread is blocked in
-pObj.waitMultiple(), another thread calling pObj.add(fd) will block
-until waitMultiple() returns.  There is no provided mechanism to
-interrupt waitMultiple(), as one might expect a ServerSocket to be in
-the list waited on (see PollingServer.java).
-
-  One might also need to interrupt waitMultiple() to remove()
-fds/sockets, in which case one could create a Pipe or loopback localhost
-connection (at the level of PollingServer) and use a write() to that
-connection to interrupt.  Or, better, one could queue up deletions
-until the next return of waitMultiple().  Or one could implement an
-interrupt mechanism in the JNI C code using a pipe(), and expose that
-at the Java level.
-
-  If frequent deletions/re-additions of socks/fds is to be done with
-very large sets of monitored fds, the Solaris 7 kernel cache will
-likely perform poorly without some tuning.  One could differentiate
-between deleted (no longer cared for) fds/socks and those that are
-merely being disabled while data is processed on their behalf.  In
-that case, re-enabling a disabled fd/sock could put it in it's
-original position in the poll array, thereby increasing the kernel
-cache performance.  This would best be done in Poller.c.  Of course
-this is not necessary for optimal /dev/poll performance.
-
-  Caution...the next paragraph gets a little technical for the
-benefit of those who already understand poll()ing fairly well.  Others
-may choose to skip over it to read notes on the demo server.
-
-  An optimal solution for frequent enabling/disabling of socks/fds
-could involve a separately synchronized structure of "async"
-operations.  Using a simple array (0..64k) containing the action
-(ADD,ENABLE,DISABLE, NONE), the events, and the index into the poll
-array, and having nativeWait() wake up in the poll() call periodically
-to process these async operations, I was able to speed up performance
-of the PollingServer by a factor of 2x at 8000 connections.  Of course
-much of that gain was from the fact that I could (with the advent of
-an asyncAdd() method) move the accept() loop into a separate thread
-from the main poll() loop, and avoid the overhead of calling poll()
-with up to 7999 fds just for an accept.  In implementing the async
-Disable/Enable, a further large optimization was to auto-disable fds
-with events available (before return from nativeWait()), so I could
-just call asyncEnable(fd) after processing (read()ing) the available
-data.  This removed the need for inefficient gang-scheduling the
-attached PollingServer uses.  In order to separately synchronize the
-async structure, yet still be able to operate on it from within
-nativeWait(), synchronization had to be done at the C level here.  Due
-to the new complexities this introduced, as well as the fact that it
-was tuned specifically for Solaris 7 poll() improvements (not
-/dev/poll), this extra logic was left out of this demo.
-
-
-Client/Server Demo Notes :
-
-  Do not run the sample client/server with high numbers of connections
-unless you have a lot of free memory on your machine, as it can saturate
-CPU and lock you out of CDE just by its very resource intensive nature
-(much more so the SimpleServer than PollingServer).
-
-  Different OS versions will behave very differently as far as poll()
-performance (or /dev/poll existence) but, generally, real world applications
-"hit the wall" much earlier when a separate thread is used to handle
-each client connection.  Issues of thread synchronization and locking
-granularity become performance killers.  There is some overhead associated
-with multiplexing, such as keeping track of the state of each connection; as
-the number of connections gets very large, however, this overhead is more
-than made up for by the reduced synchronization overhead.
-
-  As an example, running the servers on a Solaris 7 PC (Pentium II-350 x 
-2 CPUS) with 1 GB RAM, and the client on an Ultra-2, I got the following
-times (shorter is better) :
-
-  1000 connections :
-
-PollingServer took 11 seconds
-SimpleServer took 12 seconds
-
-  4000 connections :
-
-PollingServer took 20 seconds
-SimpleServer took 37 seconds
-
-  8000 connections :
-
-PollingServer took 39 seconds
-SimpleServer took 1:48 seconds
-
-  This demo is not, however, meant to be considered some form of proof
-that multiplexing with the Poller class will gain you performance; this
-code is actually very heavily biased towards the non-polling server as
-very little synchronization is done, and most of the overhead is in the
-kernel IO for both servers.  Use of multiplexing may be helpful in
-many, but certainly not all, circumstances.
-
-  Benchmarking a major Java server application which can run
-in a single-thread-per-client mode or using the  new Poller class showed
-Poller provided a 253% improvement in throughput at a moderate load, as
-well as a 300% improvement in peak capacity.  It also yielded a 21%
-smaller memory footprint at the lower load level.
-
-  Finally, there is code in Poller.c to take advantage of /dev/poll
-on OS versions that have that device; however, DEVPOLL must be defined
-in compiling Poller.c (and it must be compiled on a machine with
-/usr/include/sys/devpoll.h) to use it.  Code compiled with DEVPOLL
-turned on will work on machines that don't have kernel support for
-the device, as it will fall back to using poll() in those cases.
-Currently /dev/poll does not correctly return an error if you attempt
-to remove() an object that was never added, but this should be fixed
-in an upcoming /dev/poll patch.  The binary as shipped is not built with
-/dev/poll support as our build machine does not have devpoll.h.
-
--- a/jdk/src/demo/solaris/jni/Poller/SimpleServer.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.net.*;
-import java.lang.Byte;
-
-/**
- * Simple Java "server" using a single thread to handle each connection.
- */
-
-public class SimpleServer
-{
-  private final static int BYTESPEROP= PollingServer.BYTESPEROP;
-  private final static int PORTNUM   = PollingServer.PORTNUM;
-  private final static int MAXCONN   = PollingServer.MAXCONN;
-
-  /*
-   * This synchronization object protects access to certain
-   * data (bytesRead,eventsToProcess) by concurrent Consumer threads.
-   */
-  private final static Object eventSync = new Object();
-
-  private static InputStream[] instr = new InputStream[MAXCONN];
-  private static int bytesRead;
-  private static int bytesToRead;
-
-  public SimpleServer() {
-    Socket[] sockArr = new Socket[MAXCONN];
-    long timestart, timestop;
-    int bytes;
-    int totalConn=0;
-
-
-    System.out.println ("Serv: Initializing port " + PORTNUM);
-    try {
-
-      ServerSocket skMain = new ServerSocket (PORTNUM);
-
-      bytesRead = 0;
-      Socket ctrlSock = skMain.accept();
-
-      BufferedReader ctrlReader =
-        new BufferedReader(new InputStreamReader(ctrlSock.getInputStream()));
-      String ctrlString = ctrlReader.readLine();
-      bytesToRead = Integer.valueOf(ctrlString).intValue();
-      ctrlString = ctrlReader.readLine();
-      totalConn = Integer.valueOf(ctrlString).intValue();
-
-      System.out.println("Receiving " + bytesToRead + " bytes from " +
-                         totalConn + " client connections");
-
-      timestart = System.currentTimeMillis();
-
-      /*
-       * Take connections, spawn off connection handling threads
-       */
-      ConnHandler[] connHA = new ConnHandler[MAXCONN];
-      int conn = 0;
-      while ( conn < totalConn ) {
-          Socket sock = skMain.accept();
-          connHA[conn] = new ConnHandler(sock.getInputStream());
-          connHA[conn].start();
-          conn++;
-      }
-
-      while ( bytesRead < bytesToRead ) {
-          java.lang.Thread.sleep(500);
-      }
-      timestop = System.currentTimeMillis();
-      System.out.println("Time for all reads (" + totalConn +
-                         " sockets) : " + (timestop-timestart));
-      // Tell the client it can now go away
-      byte[] buff = new byte[BYTESPEROP];
-      ctrlSock.getOutputStream().write(buff,0,BYTESPEROP);
-    } catch (Exception exc) { exc.printStackTrace(); }
-  }
-
-  /*
-   * main ... just create invoke the SimpleServer constructor.
-   */
-  public static void main (String args[])
-  {
-    SimpleServer server = new SimpleServer();
-  }
-
-  /*
-   * Connection Handler inner class...one of these per client connection.
-   */
-  class ConnHandler extends Thread {
-    private InputStream instr;
-    public ConnHandler(InputStream inputStr) { instr = inputStr; }
-
-    public void run() {
-      try {
-        int bytes;
-        byte[] buff = new byte[BYTESPEROP];
-
-        while ( bytesRead < bytesToRead ) {
-          bytes = instr.read (buff, 0, BYTESPEROP);
-          if (bytes > 0 ) {
-            synchronized(eventSync) {
-              bytesRead += bytes;
-            }
-            /*
-             * Any real server would do some synchronized and some
-             * unsynchronized work on behalf of the client, and
-             * most likely send some data back...but this is a
-             * gross oversimplification.
-             */
-          }
-          else {
-            if (bytesRead < bytesToRead)
-              System.out.println("instr.read returned : " + bytes);
-          }
-        }
-      }
-      catch (Exception e) {e.printStackTrace();}
-    }
-  }
-}
--- a/jdk/src/java.base/macosx/native/launcher/Info-privileged.plist	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/macosx/native/launcher/Info-privileged.plist	Fri Apr 21 03:34:11 2017 +0000
@@ -7,7 +7,7 @@
         <key>CFBundleInfoDictionaryVersion</key>
         <string>6.0</string>
         <key>CFBundleName</key>
-        <string>OpenJDK 7 Command</string>
+        <string>OpenJDK Command</string>
         <key>CFBundleShortVersionString</key>
         <string>1.0</string>
         <key>CFBundleVersion</key>
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1797,12 +1797,19 @@
         } catch (ClassNotFoundException ex) {
             resolveEx = ex;
         }
+
+        // Call filterCheck on the class before reading anything else
+        filterCheck(cl, -1);
+
         skipCustomData();
 
-        desc.initProxy(cl, resolveEx, readClassDesc(false));
-
-        // Call filterCheck on the definition
-        filterCheck(desc.forClass(), -1);
+        try {
+            totalObjectRefs++;
+            depth++;
+            desc.initProxy(cl, resolveEx, readClassDesc(false));
+        } finally {
+            depth--;
+        }
 
         handles.finish(descHandle);
         passHandle = descHandle;
@@ -1847,12 +1854,19 @@
         } catch (ClassNotFoundException ex) {
             resolveEx = ex;
         }
+
+        // Call filterCheck on the class before reading anything else
+        filterCheck(cl, -1);
+
         skipCustomData();
 
-        desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));
-
-        // Call filterCheck on the definition
-        filterCheck(desc.forClass(), -1);
+        try {
+            totalObjectRefs++;
+            depth++;
+            desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));
+        } finally {
+            depth--;
+        }
 
         handles.finish(descHandle);
         passHandle = descHandle;
--- a/jdk/src/java.base/share/classes/java/lang/Comparable.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/Comparable.java	Fri Apr 21 03:34:11 2017 +0000
@@ -84,7 +84,7 @@
  *     {(x, y) such that x.equals(y)}. </pre><p>
  *
  * This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <T> the type of objects that this object may be compared to
--- a/jdk/src/java.base/share/classes/java/lang/UnsupportedOperationException.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/UnsupportedOperationException.java	Fri Apr 21 03:34:11 2017 +0000
@@ -29,7 +29,7 @@
  * Thrown to indicate that the requested operation is not supported.<p>
  *
  * This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author  Josh Bloch
--- a/jdk/src/java.base/share/classes/java/lang/ref/Reference.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/ref/Reference.java	Fri Apr 21 03:34:11 2017 +0000
@@ -143,8 +143,10 @@
     /*
      * system property to disable clearing before enqueuing.
      */
-    private static final boolean disableClearBeforeEnqueue
-        = Boolean.getBoolean("jdk.lang.ref.disableClearBeforeEnqueue");
+    private static final class ClearBeforeEnqueue {
+        static final boolean DISABLE =
+            Boolean.getBoolean("jdk.lang.ref.disableClearBeforeEnqueue");
+    }
 
     /*
      * Atomically get and clear (set to null) the VM's pending list.
@@ -297,7 +299,7 @@
      *           it was not registered with a queue when it was created
      */
     public boolean enqueue() {
-        if (!disableClearBeforeEnqueue)
+        if (!ClearBeforeEnqueue.DISABLE)
             this.referent = null;
         return this.queue.enqueue(this);
     }
--- a/jdk/src/java.base/share/classes/java/net/SocketPermission.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/net/SocketPermission.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * 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,8 +44,8 @@
 import java.util.StringTokenizer;
 import java.util.concurrent.ConcurrentSkipListMap;
 import sun.net.util.IPAddressUtil;
-import sun.net.RegisteredDomain;
 import sun.net.PortConfig;
+import sun.security.util.RegisteredDomain;
 import sun.security.util.SecurityConstants;
 import sun.security.util.Debug;
 
@@ -678,13 +678,18 @@
         String a = cname.toLowerCase();
         String b = hname.toLowerCase();
         if (a.startsWith(b)  &&
-            ((a.length() == b.length()) || (a.charAt(b.length()) == '.')))
+            ((a.length() == b.length()) || (a.charAt(b.length()) == '.'))) {
             return true;
+        }
         if (cdomain == null) {
-            cdomain = RegisteredDomain.getRegisteredDomain(a);
+            cdomain = RegisteredDomain.from(a)
+                                      .map(RegisteredDomain::name)
+                                      .orElse(a);
         }
         if (hdomain == null) {
-            hdomain = RegisteredDomain.getRegisteredDomain(b);
+            hdomain = RegisteredDomain.from(b)
+                                      .map(RegisteredDomain::name)
+                                      .orElse(b);
         }
 
         return cdomain.length() != 0 && hdomain.length() != 0
--- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -813,8 +813,9 @@
     private Properties readConfigProperties(final String calendarType) throws Exception {
         String resourceName = RESOURCE_PREFIX + calendarType + RESOURCE_SUFFIX;
         PrivilegedAction<InputStream> getResourceAction =  () -> HijrahChronology.class.getResourceAsStream(resourceName);
-        FilePermission perm = new FilePermission("<<ALL FILES>>", "read");
-        try (InputStream is = AccessController.doPrivileged(getResourceAction, null, perm)) {
+        FilePermission perm1 = new FilePermission("<<ALL FILES>>", "read");
+        RuntimePermission perm2 = new RuntimePermission("accessSystemModules");
+        try (InputStream is = AccessController.doPrivileged(getResourceAction, null, perm1, perm2)) {
             if (is == null) {
                 throw new RuntimeException("Hijrah calendar resource not found: /java/time/chrono/" + resourceName);
             }
--- a/jdk/src/java.base/share/classes/java/util/AbstractCollection.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/AbstractCollection.java	Fri Apr 21 03:34:11 2017 +0000
@@ -49,7 +49,7 @@
  * the collection being implemented admits a more efficient implementation.<p>
  *
  * This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author  Josh Bloch
--- a/jdk/src/java.base/share/classes/java/util/AbstractList.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/AbstractList.java	Fri Apr 21 03:34:11 2017 +0000
@@ -62,7 +62,7 @@
  * collection being implemented admits a more efficient implementation.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author  Josh Bloch
--- a/jdk/src/java.base/share/classes/java/util/AbstractMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/AbstractMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -52,7 +52,7 @@
  * map being implemented admits a more efficient implementation.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <K> the type of keys maintained by this map
--- a/jdk/src/java.base/share/classes/java/util/AbstractQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/AbstractQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -54,7 +54,7 @@
  * instead subclassing {@link AbstractCollection}.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/AbstractSequentialList.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/AbstractSequentialList.java	Fri Apr 21 03:34:11 2017 +0000
@@ -54,7 +54,7 @@
  * specification.<p>
  *
  * This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author  Josh Bloch
--- a/jdk/src/java.base/share/classes/java/util/AbstractSet.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/AbstractSet.java	Fri Apr 21 03:34:11 2017 +0000
@@ -42,7 +42,7 @@
  * for {@code equals} and {@code hashCode}.<p>
  *
  * This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <E> the type of elements maintained by this set
--- a/jdk/src/java.base/share/classes/java/util/ArrayDeque.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/ArrayDeque.java	Fri Apr 21 03:34:11 2017 +0000
@@ -79,7 +79,7 @@
  * Iterator} interfaces.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author  Josh Bloch and Doug Lea
--- a/jdk/src/java.base/share/classes/java/util/ArrayList.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/ArrayList.java	Fri Apr 21 03:34:11 2017 +0000
@@ -91,7 +91,7 @@
  * should be used only to detect bugs.</i>
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <E> the type of elements in this list
--- a/jdk/src/java.base/share/classes/java/util/Arrays.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Arrays.java	Fri Apr 21 03:34:11 2017 +0000
@@ -62,7 +62,7 @@
  * 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">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author Josh Bloch
@@ -8899,4 +8899,4 @@
 
         return aLength != bLength ? length : -1;
     }
-}
\ No newline at end of file
+}
--- a/jdk/src/java.base/share/classes/java/util/Collection.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Collection.java	Fri Apr 21 03:34:11 2017 +0000
@@ -112,7 +112,7 @@
  * however most current implementations do not do so.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @implSpec
--- a/jdk/src/java.base/share/classes/java/util/Collections.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Collections.java	Fri Apr 21 03:34:11 2017 +0000
@@ -65,7 +65,7 @@
  * already sorted may or may not throw {@code UnsupportedOperationException}.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author  Josh Bloch
--- a/jdk/src/java.base/share/classes/java/util/Comparator.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Comparator.java	Fri Apr 21 03:34:11 2017 +0000
@@ -94,7 +94,7 @@
  * an equivalence relation.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <T> the type of objects that may be compared by this comparator
--- a/jdk/src/java.base/share/classes/java/util/Deque.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Deque.java	Fri Apr 21 03:34:11 2017 +0000
@@ -181,9 +181,9 @@
  * methods, but instead inherit the identity-based versions from class
  * {@code Object}.
  *
- * <p>This interface is a member of the <a
- * href="{@docRoot}/../technotes/guides/collections/index.html"> Java Collections
- * Framework</a>.
+ * <p>This interface is a member of the
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
+ * Java Collections Framework</a>.
  *
  * @author Doug Lea
  * @author Josh Bloch
--- a/jdk/src/java.base/share/classes/java/util/EnumMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/EnumMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -68,7 +68,7 @@
  * {@link HashMap} counterparts.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author Josh Bloch
--- a/jdk/src/java.base/share/classes/java/util/EnumSet.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/EnumSet.java	Fri Apr 21 03:34:11 2017 +0000
@@ -69,7 +69,7 @@
  * constant time if their argument is also an enum set.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author Josh Bloch
--- a/jdk/src/java.base/share/classes/java/util/HashMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/HashMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -117,7 +117,7 @@
  * should be used only to detect bugs.</i>
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <K> the type of keys maintained by this map
--- a/jdk/src/java.base/share/classes/java/util/HashSet.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/HashSet.java	Fri Apr 21 03:34:11 2017 +0000
@@ -72,7 +72,7 @@
  * should be used only to detect bugs.</i>
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <E> the type of elements maintained by this set
--- a/jdk/src/java.base/share/classes/java/util/Hashtable.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Hashtable.java	Fri Apr 21 03:34:11 2017 +0000
@@ -106,7 +106,7 @@
  *
  * <p>As of the Java 2 platform v1.2, this class was retrofitted to
  * implement the {@link Map} interface, making it a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  *
  * Java Collections Framework</a>.  Unlike the new collection
  * implementations, {@code Hashtable} is synchronized.  If a
--- a/jdk/src/java.base/share/classes/java/util/IdentityHashMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/IdentityHashMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -122,7 +122,7 @@
  * {@link HashMap} (which uses <i>chaining</i> rather than linear-probing).
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @see     System#identityHashCode(Object)
--- a/jdk/src/java.base/share/classes/java/util/Iterator.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Iterator.java	Fri Apr 21 03:34:11 2017 +0000
@@ -40,7 +40,7 @@
  * </ul>
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @apiNote
--- a/jdk/src/java.base/share/classes/java/util/LinkedHashMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/LinkedHashMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -140,7 +140,7 @@
  * <em>fail-fast</em>, and additionally report {@link Spliterator#ORDERED}.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @implNote
--- a/jdk/src/java.base/share/classes/java/util/LinkedHashSet.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/LinkedHashSet.java	Fri Apr 21 03:34:11 2017 +0000
@@ -100,7 +100,7 @@
  * should be used only to detect bugs.</i>
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <E> the type of elements maintained by this set
--- a/jdk/src/java.base/share/classes/java/util/LinkedList.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/LinkedList.java	Fri Apr 21 03:34:11 2017 +0000
@@ -70,7 +70,7 @@
  * should be used only to detect bugs.</i>
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author  Josh Bloch
--- a/jdk/src/java.base/share/classes/java/util/List.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/List.java	Fri Apr 21 03:34:11 2017 +0000
@@ -114,7 +114,7 @@
  * </ul>
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <E> the type of elements in this list
--- a/jdk/src/java.base/share/classes/java/util/ListIterator.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/ListIterator.java	Fri Apr 21 03:34:11 2017 +0000
@@ -46,7 +46,7 @@
  * {@link #previous()}.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author  Josh Bloch
--- a/jdk/src/java.base/share/classes/java/util/Map.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Map.java	Fri Apr 21 03:34:11 2017 +0000
@@ -140,7 +140,7 @@
  * </ul>
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <K> the type of keys maintained by this map
--- a/jdk/src/java.base/share/classes/java/util/NavigableMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/NavigableMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -85,7 +85,7 @@
  * {@link #keySet()} can be overridden to return {@link NavigableSet}.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author Doug Lea
--- a/jdk/src/java.base/share/classes/java/util/NavigableSet.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/NavigableSet.java	Fri Apr 21 03:34:11 2017 +0000
@@ -79,7 +79,7 @@
  * {@code NavigableSet}.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author Doug Lea
--- a/jdk/src/java.base/share/classes/java/util/Optional.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Optional.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,9 +36,9 @@
  * {@code get()} returns the value.
  *
  * <p>Additional methods that depend on the presence or absence of a contained
- * value are provided, such as {@link #orElse(java.lang.Object) orElse()}
+ * value are provided, such as {@link #orElse(Object) orElse()}
  * (returns a default value if no value is present) and
- * {@link #ifPresent(java.util.function.Consumer) ifPresent()} (performs an
+ * {@link #ifPresent(Consumer) ifPresent()} (performs an
  * action if a value is present).
  *
  * <p>This is a <a href="../lang/doc-files/ValueBased.html">value-based</a>
@@ -46,6 +46,13 @@
  * ({@code ==}), identity hash code, or synchronization) on instances of
  * {@code Optional} may have unpredictable results and should be avoided.
  *
+ * @apiNote
+ * {@code Optional} is primarily intended for use as a method return type where
+ * there is a clear need to represent "no result," and where using {@code null}
+ * is likely to cause errors. A variable whose type is {@code Optional} should
+ * never itself be {@code null}; it should always point to an {@code Optional}
+ * instance.
+ *
  * @param <T> the type of value
  * @since 1.8
  */
@@ -129,6 +136,12 @@
      * If a value is present, returns the value, otherwise throws
      * {@code NoSuchElementException}.
      *
+     * @apiNote
+     * The methods {@link #orElse(Object) orElse} and
+     * {@link #orElseGet(Supplier) orElseGet}
+     * are generally preferable to this method, as they return a substitute
+     * value if the value is absent, instead of throwing an exception.
+     *
      * @return the non-{@code null} value described by this {@code Optional}
      * @throws NoSuchElementException if no value is present
      * @see Optional#isPresent()
--- a/jdk/src/java.base/share/classes/java/util/OptionalDouble.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/OptionalDouble.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
  * <p>Additional methods that depend on the presence or absence of a contained
  * value are provided, such as {@link #orElse(double) orElse()}
  * (returns a default value if no value is present) and
- * {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (performs
+ * {@link #ifPresent(DoubleConsumer) ifPresent()} (performs
  * an action if a value is present).
  *
  * <p>This is a <a href="../lang/doc-files/ValueBased.html">value-based</a>
@@ -45,6 +45,12 @@
  * ({@code ==}), identity hash code, or synchronization) on instances of
  * {@code OptionalDouble} may have unpredictable results and should be avoided.
  *
+ * @apiNote
+ * {@code OptionalDouble} is primarily intended for use as a method return type where
+ * there is a clear need to represent "no result." A variable whose type is
+ * {@code OptionalDouble} should never itself be {@code null}; it should always point
+ * to an {@code OptionalDouble} instance.
+ *
  * @since 1.8
  */
 public final class OptionalDouble {
@@ -110,6 +116,12 @@
      * If a value is present, returns the value, otherwise throws
      * {@code NoSuchElementException}.
      *
+     * @apiNote
+     * The methods {@link #orElse(double) orElse} and
+     * {@link #orElseGet(DoubleSupplier) orElseGet}
+     * are generally preferable to this method, as they return a substitute
+     * value if the value is absent, instead of throwing an exception.
+     *
      * @return the value described by this {@code OptionalDouble}
      * @throws NoSuchElementException if no value is present
      * @see OptionalDouble#isPresent()
--- a/jdk/src/java.base/share/classes/java/util/OptionalInt.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/OptionalInt.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
  * <p>Additional methods that depend on the presence or absence of a contained
  * value are provided, such as {@link #orElse(int) orElse()}
  * (returns a default value if no value is present) and
- * {@link #ifPresent(java.util.function.IntConsumer) ifPresent()} (performs an
+ * {@link #ifPresent(IntConsumer) ifPresent()} (performs an
  * action if a value is present).
  *
  * <p>This is a <a href="../lang/doc-files/ValueBased.html">value-based</a>
@@ -45,6 +45,12 @@
  * ({@code ==}), identity hash code, or synchronization) on instances of
  * {@code OptionalInt} may have unpredictable results and should be avoided.
  *
+ * @apiNote
+ * {@code OptionalInt} is primarily intended for use as a method return type where
+ * there is a clear need to represent "no result." A variable whose type is
+ * {@code OptionalInt} should never itself be {@code null}; it should always point
+ * to an {@code OptionalInt} instance.
+ *
  * @since 1.8
  */
 public final class OptionalInt {
@@ -110,6 +116,12 @@
      * If a value is present, returns the value, otherwise throws
      * {@code NoSuchElementException}.
      *
+     * @apiNote
+     * The methods {@link #orElse(int) orElse} and
+     * {@link #orElseGet(IntSupplier) orElseGet}
+     * are generally preferable to this method, as they return a substitute
+     * value if the value is absent, instead of throwing an exception.
+     *
      * @return the value described by this {@code OptionalInt}
      * @throws NoSuchElementException if no value is present
      * @see OptionalInt#isPresent()
--- a/jdk/src/java.base/share/classes/java/util/OptionalLong.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/OptionalLong.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
  * <p>Additional methods that depend on the presence or absence of a contained
  * value are provided, such as {@link #orElse(long) orElse()}
  * (returns a default value if no value is present) and
- * {@link #ifPresent(java.util.function.LongConsumer) ifPresent()} (performs an
+ * {@link #ifPresent(LongConsumer) ifPresent()} (performs an
  * action if a value is present).
  *
  * <p>This is a <a href="../lang/doc-files/ValueBased.html">value-based</a>
@@ -45,6 +45,12 @@
  * ({@code ==}), identity hash code, or synchronization) on instances of
  * {@code OptionalLong} may have unpredictable results and should be avoided.
  *
+ * @apiNote
+ * {@code OptionalLong} is primarily intended for use as a method return type where
+ * there is a clear need to represent "no result." A variable whose type is
+ * {@code OptionalLong} should never itself be {@code null}; it should always point
+ * to an {@code OptionalLong} instance.
+ *
  * @since 1.8
  */
 public final class OptionalLong {
@@ -110,6 +116,12 @@
      * If a value is present, returns the value, otherwise throws
      * {@code NoSuchElementException}.
      *
+     * @apiNote
+     * The methods {@link #orElse(long) orElse} and
+     * {@link #orElseGet(LongSupplier) orElseGet}
+     * are generally preferable to this method, as they return a substitute
+     * value if the value is absent, instead of throwing an exception.
+     *
      * @return the value described by this {@code OptionalLong}
      * @throws NoSuchElementException if no value is present
      * @see OptionalLong#isPresent()
--- a/jdk/src/java.base/share/classes/java/util/PriorityQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/PriorityQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -73,7 +73,7 @@
  * ({@code peek}, {@code element}, and {@code size}).
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/Queue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Queue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -125,7 +125,7 @@
  * ordering properties.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/RandomAccess.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/RandomAccess.java	Fri Apr 21 03:34:11 2017 +0000
@@ -59,7 +59,7 @@
  * </pre>
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.4
--- a/jdk/src/java.base/share/classes/java/util/Set.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Set.java	Fri Apr 21 03:34:11 2017 +0000
@@ -91,7 +91,7 @@
  * </ul>
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <E> the type of elements maintained by this set
--- a/jdk/src/java.base/share/classes/java/util/SortedMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/SortedMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -93,7 +93,7 @@
  *   SortedMap&lt;String, V&gt; sub = m.subMap(low+"\0", high);</pre>
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <K> the type of keys maintained by this map
--- a/jdk/src/java.base/share/classes/java/util/SortedSet.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/SortedSet.java	Fri Apr 21 03:34:11 2017 +0000
@@ -89,7 +89,7 @@
  *   SortedSet&lt;String&gt; sub = s.subSet(low+"\0", high);</pre>
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <E> the type of elements maintained by this set
--- a/jdk/src/java.base/share/classes/java/util/TreeMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/TreeMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -92,7 +92,7 @@
  * associated map using {@code put}.)
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <K> the type of keys maintained by this map
--- a/jdk/src/java.base/share/classes/java/util/TreeSet.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/TreeSet.java	Fri Apr 21 03:34:11 2017 +0000
@@ -74,7 +74,7 @@
  * should be used only to detect bugs.</i>
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <E> the type of elements maintained by this set
--- a/jdk/src/java.base/share/classes/java/util/Vector.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Vector.java	Fri Apr 21 03:34:11 2017 +0000
@@ -70,7 +70,7 @@
  *
  * <p>As of the Java 2 platform v1.2, this class was retrofitted to
  * implement the {@link List} interface, making it a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.  Unlike the new collection
  * implementations, {@code Vector} is synchronized.  If a thread-safe
  * implementation is not needed, it is recommended to use {@link
--- a/jdk/src/java.base/share/classes/java/util/WeakHashMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/WeakHashMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -120,7 +120,7 @@
  * should be used only to detect bugs.</i>
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @param <K> the type of keys maintained by this map
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -76,7 +76,7 @@
  * methods of the {@link Collection} and {@link Iterator} interfaces.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java	Fri Apr 21 03:34:11 2017 +0000
@@ -193,7 +193,7 @@
  * the {@code BlockingDeque} in another thread.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.6
--- a/jdk/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -170,7 +170,7 @@
  * the {@code BlockingQueue} in another thread.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -254,7 +254,7 @@
  * <p>All arguments to all task methods must be non-null.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java	Fri Apr 21 03:34:11 2017 +0000
@@ -85,7 +85,7 @@
  * the {@code ConcurrentLinkedDeque} in another thread.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.7
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -99,7 +99,7 @@
  * the {@code ConcurrentLinkedQueue} in another thread.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -61,7 +61,7 @@
  * the {@code ConcurrentMap} in another thread.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentNavigableMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentNavigableMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -43,7 +43,7 @@
  * and recursively so for its navigable sub-maps.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author Doug Lea
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Fri Apr 21 03:34:11 2017 +0000
@@ -106,7 +106,7 @@
  * elements.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author Doug Lea
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Fri Apr 21 03:34:11 2017 +0000
@@ -87,7 +87,7 @@
  * distinguished from the absence of elements.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @author Doug Lea
--- a/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Fri Apr 21 03:34:11 2017 +0000
@@ -82,7 +82,7 @@
  * the {@code CopyOnWriteArrayList} in another thread.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java	Fri Apr 21 03:34:11 2017 +0000
@@ -87,7 +87,7 @@
  * }}</pre>
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @see CopyOnWriteArrayList
--- a/jdk/src/java.base/share/classes/java/util/concurrent/DelayQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/DelayQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -67,7 +67,7 @@
  * particular order.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java	Fri Apr 21 03:34:11 2017 +0000
@@ -68,7 +68,7 @@
  * methods of the {@link Collection} and {@link Iterator} interfaces.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.6
--- a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -71,7 +71,7 @@
  * methods of the {@link Collection} and {@link Iterator} interfaces.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -81,7 +81,7 @@
  * the {@code LinkedTransferQueue} in another thread.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.7
--- a/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -101,7 +101,7 @@
  * }}</pre>
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -80,7 +80,7 @@
  * methods of the {@link Collection} and {@link Iterator} interfaces.
  *
  * <p>This class is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/TransferQueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/TransferQueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -58,7 +58,7 @@
  * and {@code transfer} are effectively synonymous.
  *
  * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
+ * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
  * @since 1.7
--- a/jdk/src/java.base/share/classes/java/util/package-info.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/package-info.java	Fri Apr 21 03:34:11 2017 +0000
@@ -29,7 +29,7 @@
  * miscellaneous utility classes (a string tokenizer, a random-number
  * generator, and a bit array).
  *
- * <h2>Package Specification</h2>
+ * <h2><a name="CollectionsFramework"></a>{@index "Java Collections Framework"}</h2>
  * <ul>
  *   <li><a href="../../../technotes/guides/collections/overview.html"><b>Collections Framework Overview</b></a>
  *   <li><a href="../../../technotes/guides/collections/reference.html"><b>
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -256,7 +256,10 @@
      */
     private static URL toFileURL(String s) {
         try {
-            return Paths.get(s).toRealPath().toUri().toURL();
+            // Use an intermediate File object to construct a URI/URL without
+            // authority component as URLClassPath can't handle URLs with a UNC
+            // server name in the authority component.
+            return Paths.get(s).toRealPath().toFile().toURI().toURL();
         } catch (InvalidPathException | IOException ignore) {
             // malformed path string or class path element does not exist
             return null;
--- a/jdk/src/java.base/share/classes/sun/net/RegisteredDomain.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/net/RegisteredDomain.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,10 @@
 import java.util.Set;
 
 /*
+ * WARNING: This class may contain out-of-date information. It should be
+ * updated or replaced with an appropriate implementation. See
+ * sun.security.util.RegisteredDomain for more information.
+ *
  * The naming tables listed below were gathered from publicly available data such as
  * the subdomain registration websites listed for each top-level domain by the Internet
  * Assigned Numbers Authority and the website of the Internet Corporation for Assigned Names
@@ -696,6 +700,36 @@
     top3Map.put("tr", new HashSet<String>(Arrays.asList("gov.nc.tr")));
 }
 
+    /**
+     * Returns a {@code sun.security.util.RegisteredDomain} representing the
+     * registered part of the specified domain.
+     *
+     * @param domain the domain name
+     * @return a {@code sun.security.util.RegisteredDomain} or null
+     *    if the domain is unknown or not registerable
+     * @throws NullPointerException if domain is null
+     */
+    public static sun.security.util.RegisteredDomain registeredDomain(String domain) {
+        String name = getRegisteredDomain(domain);
+        if (name.equals(domain)) {
+            return null;
+        }
+        return new sun.security.util.RegisteredDomain() {
+            private String rname = name;
+            @Override
+            public String name() {
+                return rname;
+            }
+            @Override
+            public sun.security.util.RegisteredDomain.Type type() {
+                return sun.security.util.RegisteredDomain.Type.ICANN;
+            }
+            @Override
+            public String publicSuffix() {
+                return rname.substring(rname.indexOf(".") + 1);
+            }
+        };
+    }
 
     /*
      * Return the registered part of a qualified domain
--- a/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -516,7 +516,8 @@
      * @return <code>true</code> if the command was successful
      * @throws IOException
      */
-    private boolean issueCommand(String cmd) throws IOException {
+    private boolean issueCommand(String cmd) throws IOException,
+            sun.net.ftp.FtpProtocolException {
         if (!isConnected()) {
             throw new IllegalStateException("Not connected");
         }
@@ -527,6 +528,12 @@
                 // ignore...
             }
         }
+        if (cmd.indexOf('\n') != -1) {
+            sun.net.ftp.FtpProtocolException ex
+                    = new sun.net.ftp.FtpProtocolException("Illegal FTP command");
+            ex.initCause(new IllegalArgumentException("Illegal carriage return"));
+            throw ex;
+        }
         sendServer(cmd + "\r\n");
         return readReply();
     }
@@ -1119,7 +1126,10 @@
      */
     public void close() throws IOException {
         if (isConnected()) {
-            issueCommand("QUIT");
+            try {
+                issueCommand("QUIT");
+            } catch (FtpProtocolException e) {
+            }
             loggedIn = false;
         }
         disconnect();
@@ -1897,7 +1907,8 @@
         return null;
     }
 
-    private boolean sendSecurityData(byte[] buf) throws IOException {
+    private boolean sendSecurityData(byte[] buf) throws IOException,
+            sun.net.ftp.FtpProtocolException {
         String s = Base64.getMimeEncoder().encodeToString(buf);
         return issueCommand("ADAT " + s);
     }
--- a/jdk/src/java.base/share/classes/sun/net/smtp/SmtpClient.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/net/smtp/SmtpClient.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
 
 public class SmtpClient extends TransferProtocolClient {
 
+    private static int DEFAULT_SMTP_PORT = 25;
     String mailhost;
     SmtpPrintStream message;
 
@@ -74,6 +75,10 @@
     }
 
     public void to(String s) throws IOException {
+        if (s.indexOf('\n') != -1) {
+            throw new IOException("Illegal SMTP command",
+                    new IllegalArgumentException("Illegal carriage return"));
+        }
         int st = 0;
         int limit = s.length();
         int pos = 0;
@@ -116,16 +121,21 @@
     }
 
     public void from(String s) throws IOException {
-        if (s.startsWith("<"))
+        if (s.indexOf('\n') != -1) {
+            throw new IOException("Illegal SMTP command",
+                    new IllegalArgumentException("Illegal carriage return"));
+        }
+        if (s.startsWith("<")) {
             issueCommand("mail from: " + s + "\r\n", 250);
-        else
+        } else {
             issueCommand("mail from: <" + s + ">\r\n", 250);
+        }
     }
 
     /** open a SMTP connection to host <i>host</i>. */
     private void openServer(String host) throws IOException {
         mailhost = host;
-        openServer(mailhost, 25);
+        openServer(mailhost, DEFAULT_SMTP_PORT);
         issueCommand("helo "+InetAddress.getLocalHost().getHostName()+"\r\n", 250);
     }
 
--- a/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java	Fri Apr 21 03:34:11 2017 +0000
@@ -102,7 +102,20 @@
     // from previous releases.
     private static boolean retryPostProp = true;
 
+    /* Value of the system property jdk.ntlm.cache;
+       if false, then NTLM connections will not be cached.
+       The default value is 'true'. */
+    private static final boolean cacheNTLMProp;
+    /* Value of the system property jdk.spnego.cache;
+       if false, then connections authentified using the Negotiate/Kerberos
+       scheme will not be cached.
+       The default value is 'true'. */
+    private static final boolean cacheSPNEGOProp;
+
     volatile boolean keepingAlive;    /* this is a keep-alive connection */
+    volatile boolean disableKeepAlive;/* keep-alive has been disabled for this
+                                         connection - this will be used when
+                                         recomputing the value of keepingAlive */
     int keepAliveConnections = -1;    /* number of keep-alives left */
 
     /**Idle timeout value, in milliseconds. Zero means infinity,
@@ -152,6 +165,8 @@
         Properties props = GetPropertyAction.privilegedGetProperties();
         String keepAlive = props.getProperty("http.keepAlive");
         String retryPost = props.getProperty("sun.net.http.retryPost");
+        String cacheNTLM = props.getProperty("jdk.ntlm.cache");
+        String cacheSPNEGO = props.getProperty("jdk.spnego.cache");
 
         if (keepAlive != null) {
             keepAliveProp = Boolean.parseBoolean(keepAlive);
@@ -161,9 +176,21 @@
 
         if (retryPost != null) {
             retryPostProp = Boolean.parseBoolean(retryPost);
-        } else
+        } else {
             retryPostProp = true;
+        }
 
+        if (cacheNTLM != null) {
+            cacheNTLMProp = Boolean.parseBoolean(cacheNTLM);
+        } else {
+            cacheNTLMProp = true;
+        }
+
+        if (cacheSPNEGO != null) {
+            cacheSPNEGOProp = Boolean.parseBoolean(cacheSPNEGO);
+        } else {
+            cacheSPNEGOProp = true;
+        }
     }
 
     /**
@@ -723,6 +750,7 @@
                 nread += r;
             }
             String keep=null;
+            String authenticate=null;
             ret = b[0] == 'H' && b[1] == 'T'
                     && b[2] == 'T' && b[3] == 'P' && b[4] == '/' &&
                 b[5] == '1' && b[6] == '.';
@@ -751,17 +779,44 @@
                  */
                 if (usingProxy) { // not likely a proxy will return this
                     keep = responses.findValue("Proxy-Connection");
+                    authenticate = responses.findValue("Proxy-Authenticate");
                 }
                 if (keep == null) {
                     keep = responses.findValue("Connection");
+                    authenticate = responses.findValue("WWW-Authenticate");
                 }
+
+                // 'disableKeepAlive' starts with the value false.
+                // It can transition from false to true, but once true
+                // it stays true.
+                // If cacheNTLMProp is false, and disableKeepAlive is false,
+                // then we need to examine the response headers to figure out
+                // whether we are doing NTLM authentication. If we do NTLM,
+                // and cacheNTLMProp is false, than we can't keep this connection
+                // alive: we will switch disableKeepAlive to true.
+                boolean canKeepAlive = !disableKeepAlive;
+                if (canKeepAlive && (cacheNTLMProp == false || cacheSPNEGOProp == false)
+                        && authenticate != null) {
+                    authenticate = authenticate.toLowerCase(Locale.US);
+                    if (cacheNTLMProp == false) {
+                        canKeepAlive &= !authenticate.startsWith("ntlm ");
+                    }
+                    if (cacheSPNEGOProp == false) {
+                        canKeepAlive &= !authenticate.startsWith("negotiate ");
+                        canKeepAlive &= !authenticate.startsWith("kerberos ");
+                    }
+                }
+                disableKeepAlive |= !canKeepAlive;
+
                 if (keep != null && keep.toLowerCase(Locale.US).equals("keep-alive")) {
                     /* some servers, notably Apache1.1, send something like:
                      * "Keep-Alive: timeout=15, max=1" which we should respect.
                      */
-                    HeaderParser p = new HeaderParser(
+                    if (disableKeepAlive) {
+                        keepAliveConnections = 1;
+                    } else {
+                        HeaderParser p = new HeaderParser(
                             responses.findValue("Keep-Alive"));
-                    if (p != null) {
                         /* default should be larger in case of proxy */
                         keepAliveConnections = p.findInt("max", usingProxy?50:5);
                         keepAliveTimeout = p.findInt("timeout", usingProxy?60:5);
@@ -771,7 +826,7 @@
                      * We're talking 1.1 or later. Keep persistent until
                      * the server says to close.
                      */
-                    if (keep != null) {
+                    if (keep != null || disableKeepAlive) {
                         /*
                          * The only Connection token we understand is close.
                          * Paranoia: if there is any Connection header then
@@ -853,7 +908,7 @@
                 keepAliveConnections = 1;
                 keepingAlive = false;
             } else {
-                keepingAlive = true;
+                keepingAlive = !disableKeepAlive;
             }
             failedOnce = false;
         } else {
@@ -886,7 +941,7 @@
                 (cl >= 0 ||
                  code == HttpURLConnection.HTTP_NOT_MODIFIED ||
                  code == HttpURLConnection.HTTP_NO_CONTENT)) {
-                keepingAlive = true;
+                keepingAlive = !disableKeepAlive;
                 failedOnce = false;
             } else if (keepingAlive) {
                 /* Previously we were keeping alive, and now we're not.  Remove
@@ -908,7 +963,11 @@
                 pi.setContentType(responses.findValue("content-type"));
             }
 
-            if (isKeepingAlive())   {
+            // If disableKeepAlive == true, the client will not be returned
+            // to the cache. But we still need to use a keepalive stream to
+            // allow the multi-message authentication exchange on the connection
+            boolean useKeepAliveStream = isKeepingAlive() || disableKeepAlive;
+            if (useKeepAliveStream)   {
                 // Wrap KeepAliveStream if keep alive is enabled.
                 logFinest("KeepAlive stream used: " + url);
                 serverInput = new KeepAliveStream(serverInput, pi, cl, this);
--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java	Fri Apr 21 03:34:11 2017 +0000
@@ -65,8 +65,7 @@
      * repeatedly, via the Authenticator. Default is false, which means that this
      * behavior is switched off.
      */
-    static boolean serializeAuth;
-
+    static final boolean serializeAuth;
     static {
         serializeAuth = java.security.AccessController.doPrivileged(
             new sun.security.action.GetBooleanAction(
@@ -106,6 +105,16 @@
     public String getProtocolScheme() {
         return protocol;
     }
+    /**
+     * Whether we should cache this instance in the AuthCache.
+     * This method returns {@code true} by default.
+     * Subclasses may override this method to add
+     * additional restrictions.
+     * @return {@code true} by default.
+     */
+    protected boolean useAuthCache() {
+        return true;
+    }
 
     /**
      * requests is used to ensure that interaction with the
@@ -373,9 +382,11 @@
      */
     void addToCache() {
         String key = cacheKey(true);
-        cache.put(key, this);
-        if (supportsPreemptiveAuthorization()) {
-            cache.put(cacheKey(false), this);
+        if (useAuthCache()) {
+            cache.put(key, this);
+            if (supportsPreemptiveAuthorization()) {
+                cache.put(cacheKey(false), this);
+            }
         }
         endAuthRequest(key);
     }
--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java	Fri Apr 21 03:34:11 2017 +0000
@@ -34,6 +34,7 @@
 import sun.util.logging.PlatformLogger;
 import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE;
 import static sun.net.www.protocol.http.AuthScheme.KERBEROS;
+import sun.security.action.GetPropertyAction;
 
 /**
  * NegotiateAuthentication:
@@ -55,7 +56,14 @@
     // if it's true, a cached Negotiator is put into <code>cache</code>.
     // the cache can be used only once, so after the first use, it's cleaned.
     static HashMap <String, Boolean> supported = null;
-    static HashMap <String, Negotiator> cache = null;
+    static ThreadLocal <HashMap <String, Negotiator>> cache = null;
+    /* Whether cache is enabled for Negotiate/Kerberos */
+    private static final boolean cacheSPNEGO;
+    static {
+        String spnegoCacheProp =
+            GetPropertyAction.privilegedGetProperty("jdk.spnego.cache", "true");
+        cacheSPNEGO = Boolean.parseBoolean(spnegoCacheProp);
+    }
 
     // The HTTP Negotiate Helper
     private Negotiator negotiator = null;
@@ -119,8 +127,7 @@
      */
     private static synchronized boolean isSupportedImpl(HttpCallerInfo hci) {
         if (supported == null) {
-            supported = new HashMap <String, Boolean>();
-            cache = new HashMap <String, Negotiator>();
+            supported = new HashMap<>();
         }
         String hostname = hci.host;
         hostname = hostname.toLowerCase();
@@ -133,7 +140,15 @@
             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);
+            if (cache == null) {
+                cache = new ThreadLocal<>() {
+                    @Override
+                    protected HashMap<String, Negotiator> initialValue() {
+                        return new HashMap<>();
+                    }
+                };
+            }
+            cache.get().put(hostname, neg);
             return true;
         } else {
             supported.put(hostname, false);
@@ -141,6 +156,16 @@
         }
     }
 
+    private static synchronized HashMap<String, Negotiator> getCache() {
+        if (cache == null) return null;
+        return cache.get();
+    }
+
+    @Override
+    protected boolean useAuthCache() {
+        return super.useAuthCache() && cacheSPNEGO;
+    }
+
     /**
      * Not supported. Must use the setHeaders() method
      */
@@ -198,12 +223,11 @@
      */
     private byte[] firstToken() throws IOException {
         negotiator = null;
-        if (cache != null) {
-            synchronized(cache) {
-                negotiator = cache.get(getHost());
-                if (negotiator != null) {
-                    cache.remove(getHost()); // so that it is only used once
-                }
+        HashMap <String, Negotiator> cachedMap = getCache();
+        if (cachedMap != null) {
+            negotiator = cachedMap.get(getHost());
+            if (negotiator != null) {
+                cachedMap.remove(getHost()); // so that it is only used once
             }
         }
         if (negotiator == null) {
--- a/jdk/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * 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,6 +35,7 @@
 import javax.net.ssl.*;
 
 import sun.security.validator.*;
+import sun.security.util.AnchorCertificates;
 import sun.security.util.HostnameChecker;
 
 /**
@@ -186,13 +187,11 @@
         return v;
     }
 
-
     private void checkTrusted(X509Certificate[] chain, String authType,
                 Socket socket, boolean isClient) throws CertificateException {
         Validator v = checkTrustedInit(chain, authType, isClient);
 
-        AlgorithmConstraints constraints = null;
-        List<byte[]> responseList = Collections.emptyList();
+        X509Certificate[] trustedChain = null;
         if ((socket != null) && socket.isConnected() &&
                                         (socket instanceof SSLSocket)) {
 
@@ -202,48 +201,46 @@
                 throw new CertificateException("No handshake session");
             }
 
-            // check endpoint identity
-            String identityAlg = sslSocket.getSSLParameters().
-                    getEndpointIdentificationAlgorithm();
-            if (identityAlg != null && identityAlg.length() != 0) {
-                checkIdentity(session, chain[0], identityAlg, isClient,
-                        getRequestedServerNames(socket));
-            }
-
             // create the algorithm constraints
             ProtocolVersion protocolVersion =
                 ProtocolVersion.valueOf(session.getProtocol());
-            if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
-                if (session instanceof ExtendedSSLSession) {
-                    ExtendedSSLSession extSession =
-                                    (ExtendedSSLSession)session;
-                    String[] localSupportedSignAlgs =
-                            extSession.getLocalSupportedSignatureAlgorithms();
+            boolean isExtSession = (session instanceof ExtendedSSLSession);
+            AlgorithmConstraints constraints = null;
+            if (protocolVersion.v >= ProtocolVersion.TLS12.v && isExtSession) {
+                ExtendedSSLSession extSession = (ExtendedSSLSession)session;
+                String[] localSupportedSignAlgs =
+                        extSession.getLocalSupportedSignatureAlgorithms();
 
-                    constraints = new SSLAlgorithmConstraints(
-                                    sslSocket, localSupportedSignAlgs, false);
-                } else {
-                    constraints =
-                            new SSLAlgorithmConstraints(sslSocket, false);
-                }
+                constraints = new SSLAlgorithmConstraints(
+                                sslSocket, localSupportedSignAlgs, false);
             } else {
                 constraints = new SSLAlgorithmConstraints(sslSocket, false);
             }
 
             // Grab any stapled OCSP responses for use in validation
-            if (session instanceof ExtendedSSLSession) {
+            List<byte[]> responseList = Collections.emptyList();
+            if (!isClient && isExtSession) {
                 responseList =
                         ((ExtendedSSLSession)session).getStatusResponses();
             }
-        }
+            trustedChain = validate(v, chain, responseList,
+                    constraints, isClient ? null : authType);
+
+            // check if EE certificate chains to a public root CA (as
+            // pre-installed in cacerts)
+            boolean chainsToPublicCA =
+                AnchorCertificates.contains(trustedChain[trustedChain.length-1]);
 
-        X509Certificate[] trustedChain = null;
-        if (isClient) {
+            // check endpoint identity
+            String identityAlg = sslSocket.getSSLParameters().
+                    getEndpointIdentificationAlgorithm();
+            if (identityAlg != null && identityAlg.length() != 0) {
+                checkIdentity(session, trustedChain[0], identityAlg, isClient,
+                        getRequestedServerNames(socket), chainsToPublicCA);
+            }
+        } else {
             trustedChain = validate(v, chain, Collections.emptyList(),
-                    constraints, null);
-        } else {
-            trustedChain = validate(v, chain, responseList, constraints,
-                    authType);
+                    null, isClient ? null : authType);
         }
         if (debug != null && Debug.isOn("trustmanager")) {
             System.out.println("Found trusted certificate:");
@@ -255,56 +252,53 @@
             SSLEngine engine, boolean isClient) throws CertificateException {
         Validator v = checkTrustedInit(chain, authType, isClient);
 
-        AlgorithmConstraints constraints = null;
-        List<byte[]> responseList = Collections.emptyList();
+        X509Certificate[] trustedChain = null;
         if (engine != null) {
             SSLSession session = engine.getHandshakeSession();
             if (session == null) {
                 throw new CertificateException("No handshake session");
             }
 
-            // check endpoint identity
-            String identityAlg = engine.getSSLParameters().
-                    getEndpointIdentificationAlgorithm();
-            if (identityAlg != null && identityAlg.length() != 0) {
-                checkIdentity(session, chain[0], identityAlg, isClient,
-                        getRequestedServerNames(engine));
-            }
-
             // create the algorithm constraints
             ProtocolVersion protocolVersion =
                 ProtocolVersion.valueOf(session.getProtocol());
-            if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
-                if (session instanceof ExtendedSSLSession) {
-                    ExtendedSSLSession extSession =
-                                    (ExtendedSSLSession)session;
-                    String[] localSupportedSignAlgs =
-                            extSession.getLocalSupportedSignatureAlgorithms();
+            boolean isExtSession = (session instanceof ExtendedSSLSession);
+            AlgorithmConstraints constraints = null;
+            if (protocolVersion.v >= ProtocolVersion.TLS12.v && isExtSession) {
+                ExtendedSSLSession extSession = (ExtendedSSLSession)session;
+                String[] localSupportedSignAlgs =
+                        extSession.getLocalSupportedSignatureAlgorithms();
 
-                    constraints = new SSLAlgorithmConstraints(
-                                    engine, localSupportedSignAlgs, false);
-                } else {
-                    constraints =
-                            new SSLAlgorithmConstraints(engine, false);
-                }
+                constraints = new SSLAlgorithmConstraints(
+                                engine, localSupportedSignAlgs, false);
             } else {
                 constraints = new SSLAlgorithmConstraints(engine, false);
             }
 
             // Grab any stapled OCSP responses for use in validation
-            if (session instanceof ExtendedSSLSession) {
+            List<byte[]> responseList = Collections.emptyList();
+            if (!isClient && isExtSession) {
                 responseList =
                         ((ExtendedSSLSession)session).getStatusResponses();
             }
-        }
+            trustedChain = validate(v, chain, responseList,
+                    constraints, isClient ? null : authType);
+
+            // check if EE certificate chains to a public root CA (as
+            // pre-installed in cacerts)
+            boolean chainsToPublicCA =
+                AnchorCertificates.contains(trustedChain[trustedChain.length-1]);
 
-        X509Certificate[] trustedChain = null;
-        if (isClient) {
+            // check endpoint identity
+            String identityAlg = engine.getSSLParameters().
+                    getEndpointIdentificationAlgorithm();
+            if (identityAlg != null && identityAlg.length() != 0) {
+                checkIdentity(session, trustedChain[0], identityAlg, isClient,
+                        getRequestedServerNames(engine), chainsToPublicCA);
+            }
+        } else {
             trustedChain = validate(v, chain, Collections.emptyList(),
-                    constraints, null);
-        } else {
-            trustedChain = validate(v, chain, responseList, constraints,
-                    authType);
+                    null, isClient ? null : authType);
         }
         if (debug != null && Debug.isOn("trustmanager")) {
             System.out.println("Found trusted certificate:");
@@ -437,7 +431,8 @@
             X509Certificate cert,
             String algorithm,
             boolean isClient,
-            List<SNIServerName> sniNames) throws CertificateException {
+            List<SNIServerName> sniNames,
+            boolean chainsToPublicCA) throws CertificateException {
 
         boolean identifiable = false;
         String peerHost = session.getPeerHost();
@@ -445,7 +440,7 @@
             String hostname = getHostNameInSNI(sniNames);
             if (hostname != null) {
                 try {
-                    checkIdentity(hostname, cert, algorithm);
+                    checkIdentity(hostname, cert, algorithm, chainsToPublicCA);
                     identifiable = true;
                 } catch (CertificateException ce) {
                     if (hostname.equalsIgnoreCase(peerHost)) {
@@ -458,7 +453,7 @@
         }
 
         if (!identifiable) {
-            checkIdentity(peerHost, cert, algorithm);
+            checkIdentity(peerHost, cert, algorithm, chainsToPublicCA);
         }
     }
 
@@ -469,6 +464,12 @@
      */
     static void checkIdentity(String hostname, X509Certificate cert,
             String algorithm) throws CertificateException {
+        checkIdentity(hostname, cert, algorithm, false);
+    }
+
+    private static void checkIdentity(String hostname, X509Certificate cert,
+            String algorithm, boolean chainsToPublicCA)
+            throws CertificateException {
         if (algorithm != null && algorithm.length() != 0) {
             // if IPv6 strip off the "[]"
             if ((hostname != null) && hostname.startsWith("[") &&
@@ -478,11 +479,11 @@
 
             if (algorithm.equalsIgnoreCase("HTTPS")) {
                 HostnameChecker.getInstance(HostnameChecker.TYPE_TLS).match(
-                        hostname, cert);
+                        hostname, cert, chainsToPublicCA);
             } else if (algorithm.equalsIgnoreCase("LDAP") ||
                     algorithm.equalsIgnoreCase("LDAPS")) {
                 HostnameChecker.getInstance(HostnameChecker.TYPE_LDAP).match(
-                        hostname, cert);
+                        hostname, cert, chainsToPublicCA);
             } else {
                 throw new CertificateException(
                         "Unknown identification algorithm: " + algorithm);
--- a/jdk/src/java.base/share/classes/sun/security/util/HostnameChecker.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/HostnameChecker.java	Fri Apr 21 03:34:11 2017 +0000
@@ -28,18 +28,16 @@
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-import java.util.*;
-
 import java.security.Principal;
 import java.security.cert.*;
-
+import java.util.*;
 import javax.security.auth.x500.X500Principal;
 
+import sun.net.util.IPAddressUtil;
 import sun.security.ssl.ClientKeyExchangeService;
+import sun.security.ssl.Debug;
 import sun.security.x509.X500Name;
 
-import sun.net.util.IPAddressUtil;
-
 /**
  * Class to check hostnames against the names specified in a certificate as
  * required for TLS and LDAP.
@@ -61,6 +59,8 @@
     private static final int ALTNAME_DNS = 2;
     private static final int ALTNAME_IP  = 7;
 
+    private static final Debug debug = Debug.getInstance("ssl");
+
     // the algorithm to follow to perform the check. Currently unused.
     private final byte checkType;
 
@@ -84,18 +84,27 @@
     /**
      * Perform the check.
      *
-     * @exception CertificateException if the name does not match any of
-     * the names specified in the certificate
+     * @param expectedName the expected host name or ip address
+     * @param cert the certificate to check against
+     * @param chainsToPublicCA true if the certificate chains to a public
+     *     root CA (as pre-installed in the cacerts file)
+     * @throws CertificateException if the name does not match any of
+     *     the names specified in the certificate
      */
-    public void match(String expectedName, X509Certificate cert)
-            throws CertificateException {
+    public void match(String expectedName, X509Certificate cert,
+                      boolean chainsToPublicCA) throws CertificateException {
         if (isIpAddress(expectedName)) {
            matchIP(expectedName, cert);
         } else {
-           matchDNS(expectedName, cert);
+           matchDNS(expectedName, cert, chainsToPublicCA);
         }
     }
 
+    public void match(String expectedName, X509Certificate cert)
+            throws CertificateException {
+        match(expectedName, cert, false);
+    }
+
     /**
      * Perform the check for Kerberos.
      */
@@ -185,20 +194,21 @@
      * Certification Authorities are encouraged to use the dNSName instead.
      *
      * Matching is performed using the matching rules specified by
-     * [RFC2459].  If more than one identity of a given type is present in
+     * [RFC5280].  If more than one identity of a given type is present in
      * the certificate (e.g., more than one dNSName name, a match in any one
      * of the set is considered acceptable.)
      */
-    private void matchDNS(String expectedName, X509Certificate cert)
+    private void matchDNS(String expectedName, X509Certificate cert,
+                          boolean chainsToPublicCA)
             throws CertificateException {
         Collection<List<?>> subjAltNames = cert.getSubjectAlternativeNames();
         if (subjAltNames != null) {
             boolean foundDNS = false;
-            for ( List<?> next : subjAltNames) {
+            for (List<?> next : subjAltNames) {
                 if (((Integer)next.get(0)).intValue() == ALTNAME_DNS) {
                     foundDNS = true;
                     String dnsName = (String)next.get(1);
-                    if (isMatched(expectedName, dnsName)) {
+                    if (isMatched(expectedName, dnsName, chainsToPublicCA)) {
                         return;
                     }
                 }
@@ -215,7 +225,8 @@
                                                     (X500Name.commonName_oid);
         if (derValue != null) {
             try {
-                if (isMatched(expectedName, derValue.getAsString())) {
+                if (isMatched(expectedName, derValue.getAsString(),
+                              chainsToPublicCA)) {
                     return;
                 }
             } catch (IOException e) {
@@ -261,7 +272,11 @@
      * The <code>template</code> parameter
      * may contain the wildcard character *
      */
-    private boolean isMatched(String name, String template) {
+    private boolean isMatched(String name, String template,
+                              boolean chainsToPublicCA) {
+        if (hasIllegalWildcard(name, template, chainsToPublicCA)) {
+            return false;
+        }
         if (checkType == TYPE_TLS) {
             return matchAllWildcards(name, template);
         } else if (checkType == TYPE_LDAP) {
@@ -271,6 +286,61 @@
         }
     }
 
+    /**
+     * Returns true if the template contains an illegal wildcard character.
+     */
+    private static boolean hasIllegalWildcard(String domain, String template,
+                                              boolean chainsToPublicCA) {
+        // not ok if it is a single wildcard character or "*."
+        if (template.equals("*") || template.equals("*.")) {
+            if (debug != null) {
+                debug.println("Certificate domain name has illegal single " +
+                              "wildcard character: " + template);
+            }
+            return true;
+        }
+
+        int lastWildcardIndex = template.lastIndexOf("*");
+
+        // ok if it has no wildcard character
+        if (lastWildcardIndex == -1) {
+            return false;
+        }
+
+        String afterWildcard = template.substring(lastWildcardIndex);
+        int firstDotIndex = afterWildcard.indexOf(".");
+
+        // not ok if there is no dot after wildcard (ex: "*com")
+        if (firstDotIndex == -1) {
+            if (debug != null) {
+                debug.println("Certificate domain name has illegal wildcard, " +
+                              "no dot after wildcard character: " + template);
+            }
+            return true;
+        }
+
+        // If the wildcarded domain is a top-level domain under which names
+        // can be registered, then a wildcard is not allowed.
+
+        if (!chainsToPublicCA) {
+            return false; // skip check for non-public certificates
+        }
+        Optional<RegisteredDomain> rd = RegisteredDomain.from(domain)
+                .filter(d -> d.type() == RegisteredDomain.Type.ICANN);
+
+        if (rd.isPresent()) {
+            String wDomain = afterWildcard.substring(firstDotIndex + 1);
+            if (rd.get().publicSuffix().equalsIgnoreCase(wDomain)) {
+                if (debug != null) {
+                    debug.println("Certificate domain name has illegal " +
+                                  "wildcard for public suffix: " + template);
+                }
+                return true;
+            }
+        }
+
+        return false;
+    }
 
     /**
      * Returns true if name matches against template.<p>
@@ -317,9 +387,9 @@
         name = name.toLowerCase(Locale.ENGLISH);
         template = template.toLowerCase(Locale.ENGLISH);
 
-        // Retreive leftmost component
-        int templateIdx = template.indexOf('.');
-        int nameIdx = name.indexOf('.');
+        // Retrieve leftmost component
+        int templateIdx = template.indexOf(".");
+        int nameIdx = name.indexOf(".");
 
         if (templateIdx == -1)
             templateIdx = template.length();
@@ -344,7 +414,7 @@
      */
     private static boolean matchWildCards(String name, String template) {
 
-        int wildcardIdx = template.indexOf('*');
+        int wildcardIdx = template.indexOf("*");
         if (wildcardIdx == -1)
             return name.equals(template);
 
@@ -367,7 +437,7 @@
 
             // update the match scope
             name = name.substring(beforeStartIdx + beforeWildcard.length());
-            wildcardIdx = afterWildcard.indexOf('*');
+            wildcardIdx = afterWildcard.indexOf("*");
         }
         return name.endsWith(afterWildcard);
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/RegisteredDomain.java	Fri Apr 21 03:34:11 2017 +0000
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.util;
+
+import java.util.Optional;
+
+/**
+ * A domain that is registered under a "public suffix". The public suffix is
+ * a top-level domain under which names can be registered. For example,
+ * "com" and "co.uk" are public suffixes, and "example.com" and "example.co.uk"
+ * are registered domains.
+ * <p>
+ * The primary purpose of this class is to determine if domains are safe to
+ * use in various use-cases.
+ */
+public interface RegisteredDomain {
+
+    public enum Type {
+        /**
+         * An ICANN registered domain.
+         */
+        ICANN,
+        /**
+         * A private registered domain.
+         */
+        PRIVATE
+    }
+
+    /**
+     * Returns the name of the registered domain.
+     *
+     * @return the name of the registered domain
+     */
+    String name();
+
+    /**
+     * Returns the type of the registered domain.
+     *
+     * @return the type of the registered domain
+     */
+    Type type();
+
+    /**
+     * Returns the public suffix of the registered domain.
+     *
+     * @return the public suffix of the registered domain
+     */
+    String publicSuffix();
+
+    /**
+     * Returns an {@code Optional<RegisteredDomain>} representing the
+     * registered part of the specified domain.
+     *
+     * {@implNote}
+     * The default implementation is based on the legacy
+     * {@code sun.net.RegisteredDomain} class which is no longer maintained.
+     * It should be updated or replaced with an appropriate implementation.
+     *
+     * @param domain the domain name
+     * @return an {@code Optional<RegisteredDomain>}; the {@code Optional} is
+     *    empty if the domain is unknown or not registerable
+     * @throws NullPointerException if domain is null
+     */
+    public static Optional<RegisteredDomain> from(String domain) {
+        if (domain == null) {
+            throw new NullPointerException();
+        }
+        return Optional.ofNullable(sun.net.RegisteredDomain.registeredDomain(domain));
+    }
+}
--- a/jdk/src/java.base/unix/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/unix/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java	Fri Apr 21 03:34:11 2017 +0000
@@ -35,6 +35,7 @@
 import java.security.GeneralSecurityException;
 import java.util.Base64;
 import java.util.Objects;
+import java.util.Properties;
 
 import sun.net.www.HeaderParser;
 import sun.net.www.protocol.http.AuthenticationInfo;
@@ -76,8 +77,15 @@
 
     private String hostname;
     /* Domain to use if not specified by user */
-    private static String defaultDomain =
-            GetPropertyAction.privilegedGetProperty("http.auth.ntlm.domain", "");
+    private static final String defaultDomain;
+    /* Whether cache is enabled for NTLM */
+    private static final boolean ntlmCache;
+    static {
+        Properties props = GetPropertyAction.privilegedGetProperties();
+        defaultDomain = props.getProperty("http.auth.ntlm.domain", "");
+        String ntlmCacheProp = props.getProperty("jdk.ntlm.cache", "true");
+        ntlmCache = Boolean.parseBoolean(ntlmCacheProp);
+    }
 
     public static boolean supportsTransparentAuth () {
         return false;
@@ -171,6 +179,11 @@
         init (pw);
     }
 
+    @Override
+    protected boolean useAuthCache() {
+        return ntlmCache && super.useAuthCache();
+    }
+
     /**
      * @return true if this authentication supports preemptive authorization
      */
--- a/jdk/src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java	Fri Apr 21 03:34:11 2017 +0000
@@ -31,6 +31,7 @@
 import java.net.UnknownHostException;
 import java.net.URL;
 import java.util.Objects;
+import java.util.Properties;
 import sun.net.www.HeaderParser;
 import sun.net.www.protocol.http.AuthenticationInfo;
 import sun.net.www.protocol.http.AuthScheme;
@@ -51,12 +52,16 @@
         NTLMAuthenticationCallback.getNTLMAuthenticationCallback();
 
     private String hostname;
-    private static String defaultDomain; /* Domain to use if not specified by user */
-
+    /* Domain to use if not specified by user */
+    private static final String defaultDomain;
+    /* Whether cache is enabled for NTLM */
+    private static final boolean ntlmCache;
     static {
-        defaultDomain = GetPropertyAction
-                .privilegedGetProperty("http.auth.ntlm.domain", "domain");
-    };
+        Properties props = GetPropertyAction.privilegedGetProperties();
+        defaultDomain = props.getProperty("http.auth.ntlm.domain", "domain");
+        String ntlmCacheProp = props.getProperty("jdk.ntlm.cache", "true");
+        ntlmCache = Boolean.parseBoolean(ntlmCacheProp);
+    }
 
     private void init0() {
 
@@ -136,6 +141,11 @@
         init (pw);
     }
 
+    @Override
+    protected boolean useAuthCache() {
+        return ntlmCache && super.useAuthCache();
+    }
+
     /**
      * @return true if this authentication supports preemptive authorization
      */
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java	Fri Apr 21 03:34:11 2017 +0000
@@ -73,8 +73,7 @@
     public void setDockIconImage(final Image image) {
         try {
             final CImage cImage = CImage.createFromImage(image);
-            final long nsImagePtr = getNSImagePtrFrom(cImage);
-            nativeSetDockIconImage(nsImagePtr);
+            cImage.execute(_AppDockIconHandler::nativeSetDockIconImage);
         } catch (final Throwable e) {
             throw new RuntimeException(e);
         }
@@ -101,16 +100,4 @@
     void setDockIconProgress(int value) {
         nativeSetDockIconProgress(value);
     }
-
-    static long getNSImagePtrFrom(final CImage cImage) {
-        if (cImage == null) return 0;
-
-        try {
-            final Field cImagePtrField = CFRetainedResource.class.getDeclaredField("ptr");
-            cImagePtrField.setAccessible(true);
-            return cImagePtrField.getLong(cImage);
-        } catch (final Throwable e) {
-            throw new RuntimeException(e);
-        }
-    }
 }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,13 @@
 
 package com.apple.eawt;
 
+import java.awt.Container;
 import java.awt.Frame;
 
-import javax.swing.*;
+
+import javax.swing.JFrame;
+import javax.swing.JLayeredPane;
+import javax.swing.JMenuBar;
 import javax.swing.plaf.MenuBarUI;
 
 import com.apple.laf.ScreenMenuBar;
@@ -102,10 +106,15 @@
             return;
         }
 
-        final MenuBarUI ui = menuBar.getUI();
+        Container parent = menuBar.getParent();
+        if (parent instanceof JLayeredPane) {
+            ((JLayeredPane) parent).remove(menuBar);
+        }
+
+        MenuBarUI ui = menuBar.getUI();
         if (!(ui instanceof AquaMenuBarUI)) {
-            // Aqua was not installed
-            throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel");
+            ui = new AquaMenuBarUI();
+            menuBar.setUI(ui);
         }
 
         final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * 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 @@
     public void uninstallUI(final JComponent c) {
         if (fScreenMenuBar != null) {
             final JFrame frame = (JFrame)(c.getTopLevelAncestor());
-            if (frame.getMenuBar() == fScreenMenuBar) {
+            if (frame != null && frame.getMenuBar() == fScreenMenuBar) {
                 frame.setMenuBar((MenuBar)null);
             }
             fScreenMenuBar = null;
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java	Fri Apr 21 03:34:11 2017 +0000
@@ -108,7 +108,7 @@
         OGLRenderQueue rq = OGLRenderQueue.getInstance();
         rq.lock();
         try {
-            validate(getPointer(), cglsd);
+            execute(ptr -> validate(ptr, cglsd));
         } finally {
             rq.unlock();
         }
@@ -124,7 +124,7 @@
     private void setScale(final int _scale) {
         if (scale != _scale) {
             scale = _scale;
-            nativeSetScale(getPointer(), scale);
+            execute(ptr -> nativeSetScale(ptr, scale));
         }
     }
 
@@ -138,7 +138,7 @@
         OGLRenderQueue rq = OGLRenderQueue.getInstance();
         rq.lock();
         try {
-            blitTexture(getPointer());
+            execute(ptr -> blitTexture(ptr));
         } finally {
             rq.unlock();
         }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java	Fri Apr 21 03:34:11 2017 +0000
@@ -25,6 +25,10 @@
 
 package sun.lwawt.macosx;
 
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
 /**
  * Safely holds and disposes of native AppKit resources, using the
  * correct AppKit threading and Objective-C GC semantics.
@@ -36,6 +40,10 @@
     // TODO this pointer should be private and accessed via CFNativeAction class
     protected volatile long ptr;
 
+    private final ReadWriteLock lock = new ReentrantReadWriteLock();
+    private final Lock writeLock = lock.writeLock();
+    private final Lock readLock = lock.readLock();
+
     /**
      * @param ptr CFRetained native object pointer
      * @param disposeOnAppKitThread is the object needs to be CFReleased on the main thread
@@ -50,21 +58,31 @@
      * @param ptr CFRetained native object pointer
      */
     protected void setPtr(final long ptr) {
-        synchronized (this) {
-            if (this.ptr != 0) dispose();
+        writeLock.lock();
+        try {
+            if (this.ptr != 0) {
+                dispose();
+            }
             this.ptr = ptr;
+        } finally {
+            writeLock.unlock();
         }
     }
 
     /**
-     * Manually CFReleases the native resource
+     * Manually CFReleases the native resource.
      */
     protected void dispose() {
         long oldPtr = 0L;
-        synchronized (this) {
-            if (ptr == 0) return;
+        writeLock.lock();
+        try {
+            if (ptr == 0) {
+                return;
+            }
             oldPtr = ptr;
             ptr = 0;
+        } finally {
+            writeLock.unlock();
         }
 
         nativeCFRelease(oldPtr, disposeOnAppKitThread); // perform outside of the synchronized block
@@ -109,9 +127,14 @@
      *
      * @param  action The native operation
      */
-    public final synchronized void execute(final CFNativeAction action) {
-        if (ptr != 0) {
-            action.run(ptr);
+    public final void execute(final CFNativeAction action) {
+        readLock.lock();
+        try {
+            if (ptr != 0) {
+                action.run(ptr);
+            }
+        } finally {
+            readLock.unlock();
         }
     }
 
@@ -127,9 +150,14 @@
      * @return result of the native operation, usually the native pointer to
      *         some other data
      */
-    final synchronized long executeGet(final CFNativeActionGet action) {
-        if (ptr != 0) {
-            return action.run(ptr);
+    final long executeGet(final CFNativeActionGet action) {
+        readLock.lock();
+        try {
+            if (ptr != 0) {
+                return action.run(ptr);
+            }
+        } finally {
+            readLock.unlock();
         }
         return 0;
     }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,8 @@
 import java.util.Arrays;
 import java.util.List;
 import java.awt.image.MultiResolutionImage;
+import java.util.concurrent.atomic.AtomicReference;
+
 import sun.awt.image.MultiResolutionCachedImage;
 
 import sun.awt.image.SunWritableRaster;
@@ -254,15 +256,26 @@
 
     /** @return A MultiResolution image created from nsImagePtr, or null. */
     private Image toImage() {
-        if (ptr == 0) return null;
+        if (ptr == 0) {
+            return null;
+        }
 
-        final Dimension2D size = nativeGetNSImageSize(ptr);
+        AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
+        execute(ptr -> {
+            sizeRef.set(nativeGetNSImageSize(ptr));
+        });
+        final Dimension2D size = sizeRef.get();
+        if (size == null) {
+            return null;
+        }
         final int w = (int)size.getWidth();
         final int h = (int)size.getHeight();
-
-        Dimension2D[] sizes
-                = nativeGetNSImageRepresentationSizes(ptr,
-                        size.getWidth(), size.getHeight());
+        AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
+        execute(ptr -> {
+            repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
+                                                           size.getHeight()));
+        });
+        Dimension2D[] sizes = repRef.get();
 
         return sizes == null || sizes.length < 2 ?
                 new MultiResolutionCachedImage(w, h, (width, height)
@@ -275,18 +288,18 @@
         final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE);
         final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();
         final int[] buffer = SunWritableRaster.stealData(dbi, 0);
-        nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight);
+        execute(ptr->nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight));
         SunWritableRaster.markDirty(dbi);
         return bimg;
     }
 
     /** If nsImagePtr != 0 then scale this NSImage. @return *this* */
     CImage resize(final double w, final double h) {
-        if (ptr != 0) nativeSetNSImageSize(ptr, w, h);
+        execute(ptr -> nativeSetNSImageSize(ptr, w, h));
         return this;
     }
 
     void resizeRepresentations(double w, double h) {
-        if (ptr != 0) nativeResizeNSImageRepresentations(ptr, w, h);
+        execute(ptr -> nativeResizeNSImageRepresentations(ptr, w, h));
     }
 }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java	Fri Apr 21 03:34:11 2017 +0000
@@ -113,7 +113,13 @@
      */
     public final void setImage(final java.awt.Image img) {
         CImage cimg = CImage.getCreator().createFromImage(img);
-        execute(ptr -> nativeSetImage(ptr, cimg == null ? 0L : cimg.ptr));
+        execute(ptr -> {
+            if (cimg == null) {
+                nativeSetImage(ptr, 0L);
+            } else {
+                cimg.execute(imgPtr -> nativeSetImage(ptr, imgPtr));
+            }
+        });
     }
 
     /**
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * 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,9 @@
         super(0, true);
     }
 
+    /**
+     * Used by JAWT.
+     */
     public long getPointer() {
         return ptr;
     }
@@ -61,7 +64,7 @@
         // translates values from the coordinate system of the top-level window
         // to the coordinate system of the content view
         final Insets insets = platformWindow.getPeer().getInsets();
-        nativeSetBounds(getPointer(), x - insets.left, y - insets.top, w, h);
+        execute(ptr->nativeSetBounds(ptr, x - insets.left, y - insets.top, w, h));
     }
 
     @Override
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java	Fri Apr 21 03:34:11 2017 +0000
@@ -107,11 +107,6 @@
     }
 
     @Override
-    public long getNSWindowPtr() {
-        return 0;
-    }
-
-    @Override
     public SurfaceData getSurfaceData() {
         return null;
     }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * 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,6 +27,9 @@
 
 import java.awt.*;
 import java.awt.geom.Rectangle2D;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 
 import sun.awt.CGraphicsConfig;
 import sun.awt.CGraphicsEnvironment;
@@ -83,7 +86,7 @@
      * Cocoa coordinates).
      */
     public void setBounds(int x, int y, int width, int height) {
-        CWrapper.NSView.setFrame(ptr, x, y, width, height);
+        execute(ptr->CWrapper.NSView.setFrame(ptr, x, y, width, height));
     }
 
     // REMIND: CGLSurfaceData expects top-level's size
@@ -96,7 +99,7 @@
     }
 
     public void setToolTip(String msg) {
-        CWrapper.NSView.setToolTip(ptr, msg);
+        execute(ptr -> CWrapper.NSView.setToolTip(ptr, msg));
     }
 
     // ----------------------------------------------------------------------
@@ -147,18 +150,25 @@
     }
 
     public void setAutoResizable(boolean toResize) {
-        nativeSetAutoResizable(this.getAWTView(), toResize);
+        execute(ptr -> nativeSetAutoResizable(ptr, toResize));
     }
 
     public boolean isUnderMouse() {
-        return nativeIsViewUnderMouse(getAWTView());
+        AtomicBoolean ref = new AtomicBoolean();
+        execute(ptr -> {
+            ref.set(nativeIsViewUnderMouse(ptr));
+        });
+        return ref.get();
     }
 
     public GraphicsDevice getGraphicsDevice() {
         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
         CGraphicsEnvironment cge = (CGraphicsEnvironment)ge;
-        int displayID = nativeGetNSViewDisplayID(getAWTView());
-        GraphicsDevice gd = cge.getScreenDevice(displayID);
+        AtomicInteger ref = new AtomicInteger();
+        execute(ptr -> {
+            ref.set(nativeGetNSViewDisplayID(ptr));
+        });
+        GraphicsDevice gd = cge.getScreenDevice(ref.get());
         if (gd == null) {
             // this could possibly happen during device removal
             // use the default screen device in this case
@@ -168,8 +178,15 @@
     }
 
     public Point getLocationOnScreen() {
-        Rectangle r = nativeGetLocationOnScreen(this.getAWTView()).getBounds();
-        return new Point(r.x, r.y);
+        AtomicReference<Rectangle> ref = new AtomicReference<>();
+        execute(ptr -> {
+            ref.set(nativeGetLocationOnScreen(ptr).getBounds());
+        });
+        Rectangle r = ref.get();
+        if (r != null) {
+            return new Point(r.x, r.y);
+        }
+        return new Point(0, 0);
     }
 
     // ----------------------------------------------------------------------
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Apr 21 03:34:11 2017 +0000
@@ -35,6 +35,9 @@
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
 
 import javax.swing.*;
 
@@ -201,16 +204,16 @@
             c.setStyleBits(FULLSCREENABLE, fullscrenable);
         }},
         new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
-            nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
+            c.execute(ptr -> nativeRevalidateNSWindowShadow(ptr));
         }},
         new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
             if (value == null || !(value instanceof java.io.File)) {
-                nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null);
+                c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, null));
                 return;
             }
 
             final String filename = ((java.io.File)value).getAbsolutePath();
-            nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
+            c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, filename));
         }}
     }) {
         @SuppressWarnings("deprecation")
@@ -261,7 +264,6 @@
         contentView = createContentView();
         contentView.initialize(peer, responder);
 
-        final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L;
         Rectangle bounds;
         if (!IS(DECORATED, styleBits)) {
             // For undecorated frames the move/resize event does not come if the frame is centered on the screen
@@ -270,9 +272,21 @@
         } else {
             bounds = _peer.constrainBounds(_target.getBounds());
         }
-        final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(),
-                ownerPtr, styleBits, bounds.x, bounds.y, bounds.width, bounds.height);
-        setPtr(nativeWindowPtr);
+        AtomicLong ref = new AtomicLong();
+        contentView.execute(viewPtr -> {
+            if (owner != null) {
+                owner.execute(ownerPtr -> {
+                    ref.set(nativeCreateNSWindow(viewPtr, ownerPtr, styleBits,
+                                                 bounds.x, bounds.y,
+                                                 bounds.width, bounds.height));
+                });
+            } else {
+                ref.set(nativeCreateNSWindow(viewPtr, 0,
+                                             styleBits, bounds.x, bounds.y,
+                                             bounds.width, bounds.height));
+            }
+        });
+        setPtr(ref.get());
 
         if (target instanceof javax.swing.RootPaneContainer) {
             final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane();
@@ -436,30 +450,31 @@
 
     // this is the counter-point to -[CWindow _nativeSetStyleBit:]
     private void setStyleBits(final int mask, final boolean value) {
-        nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0);
+        execute(ptr -> nativeSetNSWindowStyleBits(ptr, mask, value ? mask : 0));
     }
 
     private native void _toggleFullScreenMode(final long model);
 
     public void toggleFullScreen() {
-        _toggleFullScreenMode(getNSWindowPtr());
+        execute(this::_toggleFullScreenMode);
     }
 
     @Override // PlatformWindow
     public void setMenuBar(MenuBar mb) {
-        final long nsWindowPtr = getNSWindowPtr();
         CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb);
-        if (mbPeer != null) {
-            mbPeer.execute(ptr -> nativeSetNSWindowMenuBar(nsWindowPtr, ptr));
-        } else {
-            nativeSetNSWindowMenuBar(nsWindowPtr, 0);
-        }
+        execute(nsWindowPtr->{
+            if (mbPeer != null) {
+                mbPeer.execute(ptr -> nativeSetNSWindowMenuBar(nsWindowPtr, ptr));
+            } else {
+                nativeSetNSWindowMenuBar(nsWindowPtr, 0);
+            }
+        });
     }
 
     @Override // PlatformWindow
     public void dispose() {
         contentView.dispose();
-        nativeDispose(getNSWindowPtr());
+        execute(CPlatformWindow::nativeDispose);
         CPlatformWindow.super.dispose();
     }
 
@@ -472,7 +487,11 @@
 
     @Override // PlatformWindow
     public Insets getInsets() {
-        return nativeGetNSWindowInsets(getNSWindowPtr());
+        AtomicReference<Insets> ref = new AtomicReference<>();
+        execute(ptr -> {
+            ref.set(nativeGetNSWindowInsets(ptr));
+        });
+        return ref.get() != null ? ref.get() : new Insets(0, 0, 0, 0);
     }
 
     @Override // PlatformWindow
@@ -498,11 +517,11 @@
 
     @Override // PlatformWindow
     public void setBounds(int x, int y, int w, int h) {
-        nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h);
+        execute(ptr -> nativeSetNSWindowBounds(ptr, x, y, w, h));
     }
 
     public void setMaximizedBounds(int x, int y, int w, int h) {
-        nativeSetNSWindowStandardFrame(getNSWindowPtr(), x, y, w, h);
+        execute(ptr -> nativeSetNSWindowStandardFrame(ptr, x, y, w, h));
     }
 
     private boolean isMaximized() {
@@ -515,7 +534,7 @@
             return;
         }
         if (!undecorated) {
-            CWrapper.NSWindow.zoom(getNSWindowPtr());
+            execute(CWrapper.NSWindow::zoom);
         } else {
             deliverZoom(true);
 
@@ -534,7 +553,7 @@
             return;
         }
         if (!undecorated) {
-            CWrapper.NSWindow.zoom(getNSWindowPtr());
+            execute(CWrapper.NSWindow::zoom);
         } else {
             deliverZoom(false);
 
@@ -550,8 +569,6 @@
 
     @Override // PlatformWindow
     public void setVisible(boolean visible) {
-        final long nsWindowPtr = getNSWindowPtr();
-
         // Configure stuff
         updateIconImages();
         updateFocusabilityForAutoRequestFocus(false);
@@ -559,7 +576,7 @@
         boolean wasMaximized = isMaximized();
 
         if (visible && target.isLocationByPlatform()) {
-            nativeSetNSWindowLocationByPlatform(getNSWindowPtr());
+            execute(CPlatformWindow::nativeSetNSWindowLocationByPlatform);
         }
 
         // Actually show or hide the window
@@ -567,30 +584,44 @@
         if (blocker == null || !visible) {
             // If it ain't blocked, or is being hidden, go regular way
             if (visible) {
-                CWrapper.NSWindow.makeFirstResponder(nsWindowPtr, contentView.getAWTView());
+                contentView.execute(viewPtr -> {
+                    execute(ptr -> CWrapper.NSWindow.makeFirstResponder(ptr,
+                                                                        viewPtr));
+                });
 
                 boolean isPopup = (target.getType() == Window.Type.POPUP);
-                if (isPopup) {
-                    // Popups in applets don't activate applet's process
-                    CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
-                } else {
-                    CWrapper.NSWindow.orderFront(nsWindowPtr);
-                }
+                execute(ptr -> {
+                    if (isPopup) {
+                        // Popups in applets don't activate applet's process
+                        CWrapper.NSWindow.orderFrontRegardless(ptr);
+                    } else {
+                        CWrapper.NSWindow.orderFront(ptr);
+                    }
 
-                boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(nsWindowPtr);
-                if (!isKeyWindow) {
-                    CWrapper.NSWindow.makeKeyWindow(nsWindowPtr);
-                }
+                    boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(ptr);
+                    if (!isKeyWindow) {
+                        CWrapper.NSWindow.makeKeyWindow(ptr);
+                    }
+                });
             } else {
-                // immediately hide the window
-                CWrapper.NSWindow.orderOut(nsWindowPtr);
-                // process the close
-                CWrapper.NSWindow.close(nsWindowPtr);
+                execute(ptr->{
+                    // immediately hide the window
+                    CWrapper.NSWindow.orderOut(ptr);
+                    // process the close
+                    CWrapper.NSWindow.close(ptr);
+                });
             }
         } else {
             // otherwise, put it in a proper z-order
-            CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowBelow,
-                    ((CPlatformWindow)blocker.getPlatformWindow()).getNSWindowPtr());
+            CPlatformWindow bw
+                    = (CPlatformWindow) blocker.getPlatformWindow();
+            bw.execute(blockerPtr -> {
+                execute(ptr -> {
+                    CWrapper.NSWindow.orderWindow(ptr,
+                                                  CWrapper.NSWindow.NSWindowBelow,
+                                                  blockerPtr);
+                });
+            });
         }
         this.visible = visible;
 
@@ -609,7 +640,7 @@
                     }
                     switch (frameState) {
                         case Frame.ICONIFIED:
-                            CWrapper.NSWindow.miniaturize(nsWindowPtr);
+                            execute(CWrapper.NSWindow::miniaturize);
                             break;
                         case Frame.MAXIMIZED_BOTH:
                             maximize();
@@ -633,7 +664,11 @@
         if (visible) {
             // Order myself above my parent
             if (owner != null && owner.isVisible()) {
-                CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr());
+                owner.execute(ownerPtr -> {
+                    execute(ptr -> {
+                        CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
+                    });
+                });
                 applyWindowLevel(target);
             }
 
@@ -643,7 +678,11 @@
                 if (p instanceof LWWindowPeer) {
                     CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
                     if (pw != null && pw.isVisible()) {
-                        CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove, nsWindowPtr);
+                        pw.execute(childPtr -> {
+                            execute(ptr -> {
+                                CWrapper.NSWindow.orderWindow(childPtr, CWrapper.NSWindow.NSWindowAbove, ptr);
+                            });
+                        });
                         pw.applyWindowLevel(w);
                     }
                 }
@@ -659,25 +698,22 @@
 
     @Override // PlatformWindow
     public void setTitle(String title) {
-        nativeSetNSWindowTitle(getNSWindowPtr(), title);
+        execute(ptr -> nativeSetNSWindowTitle(ptr, title));
     }
 
     // Should be called on every window key property change.
     @Override // PlatformWindow
     public void updateIconImages() {
-        final long nsWindowPtr = getNSWindowPtr();
         final CImage cImage = getImageForTarget();
-        nativeSetNSWindowMinimizedIcon(nsWindowPtr, cImage == null ? 0L : cImage.ptr);
-    }
-
-    public long getNSWindowPtr() {
-        final long nsWindowPtr = ptr;
-        if (nsWindowPtr == 0L) {
-            if(logger.isLoggable(PlatformLogger.Level.FINE)) {
-                logger.fine("NSWindow already disposed?", new Exception("Pointer to native NSWindow is invalid."));
+        execute(ptr -> {
+            if (cImage == null) {
+                nativeSetNSWindowMinimizedIcon(ptr, 0L);
+            } else {
+                cImage.execute(imagePtr -> {
+                    nativeSetNSWindowMinimizedIcon(ptr, imagePtr);
+                });
             }
-        }
-        return nsWindowPtr;
+        });
     }
 
     public SurfaceData getSurfaceData() {
@@ -686,13 +722,11 @@
 
     @Override  // PlatformWindow
     public void toBack() {
-        final long nsWindowPtr = getNSWindowPtr();
-        nativePushNSWindowToBack(nsWindowPtr);
+        execute(CPlatformWindow::nativePushNSWindowToBack);
     }
 
     @Override  // PlatformWindow
     public void toFront() {
-        final long nsWindowPtr = getNSWindowPtr();
         LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
         Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
         final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
@@ -702,7 +736,7 @@
             lwcToolkit.activateApplicationIgnoringOtherApps();
         }
         updateFocusabilityForAutoRequestFocus(false);
-        nativePushNSWindowToFront(nsWindowPtr);
+        execute(CPlatformWindow::nativePushNSWindowToFront);
         updateFocusabilityForAutoRequestFocus(true);
     }
 
@@ -729,7 +763,7 @@
 
     @Override
     public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
-        nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH);
+        execute(ptr -> nativeSetNSWindowMinMax(ptr, minW, minH, maxW, maxH));
     }
 
     @Override
@@ -746,19 +780,22 @@
 
     @Override
     public boolean requestWindowFocus() {
-
-        long ptr = getNSWindowPtr();
-        if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) {
-            CWrapper.NSWindow.makeMainWindow(ptr);
-        }
-        CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
+        execute(ptr -> {
+            if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) {
+                CWrapper.NSWindow.makeMainWindow(ptr);
+            }
+            CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
+        });
         return true;
     }
 
     @Override
     public boolean isActive() {
-        long ptr = getNSWindowPtr();
-        return CWrapper.NSWindow.isKeyWindow(ptr);
+        AtomicBoolean ref = new AtomicBoolean();
+        execute(ptr -> {
+            ref.set(CWrapper.NSWindow.isKeyWindow(ptr));
+        });
+        return ref.get();
     }
 
     @Override
@@ -774,21 +811,21 @@
 
     @Override
     public void setOpacity(float opacity) {
-        CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity);
+        execute(ptr -> CWrapper.NSWindow.setAlphaValue(ptr, opacity));
     }
 
     @Override
     public void setOpaque(boolean isOpaque) {
-        CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque);
+        execute(ptr -> CWrapper.NSWindow.setOpaque(ptr, isOpaque));
         boolean isTextured = (peer == null) ? false : peer.isTextured();
         if (!isTextured) {
             if (!isOpaque) {
-                CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), 0);
+                execute(ptr -> CWrapper.NSWindow.setBackgroundColor(ptr, 0));
             } else if (peer != null) {
                 Color color = peer.getBackground();
                 if (color != null) {
                     int rgb = color.getRGB();
-                    CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), rgb);
+                    execute(ptr->CWrapper.NSWindow.setBackgroundColor(ptr, rgb));
                 }
             }
         }
@@ -801,12 +838,12 @@
     @Override
     public void enterFullScreenMode() {
         isFullScreenMode = true;
-        nativeEnterFullScreenMode(getNSWindowPtr());
+        execute(CPlatformWindow::nativeEnterFullScreenMode);
     }
 
     @Override
     public void exitFullScreenMode() {
-        nativeExitFullScreenMode(getNSWindowPtr());
+        execute(CPlatformWindow::nativeExitFullScreenMode);
         isFullScreenMode = false;
     }
 
@@ -825,7 +862,6 @@
         int prevWindowState = peer.getState();
         if (prevWindowState == windowState) return;
 
-        final long nsWindowPtr = getNSWindowPtr();
         if ((windowState & Frame.ICONIFIED) != 0) {
             // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
             windowState = Frame.ICONIFIED;
@@ -837,18 +873,18 @@
                     // the zoom call toggles between the normal and the max states
                     unmaximize();
                 }
-                CWrapper.NSWindow.miniaturize(nsWindowPtr);
+                execute(CWrapper.NSWindow::miniaturize);
                 break;
             case Frame.MAXIMIZED_BOTH:
                 if (prevWindowState == Frame.ICONIFIED) {
                     // let's return into the normal states first
-                    CWrapper.NSWindow.deminiaturize(nsWindowPtr);
+                    execute(CWrapper.NSWindow::deminiaturize);
                 }
                 maximize();
                 break;
             case Frame.NORMAL:
                 if (prevWindowState == Frame.ICONIFIED) {
-                    CWrapper.NSWindow.deminiaturize(nsWindowPtr);
+                    execute(CWrapper.NSWindow::deminiaturize);
                 } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {
                     // the zoom call toggles between the normal and the max states
                     unmaximize();
@@ -872,15 +908,15 @@
             // We are going to show a modal window. Previously displayed window will be
             // blocked/disabled. So we have to send mouse exited event to it now, since
             // all mouse events are discarded for blocked/disabled windows.
-            nativeSynthesizeMouseEnteredExitedEvents(getNSWindowPtr(), CocoaConstants.NSMouseExited);
+            execute(ptr -> nativeSynthesizeMouseEnteredExitedEvents(ptr, CocoaConstants.NSMouseExited));
         }
 
-        nativeSetEnabled(getNSWindowPtr(), !blocked);
+        execute(ptr -> nativeSetEnabled(ptr, !blocked));
         checkBlockingAndOrder();
     }
 
-    public final void invalidateShadow(){
-        nativeRevalidateNSWindowShadow(getNSWindowPtr());
+    public final void invalidateShadow() {
+        execute(ptr -> nativeRevalidateNSWindowShadow(ptr));
     }
 
     // ----------------------------------------------------------------------
@@ -975,7 +1011,11 @@
 
     protected void deliverMoveResizeEvent(int x, int y, int width, int height,
                                         boolean byUser) {
-        isZoomed = CWrapper.NSWindow.isZoomed(getNSWindowPtr());
+        AtomicBoolean ref = new AtomicBoolean();
+        execute(ptr -> {
+            ref.set(CWrapper.NSWindow.isZoomed(ptr));
+        });
+        isZoomed = ref.get();
         checkZoom();
 
         final Rectangle oldB = nativeBounds;
@@ -1069,11 +1109,11 @@
 
         pWindow.orderAboveSiblings();
 
-        final long nsWindowPtr = pWindow.getNSWindowPtr();
-        CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
-        CWrapper.NSWindow.makeKeyAndOrderFront(nsWindowPtr);
-        CWrapper.NSWindow.makeMainWindow(nsWindowPtr);
-
+        pWindow.execute(ptr -> {
+            CWrapper.NSWindow.orderFrontRegardless(ptr);
+            CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
+            CWrapper.NSWindow.makeMainWindow(ptr);
+        });
         return true;
     }
 
@@ -1112,7 +1152,7 @@
         // which is going to become 'main window', are placed above their siblings.
         CPlatformWindow rootOwner = getRootOwner();
         if (rootOwner.isVisible() && !rootOwner.isIconified()) {
-            CWrapper.NSWindow.orderFront(rootOwner.getNSWindowPtr());
+            rootOwner.execute(CWrapper.NSWindow::orderFront);
         }
         // Do not order child windows of iconified owner.
         if (!rootOwner.isIconified()) {
@@ -1139,10 +1179,13 @@
                     // the window should be ordered above its siblings; otherwise the window is just ordered
                     // above its nearest parent.
                     if (pw.isOneOfOwnersOrSelf(this)) {
-                        CWrapper.NSWindow.orderFront(pw.getNSWindowPtr());
+                        pw.execute(CWrapper.NSWindow::orderFront);
                     } else {
-                        CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove,
-                                pw.owner.getNSWindowPtr());
+                        pw.owner.execute(ownerPtr -> {
+                            pw.execute(ptr -> {
+                                CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
+                            });
+                        });
                     }
                     pw.applyWindowLevel(w);
                 }
@@ -1164,9 +1207,9 @@
 
     protected void applyWindowLevel(Window target) {
         if (target.isAlwaysOnTop() && target.getType() != Window.Type.POPUP) {
-            CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel);
+            execute(ptr->CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSFloatingWindowLevel));
         } else if (target.getType() == Window.Type.POPUP) {
-            CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel);
+            execute(ptr->CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSPopUpMenuWindowLevel));
         }
     }
 
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Fri Apr 21 03:34:11 2017 +0000
@@ -36,6 +36,7 @@
 import java.awt.peer.TrayIconPeer;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.util.concurrent.atomic.AtomicReference;
 
 import static sun.awt.AWTAccessor.*;
 
@@ -91,10 +92,6 @@
         return nativeCreate();
     }
 
-    private long getModel() {
-        return ptr;
-    }
-
     private native long nativeCreate();
 
     //invocation from the AWTTrayIcon.m
@@ -168,7 +165,7 @@
 
     @Override
     public void setToolTip(String tooltip) {
-        nativeSetToolTip(getModel(), tooltip);
+        execute(ptr -> nativeSetToolTip(ptr, tooltip));
     }
 
     //adds tooltip to the NSStatusBar's NSButton.
@@ -197,7 +194,12 @@
         }
 
         CImage cimage = CImage.getCreator().createFromImage(image);
-        setNativeImage(getModel(), cimage.ptr, target.isImageAutoSize());
+        boolean imageAutoSize = target.isImageAutoSize();
+        cimage.execute(imagePtr -> {
+            execute(ptr -> {
+                setNativeImage(ptr, imagePtr, imageAutoSize);
+            });
+        });
     }
 
     private native void setNativeImage(final long model, final long nsimage, final boolean autosize);
@@ -377,7 +379,14 @@
     private void showMessageDialog() {
 
         Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
-        Point2D iconLoc = nativeGetIconLocation(getModel());
+        AtomicReference<Point2D> ref = new AtomicReference<>();
+        execute(ptr -> {
+            ref.set(nativeGetIconLocation(ptr));
+        });
+        Point2D iconLoc = ref.get();
+        if (iconLoc == null) {
+            return;
+        }
 
         int dialogY = (int)iconLoc.getY();
         int dialogX = (int)iconLoc.getX();
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java	Fri Apr 21 03:34:11 2017 +0000
@@ -73,13 +73,13 @@
 
     @Override
     public void dispose() {
-        CWrapper.NSView.removeFromSuperview(view.getAWTView());
+        view.execute(CWrapper.NSView::removeFromSuperview);
         view.dispose();
     }
 
     @Override
     public void setVisible(boolean visible) {
-        CWrapper.NSView.setHidden(view.getAWTView(), !visible);
+        view.execute(ptr -> CWrapper.NSView.setHidden(ptr, !visible));
     }
 
     @Override
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java	Fri Apr 21 03:34:11 2017 +0000
@@ -204,14 +204,14 @@
     @Override
     public void setVisible(boolean visible) {
         synchronized (lock) {
-            final long nsWindowPtr = getNSWindowPtr();
-
-            // Actually show or hide the window
-            if (visible) {
-                CWrapper.NSWindow.orderFront(nsWindowPtr);
-            } else {
-                CWrapper.NSWindow.orderOut(nsWindowPtr);
-            }
+            execute(ptr -> {
+                // Actually show or hide the window
+                if (visible) {
+                    CWrapper.NSWindow.orderFront(ptr);
+                } else {
+                    CWrapper.NSWindow.orderOut(ptr);
+                }
+            });
 
             this.visible = visible;
 
@@ -219,8 +219,13 @@
             if (visible) {
                 // Order myself above my parent
                 if (owner != null && owner.isVisible()) {
-                    CWrapper.NSWindow.orderWindow(nsWindowPtr,
-                            CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr());
+                    owner.execute(ownerPtr -> {
+                        execute(ptr -> {
+                            CWrapper.NSWindow.orderWindow(ptr,
+                                                          CWrapper.NSWindow.NSWindowAbove,
+                                                          ownerPtr);
+                        });
+                    });
 
                     // do not allow security warning to be obscured by other windows
                     applyWindowLevel(ownerWindow);
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.h	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.h	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * 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,6 +41,8 @@
     CALayer *windowLayer;
 }
 
+@property (atomic, retain) CALayer *windowLayer;
+
 - (id) initWithWindowLayer: (CALayer *)windowLayer;
 - (void) setBounds: (CGRect)rect;
 
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.m	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.m	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,11 +38,15 @@
     self = [super init];
     if (self == nil) return self;
 
-    windowLayer = aWindowLayer;
+    self.windowLayer = aWindowLayer;
 
     return self;
 }
 
+- (void) dealloc {
+    self.windowLayer = nil;
+    [super dealloc];
+}
 
 - (CALayer *) layer {
     return layer;
--- a/jdk/src/java.desktop/share/classes/java/awt/Desktop.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Desktop.java	Fri Apr 21 03:34:11 2017 +0000
@@ -992,8 +992,6 @@
     /**
      * Sets the default menu bar to use when there are no active frames.
      *
-     * @implNote Aqua Look and Feel should be active to support this on Mac OS.
-     *
      * @param menuBar to use when no other frames are active
      * @throws SecurityException if a security manager exists and it denies the
      * {@code RuntimePermission("canProcessApplicationEvents")} permission.
--- a/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1874,7 +1874,8 @@
                     return
                         PCMM.class.getResourceAsStream("profiles/" + fileName);
                 }
-            }, null, new FilePermission("<<ALL FILES>>", "read"));
+            }, null, new FilePermission("<<ALL FILES>>", "read"),
+                     new RuntimePermission("accessSystemModules"));
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/java/awt/font/LineBreakMeasurer.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/font/LineBreakMeasurer.java	Fri Apr 21 03:34:11 2017 +0000
@@ -115,26 +115,27 @@
  * <pre>{@code
  * public void paint(Graphics graphics) {
  *
- *     Point2D pen = new Point2D(10, 20);
+ *     float dx = 0f, dy = 5f;
  *     Graphics2D g2d = (Graphics2D)graphics;
  *     FontRenderContext frc = g2d.getFontRenderContext();
  *
- *     // let styledText be an AttributedCharacterIterator containing at least
- *     // one character
+ *     AttributedString text = new AttributedString(".....");
+ *     AttributedCharacterIterator paragraph = text.getIterator();
  *
- *     LineBreakMeasurer measurer = new LineBreakMeasurer(styledText, frc);
- *     float wrappingWidth = getSize().width - 15;
+ *     LineBreakMeasurer measurer = new LineBreakMeasurer(paragraph, frc);
+ *     measurer.setPosition(paragraph.getBeginIndex());
+ *     float wrappingWidth = (float)getSize().width;
  *
- *     while (measurer.getPosition() < fStyledText.length()) {
+ *     while (measurer.getPosition() < paragraph.getEndIndex()) {
  *
  *         TextLayout layout = measurer.nextLayout(wrappingWidth);
  *
- *         pen.y += (layout.getAscent());
+ *         dy += (layout.getAscent());
  *         float dx = layout.isLeftToRight() ?
  *             0 : (wrappingWidth - layout.getAdvance());
  *
- *         layout.draw(graphics, pen.x + dx, pen.y);
- *         pen.y += layout.getDescent() + layout.getLeading();
+ *         layout.draw(graphics, dx, dy);
+ *         dy += layout.getDescent() + layout.getLeading();
  *     }
  * }
  * }</pre>
--- a/jdk/src/java.desktop/share/classes/java/awt/geom/Line2D.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/geom/Line2D.java	Fri Apr 21 03:34:11 2017 +0000
@@ -31,12 +31,7 @@
 
 /**
  * This {@code Line2D} represents a line segment in {@code (x,y)}
- * coordinate space.  This class, like all of the Java 2D API, uses a
- * default coordinate system called <i>user space</i> in which the y-axis
- * values increase downward and x-axis values increase to the right.  For
- * more information on the user space coordinate system, see the
- * <a href="{@docRoot}/../technotes/guides/2d/spec/j2d-intro.html">
- * Coordinate Systems</a> section of the Java 2D Programmer's Guide.
+ * coordinate space.
  * <p>
  * This class is only the abstract superclass for all objects that
  * store a 2D line segment.
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/package-info.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/package-info.java	Fri Apr 21 03:34:11 2017 +0000
@@ -28,9 +28,10 @@
  * (Musical Instrument Digital Interface) data.
  *
  * <h2>Related Documentation</h2>
- * For overviews, tutorials, examples, and guides, please see:
+ * For more information on using Java Sound see:
  * <ul>
- *     <li><a href="../../../../technotes/guides/sound">Sound</a></li>
+ *     <li><a href="https://docs.oracle.com/javase/tutorial/sound/">
+ *     The Java Sound Tutorial</a></li>
  * </ul>
  *
  * @since 1.3
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/package-info.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/package-info.java	Fri Apr 21 03:34:11 2017 +0000
@@ -28,9 +28,10 @@
  * devices, MIDI file readers and writers, or sound bank readers.
  *
  * <h2>Related Documentation</h2>
- * For overviews, tutorials, examples, and guides, please see:
+ * For more information on using Java Sound see:
  * <ul>
- *     <li><a href="../../../../../technotes/guides/sound">Sound</a></li>
+ *     <li><a href="https://docs.oracle.com/javase/tutorial/sound/">
+ *     The Java Sound Tutorial</a></li>
  * </ul>
  *
  * @since 1.3
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/package-info.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/package-info.java	Fri Apr 21 03:34:11 2017 +0000
@@ -28,9 +28,10 @@
  * sampled audio data.
  *
  * <h2>Related Documentation</h2>
- * For overviews, tutorials, examples, and guides, please see:
+ * For more information on using Java Sound see:
  * <ul>
- *     <li><a href="../../../../technotes/guides/sound">Sound</a></li>
+ *     <li><a href="https://docs.oracle.com/javase/tutorial/sound/">
+ *     The Java Sound Tutorial</a></li>
  * </ul>
  *
  * @since 1.3
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/package-info.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/package-info.java	Fri Apr 21 03:34:11 2017 +0000
@@ -28,9 +28,10 @@
  * audio devices, sound file readers and writers, or audio format converters.
  *
  * <h2>Related Documentation</h2>
- * For overviews, tutorials, examples, and guides, please see:
+ * For more information on using Java Sound see:
  * <ul>
- *     <li><a href="../../../../../technotes/guides/sound">Sound</a></li>
+ *     <li><a href="https://docs.oracle.com/javase/tutorial/sound/">
+ *     The Java Sound Tutorial</a></li>
  * </ul>
  *
  * @since 1.3
--- a/jdk/src/java.desktop/share/classes/javax/swing/JList.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JList.java	Fri Apr 21 03:34:11 2017 +0000
@@ -3395,15 +3395,18 @@
             }
 
             public AccessibleSelection getAccessibleSelection() {
-                return getCurrentAccessibleContext().getAccessibleSelection();
+                AccessibleContext ac = getCurrentAccessibleContext();
+                return ac != null ? ac.getAccessibleSelection() : null;
             }
 
             public AccessibleText getAccessibleText() {
-                return getCurrentAccessibleContext().getAccessibleText();
+                AccessibleContext ac = getCurrentAccessibleContext();
+                return ac != null ? ac.getAccessibleText() : null;
             }
 
             public AccessibleValue getAccessibleValue() {
-                return getCurrentAccessibleContext().getAccessibleValue();
+                AccessibleContext ac = getCurrentAccessibleContext();
+                return ac != null ? ac.getAccessibleValue() : null;
             }
 
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -541,8 +541,10 @@
             layeredPane.remove(menuBar);
         menuBar = menu;
 
-        if(menuBar != null)
+        if(menuBar != null) {
+            menuBar.updateUI();
             layeredPane.add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
+        }
     }
 
     /**
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java	Fri Apr 21 03:34:11 2017 +0000
@@ -71,7 +71,7 @@
         enable(false);
     }
 
-    public void readShortcutLabel() {
+    private void readShortcutLabel() {
         //Fix for 6288578: PIT. Windows: Shortcuts displayed for the menuitems in a popup menu
         WMenuPeer ancestor = parent;
         while (ancestor != null && !(ancestor instanceof WMenuBarPeer)) {
@@ -115,7 +115,7 @@
         readShortcutLabel();
     }
 
-    protected void checkMenuCreation()
+    void checkMenuCreation()
     {
         // fix for 5088782: check if menu peer is created successfully
         if (pData == 0)
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java	Fri Apr 21 03:34:11 2017 +0000
@@ -36,14 +36,14 @@
     // The Windows handle for the native widget.
     volatile long pData;
     // if the native peer has been destroyed
-    volatile boolean destroyed = false;
+    private volatile boolean destroyed;
     // The associated AWT object.
-    Object target;
+    volatile Object target;
 
     private volatile boolean disposed;
 
     // set from JNI if any errors in creating the peer occur
-    protected Error createError = null;
+    volatile Error createError = null;
 
     // used to synchronize the state of this peer
     private final Object stateLock = new Object();
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Fri Apr 21 03:34:11 2017 +0000
@@ -4220,7 +4220,7 @@
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
     if (drawInfo.CtlType == ODT_MENU) {
-        if (drawInfo.itemData != 0) {
+        if (IsMenu((HMENU)drawInfo.hwndItem) && drawInfo.itemData != 0) {
             AwtMenu* menu = (AwtMenu*)(drawInfo.itemData);
             menu->DrawItem(drawInfo);
         }
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Menu.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Menu.cpp	Fri Apr 21 03:34:11 2017 +0000
@@ -34,6 +34,13 @@
 /* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code.
  */
 
+/***********************************************************************/
+// struct for _DelItem() method
+struct DelItemStruct {
+    jobject menuitem;
+    jint index;
+};
+
 /************************************************************************
  * AwtMenuItem fields
  */
@@ -64,7 +71,6 @@
         ::DestroyMenu(m_hMenu);
         m_hMenu = NULL;
     }
-
     AwtMenuItem::Dispose();
 }
 
@@ -73,7 +79,7 @@
 }
 
 /* Create a new AwtMenu object and menu.   */
-AwtMenu* AwtMenu::Create(jobject self, AwtMenu* parentMenu)
+AwtMenu* AwtMenu::Create(jobject self, jobject parent)
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
@@ -85,6 +91,9 @@
             return NULL;
         }
 
+        JNI_CHECK_NULL_GOTO(parent, "peer", done);
+        AwtMenu* parentMenu = (AwtMenu*) JNI_GET_PDATA(parent);
+
         target = env->GetObjectField(self, AwtObject::targetID);
         JNI_CHECK_NULL_GOTO(target, "null target", done);
 
@@ -119,6 +128,46 @@
     return menu;
 }
 
+void AwtMenu::_AddSeparator(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        jobject self = (jobject)param;
+        AwtMenu *m = NULL;
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+        m = (AwtMenu *)pData;
+        m->AddSeparator();
+ret:
+        env->DeleteGlobalRef(self);
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenu::_AddSeparator, param);
+    }
+}
+
+void AwtMenu::_DelItem(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        DelItemStruct *dis = (DelItemStruct*) param;
+        jobject self = dis->menuitem;
+        jint index = dis->index;
+
+        AwtMenu *m = NULL;
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+        m = (AwtMenu *)pData;
+        m->DeleteItem(static_cast<UINT>(index));
+ret:
+        env->DeleteGlobalRef(self);
+        delete dis;
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenu::_DelItem, param);
+    }
+}
+
 void AwtMenu::UpdateLayout()
 {
     UpdateLayout(GetHMenu());
@@ -323,24 +372,6 @@
     return (GetMenuBar() == GetMenuContainer());
 }
 
-LRESULT AwtMenu::WinThreadExecProc(ExecuteArgs * args)
-{
-    switch( args->cmdId ) {
-        case MENU_ADDSEPARATOR:
-            this->AddSeparator();
-            break;
-
-        case MENU_DELITEM:
-            this->DeleteItem(static_cast<UINT>(args->param1));
-            break;
-
-        default:
-            AwtMenuItem::WinThreadExecProc(args);
-            break;
-    }
-    return 0L;
-}
-
 /************************************************************************
  * WMenuPeer native methods
  */
@@ -382,15 +413,14 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(self);
+    jobject selfGlobalRef = env->NewGlobalRef(self);
 
-    AwtObject::WinThreadExec(self, AwtMenu::MENU_ADDSEPARATOR);
+    AwtToolkit::GetInstance().SyncCall(AwtMenu::_AddSeparator, selfGlobalRef);
+    // selfGlobalRef is deleted in _AddSeparator
 
     CATCH_BAD_ALLOC;
 }
 
-
 /*
  * Class:     sun_awt_windows_WMenuPeer
  * Method:    delItem
@@ -402,10 +432,12 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(self);
+    DelItemStruct *dis = new DelItemStruct;
+    dis->menuitem = env->NewGlobalRef(self);
+    dis->index = index;
 
-    AwtObject::WinThreadExec(self, AwtMenu::MENU_DELITEM, index);
+    AwtToolkit::GetInstance().SyncCall(AwtMenu::_DelItem, dis);
+    // global refs and dis are deleted in _DelItem
 
     CATCH_BAD_ALLOC;
 }
@@ -421,13 +453,8 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(menuBar);
-
-    AwtMenuBar* awtMenuBar = (AwtMenuBar *)pData;
-    AwtToolkit::CreateComponent(self, awtMenuBar,
-                                (AwtToolkit::ComponentFactory)AwtMenu::Create,FALSE);
-    JNI_CHECK_PEER_CREATION_RETURN(self);
+    AwtToolkit::CreateComponent(self, menuBar,
+                                (AwtToolkit::ComponentFactory)AwtMenu::Create);
 
     CATCH_BAD_ALLOC;
 }
@@ -443,13 +470,8 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(menu);
-
-    AwtMenu* awtMenu = (AwtMenu *)pData;
-    AwtToolkit::CreateComponent(self, awtMenu,
-                                (AwtToolkit::ComponentFactory)AwtMenu::Create,FALSE);
-    JNI_CHECK_PEER_CREATION_RETURN(self);
+    AwtToolkit::CreateComponent(self, menu,
+                                (AwtToolkit::ComponentFactory)AwtMenu::Create);
 
     CATCH_BAD_ALLOC;
 }
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Menu.h	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Menu.h	Fri Apr 21 03:34:11 2017 +0000
@@ -42,13 +42,6 @@
 
 class AwtMenu : public AwtMenuItem {
 public:
-    // id's for methods executed on toolkit thread
-    enum {
-        MENU_ADDSEPARATOR = MENUITEM_LAST+1,
-        MENU_DELITEM,
-        MENU_LAST
-    };
-
     /* method ids for java.awt.Menu */
     static jmethodID countItemsMID;
     static jmethodID getItemMID;
@@ -61,7 +54,7 @@
     virtual LPCTSTR GetClassName();
 
     /* Create a new AwtMenu.  This must be run on the main thread. */
-    static AwtMenu* Create(jobject self, AwtMenu* parentMenu);
+    static AwtMenu* Create(jobject self, jobject parent);
 
     INLINE HMENU GetHMenu() { return m_hMenu; }
     INLINE void SetHMenu(HMENU hMenu) {
@@ -94,9 +87,9 @@
     void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo);
     void MeasureItems(HDC hDC, MEASUREITEMSTRUCT& measureInfo);
 
-    virtual LRESULT WinThreadExecProc(ExecuteArgs * args);
-
     // invoked on Toolkit thread
+    static void _AddSeparator(void *param);
+    static void _DelItem(void *param);
     static void _CreateMenu(void *param);
     static void _CreateSubMenu(void *param);
     virtual BOOL IsSeparator() { return FALSE; }
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp	Fri Apr 21 03:34:11 2017 +0000
@@ -30,6 +30,12 @@
  */
 
 /***********************************************************************/
+// struct for _DelItem() method
+struct DelItemStruct {
+    jobject menuitem;
+    jint index;
+};
+/***********************************************************************/
 // struct for _AddMenu() method
 struct AddMenuStruct {
     jobject menubar;
@@ -130,18 +136,6 @@
         return myFrame->GetHWnd();
 }
 
-void AwtMenuBar::SendDrawItem(AwtMenuItem* awtMenuItem,
-                              DRAWITEMSTRUCT& drawInfo)
-{
-    awtMenuItem->DrawItem(drawInfo);
-}
-
-void AwtMenuBar::SendMeasureItem(AwtMenuItem* awtMenuItem,
-                                 HDC hDC, MEASUREITEMSTRUCT& measureInfo)
-{
-    awtMenuItem->MeasureItem(hDC, measureInfo);
-}
-
 int AwtMenuBar::CountItem(jobject menuBar)
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -164,9 +158,9 @@
 
     jobject menuItemPeer = GetPeerForTarget(env, menu);
     PDATA pData;
+    AwtMenuItem* awtMenuItem = NULL;
     JNI_CHECK_PEER_GOTO(menuItemPeer, done);
-
-    AwtMenuItem* awtMenuItem = (AwtMenuItem*)pData;
+    awtMenuItem = (AwtMenuItem*)pData;
 
 done:
     env->DeleteLocalRef(menu);
@@ -215,20 +209,6 @@
     VERIFY(::DrawMenuBar(GetOwnerHWnd()));
 }
 
-LRESULT AwtMenuBar::WinThreadExecProc(ExecuteArgs * args)
-{
-    switch( args->cmdId ) {
-        case MENUBAR_DELITEM:
-            this->DeleteItem(static_cast<UINT>(args->param1));
-            break;
-
-        default:
-            AwtMenu::WinThreadExecProc(args);
-            break;
-    }
-    return 0L;
-}
-
 void AwtMenuBar::_AddMenu(void *param)
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -257,6 +237,28 @@
     delete ams;
 }
 
+void AwtMenuBar::_DelItem(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        DelItemStruct *dis = (DelItemStruct*) param;
+        jobject self = dis->menuitem;
+        jint index = dis->index;
+
+        AwtMenuBar *m = NULL;
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+        m = (AwtMenuBar *)pData;
+        m->DeleteItem(static_cast<UINT>(index));
+ret:
+        env->DeleteGlobalRef(self);
+        delete dis;
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenuBar::_DelItem, param);
+    }
+}
+
 /************************************************************************
  * MenuBar native methods
  */
@@ -325,9 +327,12 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(self);
-    AwtObject::WinThreadExec(self, AwtMenuBar::MENUBAR_DELITEM, (LPARAM)index);
+    DelItemStruct *dis = new DelItemStruct;
+    dis->menuitem = env->NewGlobalRef(self);
+    dis->index = index;
+
+    AwtToolkit::GetInstance().SyncCall(AwtMenuBar::_DelItem, dis);
+    // global refs and dis are deleted in _DelItem
 
     CATCH_BAD_ALLOC;
 }
@@ -346,9 +351,6 @@
     AwtToolkit::CreateComponent(self, frame,
                                 (AwtToolkit::ComponentFactory)
                                 AwtMenuBar::Create);
-    PDATA pData;
-    JNI_CHECK_PEER_CREATION_RETURN(self);
-
     CATCH_BAD_ALLOC;
 }
 
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h	Fri Apr 21 03:34:11 2017 +0000
@@ -42,10 +42,6 @@
 
 class AwtMenuBar : public AwtMenu {
 public:
-    // id's for methods executed on toolkit thread
-    enum MenuExecIds {
-        MENUBAR_DELITEM = MENU_LAST+1
-    };
 
     /* java.awt.MenuBar method ids */
     static jmethodID getMenuCountMID;
@@ -73,20 +69,15 @@
     AwtMenuItem* GetItem(jobject target, long index);
     int CountItem(jobject menuBar);
 
-    void SendDrawItem(AwtMenuItem* awtMenuItem,
-                      DRAWITEMSTRUCT& drawInfo);
-    void SendMeasureItem(AwtMenuItem* awtMenuItem,
-                         HDC hDC, MEASUREITEMSTRUCT& measureInfo);
     void DrawItem(DRAWITEMSTRUCT& drawInfo);
     void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo);
 
     void AddItem(AwtMenuItem* item);
     void DeleteItem(UINT index);
 
-    virtual LRESULT WinThreadExecProc(ExecuteArgs * args);
-
     // called on Toolkit thread
     static void _AddMenu(void *param);
+    static void _DelItem(void *param);
 protected:
     AwtFrame* m_frame;
 };
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.cpp	Fri Apr 21 03:34:11 2017 +0000
@@ -50,6 +50,16 @@
     jobject menuitem;
     jstring label;
 };
+// struct for _SetEnable() method
+struct SetEnableStruct {
+    jobject menuitem;
+    jboolean isEnabled;
+};
+// struct for _setState() method
+struct SetStateStruct {
+    jobject menuitem;
+    jboolean isChecked;
+};
 /************************************************************************
  * AwtMenuItem fields
  */
@@ -104,6 +114,7 @@
 {
     if (m_freeId) {
         AwtToolkit::GetInstance().RemoveCmdID( GetID() );
+        m_freeId = FALSE;
     }
 }
 void AwtMenuItem::Dispose()
@@ -206,13 +217,12 @@
         if (env->EnsureLocalCapacity(1) < 0) {
             return NULL;
         }
-        PDATA pData;
-        JNI_CHECK_PEER_RETURN_NULL(menuPeer);
+        JNI_CHECK_NULL_RETURN_NULL(menuPeer, "peer");
 
         /* target is a java.awt.MenuItem  */
         target = env->GetObjectField(peer, AwtObject::targetID);
 
-        AwtMenu* menu = (AwtMenu *)pData;
+        AwtMenu* menu = (AwtMenu *)JNI_GET_PDATA(menuPeer);
         item = new AwtMenuItem();
         jboolean isCheckbox =
             (jboolean)env->GetBooleanField(peer, AwtMenuItem::isCheckboxID);
@@ -223,7 +233,9 @@
         item->LinkObjects(env, peer);
         item->SetMenuContainer(menu);
         item->SetNewID();
-        menu->AddItem(item);
+        if (menu != NULL) {
+            menu->AddItem(item);
+        }
     } catch (...) {
         env->DeleteLocalRef(target);
         throw;
@@ -764,30 +776,6 @@
     }
 }
 
-LRESULT AwtMenuItem::WinThreadExecProc(ExecuteArgs * args)
-{
-    switch( args->cmdId ) {
-        case MENUITEM_ENABLE:
-        {
-            BOOL        isEnabled = (BOOL)args->param1;
-            this->Enable(isEnabled);
-        }
-        break;
-
-        case MENUITEM_SETSTATE:
-        {
-            BOOL        isChecked = (BOOL)args->param1;
-            this->SetState(isChecked);
-        }
-        break;
-
-        default:
-            AwtObject::WinThreadExecProc(args);
-            break;
-    }
-    return 0L;
-}
-
 void AwtMenuItem::_SetLabel(void *param) {
     if (AwtToolkit::IsMainThread()) {
         JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -887,6 +875,53 @@
     }
 }
 
+void AwtMenuItem::_SetEnable(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        SetEnableStruct *ses = (SetEnableStruct*) param;
+        jobject self = ses->menuitem;
+        jboolean isEnabled = ses->isEnabled;
+
+        AwtMenuItem *m = NULL;
+
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+
+        m = (AwtMenuItem *)pData;
+
+        m->Enable(isEnabled);
+ret:
+        env->DeleteGlobalRef(self);
+        delete ses;
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenuItem::_SetEnable, param);
+    }
+}
+
+void AwtMenuItem::_SetState(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        SetStateStruct *sts = (SetStateStruct*) param;
+        jobject self = sts->menuitem;
+        jboolean isChecked = sts->isChecked;
+
+        AwtMenuItem *m = NULL;
+
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+        m = (AwtMenuItem *)pData;
+        m->SetState(isChecked);
+ret:
+        env->DeleteGlobalRef(self);
+        delete sts;
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenuItem::_SetState, param);
+    }
+}
 BOOL AwtMenuItem::IsSeparator() {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
     if (env->EnsureLocalCapacity(2) < 0) {
@@ -1050,13 +1085,9 @@
 {
     TRY;
 
-    JNI_CHECK_NULL_RETURN(menu, "null Menu");
     AwtToolkit::CreateComponent(self, menu,
                                 (AwtToolkit::ComponentFactory)
                                 AwtMenuItem::Create);
-    PDATA pData;
-    JNI_CHECK_PEER_CREATION_RETURN(self);
-
     CATCH_BAD_ALLOC;
 }
 
@@ -1071,9 +1102,12 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(self);
-    AwtObject::WinThreadExec(self, AwtMenuItem::MENUITEM_ENABLE, (LPARAM)on );
+    SetEnableStruct *ses = new SetEnableStruct;
+    ses->menuitem = env->NewGlobalRef(self);
+    ses->isEnabled = on;
+
+    AwtToolkit::GetInstance().SyncCall(AwtMenuItem::_SetEnable, ses);
+    // global refs and ses are deleted in _SetEnable
 
     CATCH_BAD_ALLOC;
 }
@@ -1112,9 +1146,12 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(self);
-    AwtObject::WinThreadExec(self, AwtMenuItem::MENUITEM_SETSTATE, (LPARAM)on);
+    SetStateStruct *sts = new SetStateStruct;
+    sts->menuitem = env->NewGlobalRef(self);
+    sts->isChecked = on;
+
+    AwtToolkit::GetInstance().SyncCall(AwtMenuItem::_SetState, sts);
+    // global refs and sts are deleted in _SetState
 
     CATCH_BAD_ALLOC;
 }
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.h	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.h	Fri Apr 21 03:34:11 2017 +0000
@@ -45,13 +45,6 @@
 
 class AwtMenuItem : public AwtObject {
 public:
-    // id's for methods executed on toolkit thread
-    enum {
-        MENUITEM_ENABLE,
-        MENUITEM_SETSTATE,
-        MENUITEM_LAST
-    };
-
     /* java.awt.MenuComponent fields */
     static jfieldID fontID;
     static jfieldID appContextID;
@@ -154,13 +147,14 @@
      */
     MsgRouting WmNotify(UINT notifyCode);
 
-    virtual LRESULT WinThreadExecProc(ExecuteArgs * args);
     virtual BOOL IsDisabledAndPopup() {
         return FALSE;
     }
     virtual BOOL IsSeparator();
 
     // invoked on Toolkit thread
+    static void _SetState(void *param);
+    static void _SetEnable(void *param);
     static void _SetLabel(void *param);
     static void _UpdateLayout(void *param);
 
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PopupMenu.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PopupMenu.cpp	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,7 +65,7 @@
 }
 
 /* Create a new AwtPopupMenu object and menu.   */
-AwtPopupMenu* AwtPopupMenu::Create(jobject self, AwtComponent* parent)
+AwtPopupMenu* AwtPopupMenu::Create(jobject self, jobject parent)
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
@@ -77,6 +77,9 @@
             return NULL;
         }
 
+        JNI_CHECK_NULL_GOTO(parent, "peer", done);
+        AwtComponent* awtParent = (AwtComponent*) JNI_GET_PDATA(parent);
+
         target = env->GetObjectField(self, AwtObject::targetID);
         JNI_CHECK_NULL_GOTO(target, "null target", done);
 
@@ -94,7 +97,7 @@
         popupMenu->SetHMenu(hMenu);
 
         popupMenu->LinkObjects(env, self);
-        popupMenu->SetParent(parent);
+        popupMenu->SetParent(awtParent);
     } catch (...) {
         env->DeleteLocalRef(target);
         throw;
@@ -274,12 +277,8 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(parent);
-    AwtComponent* awtParent = (AwtComponent *)pData;
     AwtToolkit::CreateComponent(
-        self, awtParent, (AwtToolkit::ComponentFactory)AwtPopupMenu::Create, FALSE);
-    JNI_CHECK_PEER_CREATION_RETURN(self);
+        self, parent, (AwtToolkit::ComponentFactory)AwtPopupMenu::Create);
 
     CATCH_BAD_ALLOC;
 }
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PopupMenu.h	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PopupMenu.h	Fri Apr 21 03:34:11 2017 +0000
@@ -47,7 +47,7 @@
     virtual LPCTSTR GetClassName();
 
     /* Create a new AwtPopupMenu.  This must be run on the main thread. */
-    static AwtPopupMenu* Create(jobject self, AwtComponent* parent);
+    static AwtPopupMenu* Create(jobject self, jobject parent);
 
     /* Display the popup modally. */
     void Show(JNIEnv *env, jobject event, BOOL isTrayIconPopup);
--- a/jdk/src/java.sql/share/classes/javax/sql/PooledConnection.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/java.sql/share/classes/javax/sql/PooledConnection.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,8 +69,9 @@
  * <p>
  * If the connection pool manager wraps or provides a proxy to the logical
  * handle returned from a call to {@code PoolConnection.getConnection}, the pool
- * manager must do
- * one of the following when the application calls {@code Connection.close}:
+ * manager must do one of the following when the connection pool manager
+ * closes or returns the {@code PooledConnection} to the pool in response to
+ * the application calling {@code Connection.close}:
  * <ul>
  * <li>call {@code endRequest} on the logical {@code Connection} handle
  * <li>call {@code close} on the logical {@code Connection} handle
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,6 +59,7 @@
 
 import jdk.tools.jlink.internal.BasicImageWriter;
 import jdk.tools.jlink.internal.ExecutableImage;
+import jdk.tools.jlink.internal.Platform;
 import jdk.tools.jlink.plugin.ResourcePool;
 import jdk.tools.jlink.plugin.ResourcePoolEntry;
 import jdk.tools.jlink.plugin.ResourcePoolEntry.Type;
@@ -133,7 +134,7 @@
     private final Map<String, String> launchers;
     private final Path mdir;
     private final Set<String> modules = new HashSet<>();
-    private String targetOsName;
+    private Platform targetPlatform;
 
     /**
      * Default image builder constructor.
@@ -151,11 +152,14 @@
     @Override
     public void storeFiles(ResourcePool files) {
         try {
-            this.targetOsName = files.moduleView().
-                findModule("java.base").get().osName();
-            if (this.targetOsName == null) {
+            String targetOsName = files.moduleView()
+                                       .findModule("java.base")
+                                       .map(ResourcePoolModule::osName)
+                                       .orElse(null);
+            if (targetOsName == null) {
                 throw new PluginException("ModuleTarget attribute is missing for java.base module");
             }
+            this.targetPlatform = Platform.toPlatform(targetOsName);
 
             checkResourcePool(files);
 
@@ -476,7 +480,7 @@
     }
 
     private boolean isWindows() {
-        return targetOsName.startsWith("Windows");
+        return targetPlatform == Platform.WINDOWS;
     }
 
     /**
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java	Fri Apr 21 03:34:11 2017 +0000
@@ -158,7 +158,7 @@
          *
          * @param output Output directory, must not exist.
          * @param modulepaths Modules paths
-         * @param modules Root modules to resolve
+         * @param modules The possibly-empty set of root modules to resolve
          * @param limitmods Limit the universe of observable modules
          * @param endian Jimage byte order. Native order by default
          */
@@ -170,13 +170,10 @@
             if (Objects.requireNonNull(modulepaths).isEmpty()) {
                 throw new IllegalArgumentException("Empty module path");
             }
-            if (Objects.requireNonNull(modules).isEmpty()) {
-                throw new IllegalArgumentException("Empty modules");
-            }
 
             this.output = output;
             this.modulepaths = modulepaths;
-            this.modules = modules;
+            this.modules = Objects.requireNonNull(modules);
             this.limitmods = Objects.requireNonNull(limitmods);
             this.endian = Objects.requireNonNull(endian);
             this.finder = moduleFinder();
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Fri Apr 21 03:34:11 2017 +0000
@@ -40,7 +40,20 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -331,11 +344,6 @@
     // the token for "all modules on the module path"
     private static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
     private JlinkConfiguration initJlinkConfig() throws BadArgs {
-        if (options.addMods.isEmpty()) {
-            throw taskHelper.newBadArgs("err.mods.must.be.specified", "--add-modules")
-                .showUsage(true);
-        }
-
         Set<String> roots = new HashSet<>();
         for (String mod : options.addMods) {
             if (mod.equals(ALL_MODULE_PATH)) {
@@ -369,6 +377,10 @@
         if (options.output == null) {
             throw taskHelper.newBadArgs("err.output.must.be.specified").showUsage(true);
         }
+        if (options.addMods.isEmpty()) {
+            throw taskHelper.newBadArgs("err.mods.must.be.specified", "--add-modules")
+                            .showUsage(true);
+        }
 
         // First create the image provider
         ImageProvider imageProvider = createImageProvider(config,
@@ -430,7 +442,7 @@
             // print modules to be linked in
             cf.modules().stream()
               .sorted(Comparator.comparing(ResolvedModule::name))
-              .forEach(rm -> log.format("module %s (%s)%n",
+              .forEach(rm -> log.format("%s %s%n",
                                         rm.name(), rm.reference().location().get()));
 
             // print provider info
@@ -505,16 +517,22 @@
 
     /*
      * Returns a map of each service type to the modules that use it
+     * It will include services that are provided by a module but may not used
+     * by any of the observable modules.
      */
     private static Map<String, Set<String>> uses(Set<ModuleReference> modules) {
         // collects the services used by the modules and print uses
-        Map<String, Set<String>> uses = new HashMap<>();
+        Map<String, Set<String>> services = new HashMap<>();
         modules.stream()
                .map(ModuleReference::descriptor)
-               .forEach(md -> md.uses().forEach(s ->
-                   uses.computeIfAbsent(s, _k -> new HashSet<>()).add(md.name()))
-               );
-        return uses;
+               .forEach(md -> {
+                   // include services that may not be used by any observable modules
+                   md.provides().forEach(p ->
+                       services.computeIfAbsent(p.service(), _k -> new HashSet<>()));
+                   md.uses().forEach(s -> services.computeIfAbsent(s, _k -> new HashSet<>())
+                                                  .add(md.name()));
+               });
+        return services;
     }
 
     private static void printProviders(PrintWriter log,
@@ -524,17 +542,16 @@
     }
 
     /*
-     * Prints the providers that are used by the services specified in
-     * the given modules.
+     * Prints the providers that are used by the specified services.
      *
-     * The specified uses maps a service type name to the modules
-     * using the service type and that may or may not be present
-     * the given modules.
+     * The specified services maps a service type name to the modules
+     * using the service type which may be empty if no observable module uses
+     * that service.
      */
     private static void printProviders(PrintWriter log,
                                        String header,
                                        Set<ModuleReference> modules,
-                                       Map<String, Set<String>> uses) {
+                                       Map<String, Set<String>> serviceToUses) {
         if (modules.isEmpty())
             return;
 
@@ -544,7 +561,7 @@
             .map(ModuleReference::descriptor)
             .forEach(md -> {
                 md.provides().stream()
-                  .filter(p -> uses.containsKey(p.service()))
+                  .filter(p -> serviceToUses.containsKey(p.service()))
                   .forEach(p -> providers.computeIfAbsent(p.service(), _k -> new HashSet<>())
                                          .add(md));
             });
@@ -564,11 +581,18 @@
                  .forEach(md ->
                      md.provides().stream()
                        .filter(p -> p.service().equals(service))
-                       .forEach(p -> log.format("  module %s provides %s, used by %s%n",
-                                                md.name(), p.service(),
-                                                uses.get(p.service()).stream()
-                                                    .sorted()
-                                                    .collect(Collectors.joining(","))))
+                       .forEach(p -> {
+                           String usedBy;
+                           if (serviceToUses.get(p.service()).isEmpty()) {
+                               usedBy = "not used by any observable module";
+                           } else {
+                               usedBy = serviceToUses.get(p.service()).stream()
+                                            .sorted()
+                                            .collect(Collectors.joining(",", "used by ", ""));
+                           }
+                           log.format("  %s provides %s %s%n",
+                                      md.name(), p.service(), usedBy);
+                       })
                  );
             });
     }
@@ -589,25 +613,21 @@
 
         ModuleFinder finder = config.finder();
         if (args.isEmpty()) {
-            // print providers used by the modules resolved without service binding
-            Configuration cf = config.resolve();
-            Set<ModuleReference> mrefs = cf.modules().stream()
-                .map(ResolvedModule::reference)
-                .collect(Collectors.toSet());
-
+            // print providers used by the observable modules without service binding
+            Set<ModuleReference> mrefs = finder.findAll();
             // print uses of the modules that would be linked into the image
             mrefs.stream()
                  .sorted(Comparator.comparing(mref -> mref.descriptor().name()))
                  .forEach(mref -> {
                      ModuleDescriptor md = mref.descriptor();
-                     log.format("module %s located (%s)%n", md.name(),
+                     log.format("%s %s%n", md.name(),
                                 mref.location().get());
                      md.uses().stream().sorted()
                        .forEach(s -> log.format("    uses %s%n", s));
                  });
 
             String msg = String.format("%n%s:", taskHelper.getMessage("suggested.providers.header"));
-            printProviders(log, msg, finder.findAll(), uses(mrefs));
+            printProviders(log, msg, mrefs, uses(mrefs));
 
         } else {
             // comma-separated service types, if specified
@@ -620,17 +640,22 @@
                                     .anyMatch(names::contains))
                 .collect(Collectors.toSet());
 
-            // the specified services may or may not be in the modules that
-            // would be linked in.  So find uses declared in all observable modules
-            Map<String, Set<String>> uses = uses(finder.findAll());
+            // find the modules that uses the specified services
+            Map<String, Set<String>> uses = new HashMap<>();
+            names.forEach(s -> uses.computeIfAbsent(s, _k -> new HashSet<>()));
+            finder.findAll().stream()
+                  .map(ModuleReference::descriptor)
+                  .forEach(md -> md.uses().stream()
+                                   .filter(names::contains)
+                                   .forEach(s -> uses.get(s).add(md.name())));
 
-            // check if any name given on the command line are unused service
+            // check if any name given on the command line are not provided by any module
             mrefs.stream()
                  .flatMap(mref -> mref.descriptor().provides().stream()
                                       .map(ModuleDescriptor.Provides::service))
                  .forEach(names::remove);
             if (!names.isEmpty()) {
-                log.println(taskHelper.getMessage("warn.unused.services",
+                log.println(taskHelper.getMessage("warn.provider.notfound",
                                                   toString(names)));
             }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Platform.java	Fri Apr 21 03:34:11 2017 +0000
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.internal;
+
+import jdk.tools.jlink.plugin.ResourcePoolModule;
+
+import java.util.Locale;
+
+/**
+ * Supported platforms
+ */
+public enum Platform {
+    WINDOWS,
+    LINUX,
+    SOLARIS,
+    MACOS,
+    AIX,
+    UNKNOWN;
+
+    /**
+     * Returns the {@code Platform} of the given OS name specified
+     * in the {@code ModuleTarget} attribute.
+     *
+     * @param osName OS name in ModuleTarget attribute
+     */
+    public static Platform toPlatform(String osName) {
+        try {
+            return Platform.valueOf(osName.toUpperCase(Locale.ENGLISH));
+        } catch (IllegalArgumentException e) {
+            return Platform.UNKNOWN;
+        }
+    }
+
+    /**
+     * Returns the {@code Platform} to which the given module is target to.
+     */
+    public static Platform getTargetPlatform(ResourcePoolModule module) {
+        String osName = module.osName();
+        if (osName != null) {
+            return toPlatform(osName);
+        } else {
+            return Platform.UNKNOWN;
+        }
+    }
+}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * 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,6 +35,8 @@
 import java.util.TreeSet;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
+
+import jdk.tools.jlink.internal.Platform;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.plugin.ResourcePool;
 import jdk.tools.jlink.plugin.ResourcePoolBuilder;
@@ -115,7 +117,7 @@
     @Override
     public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
         ResourcePoolModule javaBase = in.moduleView().findModule("java.base").get();
-        String[] jvmlibs = jvmlibs(javaBase.osName());
+        String[] jvmlibs = jvmlibs(javaBase);
         TreeSet<Jvm> existing = new TreeSet<>(new JvmComparator());
         TreeSet<Jvm> removed = new TreeSet<>(new JvmComparator());
         if (!keepAll) {
@@ -257,21 +259,15 @@
         return orig.copyWithContent(content);
     }
 
-    private static String[] jvmlibs(String osName) {
-        if (isWindows(osName)) {
-            return new String[] { "jvm.dll" };
-        } else if (isMac(osName)) {
-            return new String[] { "libjvm.dylib", "libjvm.a" };
-        } else {
-            return new String[] { "libjvm.so", "libjvm.a" };
+    private static String[] jvmlibs(ResourcePoolModule module) {
+        Platform platform = Platform.getTargetPlatform(module);
+        switch (platform) {
+            case WINDOWS:
+                return new String[] { "jvm.dll" };
+            case MACOS:
+                return new String[] { "libjvm.dylib", "libjvm.a" };
+            default:
+                return new String[] { "libjvm.so", "libjvm.a" };
         }
     }
-
-    private static boolean isWindows(String osName) {
-        return osName.startsWith("Windows");
-    }
-
-    private static boolean isMac(String osName) {
-        return osName.startsWith("Mac OS") || osName.startsWith("Darwin");
-    }
 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Fri Apr 21 03:34:11 2017 +0000
@@ -57,12 +57,12 @@
 \                                        if specified  
 
 main.opt.bind-services=\
-\      --bind-services                   Do full service binding
+\      --bind-services                   Link in service provider modules and\n\
+\                                        their dependences
 
 main.opt.suggest-providers=\
-\      --suggest-providers [<name>,...]  Suggest providers of services used by\n\
-\                                        the modules that would be linked, or\n\
-\                                        of the given service types
+\      --suggest-providers [<name>,...]  Suggest providers that implement the\n\
+\                                        given service types from the module path
 
 main.command.files=\
 \      @<filename>                       Read options from file
@@ -138,7 +138,7 @@
 warn.signing=WARNING: signed modular JAR {0} is currently not supported
 warn.invalid.arg=invalid classname or pathname not exist: {0}
 warn.split.package=package {0} defined in {1} {2}
-warn.unused.services=Services specified in --suggest-providers not used: {0}
+warn.provider.notfound=No provider found for service specified to --suggest-providers: {0}
 no.suggested.providers=--bind-services option is specified. No additional providers suggested.
 suggested.providers.header=Suggested providers
 providers.header=Providers
--- a/jdk/src/jdk.pack/share/classes/module-info.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/jdk.pack/share/classes/module-info.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * 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,6 +23,13 @@
  * questions.
  */
 
+/**
+ * Defines tools for transforming a JAR file into a compressed pack200 file
+ * and transforming a packed file into a JAR file, including the pack200,
+ * and unpack200 tools.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.pack {
 }
-
--- a/jdk/src/jdk.rmic/share/classes/module-info.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/src/jdk.rmic/share/classes/module-info.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * 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,9 +23,16 @@
  * questions.
  */
 
+/**
+ * Defines the rmic compiler for generating stubs and skeletons using
+ * the Java Remote Method Protocol (JRMP) and
+ * stubs and tie class files (IIOP protocol) for remote objects.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.rmic {
     requires java.corba;
     requires jdk.compiler;
     requires jdk.javadoc;
 }
-
--- a/jdk/src/sample/share/README	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-The source code provided with samples and demos for the JDK is meant
-to illustrate the usage of a given feature or technique and has been
-deliberately simplified. Additional steps required for a
-production-quality application, such as security checks, input
-validation, and proper error handling, might not be present in the
-sample code.
--- a/jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/Device.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package checker;
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.Map;
-
-/**
- * Represents the device configuration. The values are loaded from an XML file by JAXB.
- */
-@XmlRootElement
-public class Device {
-
-    @XmlElement()
-    private Map<Module, Integer> supportedModules = new EnumMap<>(Module.class);
-
-    /**
-     * Returns map of supported modules. The map key is module. The map value is version.
-     *
-     * @return map of supported modules.
-     */
-    public Map<Module, Integer> getSupportedModules() {
-        return Collections.unmodifiableMap(supportedModules);
-    }
-}
--- a/jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/Kettle.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
-  Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in the
-    documentation and/or other materials provided with the distribution.
-
-    - Neither the name of Oracle nor the names of its
-      contributors may be used to endorse or promote products derived
-      from this software without specific prior written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
-  This source code is provided to illustrate the usage of a given feature
-  or technique and has been deliberately simplified. Additional steps
-  required for a production-quality application, such as security checks,
-  input validation and proper error handling, might not be present in
-  this sample code.
-
-  -->
-
-<device>
-    <supportedModules>
-        <entry>
-            <key>DISPLAY</key>
-            <value>2</value>
-        </entry>
-        <entry>
-            <key>THERMOMETER</key>
-            <value>1</value>
-        </entry>
-        <entry>
-            <key>CLOCK</key>
-            <value>4</value>
-        </entry>
-    </supportedModules>
-</device>
--- a/jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/Module.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package checker;
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/**
- * Represents available modules.
- */
-public enum Module {
-
-    DISPLAY, CLOCK, THERMOMETER, HEATER, SPEAKER, GSM, LED;
-}
--- a/jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/PluginChecker.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-package checker;
-
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic;
-import javax.xml.bind.JAXBContext;
-import java.io.File;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.xml.bind.JAXBException;
-
-/**
- * Reads the device configuration from the XML file specified by -Adevice=device.xml.
- * For each class in a project, checks required modules. If the device doesn't have
- * the required module, then a compilation error will be shown.
- */
-@SupportedAnnotationTypes("checker.RequireContainer")
-@SupportedSourceVersion(SourceVersion.RELEASE_8)
-public class PluginChecker extends javax.annotation.processing.AbstractProcessor {
-
-    /**
-     * Name of the option to get the path to the xml with device configuration.
-     */
-    public static final String DEVICE_OPTION = "device";
-    private Device device;
-
-    /**
-     * Only the device option is supported.
-     *
-     * {@inheritDoc}
-     */
-    @Override
-    public Set<String> getSupportedOptions() {
-        return new HashSet<>(Arrays.asList(DEVICE_OPTION));
-    }
-
-    /**
-     * Initializes the processor by loading the device configuration.
-     *
-     * {@inheritDoc}
-     */
-    @Override
-    public synchronized void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        try {
-            String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
-            device = (Device) JAXBContext.newInstance(Device.class)
-                    .createUnmarshaller().unmarshal(new File(deviceOption));
-        } catch (JAXBException e) {
-            throw new RuntimeException(
-                    "Please specify device by -Adevice=device.xml\n"
-                    + e.toString(), e);
-        }
-    }
-
-    /**
-     * Processes @Require annotations and checks that Device meets requirements.
-     *
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean process(Set<? extends TypeElement> annotations,
-            RoundEnvironment roundEnv) {
-        for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) {
-            for (Require req : el.getAnnotationsByType(Require.class)) {
-                //for every Require annotation checks if device has module of required version.
-                Integer version = device.getSupportedModules().get(req.value());
-
-                if (version == null
-                        || version < req.minVersion()
-                        || version > req.maxVersion()) {
-                    //if module is optional then show only warning not error
-                    if (req.optional()) {
-                        processingEnv.getMessager()
-                                .printMessage(Diagnostic.Kind.WARNING,
-                                        "Plugin [" + el + "] requires " + req
-                                        + "\n but device " + (version == null
-                                        ? "doesn't have such module."
-                                        + " This module is optional."
-                                        + " So plugin will work but miss"
-                                        + " some functionality"
-                                        : "has " + version
-                                        + " version of that module"));
-                    } else {
-                        processingEnv.getMessager()
-                                .printMessage(Diagnostic.Kind.ERROR,
-                                        "Plugin [" + el + "] requires " + req
-                                        + "\n but device "
-                                        + (version == null
-                                        ? "doesn't have such module"
-                                        : "has " + version
-                                        + " version of that module"));
-                    }
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-}
--- a/jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/Require.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-package checker;
-
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Indicates that a plug-in depends on a module.
- */
-@Retention(RetentionPolicy.CLASS)
-@Repeatable(RequireContainer.class)
-public @interface Require {
-
-    /**
-     * Returns the required module.
-     *
-     * @return required module.
-     */
-    Module value();
-
-    /**
-     * Returns the minimum supported version of a module.
-     *
-     * @return minimum supported version of a module.
-     */
-    int minVersion() default 1;
-
-    /**
-     * Returns the maximum supported version of a module.
-     *
-     * @return maximum supported version of a module.
-     */
-    int maxVersion() default Integer.MAX_VALUE;
-
-    /**
-     * Returns true if a module is optional. A module is optional if a system
-     * works without that module but is missing some functionality. Returns false if a system
-     * won't work without the specified module.
-     *
-     * @return true if module is optional. False otherwise.
-     */
-    boolean optional() default false;
-}
--- a/jdk/src/sample/share/annotations/DependencyChecker/PluginChecker/src/checker/RequireContainer.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package checker;
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * A container for the repeatable @Require annotation.
- */
-@Retention(RetentionPolicy.CLASS)
-public @interface RequireContainer {
-
-    Require[] value();
-}
--- a/jdk/src/sample/share/annotations/DependencyChecker/Plugins/src/plugins/BoilerPlugin.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-package plugins;
-
-import checker.Module;
-import checker.Require;
-
-/**
- * BoilerPlugin provides support for boiling water and keeping water warm.
- */
-@Require(value = Module.CLOCK, maxVersion = 3)
-@Require(value = Module.THERMOMETER)
-@Require(value = Module.HEATER)
-@Require(value = Module.LED, optional = true) //will use if present
-public class BoilerPlugin {
-
-    /**
-     * Heats water up to 100 degrees Celsius.
-     */
-    public void boil() {
-        boil(100);
-    }
-
-    /**
-     * Heats water up to temperature.
-     *
-     * @param temperature - desired temperature of the water in the boiler
-     */
-    public void boil(int temperature) {
-        /*
-         * Turn on heater and wait while temperature reaches desired temperature
-         * in Celsius. Finally, turn off heater.
-         * If present, the LED light changes color according to the temperature.
-         */
-    }
-
-    /**
-     * Keeps desired temperature.
-     *
-     * @param temperature - desired temperature of the water in the boiler
-     * @param seconds - period of time for checking temperature in seconds
-     */
-    public void keepWarm(int temperature, int seconds) {
-        //Every n seconds check temperature and warm up, if necessary.
-    }
-
-}
--- a/jdk/src/sample/share/annotations/DependencyChecker/Plugins/src/plugins/ExtendedBoilerPlugin.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-package plugins;
-
-import checker.Module;
-import checker.Require;
-import java.util.Calendar;
-
-/**
- * Introduces new features for BoilerPlugin. Features are boiling water by an
- * SMS and boiling water by date with notification by a phone call.
- */
-@Require(value = Module.SPEAKER)
-@Require(value = Module.GSM, minVersion = 3)
-@Require(value = Module.DISPLAY)
-public class ExtendedBoilerPlugin extends BoilerPlugin {
-
-    /**
-     * Boils water at the appointed time and wakes you up by a ring and phone
-     * call. Shows "Good morning" and a quote of the day from the Internet on the
-     * display.
-     *
-     * @param calendar - date and time when water should be boiled
-     * @param phoneNumber - phone number to call
-     */
-    public void boilAndWakeUp(Calendar calendar, int phoneNumber) {
-        //implementation
-    }
-
-    /**
-     * Boils water at the appointed time by getting an SMS of fixed format.
-     * Sends an SMS on finish.
-     *
-     * @param sms - text of SMS
-     */
-    public void boilBySMS(String sms) {
-        //implementation
-    }
-}
--- a/jdk/src/sample/share/annotations/DependencyChecker/Plugins/src/plugins/TimerPlugin.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-package plugins;
-
-import checker.Module;
-import checker.Require;
-
-/**
- * Timer plug-in is used to support an alarm and a timer. It depends on Display and
- * Clock modules.
- */
-@Require(Module.DISPLAY)
-@Require(value = Module.CLOCK, maxVersion = 3)
-public class TimerPlugin {
-
-    /**
-     * Sets timer.
-     *
-     * @param time - the remaining time.
-     */
-    public void timer(long time) {
-        //start timer
-        //show the remaining time on display
-    }
-
-    /**
-     * Sets alarm.
-     *
-     * @param time - the alarm time.
-     */
-    public void alarm(long time) {
-        //start alarm
-        //show current time and alarm time on display
-    }
-}
--- a/jdk/src/sample/share/annotations/Validator/src/PositiveIntegerSupplier.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-import java.util.function.Supplier;
-
-/**
- * Supplies a positive number.
- */
-@Validate(value = Validator.INTEGER_NUMBER,
-        description = "It's not an Integer ")
-@Validate(value = Validator.POSITIVE_NUMBER,
-        description = "It's not a positive Number")
-public class PositiveIntegerSupplier implements Supplier<String> {
-
-    /**
-     * Returns a string representation of a positive integer.
-     *
-     * @return string representation of a positive integer.
-     */
-    @Override
-    public String get() {
-        return "20005"; //random number
-    }
-}
--- a/jdk/src/sample/share/annotations/Validator/src/SupplierValidator.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-import javax.xml.bind.ValidationException;
-import java.util.function.Supplier;
-
-/**
- * Validates the supplier.
- */
-public class SupplierValidator {
-
-    /**
-     * Validates the supplier.
-     *
-     * @param supplier - Supplier that needs to be validated.
-     * @return true if supplier has passed validation check. False otherwise.
-     */
-    public static boolean validate(Supplier<?> supplier) {
-        for (Validate annotation
-                : supplier.getClass().getAnnotationsByType(Validate.class)) {
-            try {
-                annotation.value().validate(supplier);
-            } catch (ValidationException e) {
-                System.out.println(annotation.description());
-                e.printStackTrace();
-                return false;
-            }
-        }
-        return true;
-    }
-}
--- a/jdk/src/sample/share/annotations/Validator/src/Validate.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Indicates that the class should be validated by the specified validator.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Repeatable(ValidateContainer.class)
-public @interface Validate {
-
-    /**
-     * Returns the validator that should validate the annotated class.
-     *
-     * @return Validator that should validate annotated class.
-     */
-    Validator value();
-
-    /**
-     * Returns text to describe the failure of the validation check.
-     *
-     * @return text to describe the failure of the validation check.
-     */
-    String description() default "";
-}
-
-/**
- * A container for the repeatable @Validate annotation.
- *
- * @author Andrey Nazarov
- */
-@Retention(RetentionPolicy.RUNTIME)
-@interface ValidateContainer {
-
-    Validate[] value();
-}
--- a/jdk/src/sample/share/annotations/Validator/src/Validator.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-import javax.xml.bind.ValidationException;
-import java.util.function.Supplier;
-
-/**
- * Enum of Validator implementations.
- */
-public enum Validator {
-
-    /**
-     * This validator checks that the string represents an integer.
-     */
-    INTEGER_NUMBER {
-                /**
-                 * Checks that the string represents an integer.
-                 *
-                 * @param string - a string supplier
-                 * @throws ValidationException if the validation check fails
-                 */
-                @Override
-                void validate(Supplier<?> string) throws ValidationException {
-                    try {
-                        Integer.parseInt((String) string.get());
-                    } catch (NumberFormatException ex) {
-                        throw new ValidationException("Error while validating "
-                                + string.get());
-                    }
-                }
-            },
-    /**
-     * This validator checks that the string represents a positive number.
-     */
-    POSITIVE_NUMBER {
-                /**
-                 * Checks that the string represents a positive number.
-                 *
-                 * @param string - an string supplier
-                 * @throws ValidationException if the validation check fails
-                 */
-                @Override
-                void validate(Supplier<?> string) throws ValidationException {
-                    try {
-                        if (Double.compare(0.0, Double.parseDouble(
-                                        (String) string.get())) > 0) {
-                            throw new Exception();
-                        }
-                    } catch (Exception ex) {
-                        throw new ValidationException("Error while validating "
-                                + string.get());
-                    }
-                }
-            };
-
-    /**
-     * Checks that the supplier is valid.
-     *
-     * @param string - a string supplier
-     * @throws ValidationException if validation check fails
-     */
-    abstract void validate(Supplier<?> string) throws ValidationException;
-
-}
--- a/jdk/src/sample/share/annotations/index.html	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <title>Repeating Annotations Demo</title>
-</head>
-<body>
-<h2>Repeating Annotations Demo</h2>
-
-<p>
-    This demo shows how to use repeating annotations at runtime and at compile time.
-</p>
-
-<ul>
-    <li><h3>Dependency checker.</h3>
-
-        <p>
-            Shows how to define repeating annotations and process them at compile time.
-            The problem domain is some code that performs useful operations on hardware devices.
-            The code relies on "modules" to be present on the devices. Applicability of the code to a particular
-            device is checked while compiling the code for a particular device.
-            A set of modules provided by a device is listed in an xml file that turns red during the compilation
-            phase and is compared with the required module set specified by annotations.
-            For instance, there is kettle with hardware modules: thermometer, display, and clock.
-            There is also a boiler plug-in that requires clock, thermometer, heater, and optionally an LED light.
-
-            Build the PluginChecker annotation processor first.
-            Then, run javac with the annotation processor against plug-in sources using the following command: </p>
-
-        <code>javac -cp "PluginChecker.jar" -processor checker.PluginChecker -Adevice=Kettle.xml -proc:only &lt;source
-            files&gt;</code>
-
-        <p>
-            where <code>PluginChecker.jar</code> - path to jar file that contains PluginChecker annotation processor
-            class. </br>
-            <code>Kettle.xml</code> - path to device descriptor Kettle.xml                                         </br>
-            <code>&lt;source files&gt;</code> - source files in Plugins/src
-        </p>
-        For more information, see the source files.
-        </p>
-        <ul>
-            <li>Annotation processor sources: <a href="DependencyChecker/PluginChecker/src/">DependencyChecker/PluginChecker/src</a>
-            <li>Processing of repeating annotations can be found in <a href="DependencyChecker/PluginChecker/src/checker/PluginChecker.java">PluginChecker.java</a>
-            <li>Usage of repeating annotation is shown in modules sources.<a href="DependencyChecker/Plugins/src">DependencyChecker/Plugins/src</a>
-        </ul>
-
-    <li><h3>Validator.</h3>
-
-        <p>
-            Shows how to define repeating annotations and process them at runtime.
-            A problem domain is code that needs to validate provided Suppliers for conformance to some criteria.
-            The criteria are implemented by the Validator class which is applied by using annotations that are placed in
-            the code whenever validation is needed. For more information, see the
-            source files.
-        </p>
-
-        <p>
-        <ul>
-            <li>Usage of repeating annotation is described in <a href="Validator/src/PositiveIntegerSupplier.java">PositiveIntegerSupplier.java</a>
-            <li> Example of how to define a repeating annotation type can be found in
-                <a href="Validator/src/Validate.java">Validate.java</a>
-            <li> Usages of the new reflective methods can be found in <a href="Validator/src/SupplierValidator.java">SupplierValidator.java</a>
-        </ul>
-        </p>
-        Sources: <a href="Validator/src/">Validator/src/</a>
-</ul>
-</body>
-</html>
--- a/jdk/src/sample/share/forkjoin/mergesort/MergeDemo.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,296 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.util.Arrays;
-import java.util.Random;
-
-import static java.lang.Integer.parseInt;
-
-/**
- * MergeExample is a class that runs a demo benchmark of the {@code ForkJoin} framework
- * by benchmarking a {@link MergeSort} algorithm that is implemented using
- * {@link java.util.concurrent.RecursiveAction}.
- * The {@code ForkJoin} framework is setup with different parallelism levels
- * and the sort is executed with arrays of different sizes to see the
- * trade offs by using multiple threads for different sizes of the array.
- */
-public class MergeDemo {
-    // Use a fixed seed to always get the same random values back
-    private final Random random = new Random(759123751834L);
-    private static final int ITERATIONS = 10;
-
-    /**
-     * Represents the formula {@code f(n) = start + (step * n)} for n = 0 & n < iterations
-     */
-    private static class Range {
-        private final int start;
-        private final int step;
-        private final int iterations;
-
-        private Range(int start, int step, int iterations) {
-            this.start = start;
-            this.step = step;
-            this.iterations = iterations;
-        }
-
-        /**
-         * Parses start, step and iterations from args
-         * @param args the string array containing the arguments
-         * @param start which element to start the start argument from
-         * @return the constructed range
-         */
-        public static Range parse(String[] args, int start) {
-            if (args.length < start + 3) {
-                throw new IllegalArgumentException("Too few elements in array");
-            }
-            return new Range(parseInt(args[start]), parseInt(args[start + 1]), parseInt(args[start + 2]));
-        }
-
-        public int get(int iteration) {
-            return start + (step * iteration);
-        }
-
-        public int getIterations() {
-            return iterations;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append(start).append(" ").append(step).append(" ").append(iterations);
-            return builder.toString();
-        }
-    }
-
-    /**
-     * Wraps the different parameters that is used when running the MergeExample.
-     * {@code sizes} represents the different array sizes
-     * {@code parallelism} represents the different parallelism levels
-     */
-    private static class Configuration {
-        private final Range sizes;
-        private final Range parallelism;
-
-        private final static Configuration defaultConfig = new Configuration(new Range(20000, 20000, 10),
-                new Range(2, 2, 10));
-
-        private Configuration(Range sizes, Range parallelism) {
-            this.sizes = sizes;
-            this.parallelism = parallelism;
-        }
-
-        /**
-         * Parses the arguments and attempts to create a configuration containing the
-         * parameters for creating the array sizes and parallelism sizes
-         * @param args the input arguments
-         * @return the configuration
-         */
-        public static Configuration parse(String[] args) {
-            if (args.length == 0) {
-                return defaultConfig;
-            } else {
-                try {
-                    if (args.length == 6) {
-                        return new Configuration(Range.parse(args, 0), Range.parse(args, 3));
-                    }
-                } catch (NumberFormatException e) {
-                    System.err.println("MergeExample: error: Argument was not a number.");
-                }
-                System.err.println("MergeExample <size start> <size step> <size steps> <parallel start> <parallel step>" +
-                        " <parallel steps>");
-                System.err.println("example: MergeExample 20000 10000 3 1 1 4");
-                System.err.println("example: will run with arrays of sizes 20000, 30000, 40000" +
-                        " and parallelism: 1, 2, 3, 4");
-                return null;
-            }
-        }
-
-        /**
-         * Creates an array for reporting the test result time in
-         * @return an array containing {@code sizes.iterations * parallelism.iterations} elements
-         */
-        private long[][] createTimesArray() {
-            return new long[sizes.getIterations()][parallelism.getIterations()];
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder("");
-            if (this == defaultConfig) {
-                builder.append("Default configuration. ");
-            }
-            builder.append("Running with parameters: ");
-            builder.append(sizes);
-            builder.append(" ");
-            builder.append(parallelism);
-            return builder.toString();
-        }
-    }
-
-    /**
-     * Generates an array of {@code elements} random elements
-     * @param elements the number of elements requested in the array
-     * @return an array of {@code elements} random elements
-     */
-    private int[] generateArray(int elements) {
-        int[] array = new int[elements];
-        for (int i = 0; i < elements; ++i) {
-            array[i] = random.nextInt();
-        }
-        return array;
-    }
-
-    /**
-     * Runs the test
-     * @param config contains the settings for the test
-     */
-    private void run(Configuration config) {
-        Range sizes = config.sizes;
-        Range parallelism = config.parallelism;
-
-        // Run a couple of sorts to make the JIT compile / optimize the code
-        // which should produce somewhat more fair times
-        warmup();
-
-        long[][] times = config.createTimesArray();
-
-        for (int size = 0; size < sizes.getIterations(); size++) {
-            runForSize(parallelism, sizes.get(size), times, size);
-        }
-
-        printResults(sizes, parallelism, times);
-    }
-
-    /**
-     * Prints the results as a table
-     * @param sizes the different sizes of the arrays
-     * @param parallelism the different parallelism levels used
-     * @param times the median times for the different sizes / parallelism
-     */
-    private void printResults(Range sizes, Range parallelism, long[][] times) {
-        System.out.println("Time in milliseconds. Y-axis: number of elements. X-axis parallelism used.");
-        long[] sums = new long[times[0].length];
-        System.out.format("%8s  ", "");
-        for (int i = 0; i < times[0].length; i++) {
-            System.out.format("%4d ", parallelism.get(i));
-        }
-        System.out.println("");
-        for (int size = 0; size < sizes.getIterations(); size++) {
-            System.out.format("%8d: ", sizes.get(size));
-            for (int i = 0; i < times[size].length; i++) {
-                sums[i] += times[size][i];
-                System.out.format("%4d ", times[size][i]);
-            }
-            System.out.println("");
-        }
-        System.out.format("%8s: ", "Total");
-        for (long sum : sums) {
-            System.out.format("%4d ", sum);
-        }
-        System.out.println("");
-    }
-
-    private void runForSize(Range parallelism, int elements, long[][] times, int size) {
-        for (int step = 0; step < parallelism.getIterations(); step++) {
-            long time = runForParallelism(ITERATIONS, elements, parallelism.get(step));
-            times[size][step] = time;
-        }
-    }
-
-    /**
-     * Runs <i>iterations</i> number of test sorts of a random array of <i>element</i> length
-     * @param iterations number of iterations
-     * @param elements number of elements in the random array
-     * @param parallelism parallelism for the ForkJoin framework
-     * @return the median time of runs
-     */
-    private long runForParallelism(int iterations, int elements, int parallelism) {
-        MergeSort mergeSort = new MergeSort(parallelism);
-        long[] times = new long[iterations];
-
-        for (int i = 0; i < iterations; i++) {
-            // Suggest the VM to run a garbage collection to reduce the risk of getting one
-            // while running the test run
-            System.gc();
-            long start = System.currentTimeMillis();
-            mergeSort.sort(generateArray(elements));
-            times[i] = System.currentTimeMillis() - start;
-        }
-
-        return medianValue(times);
-    }
-
-    /**
-     * Calculates the median value of the array
-     * @param times array of times
-     * @return the median value
-     */
-    private long medianValue(long[] times) {
-        if (times.length == 0) {
-            throw new IllegalArgumentException("Empty array");
-        }
-        // Make a copy of times to avoid having side effects on the parameter value
-        Arrays.sort(times.clone());
-        long median = times[times.length / 2];
-        if (times.length > 1 && times.length % 2 != 0) {
-            median = (median + times[times.length / 2 + 1]) / 2;
-        }
-        return median;
-    }
-
-    /**
-     * Generates 1000 arrays of 1000 elements and sorts them as a warmup
-     */
-    private void warmup() {
-        MergeSort mergeSort = new MergeSort(Runtime.getRuntime().availableProcessors());
-        for (int i = 0; i < 1000; i++) {
-            mergeSort.sort(generateArray(1000));
-        }
-    }
-
-    public static void main(String[] args) {
-        Configuration configuration = Configuration.parse(args);
-        if (configuration == null) {
-            System.exit(1);
-        }
-        System.out.println(configuration);
-        new MergeDemo().run(configuration);
-    }
-}
--- a/jdk/src/sample/share/forkjoin/mergesort/MergeSort.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.util.Arrays;
-import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.ForkJoinTask;
-import java.util.concurrent.RecursiveAction;
-
-/**
- * A class for sorting an array of {@code ints} in parallel.
- * A {@code ForkJoinPool} is used for the parallelism, using the merge sort
- * algorithm the array is split into halves and a new sub task is created
- * for each part. Each sub task is dispatched to the {@code ForkJoinPool}
- * which will schedule the task to a {@code Thread}.
- * This happens until the size of the array is at most 2
- * elements long. At this point the array is sorted using a simple compare
- * and possibly a swap. The tasks then finish by using insert sort to
- * merge the two just sorted arrays.
- *
- * The idea of this class is to demonstrate the usage of RecursiveAction not
- * to implement the best possible parallel merge sort. This version creates
- * a small array for each merge (creating a lot of objects), this could
- * be avoided by keeping a single array.
- */
-public class MergeSort {
-    private final ForkJoinPool pool;
-
-    private static class MergeSortTask extends RecursiveAction {
-        private final int[] array;
-        private final int low;
-        private final int high;
-        private static final int THRESHOLD = 8;
-
-        /**
-         * Creates a {@code MergeSortTask} containing the array and the bounds of the array
-         *
-         * @param array the array to sort
-         * @param low the lower element to start sorting at
-         * @param high the non-inclusive high element to sort to
-         */
-        protected MergeSortTask(int[] array, int low, int high) {
-            this.array = array;
-            this.low = low;
-            this.high = high;
-        }
-
-        @Override
-        protected void compute() {
-            if (high - low <= THRESHOLD) {
-                Arrays.sort(array, low, high);
-            } else {
-                int middle = low + ((high - low) >> 1);
-                // Execute the sub tasks and wait for them to finish
-                invokeAll(new MergeSortTask(array, low, middle), new MergeSortTask(array, middle, high));
-                // Then merge the results
-                merge(middle);
-            }
-        }
-
-        /**
-         * Merges the two sorted arrays this.low, middle - 1 and middle, this.high - 1
-         * @param middle the index in the array where the second sorted list begins
-         */
-        private void merge(int middle) {
-            if (array[middle - 1] < array[middle]) {
-                return; // the arrays are already correctly sorted, so we can skip the merge
-            }
-            int[] copy = new int[high - low];
-            System.arraycopy(array, low, copy, 0, copy.length);
-            int copyLow = 0;
-            int copyHigh = high - low;
-            int copyMiddle = middle - low;
-
-            for (int i = low, p = copyLow, q = copyMiddle; i < high; i++) {
-                if (q >= copyHigh || (p < copyMiddle && copy[p] < copy[q]) ) {
-                    array[i] = copy[p++];
-                } else {
-                    array[i] = copy[q++];
-                }
-            }
-        }
-    }
-
-    /**
-     * Creates a {@code MergeSort} containing a ForkJoinPool with the indicated parallelism level
-     * @param parallelism the parallelism level used
-     */
-    public MergeSort(int parallelism) {
-        pool = new ForkJoinPool(parallelism);
-    }
-
-    /**
-     * Sorts all the elements of the given array using the ForkJoin framework
-     * @param array the array to sort
-     */
-    public void sort(int[] array) {
-        ForkJoinTask<Void> job = pool.submit(new MergeSortTask(array, 0, array.length));
-        job.join();
-    }
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/build.properties	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-# IMPORTANT NOTE
-#
-# If you made a private copy of this project you may have to update the
-# nbjdk.home variable at the end of this file.
-#  
-# To be able to run the test-suite, you will also have to set the
-# variable:
-#
-# libs.junit.classpath=<junit.jar> 
-#
-
-main.dir=.
-
-src.dir=${main.dir}/src
-test.src.dir=${main.dir}/test
-
-build.dir=build
-classes.dir=${build.dir}/classes
-
-dist.dir=dist
-jar=${dist.dir}/jmx-scandir.jar
-javadoc.dir=${dist.dir}/javadoc
-
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-
-build.sysclasspath=ignore
-# E.g.: cp=lib/x.jar:lib/y.jar
-cp=
-extra.run.cp=
-
-# To be able to run the test-suite, set the following property:
-# libs.junit.classpath=...
-
-javac.test.classpath=\
-    ${classes.dir}:\
-    ${libs.junit.classpath}
-
-main.agent.class=com.sun.jmx.examples.scandir.ScanDirAgent
-main.client.class=com.sun.jmx.examples.scandir.ScanDirClient
-main.class=${main.client.class}
-
-run.jvmargs=-Djava.util.logging.config.file=logging.properties
-common.jvmargs=${run.jvmargs} -Djavax.net.ssl.keyStore=keystore -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=truststore -Djavax.net.ssl.trustStorePassword=trustword
-client.jvmargs=${common.jvmargs}
-agent.jvmargs=${common.jvmargs} -Dcom.sun.management.config.file=src/etc/management.properties -Dscandir.config.file=src/etc/testconfig.xml
-
-client.args=localhost 4545
-
-run.cp=${cp}:${classes.dir}:${extra.run.cp}
-run.test.classpath=${run.cp}:${build.test.classes.dir}
-
-debug=true
-deprecation=false
-
-# Update this variable if need be to point to the JDK 6 location.
-# 
-nbjdk.home=${basedir}/../../..
--- a/jdk/src/sample/share/jmx/jmx-scandir/build.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,175 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-
-<!-- 
-  This is ant (http://ant.apache.org) build script to build the
-  "jmx-scandir" sample. Either this build.xml can be used standalone 
-  with "ant" tool or can be opened as a project with NetBeans IDE
-  (http://www.netbeans.org).
--->
-
-<project name="jmx-scandir" default="jar" basedir=".">
-
-    <import file="nbproject/jdk.xml"/>
-    
-
-    <target name="-prop-init">
-        <property file="user.build.properties"/>
-        <property file="build.properties"/>
-    </target>
-
-    <target name="-init" depends="-prop-init,-jdk-init"/>
-
-    <target name="compile" depends="-init" description="Compile main sources.">
-        <mkdir dir="${classes.dir}"/>
-        <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="${debug}" deprecation="${deprecation}">
-            <classpath path="${cp}"/>
-        </javac>
-        <copy todir="${classes.dir}">
-            <fileset dir="${src.dir}"/>
-        </copy>
-    </target>
-
-    <target name="jar" depends="compile" description="Build JAR file for main sources.">
-        <mkdir dir="${dist.dir}" />
-        <jar jarfile="${jar}" compress="true">
-            <manifest>
-                <attribute name="Main-Class" value="${main.agent.class}"/>
-            </manifest>
-            <fileset dir="${classes.dir}"/>
-        </jar>
-    </target>
-
-    <target name="run-client" depends="compile" description="Run client.">
-        <fail unless="main.client.class">Must set property 'main.client.class' (e.g. in build.properties)</fail>
-        <java classname="${main.client.class}" fork="true" failonerror="true">
-            <classpath path="${run.cp}"/>
-            <jvmarg line="${client.jvmargs}" />
-            <arg line="${client.args}" />
-        </java>
-    </target>
-
-    <target name="run-agent" depends="compile" description="Run agent.">
-        <fail unless="main.agent.class">Must set property 'main.agent.class' (e.g. in build.properties)</fail>
-        <java classname="${main.agent.class}" fork="true" failonerror="true">
-            <classpath path="${run.cp}"/>
-            <jvmarg line="${agent.jvmargs}" />
-        </java>
-    </target>
-
-    <target name="run" depends="run-agent" description="Run agent." />
-
-    <target name="run-single" depends="-init,compile">
-        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
-        <java classname="${run.class}" fork="true" failonerror="true">
-            <classpath path="${run.cp}"/>
-        </java>
-    </target>
-
-    <target name="javadoc" depends="-init" description="Build Javadoc.">
-        <mkdir dir="${javadoc.dir}"/>
-        <javadoc destdir="${javadoc.dir}">
-            <classpath path="${cp}"/>
-            <sourcepath>
-                <pathelement location="${src.dir}"/>
-            </sourcepath>
-            <fileset dir="${src.dir}"/>
-        </javadoc>
-    </target>
-
-    <target name="clean" depends="-init" description="Clean build products.">
-        <delete dir="${build.dir}"/>
-        <delete file="${jar}"/>
-        <delete dir="${dist.dir}"/>
-    </target>
-
-    <target name="profile">
-        <ant antfile="nbproject/netbeans-targets.xml" target="profile"/>
-    </target>
-
-    <!-- JUnit targets -->
-
-    <target name="compile-test" depends="-init,compile">
-        <fail unless="libs.junit.classpath">Must set libs.junit.classpath variable to the JUnit classpath in the build.properties file.</fail>
-        <mkdir dir="${build.test.classes.dir}"/>
-        <javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="${debug}" classpath="${javac.test.classpath}"/>
-        <copy todir="${build.test.classes.dir}">
-            <fileset dir="${test.src.dir}" excludes="**/*.java"/>
-        </copy>
-    </target>
-
-    <target name="-do-test-run" depends="-init,compile-test">
-        <mkdir dir="${build.test.results.dir}"/>
-        <junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
-            <batchtest todir="${build.test.results.dir}">
-                <fileset dir="${test.src.dir}" includes="**/*Test.java"/>
-            </batchtest>
-            <classpath>
-                <path path="${run.test.classpath}"/>
-            </classpath>
-            <syspropertyset>
-                <propertyref prefix="test-sys-prop."/>
-                <mapper type="glob" from="test-sys-prop.*" to="*"/>
-            </syspropertyset>
-            <formatter type="brief" usefile="false"/>
-            <formatter type="xml"/>
-            <jvmarg line="${run.jvmargs}"/>
-        </junit>
-        <fail if="tests.failed">Some tests failed; see details above.</fail>
-    </target>
-    
-    <target name="test" depends="-init,compile-test,-do-test-run" description="Run unit tests."/>
-
-    <target name="-do-test-run-single" depends="-init,compile-test">
-        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
-        <junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
-            <batchtest todir="${build.test.results.dir}">
-                <fileset dir="${test.src.dir}" includes="${test.includes}"/>
-            </batchtest>
-            <classpath>
-                <path path="${run.test.classpath}"/>
-            </classpath>
-            <syspropertyset>
-                <propertyref prefix="test-sys-prop."/>
-                <mapper type="glob" from="test-sys-prop.*" to="*"/>
-            </syspropertyset>
-            <formatter type="brief" usefile="false"/>
-            <formatter type="xml"/>
-            <jvmarg line="${run.jvmargs}"/>
-        </junit>
-        <fail if="tests.failed">Some tests failed; see details above.</fail>
-    </target>
-
-    <target name="test-single" depends="-init,compile-test,-do-test-run-single" description="Run single unit test."/>
-</project>
--- a/jdk/src/sample/share/jmx/jmx-scandir/index.html	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2217 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<html>
-  <head>
-<!--
- Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-    <title>JMX&trade; "scandir" Example</title>
-  </head>
-  <body>
-
-  <h1><center>Java&trade; Management Extensions (JMX&trade;) <i>scandir</i> Example</center></h1>
-
-  <h2><a name="h2-Introduction">Introduction</a></h2>
-  <ul>
-  <p>The JMX <i>scandir</i> example is an application that
-     scans parts of a filesystem - e.g. a set of directories
-     used by a number of lab machines when running tests - in
-     order to clean up and optimize disk space by removing
-     obsolete files - e.g. files that are leaked by the test
-     suites running on those machines, like coredump files, or
-     temporary files that might remain after a test crash.
-     It could also serve as a basis for an application that
-     would monitor disk usage and suggest removal of old big
-     long-unaccessed files.
-  </p>
-  <p>The JMX <i>scandir</i> example does not however implement
-     the full fledged logic that such an application might
-     have. It implements a subset of this logic which is
-     sufficient to demonstrate common patterns and
-     solutions used when implementing a monitoring and
-     management interface for an application with JMX
-     Technology.</p>
-  <p>This example is an advanced JMX example, which presents
-     advanced JMX concepts. It is assumed that the reader is already
-     familiar with the JMX API. Newcomers to JMX Technology are
-     invited to have a look at the <a
-     href="http://java.sun.com/javase/6/docs/technotes/guides/jmx/"
-     >JMX API Overview, Tutorial and Examples</a> before going any further.
-  </p>
-  <p></p>
-      <hr>
-  <blockquote>
-    <u>Note:</u> This example was developed using <a
-     href="http://www.netbeans.org">NetBeans 5.0 IDE</a>. The instructions
-     given in this document to build, run, and test the example assume that
-     you have at your disposal:
-     <ul><li>either <a href="http://www.netbeans.org">NetBeans 5.0 IDE</a>,</li>
-         <li>or <a href="http://ant.apache.org/">Apache Ant 1.6.5</a> and
-             <a href="http://sourceforge.net/projects/junit/">JUnit 3.8.1 or
-             3.8.2</a><br>
-             (JUnit is only needed to run the example's unit tests).
-         </li>
-     </ul>
-     <p><a name="setup">In order to build the example</a>,
-     <u>you may need to copy the jmx-scandir</u>
-     directory to somewhere where you have write permissions.
-     <br>In that case, you will need to update the <i>nbjdk.home</i> variable
-     in the copied <i><a href="build.properties">build.properties</a></i>
-     file located at the root of the copied project directory.
-     Please make sure that this variable points to the JDK 6 home directory.
-     </p>
-     <p>If you wish to run the testsuite from within the <a
-     href="http://www.netbeans.org">NetBeans IDE</a> you will also have
-     to set the <i>libs.junit.classpath</i> variable in
-     <a href="build.properties">build.properties</a>.
-     The <i>libs.junit.classpath</i>  variable should point to your
-     <a href="http://sourceforge.net/projects/junit/">junit.jar</a>,
-     version 3.8.1 or 3.8.2.
-     </p>
-  </blockquote>
-     <hr>
-     <p></p>
-     <p><u>Table Of Contents:</u></p>
-  <p><center>[<a href="#h2-Generating">Generating&nbsp;the&nbsp;Java&nbsp;Documentation</a>]
-  [<a href="#h2-Overview">Overview&nbsp;of&nbsp;the&nbsp;<i>scandir</i>&nbsp;Example</a>]
-  [<a href="#h2-API-Doc">API&nbsp;Documentation&nbsp;and&nbsp;Sources</a>]
-  [<a href="#h2-Patterns">Patterns,&nbsp;Best&nbsp;Practices,&nbsp;and&nbsp;Common&nbsp;Pitfalls</a>]
-  [<a href="#h2-Testing">Testing&nbsp;the&nbsp;<i>scandir</i>&nbsp;Example</a>]
-  [<a href="#h2-Running">Running&nbsp;the&nbsp;<i>scandir</i>&nbsp;Example</a>]
-  [<a href="#h2-Playing">Playing&nbsp;with&nbsp;JConsole</a>]
-  [<a href="#h2-Turning">Turning&nbsp;the&nbsp;example&nbsp;into&nbsp;a&nbsp;Secure&nbsp;JMX&nbsp;Application</a>]
-  [<a href="#h2-Connecting">Connecting&nbsp;to&nbsp;the&nbsp;Secure&nbsp;JMX&nbsp;Application</a>]
-  [<a href="#h2-Conclusion">Conclusion</a>]
-  [<a href="#h2-References">References</a>]</center></p>
-
-  </ul>
-  <h2><a name="h2-Generating">Generating the Java Documentation</a></h2>
-
-    <ul>
-        <p>Before reading further, you will need to generate the
-        Java Documentation for the example's sources.</p>
-        <p>In the example root directory (where the <code>build.xml</code>
-           file is located) run the following command:
-           <pre>ant javadoc</pre>
-        </p>
-        <p>Alternatively you can open the jmx-scandir project with the
-           NetBeans IDE and generate the Javadoc from its <code>Build</code>
-           menu.
-        </p>
-        <p>If building the documentation fails, please make sure to read the
-           <a href="#setup">note</a> at the beginning of this document.</p>
-    </ul>
-
-  <h2><a name="h2-Overview">Overview of the <i>scandir</i> Example</a></h2>
-
-  <ul>
-    <p>The JMX <i>scandir</i> example is built around the
-    following MBeans:</p>
-    <ul>
-        <li>The first MBean we will present here is the
-        <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-        >DirectoryScannerMXBean</a>. <br>A
-        <code>DirectoryScannerMXBean</code> is an MBean that scans a
-        file system starting at a given root directory, and then looks
-        for files that match the given criteria.  When such a file is
-        found, the <code>DirectoryScannerMXBean</code> takes the
-        action for which it was configured: emit a notification,
-        <i>and/or</i> log a <code>record</code> for this file,
-        <i>and/or</i> delete that file. The code that would actually
-        delete the file is commented out - so that nothing valuable is
-        lost if the example is run by mistake on the wrong set of
-        directories.<br> <code>DirectoryScannerMXBeans</code> are
-        created by the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-        >ScanManagerMXBean</a> - see next item on the list, from its
-        configuration.
-        </li>
-        <li>
-            The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-            >ScanManagerMXBean</a> is the actual entry point of the
-            application. It reads the application's
-            configuration, and from that configuration,
-            will create a <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManager.html"
-title="The ResultLogManager is in charge of managing result logs"
-        >ResultLogManager</a> and some <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-        >DirectoryScannerMXBeans</a>.
-            <br>The <code>ScanManagerMXBean</code> lets you start, stop, and
-            schedule directory scans. The
-            <code>ScanManagerMXBean</code> is a singleton
-            MBean: there can be at most one instance of such
-            an MBean registered in a given MBeanServer.
-        </li>
-        <li>The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBean</a> is an MBean which is able to
-           load/save the configuration to/from an XML file. It
-           will also let you modify that configuration - by e.g.
-           creating new directory scanners in there.
-           The corresponding MBeans will be created later, only
-           when you later
-           ask the <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a> </code> to apply the
-           configuration again.<br>
-           The <code>ScanDirConfigMXBean</code> is created by the
-           <code>ScanManagerMXBean</code>, when the
-           <code>ScanManagerMXBean</code> is registered.
-           It is also possible to create an alternate
-           <code>ScanDirConfigMXBean</code>, and to switch the
-           <code>ScanDirConfigMXBean</code> to use one or the other
-           configuration.
-           <br>An example of XML configuration file is given
-           <a href="src/etc/testconfig.xml"
-           title="An Example Of Configuration"
-           >here</a>. Although you could edit such a file by
-           hand, it is easier to do it programmatically (or
-           with <a href="#JConsole">JConsole</a>) through
-           the <code>ScanDirConfigMXBean</code> interface.
-        </li>
-        <li>The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-title="The ResultLogManagerMXBean is in charge of managing result logs"
-        >ResultLogManagerMXBean</a> is in charge of managing result logs.
-        <br>Directory Scanners can be configured to log a
-        <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/config/ResultRecord.html"
-title="A ResultRecord contains information about a file matching the criteria of a Directory Scanner"
-        >ResultRecord</a> whenever they take action upon a file that
-        matches their criteria. The <code>ResultLogManagerMXBean</code> is
-        responsible for logging these result records.
-        The <code>ResultLogManagerMXBean</code> can be configured to log
-        such records to a flat file, or into a log held in memory, or
-        both. Both logs (file and memory) can be configured with a
-        maximum capacity.
-        <br>When the maximum capacity of the memory
-        log is reached, its first entry (i.e. its oldest entry) is
-        removed to make place for the latest one.
-        <br>When the maximum
-        capacity of the file log is reached, the file is
-        renamed by appending a tilde '~' to its name and a
-        new result log is created.
-        <br>The <code>ResultLogManagerMXBean</code>
-        will let you interactively clear these result logs, change their
-        capacity, and decide where (memory or file) to log.
-        The memory log is useful in that its content can be interactively
-        returned by the <code>ResultLogManagerMXBean</code>, while
-        the file log doesn't have this facility.<br>
-        The result logs are intended to be used by e.g. an offline
-        program that would take some actions on the files that
-        matched the scan criteria:
-        <br>The <i>scandir</i> application
-        could be configured to only produce logs (i.e. takes no
-        action but logging the matching files), and the real
-        action could be performed by another program or module (e.g. mail the result log to the engineer who
-        maintains the lab, or parse that log and delete all the
-        files listed there, or parse the log and prepare and send
-        a single mail to each owner of matching files, containing
-        the list of files they should consider deleting).<br>
-        The <code>ResultLogManagerMXBean</code> is a singleton
-        MBean created by the <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a> </code>
-        which reads and writes its configuration from the
-        <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBean</a></code>.
-        </li>
-    </ul>
-    <p>An application <code>main()</code> method is
-       provided in the <a
-       href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirAgent.html"
-       >ScanDirAgent</a> class. The <code>main()</code> simply registers
-       a <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a> </code> in the platform MBeanServer, and
-       then waits for someone to call <code>close()</code> on the
-       <code>ScanManagerMXBean</code>.
-    </p>
-     <p>When the <code>ScanManagerMXBean</code> is registered, it
-        will create a default <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBean</a></code> bound
-        to a default XML config file.
-     </p>
-     <p>The application's default XML config file is determined as
-        follows:
-        <ol>
-            <li>If the property <code>scandir.config.file</code> is
-                defined, the default application file will be the
-                file pointed to by this property. If that file
-                doesn't exist, it will be created when
-                <code>ScanDirConfigMXBean.save()</code> is
-                invoked.
-            </li>
-            <li>Otherwise the application config file is
-                assumed to be a file called <code>jmx-scandir.xml</code>,
-                located in the user's directory (as defined by
-                the System property <code>user.home</code>).
-                If that file doesn't exists, it will be created when
-                <code>ScanDirConfigMXBean.save()</code> is
-                invoked.
-            </li>
-        </ol>
-        <p>It is worth noting that this project is defined to
-           run with the following properties:
-           <pre>-Djava.util.logging.config.file=logging.properties</pre>
-           <pre>-Dscandir.config.file=src/etc/testconfig.xml</pre>
-           With <code>ScanDirAgent</code> defined as the project's
-           main class. Hence when you invoke from the NetBeans IDE
-           <i>Run Project</i> on the <i>jmx-scandir</i> project,
-           or <i>Run file</i> on the <code>ScanDirAgent</code>, the
-           application starts with the test configuration provided in
-           <a href="src/etc/testconfig.xml"
-           title="An Example Of Configuration"
-           >src/etc/testconfig.xml</a>
-        </p>
-  </ul>
-  <h2><a name="h2-API-Doc">API Documentation and Sources</a></h2>
-  <ul>
-      <p>Once generated, the Javadoc of example classes can
-      be found starting from <a href="dist/javadoc/index.html"
-      title="The API Documentation"
-      ><code>dist/javadoc/index.html</code></a>.</p>
-      <p>You can view the sources in the <a
-      href="src"
-      title="The Example Source Tree"
-      ><code>src</code></a> subdirectory.</p>
-  </ul>
-  <h2><a name="h2-Patterns">Patterns, Best Practices, and Common Pitfalls</a></h2>
-  <ul>
-  <p>This section discusses some common patterns and
-     design choices that this example demonstrates, and some pitfalls that
-     it avoids.
-  </ul>
-  <h3>MBeans or MXBeans?</h3>
-  <ul>
-  <p>What is an MXBean? MXBeans made their appearance in
-     J2SE 5.0 (Tiger), with the Management and Monitoring
-     API of the JVM. However, Java SE 6 is the first
-     Java SE release that contains a standard framework which
-     makes it possible to create and register your own MXBeans.
-  </p>
-  <p>MXBeans are a special kind of MBean, which once registered
-     in the MBeanServer, get automatically transformed into
-     OpenMBeans. From a developer point of view, nothing changes:
-     A Wombat MBean can become an MXBean simply by renaming
-     its <code>WombatMBean</code> interface into <code>WombatMXBean</code>.</p>
-  <p>Using MXBeans rather than plain Standard MBean brings its
-     own advantages:</p>
-     <ul>
-         <li>
-             Generic tools, like JConsole, will be able to
-             display and interact with your MXBeans nicely, even
-             if your MXBean interfaces reference custom types
-             - e.g. custom Java enums. This is because all the types
-             exposed by your MXBeans are converted to Open Types.
-             Just look at the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-             >ScanDirConfigMXBean</a> with JConsole and you will
-             understand the benefits.
-         </li>
-         <li>
-             When writing a programmatic client, you can obtain
-             a proxy that implements the original MXBean interface,
-             and forget about the Open Type conversion.
-             The JUnit unit tests that come with this example
-             use this feature very widely. Have a look at them.
-         </li>
-         <li>
-            The MXBean framework also lets you nicely navigate
-            from one MXBean to another: your MXBeans can
-            have attributes and parameters which are proxies
-            to other MXBeans! We demonstrate this in the
-            <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-            >ScanManagerMXBean</a> which exposes a list
-            of <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-        >DirectoryScannerMXBean</a></code> and points
-            towards a <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBean</a></code>.
-         </li>
-     </ul>
-     <p>In short, MXBeans are so much easier to use that
-        this example doesn't even have a single regular
-        Standard MBean.
-     </p>
-     <p>See also <a
-href="http://weblogs.java.net/blog/emcmanus/archive/2006/02/what_is_an_mxbe.html"
-title="What is an MXBean?"
-     >What is an MXBean?</a>
-     and <a
-href="http://weblogs.java.net/blog/emcmanus/archive/2006/06/intermxbean_ref.html"
-title="Inter-MXBean references"
-     >Inter-MXBean References</a>.
-     </p>
-     <blockquote><u>Hint:</u> In order to simplify the task of coding a
-        JMX programmatic client, we recommend that getters, setters, and
-        operations defined in MBean and MXBean interfaces throw
-        <code>IOException</code>. Proxy objects will then be able
-        to rethrow directly any <code>IOException</code> received from
-        their underlying MBean Server connection, without wrapping
-        them into <code>UndeclaredThrowableExceptions</code>.<br>
-        Since the life cycle of the proxy object is not directly tied to
-        the life cycle of the MBean it proxies, you may also want to
-        have all methods in the MBean or MXBean interface throw
-        <code>InstanceNotFoundException</code> or more generally
-        <code>JMException</code>.
-    </blockquote>
-  </ul>
-  <h3>MBean Names - aka ObjectNames</h3>
-  <ul>
-  <p>As you must know if you've been studying JMX, MBeans are
-     named objects. The names of MBeans are represented by
-     instances of <code>ObjectName</code>. An ObjectName is
-     composed of a <i>domain</i>, followed by a colon ':',
-     followed by a comma-separated list of <i>key=value</i>
-     pairs.<br>
-     The ordering of the <i>key=value</i> pairs is not
-     important, but <code>ObjectNames</code> are case sensitive
-     (both keys and values are case sensitive) and <b>white space
-     is not ignored</b>.<br>
-     A common pitfall for JMX beginners is to inadvertently
-     insert white space after commas into an ObjectName,
-     and expect that two ObjectNames which differ only by such white
-     space will be considered identical. This is not the
-     case.<br>
-     As an example, the ObjectName '<b><code>D:k1=v1, k2=v2, k3=v3</code></b>' has
-     three keys, which are '<b><code>k1</code></b>', '<b><code> k2</code></b>',
-     and '<b><code> k3</code></b>': beware
-     of the space in the name of the second and third
-     keys!<br>
-     It is therefore a different ObjectName from
-     '<b><code>D:k1=v1,k2=v2,k3=v3</code></b>' (the keys are now
-     '<b><code>k1</code></b>', '<b><code>k2</code></b>', and
-     '<b><code>k3</code></b>'), but the same ObjectName as
-     '<b><code>D: k2=v2, k3=v3,k1=v1</code></b>', and yet different
-     from '<b><code>D:k2=v2, k3=v3, k1=v1</code></b>'!
-     <p>In this example, we are following the rules
-        for ObjectName suggested in the <a
-href="http://java.sun.com/products/JavaManagement/best-practices.html"
-        >JMX Best Practices</a>:</p>
-     <ul>
-         <li>ObjectNames should be <a
-         href="http://java.sun.com/products/JavaManagement/best-practices.html#mozTocId654884"
-         >predictable</a>
-         </li>
-        <li>The domain part of our ObjectNames starts with a Java
-            package name
-        </li>
-        <li>Our ObjectNames contain a <code>type=</code>
-            key property. This property is different for every
-            object type in our domain.
-        </li>
-        <li>For every ObjectName with a given type, we have the same set of key
-            properties with the same syntax and semantics for their values - in
-            fact we only use an additional <code>name=</code> key.
-        </li>
-        <li>When there can only be one instance of a given type
-            there aren't any other key properties than <code>type=</code>.
-            The ObjectNames of the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-            >ScanManagerMXBean</a> and <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-title="The ResultLogManagerMXBean is in charge of managing result logs"
-        >ResultLogManagerMXBean</a>, which are both singleton MBeans, are
-        composed in this way.
-        </li>
-        <li>When there can be several instances of a given type,
-            we differentiate them by further key properties.
-            To achieve this, we are using the most usual key property
-            in addition to <code>type=</code>: the <code>name=</code> key.
-            In this example, a key property list of the form
-            <code>type=X,name=Y</code> is always enough to uniquely name
-            an MBean. Tools like jconsole are usually aware
-            of the semantics of the <code>type=</code> key and
-            <code>name=</code> key, and are therefore able to
-            display this form of name in a way that
-            is easier to read than other name forms.
-        </li>
-     </ul>
-     <p>The rules listed above are implemented by a couple
-        of static helper functions in the <a
-href="src/com/sun/jmx/examples/scandir/ScanManager.java"
-title="ScanManager.java"
-      >ScanManager</a> class. See the code of the
-      <b><code>makeSingletonName</code></b> and
-      <b><code>makeMBeanName</code></b> methods.
-     </p>
-  </ul>
-  <h3>Inter MBean Navigation</h3>
-  <ul>
-  <p>One of the most common problems that needs to be solved
-     when designing a management interface with JMX is to
-     choose a representation for inter-MBean relationships.<br>
-     Prior to Java 6, there were basically three possible
-     choices:</p>
-     <ul>
-         <li><b>Make the relation appear in the ObjectName</b>.
-             For instance, if MBean B was contained in
-             MBean A, you could choose to name MBean B so
-             that its parent relationship with MBean A
-             appeared in its name. <br>
-             The obvious limitation of this solution is that
-             it only allows to model one such relation (an
-             MBean has only one name) and the relation must
-             be fixed - it cannot change during the life of
-             the MBean since the name of an MBean cannot
-             change.<br>
-             This scheme is therefore mostly used when
-             the application MBeans are modeling objects
-             which are conceptually contained within
-             each other in a tree-like structure.
-             <br>For instance, most MBean names defined by
-             <a href="http://jcp.org/en/jsr/detail?id=77"
-              >J2EE Management (JSR 77)</a> follow
-              this scheme.
-         </li>
-         <li><b>Design getters and setters (or operations) which
-             return <code>ObjectName</code> or
-             <code>ObjectName[]</code> values</b>. The ObjectNames
-             point to the MBeans which are related to that
-             object. For instance , <a
-             href="http://glassfish.dev.java.net/"
-             title="Open Source Java EE 5 Application Server"
-             >GlassFish</a>
-             defines MBeans which also use this pattern.
-         </li>
-         <li><b>Use the JMX RelationService</b>. The JMX RelationService
-             is quite powerful, but simple relationships often
-             do not justify that overhead.
-         </li>
-     </ul>
-     <p>In Java 6, these three possibilities still remain, but
-        the new MXBean framework brings up an interesting
-        alternative. Instead of returning an ObjectName or
-        an ObjectName array, <b>an MXBean can return a proxy</b>
-        to its related MXBeans. This is how we have chosen to
-        implement our inter MBean relationships in this
-        example:
-        <br>For instance the
-        <code>ScanManagerMXBean</code>/<code>DirectoryScannerMXBean</code>
-        relationship and the
-        <code>ScanManagerMXBean</code>/<code>ScanDirConfigMXBean</code>
-        relationships are implemented in this way.
-        <p>
-        The additional benefit, as compared to returning ObjectNames or
-        using the RelationService is that interface type of the MBeans
-        which are pointed to by the relationship becomes directly
-        apparent. The method:
-        <pre>
-            public Map&lt;String,DirectoryScannerMXBean&gt; getDirectoryScanners();
-        </pre>
-        makes it immediately obvious that the MBeans to which we point are
-        <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-        >DirectoryScannerMXBeans</a>. It would have been much less obvious in prior
-        versions of Java SE, were the returned type would have had to be
-        <code>Map&lt;String,ObjectName&gt;</code>, or
-        even worse just <code>Map</code>.
-     </p>
-     <p>However, it must be clear that the behaviour will be
-        quite different when an MXBean is returned as compared
-        to when a simple bean is returned.
-     </p>
-     <p>When an MXBean is returned, the remote client sees either
-        an ObjectName, if it is a generic client like jconsole, or
-        a proxy to a remote MXBean, if the client is working with the
-        MXBean interface. Invoking an operation on one of the
-        proxy returned by a method such as
-        <code>getDirectoryScanners</code> will cause the
-        MBean to be invoked on the remote server side.
-     </p>
-     <p>If <code>getDirectoryScanners</code> were
-        defined as:
-        <pre>
-            public Map&lt;String,DirectoryScannerConfig&gt; getDirectoryScanners();
-        </pre>
-        then invoking a method on one of the returned objects
-        would have absolutely no effect on the remote
-        server side - because the returned objects in this
-        case would simply be a bunch of serialized data objects.
-     </p>
-     <p>It is worth noting that although an MXBean interface
-        can have getters and operations which return an MXBean
-        interface, a regular standard MBean shouldn't have
-        any getters or methods which return MBean interfaces or
-        MXBean interfaces.
-     </p>
-     <p>For more information see also <a
-href="http://weblogs.java.net/blog/emcmanus/archive/2006/06/intermxbean_ref.html"
-title="Inter-MXBean references"
-     >Inter-MXBean References</a>.
-     </p>
-  </ul>
-  <h3>The MBeanRegistration interface, or how an MBean can
-      know or provide its own name</h3>
-  <ul>
-      <p>
-        Sometimes, an MBean needs to have a reference to the
-        MBeanServer in which it is registered, or needs to know
-        with which ObjectName it has been registered.
-      </p>
-      <p>
-         Sometimes also, an MBean may need to perform some
-         checks before being registered, or will need
-         to carry out some actions right after it has been
-         successfully registered in the MBeanServer.
-      </p>
-      <p>
-        Sometimes again, an MBean may need to perform some
-        checks, or some cleaning actions, just before, or
-        just after, it is unregistered.
-      </p>
-      <p>
-      When an MBean has such needs, the easiest solution
-      for it is to implement the <code>MBeanRegistration</code>
-      interface.
-      </p>
-      <p>The <code>MBeanRegistration</code> interface is a callback
-      interface which defines pre and post registration and
-      unregistration callbacks.
-      </p>
-      <p>
-       When an MBean implementing this interface is created
-      (with <code>createMBean</code>) or registered
-      (with <code>registerMBean</code>) in an MBeanServer,
-      the MBeanServer will call the <code>preRegister</code>
-      and <code>postRegister</code> method implemented by
-      the MBean. The <code>preRegister</code> method
-      has an <code>MBeanServer</code> and <code>ObjectName</code>
-      parameter, which are passed by the MBeanServer to the
-      MBean. The MBean can store the reference it is being passed
-      in a private instance variable for later use.
-      </p>
-      <p>
-      Most of the MXBeans we have defined in this example
-      implement the <code>MBeanRegistration</code> interface. The table
-      below show how our MBeans use this interface to control
-      their own names, make sanity checks, perform
-      initialization steps or cleanup actions.
-      </p>
-      <p><br><center>
-      <table border="1" cellpadding="4" cellspacing="2"
-             bgcolor="#eeeeee" width="95%">
-          <thead>
-              <tr bgcolor="#cecece">
-                  <th width="20%">MBean Requirement</th>
-                  <th>callback</th>
-                  <th>use case example</th>
-              </tr>
-          </thead>
-          <tbody>
-              <tr>
-                  <td bgcolor="#dedede">get a reference to the MBeanServer</td>
-                  <td><code>preRegister</code></td>
-                  <td bgcolor="#fafafa">The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a>  needs a reference
-                  to the MBeanServer in order to create and
-                  register other MBeans, such as the
-                  <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-title="The ResultLogManagerMXBean is in charge of managing result logs"
-        >ResultLogManagerMXBean</a>, and the
-                  <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-        >DirectoryScannerMXBeans</a>.
-                  </td>
-              </tr>
-              <tr>
-                  <td bgcolor="#dedede">reject registration if conditions are
-                      not met.
-                  </td>
-                  <td><code>preRegister</code></td>
-                  <td bgcolor="#fafafa">The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a>  will throw
-                  an IllegalArgumentException in <code>preRegister</code>
-                  if the ObjectName it is being passed is
-                  illegal. Throwing an exception in
-                  <code>preRegister</code> makes the registration fail.
-                  </td>
-              </tr>
-              <tr>
-                  <td bgcolor="#dedede">get my client-assigned MBean name</td>
-                  <td><code>preRegister</code></td>
-                  <td bgcolor="#fafafa">The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBean</a> propagates the
-                  value of the <code>name=</code> property of
-                  the ObjectName it is given into its
-                  ScanManagerConfig bean.
-                  </td>
-              </tr>
-              <tr>
-                  <td bgcolor="#dedede">provide my own default ObjectName if none
-                      was given to the MBeanServer
-                  </td>
-                  <td><code>preRegister</code></td>
-                  <td bgcolor="#fafafa">The name that is returned by <code>preRegister</code>
-                  is the ObjectName with which the MBean will be
-                  eventually registered.
-                  The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBean</a> is able to suggest
-                  a value for its own ObjectName if none was
-                  provided. Similarly, the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a>
-                  always returns its singleton ObjectName
-                  defined by <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html#SCAN_MANAGER_NAME"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean.SCAN_MANAGER_NAME</a>.
-                  </td>
-              </tr>
-              <tr>
-                  <td bgcolor="#dedede">perform initialization steps</td>
-                  <td><code>preRegister</code></td>
-                  <td bgcolor="#fafafa">The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBean</a> uses <code>preRegister</code>
-                  to initialize its internal ScanManagerConfig bean.
-                  </td>
-              </tr>
-              <tr>
-                  <td bgcolor="#dedede">perform initialization steps, once it is
-                  known that the registration was successful.
-                  </td>
-                  <td><code>postRegister</code></td>
-                  <td bgcolor="#fafafa">The <code>postRegister</code> method
-                  can be used to implement
-                  initialization steps that need to be done once it
-                  is known that the registration was successful, or to
-                  undo any action performed by <code>preRegister</code> once it
-                  is known that registration was not successful.
-                  The <code>postRegister</code> method has a Boolean parameter
-                  which tells the MBean whether it was or wasn't
-                  successfully registered in the MBeanServer.
-                  The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a>  uses <code>postRegister</code> to create
-                  and register other MBeans, such as the
-                  <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-title="The ResultLogManagerMXBean is in charge of managing result logs"
-        >ResultLogManagerMXBean</a> and the default
-                  <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBean</a>.
-                  Note that <code>postRegister</code> is not expected to throw any
-                  exception. If an exception needs to be thrown, it should
-                  be thrown in <code>preRegister</code>.
-                  </td>
-              </tr>
-              <tr>
-                  <td bgcolor="#dedede">check whether the MBean can be deregistered</td>
-                  <td><code>preDeregister</code></td>
-                  <td bgcolor="#fafafa">The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a>  uses this method to verify
-                   that its state allows it to be deregistered.
-                   In particular, it will refuse to be deregistered
-                   if it is in the RUNNING or SCHEDULED state.
-                   If <code>preDeregister</code> throws an exception, the unregisterMBean
-                   call will fail and the MBean will remain registered in
-                   the MBeanServer.
-                   Take particular care when implementing business logic
-                   in this method: if the logic you implement has an
-                   unfortunate bug which makes it always throw an
-                   exception, you will never be able to unregister
-                   that MBean.
-                  </td>
-              </tr>
-              <tr>
-                  <td bgcolor="#dedede">clean up resources, refusing to be deregistered if
-                      it fails
-                  </td>
-                  <td><code>preDeregister</code></td>
-                  <td bgcolor="#fafafa">The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a>  uses this method to unregister
-                  all the other MBeans it has created and registered in the
-                  MBeanServer. This includes the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-title="The ResultLogManagerMXBean is in charge of managing result logs"
-        >ResultLogManagerMXBean</a>, the
-                  <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBeans</a> it has created, and the
-                  <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-        >DirectoryScannerMXBeans</a> it has created when
-                  applying its configuration.
-                  </td>
-              </tr>
-              <tr>
-                  <td bgcolor="#dedede">clean up resources which need to be released in
-                  a best-effort way, when it is known that the MBean is no
-                  longer registered.
-                  </td>
-                  <td><code>postDeregister</code></td>
-                  <td bgcolor="#fafafa"><code>postDeregister</code> is only called if the MBean was succesfully
-                  unregistered.
-                  The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a>  uses this method to cancel
-                  its internal java.util.Timer.
-                  </td>
-              </tr>
-          </tbody>
-      </table>
-      </center><br></p>
-  </ul>
-  <h3>The Singleton MBean Pattern</h3>
-  <ul>
-      <p>
-        A singleton MBean is an MBean which can only have one
-        instance registered in a given MBeanServer. <br>
-        A singleton MBean usually has a well-known name,
-        which can be defined as a constant. In that case,
-        clients no longer need to call <code>new ObjectName(...)</code>
-        and catch the declared <code>MalformedObjectNameException</code>.
-      </p>
-      <p>There are already quite a few examples of singleton
-         MBeans in the java.lang.management API. The
-         ThreadingMXBean, ClassLoadingMXBean, RuntimeMXBean, etc.
-         are all singleton MBeans.
-      </p>
-      <p>In this example, we have two singleton MBeans:
-         The <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a></code> and the
-         <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-title="The ResultLogManagerMXBean is in charge of managing result logs"
-        >ResultLogManagerMXBean</a></code>. But in fact,
-         the only real singleton MBean is the
-        <code>ScanManagerMXBean</code>. The
-        <code>ResultLogManagerMXBean</code> just happens to
-        be a singleton MBean because it has a 1-1 relationship
-        with the <code>ScanManagerMXBean</code>.
-      </p>
-      <p>The <code>ScanManagerMXBean</code> implements the
-         singleton MBean pattern in this way:
-      </p>
-      <ul>
-          <li>The <code>ScanManagerMXBean</code> name has a single
-              key property: <code>type=ScanManagerMXBean</code>.</li>
-          <li>Its name is defined by an ObjectName constant called
-              <code>SCAN_MANAGER_NAME</code> in the <code>ScanManager</code> class</li>
-          <li>The <code>ScanManagerMXBean</code> enforces its status of
-              singleton MBean. It will refuse to be registered
-              with a name other than
-              the <code>SCAN_MANAGER_NAME</code>. You can therefore depend on
-              the fact that the <code>ScanManagerMXBean</code> will always
-              be registered with its singleton <code>SCAN_MANAGER_NAME</code>
-              (see <code>preRegister</code>)
-          </li>
-          <li>You are not obliged to provide a name when you
-              register the <code>ScanManagerMXBean</code>: if you pass null,
-              then the <code>ScanManager</code> will be registered with
-              its singleton <code>SCAN_MANAGER_NAME</code>
-              (see <code>preRegister</code>).
-          </li>
-          <li>The <code>ScanManager</code> class has a no-arg static
-              <code>register</code> method that will register
-              the singleton instance in the Platform MBeanServer.
-              This static <code>register</code> method returns
-              a proxy to the registered singleton.
-          </li>
-          <li>The <code>ScanManager</code> class has also a static
-              <code>register</code> method that will create
-              a singleton instance in a (possibly remote)
-              MBeanServerConnection - using
-              <code>createMBean</code>.
-              This static <code>register</code> method
-              also returns a proxy to the registered singleton.
-          </li>
-          <li>Only the MBeanServer has a reference to the
-              singleton instance. The singleton instance is
-              not returned to the caller, and not kept
-              in any other static data structure.
-          </li>
-      </ul>
-      <p>
-      On the other hand, the <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-title="The ResultLogManagerMXBean is in charge of managing result logs"
-        >ResultLogManagerMXBean</a></code>
-      has a much more relaxed implementation of the pattern:
-      <br>It simply provides its own singleton name if it is
-      registered with a null ObjectName, but will not enforce
-      the use of that name.
-      </p>
-      <p>Note that all singleton MBean names in this example
-      are created using the <code>ScanManager.makeSingletonName</code>
-      method, which implements the pattern for ObjectNames suggested
-      in the JMX Best Practices.
-      </p>
-  </ul>
-  <h3>Managing the Life Cycle of dependent MBeans</h3>
-  <ul>
-      <p>A common task that many JMX applications have
-        is to manage the life cycle of MBeans registered
-        in the MBeanServer.</p>
-      <p>In this example, we have decided to follow a simple
-      pattern:</p>
-      <ul>
-          <li>The application is initialized simply
-              by registering the singleton
-              <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a> in
-              the MBeanServer.
-          </li>
-          <li>The <code>ScanManagerMXBean</code> will then
-              in turn register any other MBean that the
-              application might need:
-              <ul>
-                  <li>It creates and registers the singleton
-                      <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-title="The ResultLogManagerMXBean is in charge of managing result logs"
-        >ResultLogManagerMXBean</a></code>
-                  </li>
-                  <li>It creates and registers the default
-                      <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBean</a></code>
-                      which loads the initial configuration
-                  </li>
-                  <li>It creates as many
-                     <code><a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-        >DirectoryScannerMXBeans</a></code> as
-                     needed when the configuration is applied
-                  </li>
-                  <li>It lets you create alternate
-                      <code>ScanDirConfigMXBean</code>, to
-                      which you can later switch in order
-                      to apply a new alternate configuration.
-                  </li>
-              </ul>
-          </li>
-          <li>When a new configuration is applied (or if the
-              current configuration is reapplied), the
-              <code>ScanManagerMXBean</code> will unregister
-              any <code>DirectoryScannerMXBeans</code> it has
-              previously registered, and will re-create
-              brand new <code>DirectoryScannerMXBeans</code>
-              from the applied configuration.
-          </li>
-          <li>When you unregister the <code>ScanManagerMXBean</code>,
-              it does all the cleanup for you, by unregistering
-              all the MBeans that it has created during the
-              course of the application.
-          </li>
-      </ul>
-      <p>The <code>ScanManagerMXBean</code> makes use of its
-         <code>MBeanRegistration</code> interface in order
-         to register the other MBeans it needs (see the
-         <code>ScanManager.postRegister</code> method) and to unregister
-         every MBean it has created (see the <code>ScanManager.preDeregister</code>
-         method).
-      </p>
-      <p>You will note that the <code>ScanManagerMXBean</code>
-         will only allow itself to be deregistered if it can be
-         closed - that is if there's no other action in
-         progress.
-         This is to make sure that the deregistration of
-         dependent MBeans will work smoothly.
-         <br>
-         The deregistration of related MBeans will happen
-         in the <code>ScanManager.preDeregister</code>
-         method.
-         <br>
-         If one of these MBeans could not be deregistered,
-         then the <code>ScanManagerMXBean</code> will throw
-         an exception, refusing to be deregistered.
-         <br>This leaves you a chance to try to deregister it
-         again later. Since the <code>ScanManagerMXBean</code>
-         has switched its state to CLOSED before starting
-         to unregister its dependent MBeans, it will refuse
-         any further actions, ensuring that e.g. nobody
-         can try to start it or schedule it while it
-         is in that partially-deregistered state.
-      </p>
-      <p>Handling the LifeCycle of all the application's
-         MBeans in a single MBean is usually a good design
-         pattern, especially if the application is a
-         module which is intended to share a JVM - or
-         an MBeanServer - with other modules.
-      </p>
-      <p>This is specially useful if the application needs to
-         be loaded and unloaded on demand: in that
-         case, simply registering or unregistering the top level
-         MBean (in our example the <code>ScanManagerMXBean</code>) does
-         the trick.
-      </p>
-  </ul>
-  <h3>Emitting Notifications</h3>
-  <ul>
-       <p>In order to emit notifications, an MBean must be
-       an instance of <code>NotificationEmitter</code>.
-       The <code>NotificationEmitter</code> interface defines methods
-       that the MBeanServer will call on the MBean in order
-       to register <code>NotificationListeners</code> with the MBean.
-       </p>
-       <p>It is worth noting that the MBean may not be
-          invoked each time a JMX client wants to register
-          a listener. For instance, the RMIConnectorServer
-          registers <i>only once</i> a single listener with each MBean
-          which is a <code>NotificationEmitter</code>.
-          In that specific case, the listener may even be registered
-          with the MBean before any client has actually subscribed
-          for notifications from that particular MBean.
-       </p>
-       <p>An MBean can therefore make no assumption about
-          which client or how many clients have registered for
-          notifications.
-       </p>
-       <p>It is also worth noting that the logic of the
-       methods defined in <code>NotificationEmitter</code> would not
-       be trivial to implement from scratch. Fortunately
-       the JMX API defines a helper class, called
-       <code>NotificationBroadcasterSupport</code>, which
-       provides an implementation for these methods.
-       </p>
-       <p>There are actually three ways for an MBean to
-       implement <code>NotificationEmitter</code>, of which only two
-       are recommended.
-       </p>
-  </ul>
-
-  <h4>Extending NotificationBroadcasterSupport</h4>
-  <ul>
-    <p>This is the simplest way of coding an MBean which
-       is a <code>NotificationEmitter</code>:
-    </p>
-    <p>Simply extend <code>NotificationBroadcasterSupport</code>,
-    then override its <code>getNotificationInfo</code> method
-    which returns the <code>MBeanNotificationInfo[]</code> array
-    that should be included in your MBean's <code>MBeanInfo</code>
-    and that's it.
-    <br>You just need to call the <code>sendNotification</code> method
-    inherited from <code>NotificationBroadcasterSupport</code> whenever
-    your MBean needs to send a notification.
-    </p>
-    <p>In our example, both the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-           >ScanDirConfigMXBean</a> and <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-title="The ResultLogManagerMXBean is in charge of managing result logs"
-        >ResultLogManagerMXBean</a> extend
-      <code>NotificationBroadcasterSupport</code> in order
-      to send notifications.
-    </p>
-  </ul>
-  <h4>The Delegation Pattern: delegating to a
-      NotificationBroadcasterSupport delegate</h4>
-  <ul>
-      <p>There may be cases however where delegating to a
-      wrapped <code>NotificationBroadcasterSupport</code>
-      object may be preferred to extending
-      <code>NotificationBroadcasterSupport</code>.
-      </p>
-      <p>For instance, if your MBeans already derive from
-      some base class, extending <code>NotificationBroadcasterSupport</code>
-      might not be an option.
-      </p>
-      <p>Similarly, if you do not want to have the inherited
-      <code>public void sendNotification(Notification notification)</code>
-      method appear in the Javadoc of the concrete class of your
-      MBean, you may want to consider using the delegation
-      pattern instead of extending
-      <code>NotificationBroadcasterSupport</code>
-      </p>
-      <p>In our example both the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a> and the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-        >DirectoryScannerMXBean</a> use the delegation
-       pattern rather than extending
-       <code>NotificationBroadcasterSupport</code>.
-       In the end, choosing between one or the other method
-       is more a question of taste, although the delegation
-       pattern could be considered more flexible since it
-       doesn't require extending any given superclass.
-      </p>
-      <p>It may be also worth noting that some tools like
-      the JMX Module of <a
-href="http://www.netbeans.org"
-      >NetBeans IDE</a>, will be able to
-      generate for you all the code that delegates to a
-      wrapped <code>NotificationBroadcasterSupport</code>.
-      </p>
-  </ul>
-
-  <h4>Implementing NotificationEmitter from scratch</h4>
-  <ul>
-    <p>This is the last possibility for an MBean that
-    needs to send notifications: simply implement
-    <code>NotificationEmitter</code> from scratch. This is highly
-    discouraged since that logic is not trivial, and
-    already provided by
-    <code>NotificationBroadcasterSupport</code> anyway.
-    </p>
-  </ul>
-
-  <h4>Beware of Synchronization Locks</h4>
-  <ul>
-
-       <p>One thing you must keep in mind when sending
-       notifications is not to send them from within
-       a synchronized block, or while holding a lock on
-       some resource.</p>
-       <p>Indeed, what happens when you send a notification
-          may vary greatly depending on whether the client
-          which has registered for notifications has done
-          so through a <code>JMXConnector</code> (like the
-          <code>JMXRMIConnector</code>)
-          or through a direct reference to the MBeanServer
-          (by calling
-          <code>MBeanServer.addNotificationListener</code>).
-       </p>
-       <p>In this latter case, the listener will be invoked
-       synchronously in the same thread that your MBean is
-       using to send its notification. If by misfortune, the
-       code of that listener now re-enters your MBean through a
-       call that flows through a JMXConnector, a deadlock
-       could occur. It is therefore very important to release
-       any lock you may have before calling
-       <code>sendNotification</code>.</p>
-       <p>An easy way to do that is demonstrated in the
-          <code>ScanManager</code> class. The ScanManager
-          has an internal private queue of pending notifications.
-          When a notification needs to be sent (e.g. because the
-          ScanManager state is being switched), the notification
-          is simply prepared and put into the pending notification
-          queue.
-          The notification queue is then processed later on,
-          at the end of the method, when the processing is finally
-          completed and all the locks have been released.
-          <br>At this point the notification queue might already
-          have been emptied by another thread - in which case
-          the pending notifications will have already been
-          removed from the queue. Which thread actually gets
-          to send the notifications is of no importance. The
-          important point is that all the locks detained by
-          your MBean code in that thread were released before
-          the notification was sent.
-       </p>
-       <p>In our example the <code>ScanManager</code> class
-          ensures this by:
-          <ul>
-              <li>Only calling <code>sendNotification</code>
-                  in its private <code>sendQueuedNotifications</code>
-                  method.
-              </li>
-              <li>Only calling <code>sendQueuedNotifications</code>
-                  when all locks have been released.
-              </li>
-              <li>Never calling a method that calls
-                  <code>sendQueuedNotifications</code> from within
-                  a synchronized block.</li>
-          </ul>
-       </p>
-  </ul>
-
-
-
-  <h4>Don't subclass Notification</h4>
-  <ul>
-       <p>Another common best practice when you want
-          to improve interoperability is to use directly
-          the Notification base classes provided in the
-          JMX&trade; API. Do not create your own
-          subclasses of these standard classes.
-       </p>
-       <p>Indeed, if you code your own subclass, a generic
-       client, like jconsole, will not be able to receive
-       that notification unless it has that custom
-       subclass in its classpath.
-       </p>
-       <p>
-       If you want your application to be interoperable, it is
-       therefore preferable not to subclass any of the standard
-       Notification classes. You can define your own
-       Notification type string, and if you need to send
-       additional data, you can put a CompositeData, or a
-       HashMap of serializable standard types in the
-       Notification's user data fields.
-       </p>
-       <p>In this example, we are using directly the
-       standard notification classes:
-       <ul>
-           <li>The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a> and the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-             >DirectoryScannerMXBean</a> both use directly
-             <code>AttributeChangeNotification</code> to notify
-             changes in their <code>State</code> attribute.
-           </li>
-           <li>The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-             >DirectoryScannerMXBean</a>
-             also uses the base <code>Notification</code>
-             class directly in order to notify whenever
-             it finds a matching file.
-             <br>In that case, we simply use the base
-             <code>Notification</code>
-             class with a new
-             <b><code>com.sun.jmx.examples.scandir.filematch</code></b>
-             type.
-           </li>
-           <li>The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-             >ScanDirConfigMXBean</a> and <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-title="The ResultLogManagerMXBean is in charge of managing result logs"
-             >ResultLogManagerMXBean</a> also both use the base
-             <code>Notification</code> class.
-           </li>
-       </ul>
-       <p>Careful readers will have noted that the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-             >ScanManagerMXBean</a> and the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-title="A DirectoryScannerMXBean looks for file matching a given set of criteria, starting at a given root."
-             >DirectoryScannerMXBean</a> both use the
-             <code>AttributeChangeNotification</code> class
-             to notify about their state change, whereas the
-             <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-             >ScanDirConfigMXBean</a> uses the base
-             <code>Notification</code> class.
-       </p>
-       <p>In fact, this is because the semantics of these
-          notifications is not exactly the same - although
-          both denote a state change:
-          <ul>
-              <p>In the case of <code>ScanManagerMXBean</code>
-              and <code>DirectoryScannerMXBean</code>, the
-              notification which is emitted is more about a
-              state transition, from one state to another.
-              For instance, going from <code>RUNNING</code>
-              to <code>STOPPED</code>, or from
-              <code>SCHEDULED</code> to <code>STOPPED</code>.
-              <br>In that case, the
-              <code>AttributeChangeNotification</code> was
-              more appropriate because it made it possible
-              to send the previous and the new value of the
-              state attribute, thus reflecting the whole
-              state transition.
-              </p>
-              <p>In the case of the <code>ScanDirConfigMXBean</code>
-              however, what is of interest is the state in
-              which the MBean has arrived. Using the base
-              <code>Notification</code> class with three different
-              notification type strings -
-              <b><code>com.sun.jmx.examples.scandir.config.loaded</code></b>,
-              <b><code>com.sun.jmx.examples.scandir.config.modified</code></b>,
-              and
-              <b><code>com.sun.jmx.examples.scandir.config.saved</code></b> -
-              was therefore closer to what we wanted to model.
-              </p>
-          </ul>
-       </p>
-  </ul>
-
-  <h3>Configuration MBeans</h3>
-    <ul>
-    <p>A common practice when designing a management application is
-    to have an MBean, or a set of MBeans, dedicated to configuration.
-    Separating configuration from control and monitoring allows
-    more appropriate logic, and often simplifies the design and
-    implementation of the management interface.
-    </p>
-    <p>
-    In our example, the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-     >ScanDirConfigMXBean</a> is dedicated to the application configuration.
-    </p>
-    <p>The <code>ScanDirConfigMXBean</code> will let you interactively
-        modify, save, or load the application configuration. The modifications
-        will not be taken into account until it is applied, by invoking
-        <code>applyConfiguration</code> on the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-        >ScanManagerMXBean</a>.
-    It is also possible to create many configurations, by creating as
-    many <code>ScanDirConfigMXBean</code>s, and then to choose and apply
-    one of these configurations by calling
-    <code>ScanManagerMXBean.setConfigurationMBean</code> and then
-    <code>ScanManagerMXBean.applyConfiguration</code>.
-    </p>
-    <p>In this way, all configurations aspects are gathered and concentrated
-    inside the <code>ScanDirConfigMXBean</code> instead of being scattered
-    throughout all the MBeans that compose the application.
-    </p>
-    <p>In order to save and store the application configuration data, the
-    <code>ScanDirConfigMXBean</code> uses a set of XML serializable Java beans
-    defined in the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/config/package-summary.html"
-title="The com.sun.jmx.examples.scandir.config package defines XML serializable beans"
-        >com.sun.jmx.examples.scandir.config</a> package. These beans are very
-   simple Java beans which have been lightly annotated for XML binding.
-    </p>
-    <p>It is worth noting that these same beans can also be handled by the
-    MXBean framework (our beans don't contain recursive data structures) and can
-    therefore be used directly as attributes and parameters of MXBeans, without
-    needing to be Java-serializable (the MXBean framework transform them in
-    CompositeData objects - which <b>are</b> serializable).
-    </p>
-    <p>The same <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/config/ScanManagerConfig.html"
-title="The com.sun.jmx.examples.scandir.config package defines XML serializable beans"
-        >ScanManagerConfig</a> bean that we use to read from and write to the
-        XML configuration file is thus also used as attribute of the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-title="The ScanDirConfigMXBean is in charge of the configuration"
-     >ScanDirConfigMXBean</a>. It is transformed into a <code>CompositeData</code>
-       by the MXBean framework, and can be easily introspected with
-       <a href="#JConsole">jconsole</a>.
-    </p>
-    </ul>
-  <h3>MBeans Must Be Thread-Safe</h3>
-    <ul>
-    <p>A question often asked by newcomers to JMX technology
-    is whether the MBeanServer is thread-safe. Well, the MBeanServer <b>is</b>
-    thread safe, but it doesn't put any locks on the MBeans it contains. The
-    MBeans can be concurrently accessed by multiple threads, and must therefore
-    take care of their own thread safety.
-    </p>
-    <p>In this example, we have been using two methods to ensure thread
-    safety for our MBeans: synchronized blocks, and semaphores.
-    </p>
-    <p>Using synchronized blocks is probably the most common and easiest way
-    to implement thread safety in Java. When dealing with MBeans though, here
-    are a couple of rules to keep in mind:
-    <ul>
-        <li>Don't send notifications from within a synchronized block: there's
-        no way to tell whether the listener's code will be executed in the
-        same thread or a different thread, and holding a lock in these
-        conditions is therefore dangerous, as it could lead to deadlocks.</li>
-        <li>Also avoid invoking another MBean from a synchronized block
-        unless you are completely in control of both MBeans, and you can
-        ascertain that it won't lead to any deadlock. Indeed, if you invoke an
-        MBean exposed by another application, it can be sometime hard to
-        know with certainty whether holding a lock while invoking that
-        MBean will have any side effect. Maybe that MBean will make
-        further calls to other MBeans which will in turn try to call
-        your MBean, or maybe it will emit a
-        notification, and we'll be back to the considerations just
-        above.</li>
-    </ul>
-    </p>
-    <p>Another means of implementing thread-safe code is to use semaphores.
-    The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-        >ScanManagerMXBean</a> uses a semaphore called
-        <code>sequencer</code> to ensure
-    that critical code sections are not executed concurrently. In this
-    MBean, we use <code>Semaphore.tryAcquire</code> to lock the sequencer
-    semaphore before entering the critical section. If the
-    <code>Semaphore.tryAcquire</code> returns true then we enter the critical
-    section. If it returns false, we throw an IllegalStateException, stating
-    that we couldn't acquire the lock. The code looks like this:
-    <pre>
-        if (!sequencer.tryAcquire())
-            throw new IllegalStateException("resource locked");
-        try {
-            // critical code here ...
-        } finally {
-            // Always use try/finally to ensure that the semaphore
-            // will be released, even if exceptions or errors are raised!
-            sequencer.release();
-        }
-    </pre>
-    </p>
-    <p>Using <code>Semaphore.tryAcquire</code> and throwing an exception if
-        the semaphore is already locked makes it safer to call other MBeans
-        from within the critical section: in potential deadlock situations
-        the calling code will get the <code>IllegalStateException</code>
-        instead of being blocked on the deadlocked lock.
-    </p>
-    <p>It is worth noting that each of these techniques has its own
-    advantages and disadvantages - which can make one of them more or less
-    appropriate depending on the inner logic of the MBean you're implementing.
-    </p>
-    <p>Careful readers will also have noted that we used
-       <code>IllegalStateException</code> directly, instead of defining
-       our own subclass of RuntimeException, which could have had a more
-       precise semantics. If you define a new exception for your JMX application,
-       you must keep in mind that your client will need to have the class
-       of your exception in its classpath to get that exception.
-       Otherwise your client will get a completely different exception, indicating a
-       deserialization issue.
-    </p>
-    </ul>
-
-  <h3>Waiting for Notifications</h3>
-    <ul>
-    <p>Implementing code that needs to wait for notifications is sometimes
-       difficult. Because notifications are asynchronous, doing something
-       like:
-        <pre>
-          // register a notification listener
-          ...
-          // start a management action
-          ...
-          // wait for a notification
-          ...
-          // do something based on whether the expected notification
-          // is received
-          ...
-        </pre>
-       is not always trivial. However, there's a very easy way to do that: use
-       a blocking queue of notifications.
-       <pre>
-       final BlockingQueue&lt;Notification&gt; notifQueue =
-                new LinkedBlockingQueue&lt;Notification&gt;();
-
-       final NotificationListener listener = new NotificationListener() {
-            public void handleNotification(Notification notification,
-                                           Object handback) {
-                try {
-                    // Just put the received notification in the queue.
-                    // It will be consumed later on.
-                    //
-                    notifQueue.put(notification);
-                } catch (InterruptedException ex) {
-                    // OK
-                }
-            }
-          };
-
-       // register the listener - possibly also as a JMXConnectionNotification
-       // listener to get Notification Lost notification
-       ...
-       // start management action
-       ...
-       // wait for notification
-       while (expected notif not received and delay not expired) {
-            Notification n = notifQueue.poll(3,TimeUnit.SECONDS);
-            // if expected notif, do something
-            ...
-       }
-       // if expected notification not received do something else.
-       ....
-       </pre>
-    </p>
-    <p>You will note that this is a technique we've been using in the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirAgent.html"
-title="The ScanDirAgent class defines a main method for the scandir application"
-        >ScanDirAgent</a> class and in the example unit tests.
-    </p>
-    </ul>
-
-  <h3>Holding hard references to other MBeans: proxy or direct reference?</h3>
-  <ul>
-    <p>We have seen that MXBeans will let you return proxy references to other
-    MXBeans. But should that MXBean hold a direct reference to the MXBeans it
-    relates to, or would it be better for it to hold only a proxy?
-    </p>
-    <p>
-    As a general rule it is better when an MBean reference is
-    only held by the MBeanServer. It is a better design
-    to hold a reference to a proxy, rather than to hold
-    a hard reference to an MBean. However there are two cases
-    when holding a hard reference might be preferred:
-     <ol>
-        <li>When MBean A needs to call a method of method B which
-           is not part of its MBean interface</li>
-        <li>When the overhead of going through the MBeanServer
-           plus the MXBean framework is too great (frequently-called
-           method, with creation of OpenType)</li>
-     </ol>
-    However - holding a hard reference is only advisable
-    when both MBeans are created by the same piece of code,
-    and the application can ensure that the life cycle
-    of each MBean is consistent with regard to the other.
-    </p>
-    <p>In our example, the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-        >ScanManagerMXBean</a> holds only proxy references to the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.html"
-        >ScanDirConfigMXBean</a> and the  <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.html"
-        >DirectoryScannerMXBeans</a>. <br>
-    However it holds a direct reference to the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManager.html"
-        >ResultLogManager</a>. This makes it possible to pass a direct
-        reference to the <code>DirectoryScannerMXBeans</code>,
-        which can then log their results
-        more efficiently, and would also make it possible to remove
-        the <code>log</code> method from the <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.html"
-        >ResultLogManagerMXBean</a> interface - leaving it in the
-        <code>ResultLogManager</code> class (possibly as a package method)
-        should we wish to do so.
-    </p>
-
-    </ul>
-
-  <h3>Agent Class</h3>
-    <ul>
-   <p>The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirAgent.html"
-title="The ScanDirAgent class defines a main method for the scandir application"
-     >ScanDirAgent</a> is the Agent class for the <i>scandir</i> application.
-    This class contains the <code>main</code> method to start a standalone
-    <i>scandir</i> application.
-    </p>
-    <p>The <code>main</code> method simply registers a <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-       >ScanManagerMXBean</a> in the platform MBeanServer, and then waits
-    for someone to call <code>ScanManagerMXBean.close</code>.
-    </p>
-    <p>
-    When the <code>ScanManagerMXBean</code> state is switched to
-    <code>ScanManagerMXBean.ScanState.CLOSED</code>, the
-    <code>ScanManagerMXBean</code> is unregistered, and the application
-    terminates (i.e. the main thread completes).
-    </p>
-    <p>Standalone JMX applications usually have an Agent class that contain
-       their <code>main</code> method, which performs all the MBean
-       registration steps.
-       However, it is usually not a bad idea if that class can
-       be easily turned into an MBean. Indeed, this will make your
-       application easier to integrate in an environment where it would
-       no longer be standalone and would no longer control the implementation
-       of <code>main</code>. In our example the Agent
-       class could be easily turned into an MBean, exposing its three
-    <code>init</code>, <code>waitForClose</code> and <code>cleanup</code>
-    method. However we didn't go as far as turning it into an MBean since
-    the application can be already easily started by registering an instance
-    of <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanManagerMXBean.html"
-title="The ScanManagerMXBean is the main MBean of the scandir application"
-       >ScanManagerMXBean</a>.
-    </p>
-    </ul>
-  <h3>Secure Client Class</h3>
-    <ul>
-   <p>The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirClient.html"
-title="The ScanDirClient class is a very short example of secure programmatic client"
-     >ScanDirClient</a> is an example class that shows how a
-    programmatic client can connect to a secured <i>scandir</i> application.
-    This class contains a <code>main</code> method which creates and
-    configures a <code>JMXConnector</code> client to connect with
-    a secured <i>scandir</i> daemon. This class will not work with
-    the default unsecured agent since it requires mutual authentication.
-    </p>
-    <p>How to secure a JMX <i>scandir</i> application and run
-    the secure <code>ScanDirClient</code> is discussed <a href="#secure"
-    >later</a> in this document.
-    </p>
-    <p>The <code>ScanDirClient</code> is not really part of the
-       application - and is given here only for the sake of
-       the example.
-    </p>
-    </ul>
-
-  <h2><a name="h2-Testing">Testing the <i>scandir</i> Example</a></h2>
-    <ul>
-        <p>Make sure that you have access to junit.jar (either 3.8.1 or 3.8.2).
-           Make sure also that you have junit.jar in your
-           <code>CLASSPATH</code>.<br>
-           Then in the example root directory (where the <code>build.xml</code>
-           file is located) run the following command:
-           <pre>ant test -Dlibs.junit.classpath=<i><u>path to junit jar (either 3.8.1 or 3.8.2)</u></i></pre>
-        </p>
-        <p>Alternatively you can open the jmx-scandir project with the
-           NetBeans IDE and test the jmx-scandir project from the
-           <code>Run</code> menu.
-        </p>
-
-    </ul>
-
-  <h2><a name="h2-Running">Running the <i>scandir</i> Example</a></h2>
-    <ul>
-        <p>In the example root directory (where the <code>build.xml</code>
-           file is located) run the following commands:
-        <pre>ant jar
-ant run-single -Drun.class=com.sun.jmx.examples.scandir.ScanDirAgent -Djavac.includes=src</pre>
-           or simply <pre>ant run</pre>
-        </p>
-
-        <p>This will run the example using the configuration
-           file provided in the src/etc directory.
-        </p>
-        <p>Alternatively you can open the jmx-scandir project with the
-           NetBeans IDE. You can run the example by
-           selecting the <code>ScanDirAgent</code> file
-           and run it with <code>Run File</code> in the
-           <code>Run</code> menu or simply
-           set the <i>jmx-scandir</i> project as main project and
-           select <code>Run Main Project</code> from the
-           main menu. Both targets will use the configuration
-           file provided in the src/etc directory.
-        </p>
-        <p>When the application is started, you can connect to
-           it with <a href="#JConsole">jconsole</a>.
-        </p>
-        <blockquote>
-            <u>Note:</u> You can also run the <i>scandir</i>
-            application directly from the <code>java</code>
-            command line. Make sure to build the project jar
-            first.
-            <br>On Unix systems:
-            <pre>ant jar
-java -Djava.util.logging.config.file=logging.properties \
-     -Dscandir.config.file=src/etc/testconfig.xml \
-     -jar dist/jmx-scandir.jar</pre>
-            <br>On Windows systems:
-            <p><code>ant jar<br>
-java &nbsp;-Djava.util.logging.config.file=logging.properties
-     &nbsp;-Dscandir.config.file=src\etc\testconfig.xml
-     &nbsp;-jar&nbsp;dist\jmx-scandir.jar</code></p>
-        </blockquote>
-    </ul>
-
-    <h2><a name="h2-Playing">Playing with JConsole</a></h2>
-    <ul>
-    <p>Run the example as explained in the previous section, so
-    that it uses the provided <code>src/etc/testconfig.xml</code>
-    configuration file. Then start
-    jconsole. In the connection window choose the process that runs
-    <code>com.sun.jmx.examples.scandir.ScanDirAgent</code> or
-    <code>jmx-scandir.jar</code>.
-    </p>
-    <p><center>
-        <table border="0" cellpadding="2" cellspacing="2">
-        <tr><td>
-    <a href="docfiles/connect-local-ant-run.jpg"
-    title="jconsole connection window - connect to local process"
-    ><img height="440"
-    src="docfiles/connect-local-ant-run.jpg"
-    alt="jconsole connection window - connect to local process"
-    /></a>
-    </td>
-    <td>
-    <a href="docfiles/connect-local-java-jar.jpg"
-    title="jconsole connection window - connect to local process"
-    ><img height="440"
-    src="docfiles/connect-local-java-jar.jpg"
-    alt="jconsole connection window - connect to local process"
-    /></a>
-    </td></tr></table>
-    </center>
-    </p>
-    <p>Open the MBeans tab, and look for the
-       <code>ScanDirConfigMXBean</code>.
-       Click on its <code>Attributes</code> node and double click on its
-       <code>Configuration</code> attribute, to look at
-       the loaded configuration - values in bold can
-       be expanded by a double-click.
-    </p>
-    <p><center><a href="docfiles/scandir-config.jpg"
-    title="jconsole MBean tab: ScanDirConfigMXBean"
-    ><img
-    src="docfiles/scandir-config.jpg"
-    alt="jconsole MBean tab: ScanDirConfigMXBean"
-    /></a></center>
-    </p>
-    <p>Now go to the <code>ScanManagerMXBean</code>, click on
-       its <code>Notifications</code> node, and subscribe
-       for notifications. Then click on the
-       <code>Operations</code> node and invoke the
-       <code>start()</code> operation:
-    </p>
-    <p><center><a href="docfiles/scandir-start.jpg"
-    title="jconsole MBean tab: ScanDirConfigMXBean"
-    ><img
-    src="docfiles/scandir-start.jpg"
-    alt="jconsole MBean tab: ScanDirConfigMXBean"
-    /></a></center>
-    </p>
-    <p>You can see that the notifications counter was
-       incremented by three: you have just scheduled,
-       run, and completed a batch of directory scans.
-    </p>
-    <p>Now go to the <code>ResultLogManagerMXBean</code>,
-       click on its <code>Attributes</code> node, and
-       expand its <code>MemoryLog</code> attribute:
-    </p>
-    <p><center><a href="docfiles/scandir-result.jpg"
-    title="jconsole MBean tab: ScanDirConfigMXBean"
-    ><img
-    src="docfiles/scandir-result.jpg"
-    alt="jconsole MBean tab: ScanDirConfigMXBean"
-    /></a></center>
-    </p>
-    <p>You can see that the directory scan results have
-       been logged.</p>
-    <p>To make the application terminate go back to the
-       <code>ScanManagerMXBean</code> and invoke
-       <code>close()</code>. The <code>ScanDirAgent</code>
-       will receive the notification, step out of
-       the application main thread, and the application
-       will terminate.
-    </p>
-    <p>This is of course a very limited scenario. Feel free
-    to improvise with all the features of the example, creating
-    a new configuration -
-    <code>ScanManagerMXBean.createOtherConfigurationMBean</code> -
-    adding multiple directory scanners to that configuration -
-    <code>ScanDirConfigMXBean.addDirectoryScanner</code> -
-    then switching the <code>ScanManagerMXBean</code> current
-    configuration by changing the value of the <i>ConfigurationMBean</i>
-    attribute - <code>ScanManagerMXBean.setConfigurationMBean</code>
-    - then applying the new configuration -
-    <code>ScanManagerMXBean.applyConfiguration(true)</code> -
-    then scheduling repeated directory scans every 10 seconds -
-    <code>ScanManagerMXBean.schedule(0,10000)</code> -
-    subscribing for notifications, etc...
-    </p>
-    </ul>
-
-  <a name="secure"></a>
-  <h2><a name="h2-Turning">Turning the example into a Secure JMX Application</a></h2>
-    <ul>
-    <p>In this section, we will see how to configure and
-    start the <i>scandir</i> example so that the JVM agent
-    is bootstrapped with a secure JMXConnectorServer. Indeed, until
-    now we have only used the insecure local connection,
-    which can only be used as long as both the client and
-    the server run on the same machine. This section will
-    explain how to start the <code>ScanDirAgent</code> so
-    that a real secure RMIConnectorServer is started at bootstrap.
-    </p>
-    <p>To achieve this we will: <a href="#management.properties"
-        >provide our own management.properties</a>, <a
-        href="#password-access">create our own password and access files</a>,
-        <a href="#keystore-truststore">provide a keystore and truststore</a>,
-        <a href="#start-secure-agent">start the ScanDirAgent with the
-        appropriate system properties</a>.
-    </ul>
-    <h3>Configuring the JVM Agent for Secure Remote Connection</h3>
-    <ul>
-        <p>The easiest way to <a name="management.properties">configure the
-            JVM Agent</a> for Secure Remote
-           Connection is to use your own <a
-           href="http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html#properties"
-           title="This page describes the properties you can put in your management.properties file"
-           >management.properties</a> file.
-           In this example, we have copied the default
-           <code>$JRE/conf/management/management.properties</code>
-           file to the example's <code>src/etc</code> directory and
-           modified it in <a href="src/etc/management.properties"
-           title="our modified management.properties"
-           >this way</a>:
-           <ul>
-               <li>We have set the RMI port to <u>4545</u> - this is just a
-                   random port number we have picked up. Feel free to use your
-                   own value suited to your environment.
-               <pre># For setting the JMX RMI agent port use the following line
-com.sun.management.jmxremote.port=<b>4545</b></pre>
-               </li>
-               <li>We have <u>switched on</u> SSL <u>mutual authentication</u>
-               <pre># For RMI monitoring with SSL client authentication use the following line
-com.sun.management.jmxremote.ssl.<b>need.client.auth</b>=<b>true</b></pre>
-               </li>
-               <li>We have also <u>secured the RMI Registry</u> with SSL
-               <pre># For using an SSL/TLS <b>protected</b> RMI Registry use the following line
-com.sun.management.jmxremote.<b>registry.ssl</b>=<b>true</b></pre>
-               </li>
-               <li>We have provided <a
-                href="src/etc/password.properties">our own password file</a>
-               <pre># For a non-default password file location use the following line
-com.sun.management.jmxremote.password.file=<i>src/etc/password.properties</i></pre>
-               </li>
-               <li>We have provided <a
-                href="src/etc/access.properties">our own access file</a>
-               <pre># For a non-default password file location use the following line
-com.sun.management.jmxremote.access.file=<i>src/etc/access.properties</i></pre>
-               </li>
-           </ul>
-           <p>You will note that we haven't provided any value
-              for the other security properties, like
-              <code>com.sun.management.jmxremote.authenticate=true</code>,
-              because these properties already default to a value
-              which enables security by default.
-              Note however that protecting the RMI Registry with SSL
-              improves the application security, but only as long as
-              mutual authentication is also switched on. Otherwise, just
-              anybody would be able to connect to the registry and
-              get the RMIServer stub.
-           </p>
-           <p>We do recommend that you <u>use the most secure configuration
-              when you deploy a JMX agent</u> - which means <u>switching on
-              SSL protection for the RMI registry</u> <b>and</b> <u>requiring
-              mutual authentication</u>, as we show in this example.
-           </p>
-           <p>We will use the <code>com.sun.management.config.file</code>
-           system property to pass our <a
-           href="src/etc/management.properties">management.properties</a>
-           file to the <code>ScanDirAgent</code>.
-           </p>
-    </ul>
-
-    <h3>Creating a password and access file</h3>
-    <ul>
-        <p>As explained above, we have created our own
-        <a href="src/etc/password.properties">password file</a>
-        and <a href="src/etc/access.properties">access file</a>
-        for <a name="password-access">access control and authorization</a>.
-        </p>
-        <p>In the password file, we have defined two logins:
-           <i>guest</i> and <i>admin</i>. The password for
-           <i>guest</i> is <i>guestpasswd</i> and the password
-           for <i>admin</i> is <i>adminpasswd</i>.
-        </p>
-        <p>In the access file, we have mapped these two logins
-        to access rights: the <i>admin</i> login has <i>read-write</i>
-        access, while the <i>guest</i> login only has <i>read-only</i>.
-        </p>
-        <p>Before starting the <code>ScanDirAgent</code>, you will
-           need to restrict access permission to the password file,
-           in such a way that nobody but you can read it. Otherwise, the
-           JVM Agent will refuse to start the JMXConnectorServer, as it will
-           fear that security can be compromised if other parties can
-           have read access to the password file. How to restrict
-           read access to the password file is explained in detail
-           <a href="http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html#PasswordAccessFiles"
-           title="Using Password and Access Files"
-           >here</a>.
-        </p>
-        <p>As we have seen above, the location
-           of our access and password files is configured in our own <a
-           href="src/etc/management.properties">management.properties</a>
-           file.
-        </p>
-    </ul>
-    <h3>Keystore and Truststore</h3>
-    <ul>
-        <p>Using SSL with mutual authentication means that both
-           client and server will need a <a name="keystore-truststore"
-           >keystore and a truststore</a>
-           to store their own certificates, and the certificates of
-           the parties they trust. Usually, client and server will
-           have their own keystore and truststore.
-        </p>
-        <p>For the sake of simplicity - and to get you started
-        without the tedious necessity of creating your own keystore
-        and truststore, we are providing a dummy keystore and
-        truststore, containing a certificate self-signed by duke.
-        The password for our keystore is <i>password</i>, and the
-        password for our truststore is <i>trustword</i>.
-        We suggest that you first get the example running with the
-        keystore and truststore we are providing before attempting
-        to use your own keystore and truststore.
-        </p>
-        <p>A secure application will obviously need to use its own
-        keystore and truststore, <b><u>and should not rely on the keystore
-        and truststore we are providing here!</u></b>
-        </p>
-        <p>How to create your own keystore and truststore, is explained
-        in <a
-href="http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html#SSL_enabled"
-title="Monitoring and Management Using JMX"
-        >here</a>.
-        As shown <a href="#start-secure-agent">later</a>,
-        we will need to use <a
-        href="http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html#SSL_enabled"
-        >system properties</a> to pass our truststore
-        and keystore to the <code>ScanDirAgent</code>.
-        </p>
-    </ul>
-    <h3>Starting a Secure <i>scandir</i> agent</h3>
-    <ul>
-        <p>To start a <a name="start-secure-agent"
-        >secure <i>scandir</i> agent</a>, go to the
-        <i>scandir</i> example root directory and type the
-        following command:</p>
-        <p>On Unix Systems:
-<pre>ant jar
-java \
-    -Djava.util.logging.config.file=logging.properties \
-    -Djavax.net.ssl.keyStore=keystore \
-    -Djavax.net.ssl.keyStorePassword=password \
-    -Djavax.net.ssl.trustStore=truststore \
-    -Djavax.net.ssl.trustStorePassword=trustword \
-    -Dcom.sun.management.config.file=src/etc/management.properties \
-    -Dscandir.config.file=src/etc/testconfig.xml \
-    -jar dist/jmx-scandir.jar</pre>
-        </p>
-         <p>On Windows Systems:
-<p><code>ant jar<br>
-java
-    &nbsp;-Djava.util.logging.config.file=logging.properties
-    &nbsp;-Djavax.net.ssl.keyStore=keystore
-    &nbsp;-Djavax.net.ssl.keyStorePassword=password
-    &nbsp;-Djavax.net.ssl.trustStore=truststore
-    &nbsp;-Djavax.net.ssl.trustStorePassword=trustword
-    &nbsp;-Dcom.sun.management.config.file=src\etc\management.properties
-    &nbsp;-Dscandir.config.file=src\etc\testconfig.xml
-    &nbsp;-jar&nbsp;dist\jmx-scandir.jar</code></p>
-         </p>
-    <p>If you start jconsole now, you will see that you
-       are still able to connect to the agent using the
-       local connection. However, if you try to connect
-       through the remote connector, using
-       <a href="docfiles/remote-connection.jpg">localhost:4545</a>,
-       the connection will <a href="docfiles/remote-connection-failed.jpg"
-       >fail</a>, even if you provide a correct login/password
-       pair. Indeed, since the JMXConnectorServer is now protected with SSL,
-       jconsole must also be configured with the appropriate SSL parameters
-       so that it can authenticate the server and get authenticated by the
-       server too as the SSL configuration of the server requires mutual
-       authentication.
-    </p>
-    <p>The next section will discuss how to connect to the
-    secure agent.
-    </p>
-   </ul>
-
-  <h2><a name="h2-Connecting">Connecting to the Secure JMX Application</a></h2>
-    <ul>
-    <p>We will now see how to connect to the secure agent,
-       using jconsole, and using a programmatic client.
-    </p>
-    </ul>
-
-    <h3>Using jconsole to connect to the secure agent</h3>
-    <ul>
-    <p>The only special thing you need to do in order to
-        be able to connect to your secure agent with
-        jconsole, is to give it a keystore (containing
-        its client certificate) and a truststore (containing
-        the certificates of the servers it can trust).
-        In our example, we use the same keystore/truststore
-        pair on the client and server side - but this is
-        not what a real application would do.
-        Indeed a real application would have different
-        certificates for the client and the server, and
-        thus use different keystores (and probably truststores).
-        More information on SSL authentication can be obtained from the <a
-        href="http://java.sun.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#HowSSLWorks"
-        title="How SSL Works"
-        >Java&trade; Secure Socket Extension (JSSE) Reference Guide</a>.
-    </p>
-    <p>To start jconsole with our provided keystore and
-    truststore, go to the scandir example root directory and
-    type in the following command:
-    <p><code>jconsole
-    &nbsp;-J-Djava.util.logging.config.file=logging.properties
-    &nbsp;-J-Djavax.net.ssl.keyStore=keystore
-    &nbsp;-J-Djavax.net.ssl.keyStorePassword=password
-    &nbsp;-J-Djavax.net.ssl.trustStore=truststore
-    &nbsp;-J-Djavax.net.ssl.trustStorePassword=trustword</code></p>
-    </p>
-    <p>The <code>-J-Djava.util.logging.config.file=logging.properties</code>
-       flag is not mandatory, but passing a <code>logging.properties</code>
-       may help you debug connection problems if anything goes wrong.
-    </p>
-    <p>In jconsole connection window, choose to connect to a
-       remote process, using the address <i>localhost:4545</i>
-       and the guest login:
-    </p>
-    <p><center><a href="docfiles/remote-connection.jpg"
-       ><img src="docfiles/remote-connection.jpg"
-        alt="jconsole connection window"/></a></center>
-    </p>
-    <p>You will see that the agent will let view all the
-       MBeans and their attributes, but will reject any
-       attribute modification or remote method invocation.
-    </p>
-    <hr>
-    <p><u>Note:</u> if jconsole fails to connect and show
-    you <a href="docfiles/remote-connection-failed.jpg">this screen</a>
-    you have probably misspelled some of the properties on jconsole
-    command line, or you didn't start jconsole from the
-    scandir example root directory where our <code>truststore</code>
-    and <code>keystore</code> files are located. This article - <a
-    href="http://blogs.sun.com/roller/page/jmxetc?entry=troubleshooting_connection_problems_in_jconsole"
-    title="Troubleshooting connection problems in JConsole"
-    >Troubleshooting connection problems in JConsole</a> - may help
-    you figure out what is going wrong.
-    </p>
-    <hr>
-    </ul>
-
-    <h3>Writing a programmatic client to connect to the secure agent</h3>
-    <ul>
-        <p>
-        In this section we will show the steps involved in writing
-        a programmatic client that will connect to our secure agent.
-        </p>
-   <p>The <a
-href="dist/javadoc/com/sun/jmx/examples/scandir/ScanDirClient.html"
-title="The ScanDirClient class is a very short example of secure programmatic client"
-     >ScanDirClient</a> is an example class that shows how a
-    programmatic client can connect to a secured <i>scandir</i> application.
-    This class contains a <code>main</code> method which creates and
-    configures a <code>JMXConnector</code> client to connect with
-    the secured <i>scandir</i> agent.
-    </p>
-    <p>The secure client differs only from a non secure client in
-    so far as it needs to use SSL RMI Factories and credentials to
-    connect to the secure agent. The steps required mainly involve:
-       <ul>
-           <li>Creating an empty environment map:
-           <pre>
-            // Create an environment map to hold connection properties
-            // like credentials etc... We will later pass this map
-            // to the JMX Connector.
-            //
-            System.out.println("\nInitialize the environment map");
-            final Map&lt;String,Object> env = new HashMap&lt;String,Object>();
-           </pre>
-           </li>
-           <li>Putting the client's credentials in that map:
-           <i>(here the client will log in as <b>guest</b>)</i>
-           <pre>
-            // Provide the credentials required by the server
-            // to successfully perform user authentication
-            //
-            final String[] credentials = new String[] { "guest" , "guestpasswd" };
-            env.put("jmx.remote.credentials", credentials);
-           </pre>
-           </li>
-           <li>Providing an <code>SslRMIClientSocketFactory</code> to interact
-           with the secure RMI Registry:
-           <pre>
-            // Provide the SSL/TLS-based RMI Client Socket Factory required
-            // by the JNDI/RMI Registry Service Provider to communicate with
-            // the SSL/TLS-protected RMI Registry
-            //
-            env.put("com.sun.jndi.rmi.factory.socket",
-                    new SslRMIClientSocketFactory());
-           </pre>
-           </li>
-           <li>Creating a JMXConnector and connecting with the
-               secure server:
-           <pre>
-            // Create the RMI connector client and
-            // connect it to the secure RMI connector server.
-            // args[0] is the server's host - localhost
-            // args[1] is the secure server port - 4545
-            //
-            System.out.println("\nCreate the RMI connector client and " +
-                    "connect it to the RMI connector server");
-            final JMXServiceURL url = new JMXServiceURL(
-                    "service:jmx:rmi:///jndi/rmi://"+args[0]+":"+args[1]+
-                    "/jmxrmi");
-            final JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
-           </pre>
-           </li>
-       </ul>
-       <p>For this to work, we also need to start the <code>ScanDirClient</code>
-       with the appropriate system properties that will point to our
-       <code>keystore</code> and <code>truststore</code>. To start the secure
-       client, go to the <i>scandir</i> example root directory and type
-       the following command:
-       <p><code>ant jar<br>
-java
-    &nbsp;-Djava.util.logging.config.file=logging.properties
-    &nbsp;-Djavax.net.ssl.keyStore=keystore
-    &nbsp;-Djavax.net.ssl.keyStorePassword=password
-    &nbsp;-Djavax.net.ssl.trustStore=truststore
-    &nbsp;-Djavax.net.ssl.trustStorePassword=trustword
-    &nbsp;-classpath&nbsp;dist/jmx-scandir.jar
-     &nbsp;com.sun.jmx.examples.scandir.ScanDirClient&nbsp;localhost&nbsp;4545
-       </code></p>
-       </p>
-       <p>You should be seeing this trace:
-<center><table width="90%" border="0" bgcolor="#eeeeee">
-<tr><td>
-<pre>
-Initialize the environment map
-
-Create the RMI connector client and connect it to the RMI connector server
-Connecting to: service:jmx:rmi:///jndi/rmi://localhost:4545/jmxrmi
-
-Get the MBeanServerConnection
-
-Get ScanDirConfigMXBean from ScanManagerMXBean
-
-Get 'Configuration' attribute on ScanDirConfigMXBean
-
-Configuration:
-
-&lt;ScanManager xmlns="jmx:com.sun.jmx.examples.scandir.config" name="testconfig">
-    &lt;InitialResultLogConfig>
-        &lt;LogFileMaxRecords>2048&lt;/LogFileMaxRecords>
-        &lt;LogFileName>build/scandir.log&lt;/LogFileName>
-        &lt;MemoryMaxRecords>128&lt;/MemoryMaxRecords>
-    &lt;/InitialResultLogConfig>
-    &lt;DirectoryScannerList>
-        &lt;DirectoryScanner name="scan-build">
-            &lt;Actions>NOTIFY LOGRESULT&lt;/Actions>
-            &lt;ExcludeFiles/>
-            &lt;IncludeFiles>
-                &lt;FileFilter>
-                    &lt;FilePattern>.*\.class&lt;/FilePattern>
-                    &lt;SizeExceedsMaxBytes>4096&lt;/SizeExceedsMaxBytes>
-                &lt;/FileFilter>
-            &lt;/IncludeFiles>
-            &lt;RootDirectory>build&lt;/RootDirectory>
-        &lt;/DirectoryScanner>
-    &lt;/DirectoryScannerList>
-&lt;/ScanManager>
-
-Invoke 'close' on ScanManagerMXBean
-
-Got expected security exception: java.lang.SecurityException: Access denied!
-Invalid access level for requested MBeanServer operation.
-
-Close the connection to the server
-
-Bye! Bye!
-</pre>
-</td></tr></table></center>
-    <p>If the <code>ScanDirClient</code> fails to connect with
-       the secure agent, then this article - <a
-    href="http://blogs.sun.com/roller/page/jmxetc?entry=troubleshooting_connection_problems_in_jconsole"
-    title="Troubleshooting connection problems in JConsole"
-    >Troubleshooting connection problems in JConsole</a> - may help
-    you figure out what is going wrong. Indeed the connection steps
-    performed by the <code>ScanDirClient</code> are very similar to
-    those performed by <code>jconsole</code>, and the problems you
-    could encounter are identical. Just remember that
-   <code>jconsole</code> needs the extra <code>-J</code> flag to pass
-   system properties to the VM, which is not needed with regular
-   <code>java</code> launcher invocations.
-    </p>
-    </ul>
-
-    <h2><a name="h2-Conclusion">Conclusion</a></h2>
-    <ul>
-    <p>
-        In this document, we have presented an advanced
-        JMX example, and shown how to run a secure
-        JMX agent in a production environment.
-        We have also shown how to connect to such a
-        secure agent with both jconsole and a programmatic
-        client. We have also discuss various JMX
-        design-patterns and best practices.
-        Readers who would wish to learn more about JMX, and
-        Monitoring and Management of the JVM, are invited
-        to follow the links given in reference below.
-    </p>
-    </ul>
-  <h2><a name="h2-References">References</a></h2>
-  <ol>
-     <li><a href="http://java.sun.com/products/JavaManagement/best-practices.html"
-        >JMX Best Practices</a>: This document describes best practices that
-      have been identified for modeling using the JMX API. </li>
-     <li><a href="http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html"
-      >Monitoring and Management Using JMX</a>: How to enable, configure, and
-      connect to the JVM JMX agent.</li>
-     <li><a name="JConsole"><a
-href="http://java.sun.com/javase/6/docs/technotes/guides/management/jconsole.html"
->Using JConsole</a>: JConsole is a JMX-Compliant monitoring tool which allows
-     you to interact graphically with your own MBeans.
-     </li>
-     <li><a href="http://java.sun.com/javase/6/docs/technotes/guides/management/"
-     >Monitoring and Management for the Java Platform</a>: The Java Platform
-      Standard Edition (Java SE) 6 provides comprehensive monitoring and
-      management support for the Java platform. </li>
-     <li><a href="http://java.sun.com/products/JavaManagement/community/jmx_blogs.html"
-         >List of JMX-related Blogs</a>: This page provides links to the
-          different web logs written by members of the Sun team working on the
-          JMX API.</li>
-     <li><a
-        href="http://java.sun.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#HowSSLWorks"
-        title="The JSSE Reference Guide"
-        >Java&trade; Secure Socket Extension (JSSE) Reference Guide</a>:
-        comprehensive documentation about the Java&trade; Secure Socket
-        Extension (JSSE)
-     </li>
-     <li><a href="http://java.sun.com/javase/6/docs/"
-         >Java SE 6 Documentation Index</a>: This document covers the
-          Java&trade; Platform, Standard Edition 6 JDK.</li>
-  </ol>
-  <p>
-  <hr>
-  <p>
-  </body>
-</html>
--- a/jdk/src/sample/share/jmx/jmx-scandir/logging.properties	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-handlers= java.util.logging.ConsoleHandler
-
-.level=INFO
-
-
-java.util.logging.FileHandler.pattern = %h/java%u.log
-java.util.logging.FileHandler.limit = 50000
-java.util.logging.FileHandler.count = 1
-java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
-
-java.util.logging.ConsoleHandler.level = FINEST
-java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
-
-javax.management.level=INFO
-com.sun.jmx.level=INFO
-com.sun.jmx.examples.level=FINE
-
--- a/jdk/src/sample/share/jmx/jmx-scandir/manifest.mf	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-X-COMMENT: Main-Class will be added automatically by build
-
--- a/jdk/src/sample/share/jmx/jmx-scandir/nbproject/file-targets.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<project basedir=".." name="jmx-scandir/file">
-    
-    <import file="../build.xml"/>
-    
-    <target name="compile-selected" depends="-init">
-        <fail unless="includes">Must set property 'includes'</fail>
-        <mkdir dir="${classes.dir}"/>
-        <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="${debug}" deprecation="${deprecation}" includes="${includes}">
-            <classpath path="${cp}"/>
-        </javac>
-    </target>
-    
-</project>
--- a/jdk/src/sample/share/jmx/jmx-scandir/nbproject/jdk.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<project name="jdk" basedir=".">
-
-    <target name="-jdk-preinit">
-        <condition property=".exe" value=".exe">
-            <os family="windows"/>
-        </condition>
-        <property name=".exe" value=""/>
-        <property name="nbjdk.javac" value="${nbjdk.home}/bin/javac${.exe}"/>
-        <property name="nbjdk.java" value="${nbjdk.home}/bin/java${.exe}"/>
-        <property name="nbjdk.javadoc" value="${nbjdk.home}/bin/javadoc${.exe}"/>
-        <property name="nbjdk.appletviewer" value="${nbjdk.home}/bin/appletviewer${.exe}"/>
-        <property name="nbjdk.bootclasspath" value="${nbjdk.home}/jre/lib/rt.jar"/>
-    </target>
-
-    <target name="-jdk-presetdef-basic" depends="-jdk-preinit" unless="nbjdk.presetdef.basic.done">
-        <macrodef name="javac-presetdef">
-            <attribute name="javacval"/>
-            <sequential>
-                <presetdef name="javac">
-                    <javac fork="yes" executable="@{javacval}"/>
-                </presetdef>
-            </sequential>
-        </macrodef>
-        <javac-presetdef javacval="${nbjdk.javac}"/>
-        <macrodef name="java-presetdef">
-            <attribute name="javaval"/>
-            <sequential>
-                <presetdef name="java">
-                    <java fork="yes" jvm="@{javaval}"/>
-                </presetdef>
-            </sequential>
-        </macrodef>
-        <java-presetdef javaval="${nbjdk.java}"/>
-        <macrodef name="javadoc-presetdef">
-            <attribute name="javadocval"/>
-            <sequential>
-                <presetdef name="javadoc">
-                    <javadoc executable="@{javadocval}"/>
-                </presetdef>
-            </sequential>
-        </macrodef>
-        <javadoc-presetdef javadocval="${nbjdk.javadoc}"/>
-        <property name="nbjdk.presetdef.basic.done" value="true"/>
-    </target>
-
-    <target name="-jdk-presetdef-nbjpdastart" depends="-jdk-preinit" unless="nbjdk.presetdef.nbjpdastart.done">
-        <macrodef name="nbjpdastart-presetdef">
-            <attribute name="bootcpval"/>
-            <sequential>
-                <presetdef name="nbjpdastart">
-                    <nbjpdastart>
-                        <bootclasspath>
-                            <path path="@{bootcpval}"/>
-                        </bootclasspath>
-                    </nbjpdastart>
-                </presetdef>
-            </sequential>
-        </macrodef>
-        <nbjpdastart-presetdef bootcpval="${nbjdk.bootclasspath}"/>
-        <property name="nbjdk.presetdef.nbjpdastart.done" value="true"/>
-    </target>
-
-    <target name="-jdk-init" depends="-jdk-preinit,-jdk-presetdef-basic"/>
-
-</project>
--- a/jdk/src/sample/share/jmx/jmx-scandir/nbproject/netbeans-targets.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<project basedir=".." name="jmx-scandir/NB">
-
-    <import file="../build.xml"/>
-
-    <target name="debug" depends="compile,-jdk-presetdef-nbjpdastart">
-        <nbjpdastart addressproperty="jpda.address" name="jmx-scandir" transport="dt_socket">
-            <classpath path="${run.cp}"/>
-        </nbjpdastart>
-        <java classname="${main.client.class}" failonerror="true" fork="true">
-            <classpath path="${run.cp}"/>
-            <jvmarg value="-Xdebug"/>
-            <jvmarg value="-Xnoagent"/>
-            <jvmarg value="-Djava.compiler=none"/>
-            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
-            <arg line="${client.args}" />
-        </java>
-    </target>
-    
-    <target name="debug-fix" depends="-init">
-        <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true" deprecation="${deprecation}">
-            <classpath path="${cp}"/>
-            <include name="${class}.java"/>
-        </javac>
-        <nbjpdareload>
-            <fileset dir="${classes.dir}">
-                <include name="${class}.class"/>
-            </fileset>
-        </nbjpdareload>
-    </target>
-    
-    <target name="show-info" depends="-init">
-        <nbbrowse file="${main.dir}/index.html"/>
-    </target>
-    
-    <target name="show-javadoc" depends="javadoc">
-        <nbbrowse file="${javadoc.dir}/index.html"/>
-    </target>
-    
-    <target name="profile" depends="compile">
-        <nbprofiledirect>
-            <classpath path="${run.cp}"/>
-        </nbprofiledirect>
-        <property environment="env"/>
-        <java classname="${main.client.class}" fork="true" failonerror="true" dir="${profiler.session.working.dir}" jvm="${profiler.info.jvm}">
-            <classpath path="${run.cp}"/>
-            <jvmarg value="${profiler.info.jvmargs.agent}"/>
-            <jvmarg line="${profiler.info.jvmargs}"/>
-            <arg line="localhost 4545" />
-            <env key="LD_LIBRARY_PATH" path="${profiler.info.agentpath}:${env.LD_LIBRARY_PATH}"/>
-            <env key="Path" path="${profiler.info.agentpath}:${env.Path}"/>
-        </java>
-    </target>
-
-</project>
--- a/jdk/src/sample/share/jmx/jmx-scandir/nbproject/project.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,210 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<project xmlns="http://www.netbeans.org/ns/project/1">
-    <type>org.netbeans.modules.ant.freeform</type>
-    <configuration>
-        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
-            <name>jmx-scandir</name>
-            <properties>
-                <property-file>user.build.properties</property-file>
-                <property-file>build.properties</property-file>
-                <property name="nbjdk.bootclasspath">${nbjdk.home}/jre/lib/rt.jar</property>
-            </properties>
-            <folders>
-                <source-folder>
-                    <label>JDK Demo</label>
-                    <location>${main.dir}</location>
-                </source-folder>
-                <source-folder>
-                    <label>Sources</label>
-                    <type>java</type>
-                    <location>${src.dir}</location>
-                </source-folder>
-                <source-folder>
-                    <label>test</label>
-                    <type>java</type>
-                    <location>test</location>
-                </source-folder>
-            </folders>
-            <ide-actions>
-                <action name="build">
-                    <target>jar</target>
-                </action>
-                <action name="clean">
-                    <target>clean</target>
-                </action>
-                <action name="rebuild">
-                    <target>clean</target>
-                    <target>jar</target>
-                </action>
-                <action name="run">
-                    <target>run</target>
-                </action>
-                <action name="ReadMe">
-                    <script>nbproject/netbeans-targets.xml</script>
-                    <target>show-info</target>
-                </action>
-                <action name="javadoc">
-                    <script>nbproject/netbeans-targets.xml</script>
-                    <target>show-javadoc</target>
-                </action>
-                <action name="debug">
-                    <script>nbproject/netbeans-targets.xml</script>
-                    <target>debug</target>
-                </action>
-                <action name="compile.single">
-                    <script>nbproject/file-targets.xml</script>
-                    <target>compile-selected</target>
-                    <context>
-                        <property>includes</property>
-                        <folder>${src.dir}</folder>
-                        <pattern>\.java$</pattern>
-                        <format>relative-path</format>
-                        <arity>
-                            <separated-files>,</separated-files>
-                        </arity>
-                    </context>
-                </action>
-                <action name="run.single">
-                    <target>run</target>
-                    <context>
-                        <property>main.class</property>
-                        <folder>${src.dir}</folder>
-                        <pattern>\.java$</pattern>
-                        <format>java-name</format>
-                        <arity>
-                            <one-file-only/>
-                        </arity>
-                    </context>
-                </action>
-                <action name="debug.single">
-                    <script>nbproject/netbeans-targets.xml</script>
-                    <target>debug</target>
-                    <context>
-                        <property>main.class</property>
-                        <folder>${src.dir}</folder>
-                        <pattern>\.java$</pattern>
-                        <format>java-name</format>
-                        <arity>
-                            <one-file-only/>
-                        </arity>
-                    </context>
-                </action>
-                <action name="debug.fix">
-                    <script>nbproject/netbeans-targets.xml</script>
-                    <target>debug-fix</target>
-                    <context>
-                        <property>class</property>
-                        <folder>${src.dir}</folder>
-                        <pattern>\.java$</pattern>
-                        <format>relative-path-noext</format>
-                        <arity>
-                            <one-file-only/>
-                        </arity>
-                    </context>
-                </action>
-                <action name="test">
-                    <target>test</target>
-                </action>
-            </ide-actions>
-            <export>
-                <type>folder</type>
-                <location>${classes.dir}</location>
-                <build-target>jar</build-target>
-            </export>
-            <export>
-                <type>jar</type>
-                <location>${jar}</location>
-                <build-target>jar</build-target>
-            </export>
-            <export>
-                <type>folder</type>
-                <location>${build.test.classes.dir}</location>
-                <build-target>jar</build-target>
-            </export>
-            <view>
-                <items>
-                    <source-folder style="packages">
-                        <label>Sources</label>
-                        <location>${src.dir}</location>
-                    </source-folder>
-                    <source-folder style="packages">
-                        <label>test</label>
-                        <location>test</location>
-                    </source-folder>
-                    <source-file>
-                        <location>${main.dir}/index.html</location>
-                    </source-file>
-                </items>
-                <context-menu>
-                    <ide-action name="ReadMe"/>
-                    <ide-action name="build"/>
-                    <ide-action name="clean"/>
-                    <ide-action name="rebuild"/>
-                    <ide-action name="javadoc"/>
-                    <ide-action name="debug"/>
-                    <!-- ide-action name="test"/ -->
-                    <separator/>
-                    <action>
-                        <label>Run Agent</label>
-                        <target>run-agent</target>
-                    </action>
-                    <action>
-                        <label>Run Client</label>
-                        <target>run-client</target>
-                    </action>
-                </context-menu>
-            </view>
-            <subprojects/>
-        </general-data>
-        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
-            <compilation-unit>
-                <package-root>${src.dir}</package-root>
-                <classpath mode="compile">${cp}</classpath>
-                <classpath mode="execute">${run.cp}</classpath>
-                <classpath mode="boot">${nbjdk.bootclasspath}</classpath>
-                <built-to>${classes.dir}</built-to>
-                <built-to>${jar}</built-to>
-                <javadoc-built-to>${javadoc.dir}</javadoc-built-to>
-                <source-level>1.5</source-level>
-            </compilation-unit>
-            <compilation-unit>
-                <package-root>test</package-root>
-                <unit-tests/>
-                <built-to>${build.test.classes.dir}</built-to>
-                <source-level>1.5</source-level>
-            </compilation-unit>
-        </java-data>
-    </configuration>
-</project>
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/DirectoryScanner.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,591 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import static com.sun.jmx.examples.scandir.ScanManager.getNextSeqNumber;
-import com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState;
-import static com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState.*;
-import static com.sun.jmx.examples.scandir.config.DirectoryScannerConfig.Action.*;
-import com.sun.jmx.examples.scandir.config.XmlConfigUtils;
-import com.sun.jmx.examples.scandir.config.DirectoryScannerConfig;
-import com.sun.jmx.examples.scandir.config.DirectoryScannerConfig.Action;
-import com.sun.jmx.examples.scandir.config.ResultRecord;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.management.AttributeChangeNotification;
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-
-/**
- * A <code>DirectoryScanner</code> is an MBean that
- * scans a file system starting at a given root directory,
- * and then looks for files that match a given criteria.
- * <p>
- * When such a file is found, the <code>DirectoryScanner</code> takes
- * the action for which it was configured: emit a notification,
- * <i>and or</i> log a {@link
- * com.sun.jmx.examples.scandir.config.ResultRecord} for this file,
- * <i>and or</i> delete that file.
- * </p>
- * <p>
- * The code that would actually delete the file is commented out - so that
- * nothing valuable is lost if this example is run by mistake on the wrong
- * set of directories.<br>
- * Logged results are logged by sending them to the {@link ResultLogManager}.
- * </p>
- * <p>
- * <code>DirectoryScannerMXBeans</code> are created, initialized, and
- * registered by the {@link ScanManagerMXBean}.
- * The {@link ScanManagerMXBean} will also schedule and run them in
- * background by calling their {@link #scan} method.
- * </p>
- * <p>Client code is not expected to create or register directly any such
- * MBean. Instead, clients are expected to modify the configuration, using
- * the {@link ScanDirConfigMXBean}, and then apply it, using the {@link
- * ScanManagerMXBean}. Instances of <code>DirectoryScannerMXBeans</code>
- * will then be created and registered (or unregistered and garbage collected)
- * as a side effect of applying that configuration.
- * </p>
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public class DirectoryScanner implements
-        DirectoryScannerMXBean, NotificationEmitter {
-
-    /**
-     * The type for <i>com.sun.jmx.examples.scandir.filematch</i> notifications.
-     * Notifications of this type will be emitted whenever a file that
-     * matches this {@code DirectoryScanner} criteria is found, but only if
-     * this {@code DirectoryScanner} was configured to {@link
-     * Action#NOTIFY notify} for matching files.
-     **/
-    public static final String FILE_MATCHES_NOTIFICATION =
-            "com.sun.jmx.examples.scandir.filematch";
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(DirectoryScanner.class.getName());
-
-    // Attribute : State
-    //
-    private volatile ScanState state = STOPPED;
-
-    // The DirectoryScanner delegates the implementation of
-    // the NotificationEmitter interface to a wrapped instance
-    // of NotificationBroadcasterSupport.
-    //
-    private final NotificationBroadcasterSupport broadcaster;
-
-    // The root directory at which this DirectoryScanner will start
-    // scanning. Constructed from config.getRootDirectory().
-    //
-    private final File rootFile;
-
-    // This DirectoryScanner config - this is a constant which is
-    // provided at construction time by the {@link ScanManager}.
-    //
-    private final DirectoryScannerConfig config;
-
-    // The set of actions for which this DirectoryScanner is configured.
-    // Constructed from config.getActions()
-    //
-    final Set<Action> actions;
-
-    // The ResultLogManager that this DirectoryScanner will use to log
-    // info. This is a hard reference to another MBean, provided
-    // at construction time by the ScanManager.
-    // The ScanManager makes sure that the life cycle of these two MBeans
-    // is consistent.
-    //
-    final ResultLogManager logManager;
-
-    /**
-     * Constructs a new {@code DirectoryScanner}.
-     * <p>This constructor is
-     * package protected, and this MBean cannot be created by a remote
-     * client, because it needs a reference to the {@link ResultLogManager},
-     * which cannot be provided from remote.
-     * </p>
-     * <p>This is a conscious design choice: {@code DirectoryScanner} MBeans
-     * are expected to be completely managed (created, registered, unregistered)
-     * by the {@link ScanManager} which does provide this reference.
-     * </p>
-     *
-     * @param config This {@code DirectoryScanner} configuration.
-     * @param logManager The info log manager with which to log the info
-     *        records.
-     * @throws IllegalArgumentException if one of the parameter is null, or if
-     *         the provided {@code config} doesn't have its {@code name} set,
-     *         or if the {@link DirectoryScannerConfig#getRootDirectory
-     *         root directory} provided in the {@code config} is not acceptable
-     *         (not provided or not found or not readable, etc...).
-     **/
-    public DirectoryScanner(DirectoryScannerConfig config,
-                            ResultLogManager logManager)
-        throws IllegalArgumentException {
-        if (logManager == null)
-            throw new IllegalArgumentException("log=null");
-        if (config == null)
-            throw new IllegalArgumentException("config=null");
-        if (config.getName() == null)
-            throw new IllegalArgumentException("config.name=null");
-
-         broadcaster = new NotificationBroadcasterSupport();
-
-         // Clone the config: ensure data encapsulation.
-         //
-         this.config = XmlConfigUtils.xmlClone(config);
-
-         // Checks that the provided root directory is valid.
-         // Throws IllegalArgumentException if it isn't.
-         //
-         rootFile = validateRoot(config.getRootDirectory());
-
-         // Initialize the Set<Action> for which this DirectoryScanner
-         // is configured.
-         //
-         if (config.getActions() == null)
-             actions = Collections.emptySet();
-         else
-             actions = EnumSet.copyOf(Arrays.asList(config.getActions()));
-         this.logManager = logManager;
-    }
-
-    // see DirectoryScannerMXBean
-    public void stop() {
-        // switch state to stop and send AttributeValueChangeNotification
-        setStateAndNotify(STOPPED);
-    }
-
-    // see DirectoryScannerMXBean
-    public String getRootDirectory() {
-        return rootFile.getAbsolutePath();
-    }
-
-
-    // see DirectoryScannerMXBean
-    public ScanState getState() {
-        return state;
-    }
-
-    // see DirectoryScannerMXBean
-    public DirectoryScannerConfig getConfiguration() {
-        return config;
-    }
-
-    // see DirectoryScannerMXBean
-    public String getCurrentScanInfo() {
-        final ScanTask currentOrLastTask = currentTask;
-        if (currentOrLastTask == null) return "Never Run";
-        return currentOrLastTask.getScanInfo();
-    }
-
-    // This variable points to the current (or latest) scan.
-    //
-    private volatile ScanTask currentTask = null;
-
-    // see DirectoryScannerMXBean
-    public void scan() {
-        final ScanTask task;
-
-        synchronized (this) {
-            final LinkedList<File> list;
-            switch (state) {
-                case RUNNING:
-                case SCHEDULED:
-                    throw new IllegalStateException(state.toString());
-                case STOPPED:
-                case COMPLETED:
-                    // only accept to scan if state is STOPPED or COMPLETED.
-                    list = new LinkedList<File>();
-                    list.add(rootFile);
-                    break;
-                default:
-                    throw new IllegalStateException(String.valueOf(state));
-            }
-
-            // Create a new ScanTask object for our root directory file.
-            //
-            currentTask = task = new ScanTask(list,this);
-
-            // transient state... will be switched to RUNNING when
-            // task.execute() is called. This code could in fact be modified
-            // to use java.util.concurent.Future and, to push the task to
-            // an executor. We would then need to wait for the task to
-            // complete before returning.  However, this wouldn't buy us
-            // anything - since this method should wait for the task to
-            // finish anyway: so why would we do it?
-            // As it stands, we simply call task.execute() in the current
-            // thread - brave and fearless readers may want to attempt the
-            // modification ;-)
-            //
-            setStateAndNotify(SCHEDULED);
-        }
-        task.execute();
-    }
-
-    // This method is invoked to carry out the configured actions on a
-    // matching file.
-    // Do not call this method from within synchronized() { } as this
-    // method may send notifications!
-    //
-    void actOn(File file) {
-
-        // Which action were actually taken
-        //
-        final Set<Action> taken = new HashSet<Action>();
-        boolean logresult = false;
-
-        // Check out which actions are configured and carry them out.
-        //
-        for (Action action : actions) {
-            switch (action) {
-                case DELETE:
-                    if (deleteFile(file)) {
-                        // Delete succeeded: add DELETE to the set of
-                        // actions carried out.
-                        taken.add(DELETE);
-                    }
-                    break;
-                case NOTIFY:
-                    if (notifyMatch(file)) {
-                        // Notify succeeded: add NOTIFY to the set of
-                        // actions carried out.
-                        taken.add(NOTIFY);
-                    }
-                    break;
-                case LOGRESULT:
-                    // LOGRESULT was configured - log actions carried out.
-                    // => we must execute this action as the last action.
-                    //    simply set logresult=true for now. We will do
-                    //    the logging later
-                    logresult = true;
-                    break;
-                default:
-                    LOG.fine("Failed to execute action: " +action +
-                            " - action not supported");
-                    break;
-            }
-        }
-
-        // Now is time for logging:
-        if (logresult) {
-            taken.add(LOGRESULT);
-            if (!logResult(file,taken.toArray(new Action[taken.size()])))
-                taken.remove(LOGRESULT); // just for the last trace below...
-        }
-
-        LOG.finest("File processed: "+taken+" - "+file.getAbsolutePath());
-    }
-
-    // Deletes a matching file.
-    private boolean deleteFile(File file) {
-        try {
-            // file.delete() is commented so that we don't do anything
-            // bad if the example is mistakenly run on the wrong set of
-            // directories.
-            //
-            /* file.delete(); */
-            System.out.println("DELETE not implemented for safety reasons.");
-            return true;
-        } catch (Exception x) {
-            LOG.fine("Failed to delete: "+file.getAbsolutePath());
-        }
-        return false;
-    }
-
-    // Notifies of a matching file.
-    private boolean notifyMatch(File file) {
-        try {
-            final Notification n =
-                    new Notification(FILE_MATCHES_NOTIFICATION,this,
-                    getNextSeqNumber(),
-                    file.getAbsolutePath());
-
-            // This method *is not* called from any synchronized block, so
-            // we can happily call broadcaster.sendNotification() here.
-            // Note that verifying whether a method is called from within
-            // a synchronized block demends a thoroughful code reading,
-            // examining each of the 'parent' methods in turn.
-            //
-            broadcaster.sendNotification(n);
-            return true;
-        } catch (Exception x) {
-            LOG.fine("Failed to notify: "+file.getAbsolutePath());
-        }
-        return false;
-    }
-
-    // Logs a result with the ResultLogManager
-    private boolean logResult(File file,Action[] actions) {
-        try {
-            logManager.log(new ResultRecord(config, actions,file));
-            return true;
-        } catch (Exception x) {
-            LOG.fine("Failed to log: "+file.getAbsolutePath());
-        }
-        return false;
-    }
-
-
-    // Contextual object used to store info about current
-    // (or last) scan.
-    //
-    private static class ScanTask {
-
-        // List of Files that remain to scan.
-        // When files are discovered they are added to the list.
-        // When they are being handled, they are removed from the list.
-        // When the list is empty, the scanning is finished.
-        //
-        private final LinkedList<File>   list;
-        private final DirectoryScanner scan;
-
-        // Some statistics...
-        //
-        private volatile long scanned=0;
-        private volatile long matching=0;
-
-        private volatile String info="Not started";
-
-        ScanTask(LinkedList<File> list, DirectoryScanner scan) {
-            this.list = list; this.scan = scan;
-        }
-
-        public void execute() {
-            scan(list);
-        }
-
-        private void scan(LinkedList<File> list) {
-             scan.scan(this,list);
-        }
-
-        public String getScanInfo() {
-            return info+" - ["+scanned+" scanned, "+matching+" matching]";
-        }
-    }
-
-    // The actual scan logic. Switches state to RUNNING,
-    // and scan the list of given dirs.
-    // The list is a live object which is updated by this method.
-    // This would allow us to implement methods like "pause" and "resume",
-    // since all the info needed to resume would be in the list.
-    //
-    private void scan(ScanTask task, LinkedList<File> list) {
-        setStateAndNotify(RUNNING);
-        task.info = "In Progress";
-        try {
-
-            // The FileFilter will tell us which files match and which don't.
-            //
-            final FileFilter filter = config.buildFileFilter();
-
-            // We have two condition to end the loop: either the list is
-            // empty, meaning there's nothing more to scan, or the state of
-            // the DirectoryScanner was asynchronously switched to STOPPED by
-            // another thread, e.g. because someone called "stop" on the
-            // ScanManagerMXBean
-            //
-            while (!list.isEmpty() && state == RUNNING) {
-
-                // Get and remove the first element in the list.
-                //
-                final File current = list.poll();
-
-                // Increment number of file scanned.
-                task.scanned++;
-
-                // If 'current' is a file, it's already been matched by our
-                // file filter (see below): act on it.
-                // Note that for the first iteration of this loop, there will
-                // be one single file in the list: the root directory for this
-                // scanner.
-                //
-                if (current.isFile()) {
-                    task.matching++;
-                    actOn(current);
-                }
-
-                // If 'current' is a directory, then
-                // find files and directories that match the file filter
-                // in this directory
-                //
-                if (current.isDirectory()) {
-
-                    // Gets matching files and directories
-                    final File[] content = current.listFiles(filter);
-                    if (content == null) continue;
-
-                    // Adds all matching file to the list.
-                    list.addAll(0,Arrays.asList(content));
-                }
-            }
-
-            // The loop terminated. If the list is empty, then we have
-            // completed our task. If not, then somebody must have called
-            // stop() on this directory scanner.
-            //
-            if (list.isEmpty()) {
-                task.info = "Successfully Completed";
-                setStateAndNotify(COMPLETED);
-            }
-        } catch (Exception x) {
-            // We got an exception: stop the scan
-            //
-            task.info = "Failed: "+x;
-            if (LOG.isLoggable(Level.FINEST))
-                LOG.log(Level.FINEST,"scan task failed: "+x,x);
-            else if (LOG.isLoggable(Level.FINE))
-                LOG.log(Level.FINE,"scan task failed: "+x);
-            setStateAndNotify(STOPPED);
-        } catch (Error e) {
-            // We got an Error:
-            // Should not happen unless we ran out of memory or
-            // whatever - don't even try to notify, but
-            // stop the scan anyway!
-            //
-            state=STOPPED;
-            task.info = "Error: "+e;
-
-            // rethrow error.
-            //
-            throw e;
-        }
-    }
-
-    /**
-     * MBeanNotification support - delegates to broadcaster.
-     */
-    public void addNotificationListener(NotificationListener listener,
-            NotificationFilter filter, Object handback)
-            throws IllegalArgumentException {
-        broadcaster.addNotificationListener(listener, filter, handback);
-    }
-
-    // Switch this object state to the desired value an send
-    // a notification. Don't call this method from within a
-    // synchronized block!
-    //
-    private final void setStateAndNotify(ScanState desired) {
-        final ScanState old = state;
-        if (old == desired) return;
-        state = desired;
-        final AttributeChangeNotification n =
-                new AttributeChangeNotification(this,
-                getNextSeqNumber(),System.currentTimeMillis(),
-                "state change","State",ScanState.class.getName(),
-                String.valueOf(old),String.valueOf(desired));
-        broadcaster.sendNotification(n);
-    }
-
-
-    /**
-     * The {@link DirectoryScannerMXBean} may send two types of
-     * notifications: filematch, and state attribute changed.
-     **/
-    public MBeanNotificationInfo[] getNotificationInfo() {
-        return new MBeanNotificationInfo[] {
-            new MBeanNotificationInfo(
-                    new String[] {FILE_MATCHES_NOTIFICATION},
-                    Notification.class.getName(),
-                    "Emitted when a file that matches the scan criteria is found"
-                    ),
-            new MBeanNotificationInfo(
-                    new String[] {AttributeChangeNotification.ATTRIBUTE_CHANGE},
-                    AttributeChangeNotification.class.getName(),
-                    "Emitted when the State attribute changes"
-                    )
-        };
-    }
-
-    /**
-     * MBeanNotification support - delegates to broadcaster.
-     */
-    public void removeNotificationListener(NotificationListener listener)
-        throws ListenerNotFoundException {
-        broadcaster.removeNotificationListener(listener);
-    }
-
-    /**
-     * MBeanNotification support - delegates to broadcaster.
-     */
-    public void removeNotificationListener(NotificationListener listener,
-            NotificationFilter filter, Object handback)
-            throws ListenerNotFoundException {
-        broadcaster.removeNotificationListener(listener, filter, handback);
-    }
-
-    // Validates the given root directory, returns a File object for
-    // that directory.
-    // Throws IllegalArgumentException if the given root is not
-    // acceptable.
-    //
-    private static File validateRoot(String root) {
-        if (root == null)
-            throw new IllegalArgumentException("no root specified");
-        if (root.length() == 0)
-            throw new IllegalArgumentException("specified root \"\" is invalid");
-        final File f = new File(root);
-        if (!f.canRead())
-            throw new IllegalArgumentException("can't read "+root);
-        if (!f.isDirectory())
-            throw new IllegalArgumentException("no such directory: "+root);
-        return f;
-    }
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/DirectoryScannerMXBean.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState;
-import com.sun.jmx.examples.scandir.config.DirectoryScannerConfig;
-import java.io.IOException;
-import javax.management.InstanceNotFoundException;
-
-/**
- * A <code>DirectoryScannerMXBean</code> is an MBean that
- * scans a file system starting at a given root directory,
- * and then looks for files that match a given criteria.
- * <p>
- * When such a file is found, the <code>DirectoryScannerMXBean</code> takes
- * the actions for which it was configured: see {@link #scan scan()}.
- * <p>
- * <code>DirectoryScannerMXBeans</code> are created, initialized, and
- * registered by the {@link ScanManagerMXBean}.
- * The {@link ScanManagerMXBean} will also schedule and run them in
- * background by calling their {@link #scan} method.
- * </p>
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public interface DirectoryScannerMXBean {
-    /**
-     * Get The {@link DirectoryScanner} state.
-     * @return the current state of the <code>DirectoryScanner</code>.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public ScanState getState()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Stops the current scan if {@link ScanState#RUNNING running}.
-     * After this method completes the state of the application will
-     * be {@link ScanState#STOPPED STOPPED}.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void stop()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Scans the file system starting at the specified {@link #getRootDirectory
-     * root directory}.
-     * <p>If a file that matches this <code>DirectoryScannerMXBean</code>
-     * {@link #getConfiguration} criteria is found,
-     * the <code>DirectoryScannerMXBean</code> takes the {@link
-     * DirectoryScannerConfig#getActions() actions} for which
-     * it was {@link #getConfiguration configured}: emit a notification,
-     * <i>and or</i> log a {@link
-     * com.sun.jmx.examples.scandir.config.ResultRecord} for this file,
-     * <i>and or</i> delete that file.
-     * </p>
-     * <p>
-     * The code that would actually delete the file is commented out - so that
-     * nothing valuable is lost if this example is run by mistake on the wrong
-     * set of directories.
-     * </p>
-     * <p>This method returns only when the directory scan is completed, or
-     *    if it was {@link #stop stopped} by another thread.
-     * </p>
-     * @throws IllegalStateException if already {@link ScanState#RUNNING}
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void scan()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Gets the root directory at which this <code>DirectoryScannerMXBean</code>
-     * will start scanning the file system.
-     * <p>
-     * This is a shortcut to {@link #getConfiguration
-     * getConfiguration()}.{@link
-     * DirectoryScannerConfig#getRootDirectory
-     * getRootDirectory()}.
-     * </p>
-     * @return This <code>DirectoryScannerMXBean</code> root directory.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public String getRootDirectory()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * The configuration data from which this {@link DirectoryScanner} was
-     * created.
-     * <p>
-     * You cannot change this configuration here. You can however
-     * {@link ScanDirConfigMXBean#setConfiguration modify} the
-     * {@link ScanDirConfigMXBean} configuration, and ask the
-     * {@link ScanManagerMXBean} to {@link ScanManagerMXBean#applyConfiguration
-     * apply} it. This will get all <code>DirectoryScannerMXBean</code>
-     * replaced by new MBeans created from the modified configuration.
-     * </p>
-     *
-     * @return This <code>DirectoryScannerMXBean</code> configuration data.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public DirectoryScannerConfig getConfiguration()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * A short string describing what's happening in current/latest scan.
-     * @return a short info string.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public String getCurrentScanInfo()
-        throws IOException, InstanceNotFoundException;
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ResultLogManager.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,534 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import static com.sun.jmx.examples.scandir.ScanManager.getNextSeqNumber;
-import com.sun.jmx.examples.scandir.config.ResultLogConfig;
-import com.sun.jmx.examples.scandir.config.XmlConfigUtils;
-import com.sun.jmx.examples.scandir.config.ResultRecord;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Logger;
-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.xml.bind.JAXBException;
-
-/**
- * The <code>ResultLogManager</code> is in charge of managing result logs.
- * {@link DirectoryScanner DirectoryScanners} can be configured to log a
- * {@link ResultRecord} whenever they take action upon a file that
- * matches their set of matching criteria.
- * The <code>ResultLogManagerMXBean</code> is responsible for storing these
- * results in its result logs.
- * <p>The <code>ResultLogManagerMXBean</code> can be configured to log
- * these records to a flat file, or into a log held in memory, or both.
- * Both logs (file and memory) can be configured with a maximum capacity.
- * <br>When the maximum capacity of the memory log is reached - its first
- * entry (i.e. its eldest entry) is removed to make place for the latest.
- * <br>When the maximum capacity of the file log is reached, the file is
- * renamed by appending a tilde '~' to its name and a new result log is created.
- *
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public class ResultLogManager extends NotificationBroadcasterSupport
-        implements ResultLogManagerMXBean, MBeanRegistration {
-
-    /**
-     * The default singleton name of the {@link ResultLogManagerMXBean}.
-     **/
-    public static final ObjectName RESULT_LOG_MANAGER_NAME =
-            ScanManager.makeSingletonName(ResultLogManagerMXBean.class);
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(ResultLogManager.class.getName());
-
-    // The memory log
-    //
-    private final List<ResultRecord> memoryLog;
-
-    // Whether the memory log capacity was reached. In that case every
-    // new entry triggers the deletion of the eldest one.
-    //
-    private volatile boolean memCapacityReached = false;
-
-    // The maximum number of record that the memory log can
-    // contain.
-    //
-    private volatile int memCapacity;
-
-    // The maximum number of record that the ResultLogManager can
-    // log in the log file before creating a new file.
-    //
-    private volatile long fileCapacity;
-
-    // The current log file.
-    //
-    private volatile File logFile;
-
-    // The OutputStream of the current log file.
-    //
-    private volatile OutputStream logStream = null;
-
-    // number of record that this object has logged in the log file
-    // since the log file was created. Creating a new file or clearing
-    // the log file reset this value to '0'
-    //
-    private volatile long logCount = 0;
-
-    // The ResultLogManager config - modified whenever
-    // ScanManager.applyConfiguration is called.
-    //
-    private volatile ResultLogConfig config;
-
-    /**
-     * Create a new ResultLogManagerMXBean. This constructor is package
-     * protected: only the {@link ScanManager} can create a
-     * <code>ResultLogManager</code>.
-     **/
-    ResultLogManager() {
-        // Instantiate the memory log - override the add() method so that
-        // it removes the head of the list when the maximum capacity is
-        // reached. Note that add() is the only method we will be calling,
-        // otherwise we would have to override all the other flavors
-        // of adding methods. Note also that this implies that the memoryLog
-        // will *always* remain encapsulated in this object and is *never*
-        // handed over (otherwise we wouldn't be able to ensure that
-        // add() is the only method ever called to add a record).
-        //
-        memoryLog =
-                Collections.synchronizedList(new LinkedList<ResultRecord>() {
-            public synchronized boolean add(ResultRecord e) {
-                final int max = getMemoryLogCapacity();
-                while (max > 0 && size() >= max) {
-                    memCapacityReached = true;
-                    removeFirst();
-                }
-                return super.add(e);
-            }
-        });
-
-        // default memory capacity
-        memCapacity = 2048;
-
-        // default file capacity: 0 means infinite ;-)
-        fileCapacity = 0;
-
-        // by default logging to file is disabled.
-        logFile = null;
-
-        // Until the ScanManager apply a new configuration, we're going to
-        // work with a default ResultLogConfig object.
-        config = new ResultLogConfig();
-        config.setMemoryMaxRecords(memCapacity);
-        config.setLogFileName(getLogFileName(false));
-        config.setLogFileMaxRecords(fileCapacity);
-    }
-
-
-    /**
-     * Allows the MBean to perform any operations it needs before being
-     * registered in the MBean server.
-     * <p>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.</p>
-     * <p>The {@code ResultLogManager} uses this method to supply its own
-     * default singleton ObjectName (if <var>name</var> parameter is null).
-     * @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.
-     */
-    public ObjectName preRegister(MBeanServer server, ObjectName name)
-    throws Exception {
-        if (name == null)
-            name = RESULT_LOG_MANAGER_NAME;
-        objectName = name;
-        mbeanServer = server;
-        return name;
-    }
-
-    /**
-     * Allows the MBean to perform any operations needed after having
-     * been registered in the MBean server or after the registration has
-     * failed.
-     * <p>This implementation does nothing.</p>
-     * @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) {
-        // Don't need to do anything here.
-    }
-
-    /**
-     * Allows the MBean to perform any operations it needs before being
-     * unregistered by the MBean server.
-     * <p>This implementation does nothing.</p>
-     * @throws Exception This exception will be caught by the MBean server and
-     * re-thrown as an MBeanRegistrationException.
-     */
-    public void preDeregister() throws Exception {
-        // Don't need to do anything here.
-    }
-
-    /**
-     * Allows the MBean to perform any operations needed after having been
-     * unregistered in the MBean server.
-     * <p>Closes the log file stream, if it is still open.</p>
-     */
-    public void postDeregister() {
-        try {
-            if (logStream != null) {
-                synchronized(this)  {
-                    logStream.flush();
-                    logStream.close();
-                    logFile = null;
-                    logStream = null;
-                }
-            }
-        } catch (Exception x) {
-            LOG.finest("Failed to close log properly: "+x);
-        }
-    }
-
-    /**
-     * Create a new empty log file from the given basename, renaming
-     * previously existing file by appending '~' to its name.
-     **/
-    private File createNewLogFile(String basename) throws IOException {
-        return XmlConfigUtils.createNewXmlFile(basename);
-    }
-
-    /**
-     * Check whether a new log file should be created.
-     * If a new file needs to be created, creates it, renaming
-     * previously existing file by appending '~' to its name.
-     * Also reset the log count and file capacity.
-     * Sends a notification indicating that the log file was changed.
-     * Returns the new log stream;
-     * Creation of a new file can be forced by passing force=true.
-     **/
-    private OutputStream checkLogFile(String basename, long maxRecords,
-                                      boolean force)
-    throws IOException {
-        final OutputStream newStream;
-        synchronized(this) {
-            if ((force==false) && (logCount < maxRecords))
-                return logStream;
-            final OutputStream oldStream = logStream;
-
-            // First close the stream. On some platforms you cannot rename
-            // a file that has open streams...
-            //
-            if (oldStream != null) {
-                oldStream.flush();
-                oldStream.close();
-            }
-            final File newFile = (basename==null)?null:createNewLogFile(basename);
-
-            newStream = (newFile==null)?null:new FileOutputStream(newFile,true);
-            logStream = newStream;
-            logFile = newFile;
-            fileCapacity = maxRecords;
-            logCount = 0;
-        }
-        sendNotification(new Notification(LOG_FILE_CHANGED,objectName,
-                getNextSeqNumber(),
-                basename));
-        return newStream;
-    }
-
-    // see ResultLogManagerMXBean
-    public void log(ResultRecord record)
-    throws IOException {
-        if (memCapacity > 0) logToMemory(record);
-        if (logFile != null) logToFile(record);
-    }
-
-    // see ResultLogManagerMXBean
-    public ResultRecord[] getMemoryLog() {
-        return memoryLog.toArray(new ResultRecord[0]);
-    }
-
-    // see ResultLogManagerMXBean
-    public int getMemoryLogCapacity() {
-        return memCapacity;
-    }
-
-    // see ResultLogManagerMXBean
-    public void setMemoryLogCapacity(int maxRecords)  {
-        synchronized(this) {
-            memCapacity = maxRecords;
-            if (memoryLog.size() < memCapacity)
-                memCapacityReached = false;
-            config.setMemoryMaxRecords(maxRecords);
-        }
-    }
-
-    // see ResultLogManagerMXBean
-    public void setLogFileCapacity(long maxRecords)
-    throws IOException {
-        synchronized (this) {
-            fileCapacity = maxRecords;
-            config.setLogFileMaxRecords(maxRecords);
-        }
-        checkLogFile(getLogFileName(),fileCapacity,false);
-    }
-
-    // see ResultLogManagerMXBean
-    public long getLogFileCapacity()  {
-        return fileCapacity;
-    }
-
-    // see ResultLogManagerMXBean
-    public long getLoggedCount() {
-        return logCount;
-    }
-
-    // see ResultLogManagerMXBean
-    public void newLogFile(String logname, long maxRecord)
-    throws IOException {
-        checkLogFile(logname,maxRecord,true);
-        config.setLogFileName(getLogFileName(false));
-        config.setLogFileMaxRecords(getLogFileCapacity());
-    }
-
-    // see ResultLogManagerMXBean
-    public String getLogFileName() {
-        return getLogFileName(true);
-    }
-
-    // see ResultLogManagerMXBean
-    public void clearLogs() throws IOException {
-        clearMemoryLog();
-        clearLogFile();
-    }
-
-    // Clear the memory log, sends a notification indicating that
-    // the memory log was cleared.
-    //
-    private void clearMemoryLog()throws IOException {
-        synchronized(this) {
-            memoryLog.clear();
-            memCapacityReached = false;
-        }
-        sendNotification(new Notification(MEMORY_LOG_CLEARED,
-                objectName,
-                getNextSeqNumber(),"memory log cleared"));
-    }
-
-    // Clears the log file.
-    //
-    private void clearLogFile() throws IOException {
-        // simply force the creation of a new log file.
-        checkLogFile(getLogFileName(),fileCapacity,true);
-    }
-
-    // Log a record to the memory log. Send a notification if the
-    // maximum capacity of the memory log is reached.
-    //
-    private void logToMemory(ResultRecord record) {
-
-        final boolean before = memCapacityReached;
-        final boolean after;
-        synchronized(this) {
-            memoryLog.add(record);
-            after = memCapacityReached;
-        }
-        if (before==false && after==true)
-            sendNotification(new Notification(MEMORY_LOG_MAX_CAPACITY,
-                    objectName,
-                    getNextSeqNumber(),"memory log capacity reached"));
-    }
-
-
-    // Log a record to the memory log. Send a notification if the
-    // maximum capacity of the memory log is reached.
-    //
-    private void logToFile(ResultRecord record) throws IOException {
-        final String basename;
-        final long   maxRecords;
-        synchronized (this) {
-            if (logFile == null) return;
-            basename = getLogFileName(false);
-            maxRecords = fileCapacity;
-        }
-
-        // Get the stream into which we should log.
-        final OutputStream stream =
-                checkLogFile(basename,maxRecords,false);
-
-        // logging to file now disabled - too bad.
-        if (stream == null) return;
-
-        synchronized (this) {
-            try {
-                XmlConfigUtils.write(record,stream,true);
-                stream.flush();
-                // don't increment logCount if we were not logging in logStream.
-                if (stream == logStream) logCount++;
-            } catch (JAXBException x) {
-                final IllegalArgumentException iae =
-                        new IllegalArgumentException("bad record",x);
-                LOG.finest("Failed to log record: "+x);
-                throw iae;
-            }
-        }
-    }
-
-    /**
-     * The notification type which indicates that the log file was switched:
-     * <i>com.sun.jmx.examples.scandir.log.file.switched</i>.
-     * The message contains the name of the new file (or null if log to file
-     * is now disabled).
-     **/
-    public final static String LOG_FILE_CHANGED =
-            "com.sun.jmx.examples.scandir.log.file.switched";
-
-    /**
-     * The notification type which indicates that the memory log capacity has
-     * been reached:
-     * <i>com.sun.jmx.examples.scandir.log.memory.full</i>.
-     **/
-    public final static String MEMORY_LOG_MAX_CAPACITY =
-            "com.sun.jmx.examples.scandir.log.memory.full";
-
-    /**
-     * The notification type which indicates that the memory log was
-     * cleared:
-     * <i>com.sun.jmx.examples.scandir.log.memory.cleared</i>.
-     **/
-    public final static String MEMORY_LOG_CLEARED =
-            "com.sun.jmx.examples.scandir.log.memory.cleared";
-
-    /**
-     * This MBean emits three kind of notifications:
-     * <pre>
-     *    <i>com.sun.jmx.examples.scandir.log.file.switched</i>
-     *    <i>com.sun.jmx.examples.scandir.log.memory.full</i>
-     *    <i>com.sun.jmx.examples.scandir.log.memory.cleared</i>
-     * </pre>
-     **/
-    public MBeanNotificationInfo[] getNotificationInfo() {
-        return new MBeanNotificationInfo[] {
-            new MBeanNotificationInfo(new String[] {
-                LOG_FILE_CHANGED},
-                    Notification.class.getName(),
-                    "Emitted when the log file is switched")
-                    ,
-            new MBeanNotificationInfo(new String[] {
-                MEMORY_LOG_MAX_CAPACITY},
-                    Notification.class.getName(),
-                    "Emitted when the memory log capacity is reached")
-                    ,
-            new MBeanNotificationInfo(new String[] {
-                MEMORY_LOG_CLEARED},
-                    Notification.class.getName(),
-                    "Emitted when the memory log is cleared")
-        };
-    }
-
-    // Return the name of the log file, or null if logging to file is
-    // disabled.
-    private String getLogFileName(boolean absolute) {
-        synchronized (this) {
-            if (logFile == null) return null;
-            if (absolute) return logFile.getAbsolutePath();
-            return logFile.getPath();
-        }
-    }
-
-    // This method is be called by the ScanManagerMXBean when a configuration
-    // is applied.
-    //
-    void setConfig(ResultLogConfig logConfigBean) throws IOException {
-        if (logConfigBean == null)
-            throw new IllegalArgumentException("logConfigBean is null");
-        synchronized (this) {
-            config = logConfigBean;
-            setMemoryLogCapacity(config.getMemoryMaxRecords());
-        }
-        final String filename = config.getLogFileName();
-        final String logname  = getLogFileName(false);
-        if ((filename != null && !filename.equals(logname))
-        || (filename == null && logname != null)) {
-            newLogFile(config.getLogFileName(),
-                    config.getLogFileMaxRecords());
-        } else {
-            setLogFileCapacity(config.getLogFileMaxRecords());
-        }
-    }
-
-    // This method is called by the ScanManagerMXBean when
-    // applyCurrentResultLogConfig() is called.
-    //
-    ResultLogConfig getConfig() {
-        return config;
-    }
-
-
-    // Set by preRegister().
-    private MBeanServer mbeanServer;
-    private ObjectName objectName;
-
-
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ResultLogManagerMXBean.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,257 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import com.sun.jmx.examples.scandir.config.ResultRecord;
-import java.io.IOException;
-import javax.management.InstanceNotFoundException;
-
-/**
- * The <code>ResultLogManagerMXBean</code> is in charge of managing result logs.
- * {@link DirectoryScanner DirectoryScanners} can be configured to log a
- * {@link ResultRecord} whenever they take action upon a file that
- * matches their set of matching criteria.
- * The <code>ResultLogManagerMXBean</code> is responsible for storing these
- * results in its result logs.
- * <p>The <code>ResultLogManagerMXBean</code>
- * will let you interactively clear these result logs, change their
- * capacity, and decide where (memory or file or both) the
- * {@link ResultRecord ResultRecords} should be stored.
- * <p>The memory log is useful in so far that its content can be interactively
- * returned by the <code>ResultLogManagerMXBean</code>.
- * The file log doesn't have this facility.
- * <p>The result logs are intended to be used by e.g. an offline program that
- * would take some actions on the files that were matched by the scanners
- * criteria:
- * <p>The <i>scandir</i> application could be configured to only produce logs
- * (i.e. takes no action but logging the matching files), and the real
- * action (e.g. mail the result log to the engineer which maintains the lab,
- * or parse the log and prepare and send a single mail to the matching
- * files owners, containing the list of file he/she should consider deleting)
- * could be performed by such another program/module.
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public interface ResultLogManagerMXBean {
-
-    /**
-     * Creates a new log file in which to store results.
-     * <p>When this method is called, the {@link ResultLogManager} will stop
-     * logging in its current log file and use the new specified file instead.
-     * If that file already exists, it will be renamed by appending a '~' to
-     * its name, and a new empty file with the name specified by
-     * <var>basename</var> will be created.
-     * </p>
-     * <p>Calling this method has no side effect on the {@link
-     * com.sun.jmx.examples.scandir.config.ScanManagerConfig#getInitialResultLogConfig
-     * InitialResultLogConfig} held in the {@link ScanDirConfigMXBean}
-     * configuration. To apply these new values to the
-     * {@link ScanDirConfigMXBean}
-     * configuration, you must call {@link
-     * ScanManagerMXBean#applyCurrentResultLogConfig
-     * ScanManagerMXBean.applyCurrentResultLogConfig}.
-     *<p>
-     * @param basename The name of the new log file. This will be the
-     *        new name returned by {@link #getLogFileName}.
-     * @param maxRecord maximum number of records to log in the specified file
-     *        before creating a new file. <var>maxRecord</var> will be the
-     *        new value returned by {@link #getLogFileCapacity}.
-     *        When that maximum number of
-     *        records is reached the {@link ResultLogManager} will rename
-     *        the file by appending a '~' to its name, and a new empty
-     *        log file will be created.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void newLogFile(String basename, long maxRecord)
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Logs a result record to the active result logs (memory,file,both,or none)
-     * depending on how this MBean is currently configured.
-     * @see #getLogFileName()
-     * @see #getMemoryLogCapacity()
-     * @param record The result record to log.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     */
-    public void log(ResultRecord record)
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Gets the name of the current result log file.
-     * <p><code>null</code> means that no log file is configured: logging
-     * to file is disabled.
-     * </p>
-     * @return The name of the current result log file, or <code>null</code>
-     *         if logging to file is disabled.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public String getLogFileName()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Gets the whole content of the memory log. This cannot exceed
-     * {@link #getMemoryLogCapacity} records.
-     *
-     * @return the whole content of the memory log.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public ResultRecord[] getMemoryLog()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Gets the maximum number of records that can be logged in the
-     * memory log.
-     * <p>
-     * A non positive value - <code>0</code> or negative - means that
-     * logging in memory is disabled.
-     * </p>
-     * <p>The memory log is a FIFO: when its maximum capacity is reached, its
-     *    head element is removed to make place for a new element at its tail.
-     * </p>
-     * @return The maximum number of records that can be logged in the
-     * memory log. A value {@code <= 0} means that logging in memory is
-     * disabled.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public int getMemoryLogCapacity()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Sets the maximum number of records that can be logged in the
-     * memory log.
-     * <p>The memory log is a FIFO: when its maximum capacity is reached, its
-     *    head element is removed to make place for a new element at its tail.
-     * </p>
-     * @param size The maximum number of result records that can be logged in the memory log.  <p>
-     * A non positive value - <code>0</code> or negative - means that
-     * logging in memory is disabled. It will also have the side
-     * effect of clearing the memory log.
-     * </p>
-     *
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     */
-    public void setMemoryLogCapacity(int size)
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Sets the maximum number of records that can be logged in the result log
-     * file.
-     * <p>When that maximum number of
-     * records is reached the {@link ResultLogManager} will rename
-     * the result log file by appending a '~' to its name, and a new empty
-     * log file will be created.
-     * </p>
-     * <p>If logging to file is disabled calling this method
-     *    is irrelevant.
-     * </p>
-     * @param maxRecord maximum number of records to log in the result log file.
-     * @see #getLogFileName()
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void setLogFileCapacity(long maxRecord)
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Gets the maximum number of records that can be logged in the result log
-     * file.
-     * <p>When that maximum number of
-     * records is reached the {@link ResultLogManager} will rename
-     * the result log file by appending a '~' to its name, and a new empty
-     * log file will be created.
-     * </p>
-     * @see #getLogFileName()
-     * @return The maximum number of records that can be logged in the result
-     *         log file.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public long getLogFileCapacity()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Gets The number of records that have been logged in the
-     * current result log file. This will always be less than
-     * {@link #getLogFileCapacity()}.
-     * @return The number of records in the
-     *         current result log file.
-     *
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public long getLoggedCount()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Clears the memory log and result log file.
-     *
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void clearLogs()
-        throws IOException, InstanceNotFoundException;
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanDirAgent.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Logger;
-import javax.management.JMException;
-import javax.management.Notification;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationListener;
-
-/**
- * <p>
- * The <code>ScanDirAgent</code> is the Agent class for the <i>scandir</i>
- * application.
- * This class contains the {@link #main} method to start a standalone
- * <i>scandir</i> application.
- * </p>
- * <p>
- * The {@link #main main()} method simply registers a {@link
- * ScanManagerMXBean} in the platform MBeanServer - see {@link #init init},
- * and then waits for someone to call {@link ScanManagerMXBean#close close}
- * on that MBean.
- * </p>
- * <p>
- * When the {@link ScanManagerMXBean} state is switched to {@link
- * ScanManagerMXBean.ScanState#CLOSED CLOSED}, {@link #cleanup cleanup} is
- * called, the {@link ScanManagerMXBean} is unregistered, and the application
- * terminates (i.e. the main thread completes).
- * </p>
- * @author Sun Microsystems, 2006 - All rights reserved.
- **/
-public class ScanDirAgent {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(ScanDirAgent.class.getName());
-
-    // Proxy to the ScanManagerMXBean - created by init();
-    //
-    private volatile ScanManagerMXBean proxy = null;
-
-    // A queue to put received Notifications.
-    //
-    private final BlockingQueue<Notification> queue;
-
-    // A listener that will put notifications into the queue.
-    //
-    private final NotificationListener listener;
-
-    /**
-     * Creates a new instance of ScanDirAgent
-     * You will need to call {@link #init()} later on in order to initialize
-     * the application.
-     * @see #main
-     **/
-    public ScanDirAgent() {
-        // Initialize the notification queue
-        queue = new LinkedBlockingQueue<Notification>();
-
-        // Creates the listener.
-        listener = new NotificationListener() {
-            public void handleNotification(Notification notification,
-                                           Object handback) {
-                try {
-                    // Just put the received notification in the queue.
-                    // It will be consumed later on by 'waitForClose()'
-                    //
-                    LOG.finer("Queuing received notification "+notification);
-                    queue.put(notification);
-                } catch (InterruptedException ex) {
-                    // OK
-                }
-            }
-        };
-    }
-
-    /**
-     * Initialize the application by registering a ScanManagerMXBean in
-     * the platform MBeanServer
-     * @throws java.io.IOException Registration failed for communication-related reasons.
-     * @throws javax.management.JMException Registration failed for JMX-related reasons.
-     */
-    public void init() throws IOException, JMException {
-
-        // Registers the ScanManagerMXBean singleton in the
-        // platform MBeanServer
-        //
-        proxy = ScanManager.register();
-
-        // Registers a NotificationListener with the ScanManagerMXBean in
-        // order to receive state changed notifications.
-        //
-        ((NotificationEmitter)proxy).addNotificationListener(listener,null,null);
-    }
-
-    /**
-     * Cleanup after close: unregister the ScanManagerMXBean singleton.
-     * @throws java.io.IOException Cleanup failed for communication-related reasons.
-     * @throws javax.management.JMException Cleanup failed for JMX-related reasons.
-     */
-    public void cleanup() throws IOException, JMException {
-        try {
-            ((NotificationEmitter)proxy).
-                    removeNotificationListener(listener,null,null);
-        } finally {
-            ManagementFactory.getPlatformMBeanServer().
-                unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-        }
-    }
-
-    /**
-     * Wait for someone to call 'close()' on the ScanManagerMXBean singleton.
-     * Every time its state changes, the ScanManagerMXBean emits a notification.
-     * We don't rely on the notification content (if we were using a remote
-     * connection, we could miss some notifications) - we simply use the
-     * state change notifications to react more quickly to state changes.
-     * We do so simply by polling the {@link BlockingQueue} in which our
-     * listener is pushing notifications, and checking the ScanManagerMXBean
-     * state every time that a notification is received.
-     * <p>
-     * We can do so because we know that once the ScanManagerMXBean state is
-     * switched to 'CLOSED', it will remain 'CLOSED' whatsoever. <br>
-     * Therefore we don't need to concern ourselves with the possibility of
-     * missing the window in which the ScanManagerMXBean state's will be
-     * CLOSED, because that particular window stays opened forever.
-     * <p>
-     * Had we wanted to wait for 'RUNNING', we would have needed to apply
-     * a different strategy - e.g. by taking into account the actual content
-     * of the state changed notifications we received.
-     * @throws java.io.IOException wait failed - a communication problem occurred.
-     * @throws javax.management.JMException wait failed - the MBeanServer threw an exception.
-     */
-    public void waitForClose() throws IOException, JMException {
-
-        // Wait until state is closed
-        while(proxy.getState() != ScanState.CLOSED ) {
-            try {
-                // Wake up at least every 30 seconds - if we missed a
-                // notification - we will at least get a chance to
-                // call getState(). 30 seconds is obviously quite
-                // arbitrary - if this were a real daemon - id'be tempted
-                // to wait 30 minutes - knowing that any incoming
-                // notification will wake me up anyway.
-                // Note: we simply use the state change notifications to
-                // react more quickly to state changes: see javadoc above.
-                //
-                queue.poll(30,TimeUnit.SECONDS);
-            } catch (InterruptedException ex) {
-                // OK
-            }
-        }
-    }
-
-    /**
-     * The agent's main: {@link #init registers} a {@link ScanManagerMXBean},
-     * {@link #waitForClose waits} until its state is {@link
-     * ScanManagerMXBean.ScanState#CLOSED CLOSED}, {@link #cleanup cleanup}
-     * and exits.
-     * @param args the command line arguments - ignored
-     * @throws java.io.IOException A communication problem occurred.
-     * @throws javax.management.JMException A JMX problem occurred.
-     */
-    public static void main(String[] args)
-        throws IOException, JMException {
-        System.out.println("Initializing ScanManager...");
-        final ScanDirAgent agent = new ScanDirAgent();
-        agent.init();
-        try {
-            System.out.println("Waiting for ScanManager to close...");
-            agent.waitForClose();
-        } finally {
-            System.out.println("Cleaning up...");
-            agent.cleanup();
-        }
-    }
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanDirClient.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.HashMap;
-import java.util.Map;
-import javax.management.MBeanServerConnection;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-import javax.rmi.ssl.SslRMIClientSocketFactory;
-
-/**
- * The ScanDirClient class is a very simple programmatic client example
- * which is able to connect to a secured JMX <i>scandir</i> application.
- * <p>The program initialize the connection environment map with the
- * appropriate properties and credentials, and then connects to the
- * secure JMX <i>scandir</i> daemon.</p>
- * <p>It gets the application's current configuration and prints it on
- * its <code>System.out</code>.</p>
- * <p>The {@link #main main} method takes two arguments: the host on which
- * the server is running (localhost), and the port number
- * that was configured to start the server RMI Connector (4545).
- * </p>
- * @author Sun Microsystems, 2006 - All rights reserved.
- **/
-public class ScanDirClient {
-
-    // This class has only a main.
-    private ScanDirClient() { }
-
-    /**
-     * The usage string for the ScanDirClient.
-     */
-    public static final String USAGE = ScanDirClient.class.getSimpleName() +
-            " <server-host> <rmi-port-number>";
-
-    /**
-     * Connects to a secured JMX <i>scandir</i> application.
-     * @param args The {@code main} method takes two parameters:
-     *        <ul>
-     *        <li>args[0] must be the server's host</li>
-     *        <li>args[1] must be the rmi port number at which the
-     *        JMX <i>scandir</i> daemon is listening for connections
-     *        - that is, the port number of its JMX RMI Connector which
-     *        was configured in {@code management.properties}
-     *        </li>
-     *        <ul>
-     **/
-    public static void main(String[] args) {
-        try {
-            // Check args
-            //
-            if (args==null || args.length!=2) {
-                System.err.println("Bad number of arguments: usage is: \n\t" +
-                        USAGE);
-                System.exit(1);
-            }
-            try {
-                InetAddress.getByName(args[0]);
-            } catch (UnknownHostException x) {
-                System.err.println("No such host: " + args[0]+
-                            "\n usage is: \n\t" + USAGE);
-                System.exit(2);
-            } catch (Exception x) {
-                System.err.println("Bad address: " + args[0]+
-                            "\n usage is: \n\t" + USAGE);
-                System.exit(2);
-            }
-            try {
-                if (Integer.parseInt(args[1]) <= 0) {
-                    System.err.println("Bad port value: " + args[1]+
-                            "\n usage is: \n\t" + USAGE);
-                    System.exit(2);
-                }
-            } catch (Exception x) {
-                System.err.println("Bad argument: " + args[1]+
-                        "\n usage is: \n\t" + USAGE);
-                System.exit(2);
-            }
-
-            // Create an environment map to hold connection properties
-            // like credentials etc... We will later pass this map
-            // to the JMX Connector.
-            //
-            System.out.println("\nInitialize the environment map");
-            final Map<String,Object> env = new HashMap<String,Object>();
-
-            // Provide the credentials required by the server
-            // to successfully perform user authentication
-            //
-            final String[] credentials = new String[] { "guest" , "guestpasswd" };
-            env.put("jmx.remote.credentials", credentials);
-
-            // Provide the SSL/TLS-based RMI Client Socket Factory required
-            // by the JNDI/RMI Registry Service Provider to communicate with
-            // the SSL/TLS-protected RMI Registry
-            //
-            env.put("com.sun.jndi.rmi.factory.socket",
-                    new SslRMIClientSocketFactory());
-
-            // Create the RMI connector client and
-            // connect it to the RMI connector server
-            // args[0] is the server's host - localhost
-            // args[1] is the secure server port - 4545
-            //
-            System.out.println("\nCreate the RMI connector client and " +
-                    "connect it to the RMI connector server");
-            final JMXServiceURL url = new JMXServiceURL(
-                    "service:jmx:rmi:///jndi/rmi://"+args[0]+":"+args[1] +
-                    "/jmxrmi");
-
-            System.out.println("Connecting to: "+url);
-            final JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
-
-            // Get an MBeanServerConnection
-            //
-            System.out.println("\nGet the MBeanServerConnection");
-            final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
-
-            // Create a proxy for the ScanManager MXBean
-            //
-            final ScanManagerMXBean proxy =
-                    ScanManager.newSingletonProxy(mbsc);
-
-            // Get the ScanDirConfig MXBean from the scan manager
-            //
-            System.out.println(
-                    "\nGet ScanDirConfigMXBean from ScanManagerMXBean");
-            final ScanDirConfigMXBean configMBean =
-                    proxy.getConfigurationMBean();
-
-            // Print the scan dir configuration
-            //
-            System.out.println(
-                    "\nGet 'Configuration' attribute on ScanDirConfigMXBean");
-            System.out.println("\nConfiguration:\n" +
-                    configMBean.getConfiguration());
-
-            // Try to invoke the "close" method on the ScanManager MXBean.
-            //
-            // Should get a SecurityException as the user "guest" doesn't
-            // have readwrite access.
-            //
-            System.out.println("\nInvoke 'close' on ScanManagerMXBean");
-            try {
-                proxy.close();
-            } catch (SecurityException e) {
-                System.out.println("\nGot expected security exception: " + e);
-            }
-
-            // Close MBeanServer connection
-            //
-            System.out.println("\nClose the connection to the server");
-            jmxc.close();
-            System.out.println("\nBye! Bye!");
-        } catch (Exception e) {
-            System.out.println("\nGot unexpected exception: " + e);
-            e.printStackTrace();
-            System.exit(3);
-        }
-    }
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanDirConfig.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,440 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import static com.sun.jmx.examples.scandir.ScanManager.getNextSeqNumber;
-import static com.sun.jmx.examples.scandir.ScanDirConfigMXBean.SaveState.*;
-import com.sun.jmx.examples.scandir.config.XmlConfigUtils;
-import com.sun.jmx.examples.scandir.config.DirectoryScannerConfig;
-import com.sun.jmx.examples.scandir.config.FileMatch;
-import com.sun.jmx.examples.scandir.config.ScanManagerConfig;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Date;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.management.*;
-import javax.xml.bind.JAXBException;
-
-/**
- * <p>The <code>ScanDirConfig</code> MBean is in charge of the
- * <i>scandir</i> application configuration.
- * </p>
- * <p>The <code>ScanDirConfig</code> MBean is able to
- * load and save the <i>scandir</i> application configuration to and from an
- * XML file.
- * </p>
- * <p>
- * It will let you also interactively modify that configuration, which you
- * can later save to the file, by calling {@link #save}, or discard, by
- * reloading the file without saving - see {@link #load}.
- * </p>
- * <p>
- * There can be as many <code>ScanDirConfigMXBean</code> registered
- * in the MBeanServer as you like, but only one of them will be identified as
- * the current configuration of the {@link ScanManagerMXBean}.
- * You can switch to another configuration by calling {@link
- * ScanManagerMXBean#setConfigurationMBean
- * ScanManagerMXBean.setConfigurationMBean}.
- * </p>
- * <p>
- * Once the current configuration has been loaded (by calling {@link #load})
- * or modified (by calling one of {@link #addDirectoryScanner
- * addDirectoryScanner}, {@link #removeDirectoryScanner removeDirectoryScanner}
- * or {@link #setConfiguration setConfiguration}) it can be pushed
- * to the {@link ScanManagerMXBean} by calling {@link
- * ScanManagerMXBean#applyConfiguration
- * ScanManagerMXBean.applyConfiguration(true)} -
- * <code>true</code> means that we apply the configuration from memory,
- * without first reloading the file.
- * </p>
- * <p>
- * The <code>ScanDirConfig</code> uses the XML annotated Java Beans defined
- * in the {@link com.sun.jmx.examples.scandir.config} package.
- * </p>
- * <p>
- * <u>Note:</u> The <code>ScanDirConfig</code> should probably use
- * {@code java.nio.channels.FileLock} and lock its configuration file so that
- * two <code>ScanDirConfig</code> object do not share the same file, but it
- * doesn't. Feel free to improve the application in that way.
- * </p>
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public class ScanDirConfig extends NotificationBroadcasterSupport
-        implements ScanDirConfigMXBean, MBeanRegistration {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(ScanDirConfig.class.getName());
-
-    // We will emit a notification when the save state of this object
-    // chenges. We use directly the base notification class, with a
-    // notification type that indicates the new state at which the
-    // object has arrived.
-    //
-    // All these notification types will have the same prefix, which is
-    // 'com.sun.jmx.examples.scandir.config'.
-    //
-    private final static String NOTIFICATION_PREFIX =
-            ScanManagerConfig.class.getPackage().getName();
-
-    /**
-     * The <i>com.sun.jmx.examples.scandir.config.saved</i> notification
-     * indicates that the configuration data was saved.
-     **/
-    public final static String NOTIFICATION_SAVED =
-            NOTIFICATION_PREFIX+".saved";
-    /**
-     * The <i>com.sun.jmx.examples.scandir.config.loaded</i> notification
-     * indicates that the configuration data was loaded.
-     **/
-    public final static String NOTIFICATION_LOADED =
-            NOTIFICATION_PREFIX+".loaded";
-
-    /**
-     * The <i>com.sun.jmx.examples.scandir.config.modified</i> notification
-     * indicates that the configuration data was modified.
-     **/
-    public final static String NOTIFICATION_MODIFIED =
-            NOTIFICATION_PREFIX+".modified";
-
-    // The array of MBeanNotificationInfo that will be exposed in the
-    // ScanDirConfigMXBean MBeanInfo.
-    // We will pass this array to the NotificationBroadcasterSupport
-    // constructor.
-    //
-    private static MBeanNotificationInfo[] NOTIFICATION_INFO = {
-        new MBeanNotificationInfo(
-                new String[] {NOTIFICATION_SAVED},
-                Notification.class.getName(),
-                "Emitted when the configuration is saved"),
-        new MBeanNotificationInfo(
-                new String[] {NOTIFICATION_LOADED},
-                Notification.class.getName(),
-                "Emitted when the configuration is loaded"),
-        new MBeanNotificationInfo(
-                new String[] {NOTIFICATION_MODIFIED},
-                Notification.class.getName(),
-                "Emitted when the configuration is modified"),
-    };
-
-     // The ScanDirConfigMXBean configuration data.
-    private volatile ScanManagerConfig config;
-
-    // The name of the configuration file
-    private String filename = null;
-
-    // The name of this configuration. This is usually both equal to
-    // config.getName() and objectName.getKeyProperty(name).
-    private volatile String configname = null;
-
-    // This object save state. CREATED is the initial state.
-    //
-    private volatile SaveState status = CREATED;
-
-    /**
-     * Creates a new {@link ScanDirConfigMXBean}.
-     * <p>{@code ScanDirConfigMXBean} can be created by the {@link
-     * ScanManagerMXBean}, or directly by a remote client, using
-     * {@code createMBean} or {@code registerMBean}.
-     * </p>
-     * <p>{@code ScanDirConfigMXBean} created by the {@link
-     * ScanManagerMXBean} will be unregistered by the
-     * {@code ScanManagerMXBean}. {@code ScanDirConfigMXBean} created
-     * directly by a remote client will not be unregistered by the
-     * {@code ScanManagerMXBean} - this will remain to the responsibility of
-     * the code/client that created them.
-     * </p>
-     * <p>This object is created empty, you should call load() if you want it
-     *    to load its data from the configuration file.
-     * </p>
-     * @param  filename The configuration file used by this MBean.
-     *         Can be null (in which case load() and save() will fail).
-     *         Can point to a file that does not exists yet (in which case
-     *         load() will fail if called before save(), and save() will
-     *         attempt to create that file). Can point to an existing file,
-     *         in which case load() will load that file and save() will save
-     *         to that file.
-     *
-     **/
-    public ScanDirConfig(String filename) {
-        this(filename,null);
-    }
-
-    /**
-     * Create a new ScanDirConfig MBean with an initial configuration.
-     * @param filename The name of the configuration file.
-     * @param initialConfig an initial configuration.
-     **/
-    public ScanDirConfig(String filename, ScanManagerConfig initialConfig) {
-        super(NOTIFICATION_INFO);
-        this.filename = filename;
-        this.config = initialConfig;
-    }
-
-
-    // see ScanDirConfigMXBean
-    public void load() throws IOException {
-        if (filename == null)
-            throw new UnsupportedOperationException("load");
-
-        synchronized(this) {
-            config = new XmlConfigUtils(filename).readFromFile();
-            if (configname != null) config = config.copy(configname);
-            else configname = config.getName();
-
-            status=LOADED;
-        }
-        sendNotification(NOTIFICATION_LOADED);
-    }
-
-    // see ScanDirConfigMXBean
-    public void save() throws IOException {
-        if (filename == null)
-            throw new UnsupportedOperationException("load");
-        synchronized (this) {
-            new XmlConfigUtils(filename).writeToFile(config);
-            status = SAVED;
-        }
-        sendNotification(NOTIFICATION_SAVED);
-    }
-
-    // see ScanDirConfigMXBean
-    public ScanManagerConfig getConfiguration() {
-        synchronized (this) {
-            return XmlConfigUtils.xmlClone(config);
-        }
-    }
-
-
-    // sends a notification indicating the new save state.
-    private void sendNotification(String type) {
-        final Object source = (objectName==null)?this:objectName;
-        final Notification n = new Notification(type,source,
-                getNextSeqNumber(),
-                "The configuration is "+
-                type.substring(type.lastIndexOf('.')+1));
-        sendNotification(n);
-    }
-
-
-    /**
-     * 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 will
-     * try to guess its MBean name by examining its configuration data.
-     * If its configuration data is null (nothing was provided in the
-     * constructor) or doesn't contain a name, this method returns {@code null},
-     * and registration will fail.
-     * <p>
-     * Otherwise, if {@code name} wasn't {@code null} or if a default name could
-     * be constructed, the name of the configuration will be set to
-     * the value of the ObjectName's {@code name=} key, and the configuration
-     * data will always be renamed to reflect this change.
-     * </p>
-     *
-     * @return The name under which the MBean is to be registered.
-     * @throws Exception This exception will be caught by the MBean server and
-     * re-thrown as an MBeanRegistrationException.
-     */
-    public ObjectName preRegister(MBeanServer server, ObjectName name)
-        throws Exception {
-        if (name == null) {
-            if (config == null) return null;
-            if (config.getName() == null) return null;
-            name = ScanManager.
-                    makeMBeanName(ScanDirConfigMXBean.class,config.getName());
-        }
-        objectName = name;
-        mbeanServer = server;
-        synchronized (this) {
-            configname = name.getKeyProperty("name");
-            if (config == null) config = new ScanManagerConfig(configname);
-            else config = config.copy(configname);
-        }
-        return name;
-    }
-
-    /**
-     * Allows the MBean to perform any operations needed after having
-     * been registered in the MBean server or after the registration has
-     * failed.
-     * <p>This implementation does nothing</p>
-     * @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) {
-        // Nothing to do here.
-    }
-
-    /**
-     * Allows the MBean to perform any operations it needs before being
-     * unregistered by the MBean server.
-     * <p>This implementation does nothing</p>
-     * @throws Exception This exception will be caught by the MBean server and
-     * re-thrown as an MBeanRegistrationException.
-     */
-    public void preDeregister() throws Exception {
-        // Nothing to do here.
-    }
-
-    /**
-     * Allows the MBean to perform any operations needed after having been
-     * unregistered in the MBean server.
-     * <p>This implementation does nothing</p>
-     */
-    public void postDeregister() {
-        // Nothing to do here.
-    }
-
-    // see ScanDirConfigMXBean
-    public String getConfigFilename() {
-        return filename;
-    }
-
-    // see ScanDirConfigMXBean
-    public void setConfiguration(ScanManagerConfig config) {
-        synchronized (this) {
-            if (config == null) {
-                this.config = null;
-                return;
-            }
-
-            if (configname == null)
-                configname = config.getName();
-
-            this.config = config.copy(configname);
-            status = MODIFIED;
-        }
-        sendNotification(NOTIFICATION_MODIFIED);
-    }
-
-    // see ScanDirConfigMXBean
-    public DirectoryScannerConfig
-            addDirectoryScanner(String name, String dir, String filePattern,
-                                long sizeExceedsMaxBytes, long sinceLastModified) {
-         final DirectoryScannerConfig scanner =
-                 new DirectoryScannerConfig(name);
-         scanner.setRootDirectory(dir);
-         if (filePattern!=null||sizeExceedsMaxBytes>0||sinceLastModified>0) {
-            final FileMatch filter = new FileMatch();
-            filter.setFilePattern(filePattern);
-            filter.setSizeExceedsMaxBytes(sizeExceedsMaxBytes);
-            if (sinceLastModified > 0)
-                filter.setLastModifiedBefore(new Date(new Date().getTime()
-                                                -sinceLastModified));
-            scanner.addIncludeFiles(filter);
-         }
-         synchronized (this) {
-            config.putScan(scanner);
-            status = MODIFIED;
-         }
-         LOG.fine("config: "+config);
-         sendNotification(NOTIFICATION_MODIFIED);
-         return scanner;
-    }
-
-    // see ScanDirConfigMXBean
-    public DirectoryScannerConfig removeDirectoryScanner(String name)
-        throws IOException, InstanceNotFoundException {
-        final DirectoryScannerConfig scanner;
-        synchronized (this) {
-            scanner = config.removeScan(name);
-            if (scanner == null)
-                throw new IllegalArgumentException(name+": scanner not found");
-            status = MODIFIED;
-        }
-        sendNotification(NOTIFICATION_MODIFIED);
-        return scanner;
-    }
-
-    // see ScanDirConfigMXBean
-    public SaveState getSaveState() {
-        return status;
-    }
-
-    // These methods are used by ScanManager to guess a configuration name from
-    // a configuration filename.
-    //
-    static String DEFAULT = "DEFAULT";
-
-    private static String getBasename(String name) {
-        final int dot = name.indexOf('.');
-        if (dot<0)  return name;
-        if (dot==0) return getBasename(name.substring(1));
-        return name.substring(0,dot);
-    }
-
-    static String guessConfigName(String configFileName,String defaultFile) {
-        try {
-            if (configFileName == null) return DEFAULT;
-            final File f = new File(configFileName);
-            if (f.canRead()) {
-                final String confname = XmlConfigUtils.read(f).getName();
-                if (confname != null && confname.length()>0) return confname;
-            }
-            final File f2 = new File(defaultFile);
-            if (f.equals(f2)) return DEFAULT;
-            final String guess = getBasename(f.getName());
-            if (guess == null) return DEFAULT;
-            if (guess.length()==0) return DEFAULT;
-            return guess;
-        } catch (Exception x) {
-            return DEFAULT;
-        }
-    }
-
-    // Set by preRegister()
-    private volatile MBeanServer mbeanServer;
-    private volatile ObjectName objectName;
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanDirConfigMXBean.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,351 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import com.sun.jmx.examples.scandir.config.DirectoryScannerConfig;
-import com.sun.jmx.examples.scandir.config.ScanManagerConfig;
-import java.io.IOException;
-import javax.management.InstanceNotFoundException;
-
-/**
- * <p>The <code>ScanDirConfigMXBean</code> is in charge of the
- * <i>scandir</i> application configuration.
- * </p>
- * <p>The <code>ScanDirConfigMXBean</code> is an MBean which is able to
- * load and save the <i>scandir</i> application configuration to and from an
- * XML file.
- * </p>
- * <p>
- * It will let you also interactively modify that configuration, which you
- * can later save to the file, by calling {@link #save}, or discard, by
- * reloading the file without saving - see {@link #load}.
- * </p>
- * <p>
- * There can be as many <code>ScanDirConfigMXBean</code> registered
- * in the MBeanServer as you like, but only one of them will be identified as
- * the current configuration of the {@link ScanManagerMXBean}.
- * You can switch to another configuration by calling {@link
- * ScanManagerMXBean#setConfigurationMBean
- * ScanManagerMXBean.setConfigurationMBean}.
- * </p>
- * <p>
- * Once the current configuration has been loaded (by calling {@link #load})
- * or modified (by calling one of {@link #addDirectoryScanner
- * addDirectoryScanner}, {@link #removeDirectoryScanner removeDirectoryScanner}
- * or {@link #setConfiguration setConfiguration}) it can be pushed
- * to the {@link ScanManagerMXBean} by calling {@link
- * ScanManagerMXBean#applyConfiguration
- * ScanManagerMXBean.applyConfiguration(true)} -
- * <code>true</code> means that we apply the configuration from memory,
- * without first reloading the file.
- * </p>
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public interface ScanDirConfigMXBean {
-    /**
-     * This state tells whether the configuration reflected by the
-     * {@link ScanDirConfigMXBean} was loaded in memory, saved to the
-     * configuration file, or modified since last saved.
-     * Note that this state doesn't tell whether the configuration was
-     * applied by the {@link ScanManagerMXBean}.
-     **/
-    public enum SaveState {
-        /**
-         * Initial state: the {@link ScanDirConfigMXBean} is created, but
-         * neither {@link #load} or  {@link #save} was yet called.
-         **/
-        CREATED,
-
-        /**
-         * The configuration reflected by the {@link ScanDirConfigMXBean} has
-         * been loaded, but not modified yet.
-         **/
-        LOADED,
-
-        /**
-         * The configuration was modified. The modifications are held in memory.
-         * Call {@link #save} to save them to the file, or {@link #load} to
-         * reload the file and discard them.
-         **/
-        MODIFIED,
-
-        /**
-         * The configuration was saved.
-         **/
-        SAVED
-    };
-
-    /**
-     * Loads the configuration from the {@link
-     * #getConfigFilename configuration file}.
-     * <p>Any unsaved modification will be lost. The {@link #getSaveState state}
-     * is switched to {@link SaveState#LOADED LOADED}.
-     * </p>
-     * <p>
-     * This action has no effect on the {@link ScanManagerMXBean} until
-     * {@link ScanManagerMXBean#getConfigurationMBean ScanManagerMXBean}
-     * points to this MBean and {@link ScanManagerMXBean#applyConfiguration
-     * ScanManagerMXBean.applyConfiguration} is called.
-     * </p>
-     * @see #getSaveState()
-     * @throws IOException The configuration couldn't be loaded from the file,
-     *                     e.g. because the file doesn't exist or isn't
-     *                     readable.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void load()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Saves the configuration to the {@link
-     * #getConfigFilename configuration file}.
-     *
-     * <p>If the configuration file doesn't exists, this method will
-     *    attempt to create it. Otherwise, the existing file will
-     *    be renamed by appending a '~' to its name, and a new file
-     *    will be created, in which the configuration will be saved.
-     * The {@link #getSaveState state}
-     * is switched to {@link SaveState#SAVED SAVED}.
-     * </p>
-     * <p>
-     * This action has no effect on the {@link ScanManagerMXBean}.
-     * </p>
-     * @see #getSaveState()
-     *
-     * @throws IOException The configuration couldn't be saved to the file,
-     *                     e.g. because the file couldn't be created.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void save()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Gets the name of the configuration file.
-     * <p>If the configuration file doesn't exists, {@link #load} will fail
-     * and {@link #save} will attempt to create the file.
-     * </p>
-     *
-     * @return The configuration file name for this MBean.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public String getConfigFilename()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Gets the current configuration data.
-     * <p>
-     * This method returns the configuration data which is currently held
-     * in memory.
-     * </p>
-     * <p>Call {@link #load} to reload the data from the configuration
-     *    file, and {@link #save} to save the data to the configuration
-     *    file.
-     * </p>
-     * @see #getSaveState()
-     * @return The current configuration data in memory.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public ScanManagerConfig getConfiguration()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Sets the current configuration data.
-     * <p>
-     * This method replaces the configuration data in memory.
-     * The {@link #getSaveState state} is switched to {@link
-     * SaveState#MODIFIED MODIFIED}.
-     * </p>
-     * <p>Calling {@link #load} will reload the data from the configuration
-     *    file, and all modifications will be lost.
-     *    Calling {@link #save} will save the modified data to the configuration
-     *    file.
-     * </p>
-     * <p>
-     * This action has no effect on the {@link ScanManagerMXBean} until
-     * {@link ScanManagerMXBean#getConfigurationMBean ScanManagerMXBean}
-     * points to this MBean and {@link ScanManagerMXBean#applyConfiguration
-     * ScanManagerMXBean.applyConfiguration} is called.
-     * </p>
-     * @param config The new configuration data.
-     * @see #getSaveState()
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     */
-    public void setConfiguration(ScanManagerConfig config)
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Adds a new directory scanner to the current configuration data.
-     * <p>
-     * This method updates the configuration data in memory, adding
-     * a {@link DirectoryScannerConfig} to the {@link
-     * ScanManagerConfig#getScanList directory scanner list}.
-     * The {@link #getSaveState state} is switched to {@link
-     * SaveState#MODIFIED MODIFIED}.
-     * </p>
-     * <p>Calling {@link #load} will reload the data from the configuration
-     *    file, and all modifications will be lost.
-     *    Calling {@link #save} will save the modified data to the configuration
-     *    file.
-     * </p>
-     * <p>
-     * This action has no effect on the {@link ScanManagerMXBean} until
-     * {@link ScanManagerMXBean#getConfigurationMBean ScanManagerMXBean}
-     * points to this MBean and {@link ScanManagerMXBean#applyConfiguration
-     * ScanManagerMXBean.applyConfiguration} is called.
-     * </p>
-     * @param name A name for the new directory scanner. This is the value
-     *             that will be later used in the {@link DirectoryScannerMXBean}
-     *             ObjectName for the <code>name=</code> key.
-     * @param dir The root directory at which this scanner will start scanning.
-     * @param filePattern A {@link java.util.regex.Pattern regular expression}
-     *        to match against a selected file name.
-     * @param sizeExceedsMaxBytes Only file whose size exceeds that limit will
-     *        be selected. <code.0</code> or  a
-     *        negative value means no limit.
-     * @param sinceLastModified Select files which haven't been modified for
-     *        that number of milliseconds - i.e.
-     *        {@code sinceLastModified=3600000} will exclude files which
-     *        have been modified in the last hour.
-     *        The date of last modification is ignored if <code>0</code> or  a
-     *        negative value is provided.
-     * @see #getSaveState()
-     * @return The added <code>DirectoryScannerConfig</code>.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public DirectoryScannerConfig
-            addDirectoryScanner(String name, String dir, String filePattern,
-                                long sizeExceedsMaxBytes, long sinceLastModified)
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Removes a directory scanner from the current configuration data.
-     * <p>
-     * This method updates the configuration data in memory, removing
-     * a {@link DirectoryScannerConfig} from the {@link
-     * ScanManagerConfig#getScanList directory scanner list}.
-     * The {@link #getSaveState state} is switched to {@link
-     * SaveState#MODIFIED MODIFIED}.
-     * </p>
-     * <p>Calling {@link #load} will reload the data from the configuration
-     *    file, and all modifications will be lost.
-     *    Calling {@link #save} will save the modified data to the configuration
-     *    file.
-     * </p>
-     * <p>
-     * This action has no effect on the {@link ScanManagerMXBean} until
-     * {@link ScanManagerMXBean#getConfigurationMBean ScanManagerMXBean}
-     * points to this MBean and {@link ScanManagerMXBean#applyConfiguration
-     * ScanManagerMXBean.applyConfiguration} is called.
-     * </p>
-     * @param name The name of the new directory scanner. This is the value
-     *             that is used in the {@link DirectoryScannerMXBean}
-     *             ObjectName for the <code>name=</code> key.
-     * @return The removed <code>DirectoryScannerConfig</code>.
-     * @throws IllegalArgumentException if there's no directory scanner by
-     *         that name in the current configuration data.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public DirectoryScannerConfig
-            removeDirectoryScanner(String name)
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Gets the save state of the current configuration data.
-     * <p>
-     * {@link SaveState#CREATED CREATED} means that the configuration data was just
-     * created. It has not been loaded from the configuration file.
-     * Calling {@link #load} will load the data from the configuration file.
-     * Calling {@link #save} will write the empty data to the configuration
-     * file.
-     * </p>
-     * <p>
-     * {@link SaveState#LOADED LOADED} means that the configuration data
-     * was loaded from the configuration file.
-     * </p>
-     * <p>
-     * {@link SaveState#MODIFIED MODIFIED} means that the configuration data
-     * was modified since it was last loaded or saved.
-     * Calling {@link #load} will reload the data from the configuration file,
-     * and all modifications will be lost.
-     * Calling {@link #save} will write the modified data to the configuration
-     * file.
-     * </p>
-     * <p>
-     * {@link SaveState#SAVED SAVED} means that the configuration data
-     * was saved to the configuration file.
-     * </p>
-     * <p>
-     * This state doesn't indicate whether this MBean configuration data
-     * was {@link ScanManagerMXBean#applyConfiguration applied} by the
-     * {@link ScanManagerMXBean}.
-     * </p>
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     * @return The save state of the {@code ScanDirConfigMXBean}.
-     */
-    public SaveState getSaveState()
-        throws IOException, InstanceNotFoundException;
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanManager.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1160 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import static com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState.*;
-import com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState;
-import com.sun.jmx.examples.scandir.config.DirectoryScannerConfig;
-import com.sun.jmx.examples.scandir.config.ScanManagerConfig;
-import java.io.File;
-
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.management.AttributeChangeNotification;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMException;
-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.MalformedObjectNameException;
-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;
-
-/**
- * <p>
- * The <code>ScanManager</code> is responsible for applying a configuration,
- * starting and scheduling directory scans, and reporting application state.
- * </p>
- * <p>
- * The ScanManager MBean is a singleton MBean which controls
- * scan session. The ScanManager name is defined by
- * {@link #SCAN_MANAGER_NAME ScanManager.SCAN_MANAGER_NAME}.
- * </p>
- * <p>
- * The <code>ScanManager</code> MBean is the entry point of the <i>scandir</i>
- * application management interface. It is from this MBean that all other MBeans
- * will be created and registered.
- * </p>
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public class ScanManager implements ScanManagerMXBean,
-        NotificationEmitter, MBeanRegistration {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(ScanManager.class.getName());
-
-    /**
-     * The name of the ScanManager singleton MBean.
-     **/
-    public final static ObjectName SCAN_MANAGER_NAME =
-            makeSingletonName(ScanManagerMXBean.class);
-
-    /**
-     * Sequence number used for sending notifications. We use this
-     * sequence number throughout the application.
-     **/
-    private static long seqNumber=0;
-
-    /**
-     * The NotificationBroadcasterSupport object used to handle
-     * listener registration.
-     **/
-    private final NotificationBroadcasterSupport broadcaster;
-
-    /**
-     * The MBeanServer in which this MBean is registered. We obtain
-     * this reference by implementing the {@link MBeanRegistration}
-     * interface.
-     **/
-    private volatile MBeanServer mbeanServer;
-
-    /**
-     * A queue of pending notifications we are about to send.
-     * We're using a BlockingQueue in order to avoid sending
-     * notifications from within a synchronized block.
-     **/
-    private final BlockingQueue<Notification> pendingNotifs;
-
-    /**
-     * The state of the scan session.
-     **/
-    private volatile ScanState state = STOPPED;
-
-    /**
-     * The list of DirectoryScannerMBean that are run by a scan session.
-     **/
-    private final Map<ObjectName,DirectoryScannerMXBean> scanmap;
-
-    /**
-     * The list of ScanDirConfigMXBean that were created by this MBean.
-     **/
-    private final Map<ObjectName, ScanDirConfigMXBean> configmap;
-
-    // The ResultLogManager for this application.
-    private final ResultLogManager log;
-
-    /**
-     * We use a semaphore to ensure proper sequencing of exclusive
-     * action. The logic we have implemented is to fail - rather
-     * than block, if an exclusive action is already in progress.
-     **/
-    private final Semaphore sequencer = new Semaphore(1);
-
-    // A proxy to the current ScanDirConfigMXBean which holds the current
-    // configuration data.
-    //
-    private volatile ScanDirConfigMXBean config = null;
-
-    // Avoid to write parameters twices when creating a new ConcurrentHashMap.
-    //
-    private static <K, V> Map<K, V> newConcurrentHashMap() {
-        return new ConcurrentHashMap<K, V>();
-    }
-
-    // Avoid to write parameters twices when creating a new HashMap.
-    //
-    private static <K, V> Map<K, V> newHashMap() {
-        return new HashMap<K, V>();
-    }
-
-    /**
-     * Creates a default singleton ObjectName for a given class.
-     * @param clazz The interface class of the MBean for which we want to obtain
-     *        a default singleton name, or its implementation class.
-     *        Give one or the other depending on what you wish to see in
-     *        the value of the key {@code type=}.
-     * @return A default singleton name for a singleton MBean class.
-     * @throws IllegalArgumentException if the name can't be created
-     *         for some unfathomable reason (e.g. an unexpected
-     *         exception was raised).
-     **/
-    public final static ObjectName makeSingletonName(Class clazz) {
-        try {
-            final Package p = clazz.getPackage();
-            final String packageName = (p==null)?null:p.getName();
-            final String className   = clazz.getSimpleName();
-            final String domain;
-            if (packageName == null || packageName.length()==0) {
-                // We use a reference to ScanDirAgent.class to ease
-                // to keep track of possible class renaming.
-                domain = ScanDirAgent.class.getSimpleName();
-            } else {
-                domain = packageName;
-            }
-            final ObjectName name = new ObjectName(domain,"type",className);
-            return name;
-        } catch (Exception x) {
-            final IllegalArgumentException iae =
-                    new IllegalArgumentException(String.valueOf(clazz),x);
-            throw iae;
-        }
-    }
-
-    /**
-     * Creates a default ObjectName with keys <code>type=</code> and
-     * <code>name=</code> for an instance of a given MBean interface class.
-     * @param clazz The interface class of the MBean for which we want to obtain
-     *        a default name, or its implementation class.
-     *        Give one or the other depending on what you wish to see in
-     *        the value of the key {@code type=}.
-     * @param name The value of the <code>name=</code> key.
-     * @return A default name for an instance of the given MBean interface class.
-     * @throws IllegalArgumentException if the name can't be created.
-     *         (e.g. an unexpected exception was raised).
-     **/
-    public static final ObjectName makeMBeanName(Class clazz, String name) {
-        try {
-            return ObjectName.
-                getInstance(makeSingletonName(clazz)
-                        .toString()+",name="+name);
-        } catch (MalformedObjectNameException x) {
-            final IllegalArgumentException iae =
-                    new IllegalArgumentException(String.valueOf(name),x);
-            throw iae;
-        }
-    }
-
-    /**
-     * Return the ObjectName for a DirectoryScannerMXBean of that name.
-     * This is {@code makeMBeanName(DirectoryScannerMXBean.class,name)}.
-     * @param name The value of the <code>name=</code> key.
-     * @return the ObjectName for a DirectoryScannerMXBean of that name.
-     */
-    public static final ObjectName makeDirectoryScannerName(String name) {
-        return makeMBeanName(DirectoryScannerMXBean.class,name);
-    }
-
-    /**
-     * Return the ObjectName for a {@code ScanDirConfigMXBean} of that name.
-     * This is {@code makeMBeanName(ScanDirConfigMXBean.class,name)}.
-     * @param name The value of the <code>name=</code> key.
-     * @return the ObjectName for a {@code ScanDirConfigMXBean} of that name.
-     */
-    public static final ObjectName makeScanDirConfigName(String name) {
-        return makeMBeanName(ScanDirConfigMXBean.class,name);
-    }
-
-    /**
-     * Create and register a new singleton instance of the ScanManager
-     * MBean in the given {@link MBeanServerConnection}.
-     * @param mbs The MBeanServer in which the new singleton instance
-     *         should be created.
-     * @throws JMException The MBeanServer connection raised an exception
-     *         while trying to instantiate and register the singleton MBean
-     *         instance.
-     * @throws IOException There was a connection problem while trying to
-     *         communicate with the underlying MBeanServer.
-     * @return A proxy for the registered MBean.
-     **/
-    public static ScanManagerMXBean register(MBeanServerConnection mbs)
-        throws IOException, JMException {
-        final ObjectInstance moi =
-                mbs.createMBean(ScanManager.class.getName(),SCAN_MANAGER_NAME);
-        final ScanManagerMXBean proxy =
-                JMX.newMXBeanProxy(mbs,moi.getObjectName(),
-                                  ScanManagerMXBean.class,true);
-        return proxy;
-    }
-
-    /**
-     * Creates a new {@code ScanManagerMXBean} proxy over the given
-     * {@code MBeanServerConnection}. Does not check whether a
-     * {@code ScanManagerMXBean}
-     * is actually registered in that {@code MBeanServerConnection}.
-     * @return a new {@code ScanManagerMXBean} proxy.
-     * @param mbs The {@code MBeanServerConnection} which holds the
-     * {@code ScanManagerMXBean} to proxy.
-     */
-    public static ScanManagerMXBean
-            newSingletonProxy(MBeanServerConnection mbs) {
-        final ScanManagerMXBean proxy =
-                JMX.newMXBeanProxy(mbs,SCAN_MANAGER_NAME,
-                                  ScanManagerMXBean.class,true);
-        return proxy;
-    }
-
-    /**
-     * Creates a new {@code ScanManagerMXBean} proxy over the platform
-     * {@code MBeanServer}. This is equivalent to
-     * {@code newSingletonProxy(ManagementFactory.getPlatformMBeanServer())}.
-     * @return a new {@code ScanManagerMXBean} proxy.
-     **/
-    public static ScanManagerMXBean newSingletonProxy() {
-        return newSingletonProxy(ManagementFactory.getPlatformMBeanServer());
-    }
-
-    /**
-     * Create and register a new singleton instance of the ScanManager
-     * MBean in the given {@link MBeanServerConnection}.
-     * @throws JMException The MBeanServer connection raised an exception
-     *         while trying to instantiate and register the singleton MBean
-     *         instance.
-     * @throws IOException There was a connection problem while trying to
-     *         communicate with the underlying MBeanServer.
-     * @return A proxy for the registered MBean.
-     **/
-    public static ScanManagerMXBean register()
-        throws IOException, JMException {
-        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        return register(mbs);
-    }
-
-    /**
-     * Create a new ScanManager MBean
-     **/
-    public ScanManager() {
-        broadcaster = new NotificationBroadcasterSupport();
-        pendingNotifs = new LinkedBlockingQueue<Notification>(100);
-        scanmap = newConcurrentHashMap();
-        configmap = newConcurrentHashMap();
-        log = new ResultLogManager();
-    }
-
-
-    // Creates a new DirectoryScannerMXBean, from the given configuration data.
-    DirectoryScannerMXBean createDirectoryScanner(DirectoryScannerConfig config) {
-            return new DirectoryScanner(config,log);
-    }
-
-    // Applies a configuration.
-    // throws IllegalStateException if lock can't be acquired.
-    // Unregisters all existing directory scanners, the create and registers
-    // new directory scanners according to the given config.
-    // Then pushes the log config to the result log manager.
-    //
-    private void applyConfiguration(ScanManagerConfig bean)
-        throws IOException, JMException {
-        if (bean == null) return;
-        if (!sequencer.tryAcquire()) {
-            throw new IllegalStateException("Can't acquire lock");
-        }
-        try {
-            unregisterScanners();
-            final DirectoryScannerConfig[] scans = bean.getScanList();
-            if (scans == null) return;
-            for (DirectoryScannerConfig scan : scans) {
-                addDirectoryScanner(scan);
-            }
-            log.setConfig(bean.getInitialResultLogConfig());
-        } finally {
-            sequencer.release();
-        }
-    }
-
-    // See ScanManagerMXBean
-    public void applyConfiguration(boolean fromMemory)
-        throws IOException, JMException {
-        if (fromMemory == false) config.load();
-        applyConfiguration(config.getConfiguration());
-    }
-
-    // See ScanManagerMXBean
-    public void applyCurrentResultLogConfig(boolean toMemory)
-        throws IOException, JMException {
-        final ScanManagerConfig bean = config.getConfiguration();
-        bean.setInitialResultLogConfig(log.getConfig());
-        config.setConfiguration(bean);
-        if (toMemory==false) config.save();
-    }
-
-    // See ScanManagerMXBean
-    public void setConfigurationMBean(ScanDirConfigMXBean config) {
-        this.config = config;
-    }
-
-    // See ScanManagerMXBean
-    public ScanDirConfigMXBean getConfigurationMBean() {
-        return config;
-    }
-
-    // Creates and registers a new directory scanner.
-    // Called by applyConfiguration.
-    // throws IllegalStateException if state is not STOPPED or COMPLETED
-    // (you cannot change the config while scanning is scheduled or running).
-    //
-    private DirectoryScannerMXBean addDirectoryScanner(
-                DirectoryScannerConfig bean)
-        throws JMException {
-        try {
-            final DirectoryScannerMXBean scanner;
-            final ObjectName scanName;
-            synchronized (this) {
-                if (state != STOPPED && state != COMPLETED)
-                   throw new IllegalStateException(state.toString());
-                scanner = createDirectoryScanner(bean);
-                scanName = makeDirectoryScannerName(bean.getName());
-            }
-            LOG.fine("server: "+mbeanServer);
-            LOG.fine("scanner: "+scanner);
-            LOG.fine("scanName: "+scanName);
-            final ObjectInstance moi =
-                mbeanServer.registerMBean(scanner,scanName);
-            final ObjectName moiName = moi.getObjectName();
-            final DirectoryScannerMXBean proxy =
-                JMX.newMXBeanProxy(mbeanServer,moiName,
-                DirectoryScannerMXBean.class,true);
-            scanmap.put(moiName,proxy);
-            return proxy;
-        } catch (RuntimeException x) {
-            final String msg = "Operation failed: "+x;
-            if (LOG.isLoggable(Level.FINEST))
-                LOG.log(Level.FINEST,msg,x);
-            else LOG.fine(msg);
-            throw x;
-        } catch (JMException x) {
-            final String msg = "Operation failed: "+x;
-            if (LOG.isLoggable(Level.FINEST))
-                LOG.log(Level.FINEST,msg,x);
-            else LOG.fine(msg);
-            throw x;
-        }
-    }
-
-    // See ScanManagerMXBean
-    public ScanDirConfigMXBean createOtherConfigurationMBean(String name,
-            String filename)
-        throws JMException {
-        final ScanDirConfig profile = new ScanDirConfig(filename);
-        final ObjectName profName = makeScanDirConfigName(name);
-        final ObjectInstance moi = mbeanServer.registerMBean(profile,profName);
-        final ScanDirConfigMXBean proxy =
-                JMX.newMXBeanProxy(mbeanServer,profName,
-                    ScanDirConfigMXBean.class,true);
-        configmap.put(moi.getObjectName(),proxy);
-        return proxy;
-    }
-
-
-    // See ScanManagerMXBean
-    public Map<String,DirectoryScannerMXBean> getDirectoryScanners() {
-        final Map<String,DirectoryScannerMXBean> proxyMap = newHashMap();
-        for (Entry<ObjectName,DirectoryScannerMXBean> item : scanmap.entrySet()){
-            proxyMap.put(item.getKey().getKeyProperty("name"),item.getValue());
-        }
-        return proxyMap;
-    }
-
-    // ---------------------------------------------------------------
-    // State Management
-    // ---------------------------------------------------------------
-
-    /**
-     * For each operation, this map stores a list of states from
-     * which the corresponding operation can be legally called.
-     * For instance, it is legal to call "stop" regardless of the
-     * application state. However, "schedule" can be called only if
-     * the application state is STOPPED, etc...
-     **/
-    private final static Map<String,EnumSet<ScanState>> allowedStates;
-    static {
-        allowedStates = newHashMap();
-        // You can always call stop
-        allowedStates.put("stop",EnumSet.allOf(ScanState.class));
-
-        // You can only call closed when stopped
-        allowedStates.put("close",EnumSet.of(STOPPED,COMPLETED,CLOSED));
-
-        // You can call schedule only when the current task is
-        // completed or stopped.
-        allowedStates.put("schedule",EnumSet.of(STOPPED,COMPLETED));
-
-        // switch reserved for background task: goes from SCHEDULED to
-        //    RUNNING when it enters the run() method.
-        allowedStates.put("scan-running",EnumSet.of(SCHEDULED));
-
-        // switch reserved for background task: goes from RUNNING to
-        //    SCHEDULED when it has completed but needs to reschedule
-        //    itself for specified interval.
-        allowedStates.put("scan-scheduled",EnumSet.of(RUNNING));
-
-        // switch reserved for background task:
-        //     goes from RUNNING to COMPLETED upon successful completion
-        allowedStates.put("scan-done",EnumSet.of(RUNNING));
-    }
-
-    // Get this object's state. No need to synchronize because
-    // state is volatile.
-    // See ScanManagerMXBean
-    public ScanState getState() {
-        return state;
-    }
-
-    /**
-     * Enqueue a state changed notification for the given states.
-     **/
-    private void queueStateChangedNotification(
-                    long sequence,
-                    long time,
-                    ScanState old,
-                    ScanState current) {
-        final AttributeChangeNotification n =
-                new AttributeChangeNotification(SCAN_MANAGER_NAME,sequence,time,
-                "ScanManager State changed to "+current,"State",
-                ScanState.class.getName(),old.toString(),current.toString());
-        // Queue the notification. We have created an unlimited queue, so
-        // this method should always succeed.
-        try {
-            if (!pendingNotifs.offer(n,2,TimeUnit.SECONDS)) {
-                LOG.fine("Can't queue Notification: "+n);
-            }
-        } catch (InterruptedException x) {
-                LOG.fine("Can't queue Notification: "+x);
-        }
-    }
-
-    /**
-     * Send all notifications present in the queue.
-     **/
-    private void sendQueuedNotifications() {
-        Notification n;
-        while ((n = pendingNotifs.poll()) != null) {
-            broadcaster.sendNotification(n);
-        }
-    }
-
-    /**
-     * Checks that the current state is allowed for the given operation,
-     * and if so, switch its value to the new desired state.
-     * This operation also enqueue the appropriate state changed
-     * notification.
-     **/
-    private ScanState switchState(ScanState desired,String forOperation) {
-        return switchState(desired,allowedStates.get(forOperation));
-    }
-
-    /**
-     * Checks that the current state is one of the allowed states,
-     * and if so, switch its value to the new desired state.
-     * This operation also enqueue the appropriate state changed
-     * notification.
-     **/
-    private ScanState switchState(ScanState desired,EnumSet<ScanState> allowed) {
-        final ScanState old;
-        final long timestamp;
-        final long sequence;
-        synchronized(this) {
-            old = state;
-            if (!allowed.contains(state))
-               throw new IllegalStateException(state.toString());
-            state = desired;
-            timestamp = System.currentTimeMillis();
-            sequence  = getNextSeqNumber();
-        }
-        LOG.fine("switched state: "+old+" -> "+desired);
-        if (old != desired)
-            queueStateChangedNotification(sequence,timestamp,old,desired);
-        return old;
-    }
-
-
-    // ---------------------------------------------------------------
-    // schedule() creates a new SessionTask that will be executed later
-    // (possibly right away if delay=0) by a Timer thread.
-    // ---------------------------------------------------------------
-
-    // The timer used by this object. Lazzy evaluation. Cleaned in
-    // postDeregister()
-    //
-    private Timer timer = null;
-
-    // See ScanManagerMXBean
-    public void schedule(long delay, long interval) {
-        if (!sequencer.tryAcquire()) {
-            throw new IllegalStateException("Can't acquire lock");
-        }
-        try {
-            LOG.fine("scheduling new task: state="+state);
-            final ScanState old = switchState(SCHEDULED,"schedule");
-            final boolean scheduled =
-                scheduleSession(new SessionTask(interval),delay);
-            if (scheduled)
-                LOG.fine("new task scheduled: state="+state);
-        } finally {
-            sequencer.release();
-        }
-        sendQueuedNotifications();
-    }
-
-    // Schedule a SessionTask. The session task may reschedule
-    // a new identical task when it eventually ends.
-    // We use this logic so that the 'interval' time is measured
-    // starting at the end of the task that finishes, rather than
-    // at its beginning. Therefore if a repeated task takes x ms,
-    // it will be repeated every x+interval ms.
-    //
-    private synchronized boolean scheduleSession(SessionTask task, long delay) {
-        if (state == STOPPED) return false;
-        if (timer == null) timer = new Timer("ScanManager");
-        tasklist.add(task);
-        timer.schedule(task,delay);
-        return true;
-    }
-
-    // ---------------------------------------------------------------
-    // start() is equivalent to schedule(0,0)
-    // ---------------------------------------------------------------
-
-    // See ScanManagerMXBean
-    public void start() throws IOException, InstanceNotFoundException {
-        schedule(0,0);
-    }
-
-    // ---------------------------------------------------------------
-    // Methods used to implement stop() -  stop() is asynchronous,
-    // and needs to notify any running background task that it needs
-    // to stop. It also needs to prevent scheduled task from being
-    // run.
-    // ---------------------------------------------------------------
-
-    // See ScanManagerMXBean
-    public void stop() {
-        if (!sequencer.tryAcquire())
-            throw new IllegalStateException("Can't acquire lock");
-        int errcount = 0;
-        final StringBuilder b = new StringBuilder();
-
-        try {
-            switchState(STOPPED,"stop");
-
-            errcount += cancelSessionTasks(b);
-            errcount += stopDirectoryScanners(b);
-        } finally {
-            sequencer.release();
-        }
-
-        sendQueuedNotifications();
-        if (errcount > 0) {
-            b.insert(0,"stop partially failed with "+errcount+" error(s):");
-            throw new RuntimeException(b.toString());
-        }
-    }
-
-    // See ScanManagerMXBean
-    public void close() {
-        switchState(CLOSED,"close");
-        sendQueuedNotifications();
-    }
-
-    // Appends exception to a StringBuilder message.
-    //
-    private void append(StringBuilder b,String prefix,Throwable t) {
-        final String first = (prefix==null)?"\n":"\n"+prefix;
-        b.append(first).append(String.valueOf(t));
-        Throwable cause = t;
-        while ((cause = cause.getCause())!=null) {
-            b.append(first).append("Caused by:").append(first);
-            b.append('\t').append(String.valueOf(cause));
-        }
-    }
-
-    // Cancels all scheduled session tasks
-    //
-    private int cancelSessionTasks(StringBuilder b) {
-        int errcount = 0;
-        // Stops scheduled tasks if any...
-        //
-        for (SessionTask task : tasklist) {
-            try {
-                task.cancel();
-                tasklist.remove(task);
-            } catch (Exception ex) {
-                errcount++;
-                append(b,"\t",ex);
-            }
-        }
-        return errcount;
-    }
-
-    // Stops all DirectoryScanners configured for this object.
-    //
-    private int stopDirectoryScanners(StringBuilder b) {
-        int errcount = 0;
-        // Stops directory scanners if any...
-        //
-        for (DirectoryScannerMXBean s : scanmap.values()) {
-            try {
-                s.stop();
-            } catch (Exception ex) {
-                errcount++;
-                append(b,"\t",ex);
-            }
-        }
-        return errcount;
-    }
-
-
-    // ---------------------------------------------------------------
-    // We start scanning in background in a Timer thread.
-    // The methods below implement that logic.
-    // ---------------------------------------------------------------
-
-    private void scanAllDirectories()
-        throws IOException, InstanceNotFoundException {
-
-        int errcount = 0;
-        final StringBuilder b = new StringBuilder();
-        for (ObjectName key : scanmap.keySet()) {
-            final DirectoryScannerMXBean s = scanmap.get(key);
-            try {
-                if (state == STOPPED) return;
-                s.scan();
-            } catch (Exception ex) {
-                LOG.log(Level.FINE,key + " failed to scan: "+ex,ex);
-                errcount++;
-                append(b,"\t",ex);
-            }
-        }
-        if (errcount > 0) {
-            b.insert(0,"scan partially performed with "+errcount+" error(s):");
-            throw new RuntimeException(b.toString());
-        }
-    }
-
-    // List of scheduled session task. Needed by stop() to cancel
-    // scheduled sessions. There's usually at most 1 session in
-    // this list (unless there's a bug somewhere ;-))
-    //
-    private final ConcurrentLinkedQueue<SessionTask> tasklist =
-            new ConcurrentLinkedQueue<SessionTask>();
-
-    // Used to give a unique id to session task - useful for
-    // debugging.
-    //
-    private volatile static long taskcount = 0;
-
-    /**
-     * A session task will be scheduled to run in background in a
-     * timer thread. There can be at most one session task running
-     * at a given time (this is ensured by using a timer - which is
-     * a single threaded object).
-     *
-     * If the session needs to be repeated, it will reschedule an
-     * identical session when it finishes to run. This ensure that
-     * two session runs are separated by the given interval time.
-     *
-     **/
-    private class SessionTask extends TimerTask {
-
-        /**
-         * Delay after which the next iteration of this task will
-         * start. This delay is measured  starting at the end of
-         * the previous iteration.
-         **/
-        final long delayBeforeNext;
-
-        /**
-         * A unique id for this task.
-         **/
-        final long taskid;
-
-        /**
-         * Whether it's been cancelled by stop()
-         **/
-        volatile boolean cancelled=false;
-
-        /**
-         * create a new SessionTask.
-         **/
-        SessionTask(long scheduleNext) {
-            delayBeforeNext = scheduleNext;
-            taskid = taskcount++;
-        }
-
-        /**
-         * When run() begins, the state is switched to RUNNING.
-         * When run() ends then:
-         *      If the task is repeated, the state will be switched
-         *      to SCHEDULED (because a new task was scheduled).
-         *      Otherwise the state will be switched to either
-         *      STOPPED (if it was stopped before it could complete)
-         *      or COMPLETED (if it completed gracefully)
-         * This method is used to switch to the desired state and
-         * send the appropriate notifications.
-         * When entering the method, we check whether the state is
-         * STOPPED. If so, we return false - and the SessionTask will
-         * stop. Otherwise, we switch the state to the desired value.
-         **/
-        private boolean notifyStateChange(ScanState newState,String condition) {
-            synchronized (ScanManager.this) {
-                if (state == STOPPED || state == CLOSED) return false;
-                switchState(newState,condition);
-            }
-            sendQueuedNotifications();
-            return true;
-        }
-
-        // Cancels this task.
-        public boolean cancel() {
-            cancelled=true;
-            return super.cancel();
-        }
-
-        /**
-         * Invoke all directories scanners in sequence. At each
-         * step, checks to see whether the task should stop.
-         **/
-        private boolean execute() {
-            final String tag = "Scheduled session["+taskid+"]";
-            try {
-                if (cancelled) {
-                    LOG.finer(tag+" cancelled: done");
-                    return false;
-                }
-                if (!notifyStateChange(RUNNING,"scan-running")) {
-                    LOG.finer(tag+" stopped: done");
-                    return false;
-                }
-                scanAllDirectories();
-            } catch (Exception x) {
-                if (LOG.isLoggable(Level.FINEST)) {
-                    LOG.log(Level.FINEST,
-                            tag+" failed to scan: "+x,x);
-                } else if (LOG.isLoggable(Level.FINE)) {
-                    LOG.fine(tag+" failed to scan: "+x);
-                }
-            }
-            return true;
-        }
-
-        /**
-         * Schedule an identical task for next iteration.
-         **/
-        private boolean scheduleNext() {
-            final String tag = "Scheduled session["+taskid+"]";
-
-            // We need now to reschedule a new task for after 'delayBeforeNext' ms.
-            try {
-                LOG.finer(tag+": scheduling next session for "+ delayBeforeNext + "ms");
-                if (cancelled || !notifyStateChange(SCHEDULED,"scan-scheduled")) {
-                    LOG.finer(tag+" stopped: do not reschedule");
-                    return false;
-                }
-                final SessionTask nextTask = new SessionTask(delayBeforeNext);
-                if (!scheduleSession(nextTask,delayBeforeNext)) return false;
-                LOG.finer(tag+": next session successfully scheduled");
-            } catch (Exception x) {
-                if (LOG.isLoggable(Level.FINEST)) {
-                    LOG.log(Level.FINEST,tag+
-                            " failed to schedule next session: "+x,x);
-                } else if (LOG.isLoggable(Level.FINE)) {
-                    LOG.fine(tag+" failed to schedule next session: "+x);
-                }
-            }
-            return true;
-        }
-
-
-        /**
-         * The run method:
-         * executes scanning logic, the schedule next iteration if needed.
-         **/
-        public void run() {
-            final String tag = "Scheduled session["+taskid+"]";
-            LOG.entering(SessionTask.class.getName(),"run");
-            LOG.finer(tag+" starting...");
-            try {
-                if (execute()==false) return;
-
-                LOG.finer(tag+" terminating - state is "+state+
-                    ((delayBeforeNext >0)?(" next session is due in "+delayBeforeNext+" ms."):
-                        " no additional session scheduled"));
-
-                // if delayBeforeNext <= 0 we are done, either because the session was
-                // stopped or because it successfully completed.
-                if (delayBeforeNext <= 0) {
-                    if (!notifyStateChange(COMPLETED,"scan-done"))
-                        LOG.finer(tag+" stopped: done");
-                    else
-                        LOG.finer(tag+" completed: done");
-                    return;
-                }
-
-                // we need to reschedule a new session for 'delayBeforeNext' ms.
-                scheduleNext();
-
-            } finally {
-                tasklist.remove(this);
-                LOG.finer(tag+" finished...");
-                LOG.exiting(SessionTask.class.getName(),"run");
-            }
-        }
-    }
-
-    // ---------------------------------------------------------------
-    // ---------------------------------------------------------------
-
-    // ---------------------------------------------------------------
-    // MBean Notification support
-    // The methods below are imported from {@link NotificationEmitter}
-    // ---------------------------------------------------------------
-
-    /**
-     * Delegates the implementation of this method to the wrapped
-     * {@code NotificationBroadcasterSupport} object.
-     **/
-    public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException {
-        broadcaster.addNotificationListener(listener, filter, handback);
-    }
-
-
-    /**
-     * We emit an {@code AttributeChangeNotification} when the {@code State}
-     * attribute changes.
-     **/
-    public MBeanNotificationInfo[] getNotificationInfo() {
-        return new MBeanNotificationInfo[] {
-            new MBeanNotificationInfo(new String[] {
-                AttributeChangeNotification.ATTRIBUTE_CHANGE},
-                AttributeChangeNotification.class.getName(),
-                "Emitted when the State attribute changes")
-            };
-    }
-
-    /**
-     * Delegates the implementation of this method to the wrapped
-     * {@code NotificationBroadcasterSupport} object.
-     **/
-    public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
-        broadcaster.removeNotificationListener(listener);
-    }
-
-    /**
-     * Delegates the implementation of this method to the wrapped
-     * {@code NotificationBroadcasterSupport} object.
-     **/
-    public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
-        broadcaster.removeNotificationListener(listener, filter, handback);
-    }
-
-    /**
-     * Returns and increment the sequence number used for
-     * notifications. We use the same sequence number throughout the
-     * application - this is why this method is only package protected.
-     * @return A unique sequence number for the next notification.
-     */
-    static synchronized long getNextSeqNumber() {
-        return seqNumber++;
-    }
-
-    // ---------------------------------------------------------------
-    // End of MBean Notification support
-    // ---------------------------------------------------------------
-
-    // ---------------------------------------------------------------
-    // MBeanRegistration support
-    // The methods below are imported from {@link MBeanRegistration}
-    // ---------------------------------------------------------------
-
-    /**
-     * 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.
-     * <p>In this implementation, we check that the provided name is
-     * either {@code null} or equals to {@link #SCAN_MANAGER_NAME}. If it
-     * isn't then we throw an IllegalArgumentException, otherwise we return
-     * {@link #SCAN_MANAGER_NAME}.</p>
-     * <p>This ensures that there will be a single instance of ScanManager
-     * registered in a given MBeanServer, and that it will always be
-     * registered with the singleton's {@link #SCAN_MANAGER_NAME}.</p>
-     * <p>We do not need to check whether an MBean by that name is
-     *    already registered because the MBeanServer will perform
-     *    this check just after having called preRegister().</p>
-     * @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.
-     */
-    public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
-        if (name != null) {
-            if (!SCAN_MANAGER_NAME.equals(name))
-                throw new IllegalArgumentException(String.valueOf(name));
-        }
-        mbeanServer = server;
-        return SCAN_MANAGER_NAME;
-    }
-
-    // Returns the default configuration filename
-    static String getDefaultConfigurationFileName() {
-        // This is a file calles 'jmx-scandir.xml' located
-        // in the user directory.
-        final String user = System.getProperty("user.home");
-        final String defconf = user+File.separator+"jmx-scandir.xml";
-        return defconf;
-    }
-
-    /**
-     * Allows the MBean to perform any operations needed after having
-     * been registered in the MBean server or after the registration has
-     * failed.
-     * <p>
-     * If registration was not successful, the method returns immediately.
-     * <p>
-     * If registration is successful, register the {@link ResultLogManager}
-     * and default {@link ScanDirConfigMXBean}. If registering these
-     * MBean fails, the {@code ScanManager} state will be switched to
-     * {@link #close CLOSED}, and postRegister ends there.
-     * </p>
-     * <p>Otherwise the {@code ScanManager} will ask the
-     * {@link ScanDirConfigMXBean} to load its configuration.
-     * If it succeeds, the configuration will be {@link
-     * #applyConfiguration applied}. Otherwise, the method simply returns,
-     * assuming that the user will later create/update a configuration and
-     * apply it.
-     * @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) {
-        if (!registrationDone) return;
-        Exception test=null;
-        try {
-            mbeanServer.registerMBean(log,
-                    ResultLogManager.RESULT_LOG_MANAGER_NAME);
-            final String defconf = getDefaultConfigurationFileName();
-            final String conf = System.getProperty("scandir.config.file",defconf);
-            final String confname = ScanDirConfig.guessConfigName(conf,defconf);
-            final ObjectName defaultProfileName =
-                    makeMBeanName(ScanDirConfigMXBean.class,confname);
-            if (!mbeanServer.isRegistered(defaultProfileName))
-                mbeanServer.registerMBean(new ScanDirConfig(conf),
-                        defaultProfileName);
-            config = JMX.newMXBeanProxy(mbeanServer,defaultProfileName,
-                    ScanDirConfigMXBean.class,true);
-            configmap.put(defaultProfileName,config);
-        } catch (Exception x) {
-            LOG.config("Failed to populate MBeanServer: "+x);
-            close();
-            return;
-        }
-        try {
-            config.load();
-        } catch (Exception x) {
-            LOG.finest("No config to load: "+x);
-            test = x;
-        }
-        if (test == null) {
-            try {
-                applyConfiguration(config.getConfiguration());
-            } catch (Exception x) {
-                if (LOG.isLoggable(Level.FINEST))
-                    LOG.log(Level.FINEST,"Failed to apply config: "+x,x);
-                LOG.config("Failed to apply config: "+x);
-            }
-        }
-    }
-
-    // Unregisters all created DirectoryScanners
-    private void unregisterScanners() throws JMException {
-        unregisterMBeans(scanmap);
-    }
-
-    // Unregisters all created ScanDirConfigs
-    private void unregisterConfigs() throws JMException {
-        unregisterMBeans(configmap);
-    }
-
-    // Unregisters all MBeans named by the given map
-    private void unregisterMBeans(Map<ObjectName,?> map) throws JMException {
-        for (ObjectName key : map.keySet()) {
-            if (mbeanServer.isRegistered(key))
-                mbeanServer.unregisterMBean(key);
-            map.remove(key);
-        }
-    }
-
-    // Unregisters the ResultLogManager.
-    private void unregisterResultLogManager() throws JMException {
-        final ObjectName name = ResultLogManager.RESULT_LOG_MANAGER_NAME;
-        if (mbeanServer.isRegistered(name)) {
-            mbeanServer.unregisterMBean(name);
-        }
-    }
-
-    /**
-     * Allows the MBean to perform any operations it needs before being
-     * unregistered by the MBean server.
-     * This implementation also unregisters all the MXBeans
-     * that were created by this object.
-     * @throws IllegalStateException if the lock can't be acquire, or if
-     *         the MBean's state doesn't allow the MBean to be unregistered
-     *         (e.g. because it's scheduled or running).
-     * @throws Exception This exception will be caught by the MBean server and
-     * re-thrown as an MBeanRegistrationException.
-     */
-    public void preDeregister() throws Exception {
-        try {
-            close();
-            if (!sequencer.tryAcquire())
-                throw new IllegalStateException("can't acquire lock");
-            try {
-                unregisterScanners();
-                unregisterConfigs();
-                unregisterResultLogManager();
-            } finally {
-                sequencer.release();
-            }
-        } catch (Exception x) {
-            LOG.log(Level.FINEST,"Failed to unregister: "+x,x);
-            throw x;
-        }
-    }
-
-    /**
-     * Allows the MBean to perform any operations needed after having been
-     * unregistered in the MBean server.
-     * Cancels the internal timer - if any.
-     */
-    public synchronized void postDeregister() {
-        if (timer != null) {
-            try {
-                timer.cancel();
-            } catch (Exception x) {
-                if (LOG.isLoggable(Level.FINEST))
-                    LOG.log(Level.FINEST,"Failed to cancel timer",x);
-                else if (LOG.isLoggable(Level.FINE))
-                    LOG.fine("Failed to cancel timer: "+x);
-            } finally {
-                timer = null;
-            }
-        }
-   }
-
-    // ---------------------------------------------------------------
-    // End of MBeanRegistration support
-    // ---------------------------------------------------------------
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/ScanManagerMXBean.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,317 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import java.io.IOException;
-import java.util.Map;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMException;
-
-/**
- * The <code>ScanManagerMXBean</code> is responsible for applying a
- * configuration, starting and scheduling directory scans, and reporting
- * application state.
- * <p>
- * The <code>ScanManagerMXBean</code> is a singleton MBean: there can be
- * at most one instance of such an MBean registered in a given MBeanServer.
- * The name of that MBean is a constant defined in
- * {@link ScanManager#SCAN_MANAGER_NAME ScanManager.SCAN_MANAGER_NAME}.
- * </p>
- * <p>
- * The <code>ScanManagerMXBean</code> is the entry point of the <i>scandir</i>
- * application management interface. It is from this MBean that all other
- * MBeans will be created and registered.
- * </p>
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- **/
-public interface ScanManagerMXBean {
-    /**
-     * This state tells whether directory scans are running, scheduled,
-     * successfully completed, or stopped.
-     * <p>
-     * The {@link #CLOSED} state means
-     * that the {@link ScanManagerMXBean} was closed and is no longer usable.
-     * This state is used when the {@link ScanManagerMXBean} needs to be
-     * unregistered.
-     * </p>
-     **/
-    public enum ScanState {
-        /**
-         * Scanning of directories is in process.
-         **/
-        RUNNING,
-
-        /**
-         * Scanning of directories is not in process, but is scheduled
-         * for a later date.
-         **/
-        SCHEDULED,
-
-        /**
-         * Scanning is successfully completed.
-         **/
-        COMPLETED,
-
-        /**
-         * Scanning is stopped. No scanning is scheduled.
-         **/
-        STOPPED,
-
-        /**
-         * close() was called.
-         **/
-        CLOSED
-
-    }
-
-    /**
-     * Returns the current state of the application.
-     * @return the current state of the application.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public ScanState getState()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Schedule a scan session for a later date.
-     * <p>
-     * A scan session is a background task that will sequentially call {@link
-     * DirectoryScannerMXBean#scan scan()} on every {@link
-     * DirectoryScannerMXBean} configured for this MBean.
-     * </p>
-     * @see #getDirectoryScanners
-     * @param delay The first scan session will be started after
-     *        the given delay. 0 means start now.
-     * @param interval Scan session will be rescheduled periodically
-     *        at the specified interval. The interval starts at the
-     *        the end of the scan session: if a scan session takes
-     *        on average x milliseconds to complete, then a scan session will
-     *        be started on average every x+interval milliseconds.
-     *        if (interval == 0) then scan session will not be
-     *        rescheduled, and will run only once.
-     * @throws IllegalStateException if a scan session is already
-     *         running or scheduled, or the MBean is closed.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void schedule(long delay, long interval)
-        throws IOException, InstanceNotFoundException;
-
-
-    /**
-     * Stops current running or scheduled scan sessions if any.
-     * <p>
-     * A scan session is a background task that will sequentially call {@link
-     * DirectoryScannerMXBean#scan scan()} on every {@link
-     * DirectoryScannerMXBean} configured for this MBean.
-     * </p>
-     * <p>
-     * Scan sessions are started/scheduled by calls to {@link #start start} or
-     * {@link #schedule schedule}.
-     * </p>
-     * After this method completes the state of the application will
-     * be {@link ScanState#STOPPED}.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void stop()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Switches the state to CLOSED.
-     * When closed, this MBean cannot be used any more.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void close()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Starts a scan session immediately.
-     * This is equivalent to {@link #schedule(long,long) schedule(0,0)}.
-     * @throws IllegalStateException if a scan session is already
-     *         running or scheduled, or the MBean is closed.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public void start()
-        throws IOException, InstanceNotFoundException;
-
-    /**
-     * Gets the list of directory scanners configured for this MBean.
-     * @return A {@code Map<String,DirectoryScannerMXBean>} where the
-     *         key in the map is the value of the <code>name=</code> key
-     *         of the {@link DirectoryScannerMXBean} ObjectName.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws JMException The MBeanServer failed to call the underlying MBean.
-     **/
-    public Map<String,DirectoryScannerMXBean> getDirectoryScanners()
-        throws IOException, JMException;
-
-    /**
-     * Apply the configuration handled by the {@link
-     * #getConfigurationMBean configuration MBean}.
-     * <p>
-     * When the configuration is applied, all the {@link DirectoryScannerMXBean}
-     * created by this MBean will be unregistered, and new {@link
-     * DirectoryScannerMXBean} will be created and registered from the
-     * new {@link ScanDirConfigMXBean#getConfiguration configuration data}.
-     * </p>
-     * <p>
-     * The initial result log configuration held by the {@link
-     * #getConfigurationMBean configuration MBean} will also be pushed to the
-     * {@link ResultLogManagerMXBean}. If you don't want to lose your current
-     * {@link ResultLogManagerMXBean} configuration, you should therefore call
-     * {@link #applyCurrentResultLogConfig
-     * applyCurrentResultLogConfig} before calling
-     * {@link #applyConfiguration applyConfiguration}
-     * </p>
-     * @param fromMemory if {@code true}, the configuration will be applied
-     *        from memory. if {@code false}, the {@code ScanManagerMXBean} will
-     *        ask the {@link
-     * #getConfigurationMBean configuration MBean} to {@link
-     * ScanDirConfigMXBean#load reload its configuration} before applying
-     * it.
-     * @throws IllegalStateException if a scan session is
-     *         running or scheduled, or the MBean is closed.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws JMException The MBeanServer failed to call the underlying MBean.
-     **/
-    public void applyConfiguration(boolean fromMemory)
-        throws IOException, JMException;
-    /**
-     * Replaces the {@link
-     * #getConfigurationMBean configuration MBean}'s {@link
-     * com.sun.jmx.examples.scandir.config.ScanManagerConfig#getInitialResultLogConfig
-     * initial result log configuration} with the current {@link
-     * ResultLogManagerMXBean}
-     * configuration. This prevents the <code>ResultLogManagerMXBean</code>
-     * current configuration from being reset when {@link #applyConfiguration
-     * applyConfiguration} is called.
-     * @param toMemory if {@code true} only replaces the initial result log
-     *                 configuration held in memory.
-     *                 if {@code false}, the {@link
-     * #getConfigurationMBean configuration MBean} will be asked to commit
-     * the whole configuration to the configuration file.
-     *
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws JMException The MBeanServer failed to call the underlying MBean.
-     **/
-    public void applyCurrentResultLogConfig(boolean toMemory)
-        throws IOException, JMException;
-
-    /**
-     * Instruct the {@code ScanManagerMXBean} to use another {@link
-     * ScanDirConfigMXBean configuration MBean}.
-     * <p>This method doesn't {@link #applyConfiguration apply} the new
-     * configuration. If you want to apply the new configuration, you should
-     * additionally call {@link #applyConfiguration
-     * applyConfiguration(true|false)}. Note that you cannot apply a
-     * configuration as long as a scan session is scheduled or running.
-     * In that case you will need to wait for that session to complete
-     * or call {@link #stop} to stop it.
-     * </p>
-     * @param config A proxy to the {@link ScanDirConfigMXBean} that holds
-     * the new configuration for the application.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     */
-    public void setConfigurationMBean(ScanDirConfigMXBean config)
-        throws IOException, InstanceNotFoundException;
-    /**
-     * Gets the current configuration MBean.
-     * @return A proxy to the current configuration MBean.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws InstanceNotFoundException The underlying MBean is not
-     *         registered in the MBeanServer.
-     **/
-    public ScanDirConfigMXBean getConfigurationMBean()
-        throws IOException, InstanceNotFoundException;
-    /**
-     * This method creates a new alternate {@link ScanDirConfigMXBean}.
-     *
-     * <p>You will need to call {@link #setConfigurationMBean
-     * setConfigurationMBean} if you
-     * want this new {@link ScanDirConfigMXBean} to become the
-     * current configuration MBean.
-     * </p>
-     * <p>
-     * This new {@link ScanDirConfigMXBean} will be unregistered automatically
-     * by the {@code ScanManagerMXBean} when the {@code ScanManagerMXBean}
-     * is unregistered.
-     * </p>
-     * @param name The short name for the new {@link ScanDirConfigMXBean}.
-     *        This name will be used in the ObjectName <code>name=</code> key
-     *        of the new {@link ScanDirConfigMXBean}.
-     * @param filename The path of the file from which the new {@link
-     *        ScanDirConfigMXBean} can {@link ScanDirConfigMXBean#load load} or
-     *        {@link ScanDirConfigMXBean#save save} its configuration data.
-     *        Note that even if the file exists and contain a valid
-     *        configuration, you will still need to call {@link
-     *        ScanDirConfigMXBean#load load} to make the {@link
-     *        ScanDirConfigMXBean} load its configuration data.
-     * @throws IOException A connection problem occurred when accessing
-     *                     the underlying resource.
-     * @throws JMException The MBeanServer failed to call the underlying MBean.
-     * @return A proxy to the created {@link ScanDirConfigMXBean}.
-     */
-    public ScanDirConfigMXBean createOtherConfigurationMBean(String name,
-            String filename)
-        throws JMException, IOException;
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/DirectoryScannerConfig.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,392 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir.config;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.logging.Logger;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementRef;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlList;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * The <code>DirectoryScannerConfig</code> Java Bean is used to model
- * the configuration of a {@link
- * com.sun.jmx.examples.scandir.DirectoryScannerMXBean}.
- * <p>
- * This class is annotated for XML binding.
- * </p>
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-@XmlRootElement(name="DirectoryScanner",
-        namespace=XmlConfigUtils.NAMESPACE)
-public class DirectoryScannerConfig {
-
-    //
-    // A logger for this class.
-    //
-    // private static final Logger LOG =
-    //        Logger.getLogger(DirectoryScannerConfig.class.getName());
-
-    /**
-     * This enumeration is used to model the actions that a {@link
-     * com.sun.jmx.examples.scandir.DirectoryScannerMXBean
-     * DirectoryScannerMXBean} should take when a file matches its set
-     * of matching criteria.
-     **/
-    public enum Action {
-        /**
-         * Indicates that the {@code DirectoryScannerMXBean} should
-         * emit a {@code Notification} when a matching file is found.
-         */
-        NOTIFY,
-        /**
-         * Indicates that the {@code DirectoryScannerMXBean} should
-         * delete the matching files.
-         */
-        DELETE,
-        /**
-         * Indicates that the {@code DirectoryScannerMXBean} should
-         * log the actions that were taken on the matching files.
-         */
-        LOGRESULT };
-
-    // A short name for the Directory Scanner
-    // This name is used for the value of the {@code name=} key in the
-    // {@code DirectoryScannerMXBean} ObjectName.
-    private String name;
-
-    // The root directory of the Directory Scanner
-    private String rootDirectory;
-
-    // List of filters identifying files that should be selected.
-    // A file is selected if at least one filter matches.
-    //
-    private final List<FileMatch> includeFiles =
-            new ArrayList<FileMatch>();
-
-    // List of filters identifying files that should be excluded.
-    // A file is excluded if at least one filter matches.
-    //
-    private final List<FileMatch> excludeFiles =
-            new ArrayList<FileMatch>();
-
-
-    // The actions that this Directory Scanner should carry out when a
-    // file is selected. Default is NOTIFY and LOGRESULT.
-    //
-    private Action[] actions = { Action.NOTIFY, Action.LOGRESULT };
-
-    /**
-     * Creates a new instance of {@code DirectoryScannerConfig}.
-     * We keep this empty constructor to make XML binding easier.
-     * You shouldn't use this constructor directly:
-     * use {@link #DirectoryScannerConfig(String)
-     * DirectoryScannerConfig(String name)} instead.
-     * @deprecated <p>Tagged deprecated so that a compiler warning is issued.
-     *             Use {@link #DirectoryScannerConfig(String)
-     *                  DirectoryScannerConfig(String name)} instead.
-     *             </p>
-     **/
-    public DirectoryScannerConfig() {
-        this(null);
-    }
-
-    /**
-     * Creates a new instance of {@code DirectoryScannerConfig}.
-     * @param name A short name for the Directory Scanner. This name is used for
-     *        the value of the {@code name=} key in the
-     *        {@code DirectoryScannerMXBean} ObjectName.
-     **/
-    public DirectoryScannerConfig(String name) {
-        this.name = name;
-        rootDirectory = null;
-    }
-
-    /**
-     * Gets the root directory configured for that Directory Scanner.
-     * @return the root directory at which the directory scanner should start
-     *         scanning.
-     **/
-    @XmlElement(name="RootDirectory",namespace=XmlConfigUtils.NAMESPACE)
-    public String getRootDirectory() {
-        return rootDirectory;
-    }
-
-    /**
-     * Configures a root directory for that Directory Scanner.
-     * @param root The root directory at which the directory scanner should
-     *        start scanning.
-     **/
-    public void setRootDirectory(String root) {
-        rootDirectory=root;
-    }
-
-
-    /**
-     * Gets the short name of this directory scanner.
-     *
-     * <p>
-     * This name is used for the value of the {@code name=} key in the
-     * {@code DirectoryScannerMXBean} ObjectName.
-     * </p>
-     *
-     * @return the short name of this directory scanner.
-     **/
-    @XmlAttribute(name="name",required=true)
-    public String getName() {
-        return this.name;
-    }
-
-    /**
-     * Setter for property {@link #getName() name}.
-     * Once set its value cannot change.
-     * @param name New value of property name.
-     * @throws IllegalArgumentException if {@code name} is already set to a
-     *         different non null value.
-     */
-    public void setName(String name) {
-        if (this.name == null)
-            this.name = name;
-        else if (name == null)
-            throw new IllegalArgumentException("name=null");
-        else if (!name.equals(this.name))
-            throw new IllegalArgumentException("name="+name);
-    }
-
-    /**
-     * Getter for property includeFiles.
-     * This is an array of filters identifying files that should be selected.
-     * A file is selected if at least one filter matches.
-     * @return Value of property includeFiles.
-     */
-    @XmlElementWrapper(name="IncludeFiles",
-            namespace=XmlConfigUtils.NAMESPACE)
-    @XmlElementRef
-    public FileMatch[] getIncludeFiles() {
-        synchronized(includeFiles) {
-            return includeFiles.toArray(new FileMatch[0]);
-        }
-    }
-
-    /**
-     * Adds a filter to the includeFiles property.
-     * A file is selected if at least one filter matches.
-     * @param include A filter identifying files that should be selected.
-     */
-    public void addIncludeFiles(FileMatch include) {
-        if (include == null)
-            throw new IllegalArgumentException("null");
-        synchronized (includeFiles) {
-            includeFiles.add(include);
-        }
-    }
-
-    /**
-     * Setter for property includeFiles.
-     * @param includeFiles New value of property includeFiles.
-     *        This is an array of filters identifying files
-     *        that should be selected. A file is selected if at least
-     *        one filter matches.
-     */
-    public void setIncludeFiles(FileMatch[] includeFiles) {
-        synchronized (this.includeFiles) {
-            this.includeFiles.clear();
-            if (includeFiles == null) return;
-            this.includeFiles.addAll(Arrays.asList(includeFiles));
-        }
-    }
-
-    /**
-     * Getter for property excludeFiles.
-     * This is an array of filters identifying files that should be excluded.
-     * A file is excluded if at least one filter matches.
-     * @return Value of property excludeFiles.
-     */
-    @XmlElementWrapper(name="ExcludeFiles",
-            namespace=XmlConfigUtils.NAMESPACE)
-    @XmlElementRef
-    public FileMatch[] getExcludeFiles() {
-        synchronized(excludeFiles) {
-            return excludeFiles.toArray(new FileMatch[0]);
-        }
-    }
-
-    /**
-     * Setter for property excludeFiles.
-     * @param excludeFiles New value of property excludeFiles.
-     *        This is an array of filters identifying files
-     *        that should be excluded. A file is excluded if at least
-     *        one filter matches.
-     */
-    public void setExcludeFiles(FileMatch[] excludeFiles) {
-        synchronized (this.excludeFiles) {
-            this.excludeFiles.clear();
-            if (excludeFiles == null) return;
-            this.excludeFiles.addAll(Arrays.asList(excludeFiles));
-        }
-    }
-
-    /**
-     * Adds a filter to the excludeFiles property.
-     * A file is excluded if at least one filter matches.
-     * @param exclude A filter identifying files that should be excluded.
-     */
-    public void addExcludeFiles(FileMatch exclude) {
-        if (exclude == null)
-            throw new IllegalArgumentException("null");
-        synchronized (excludeFiles) {
-            this.excludeFiles.add(exclude);
-        }
-    }
-
-    /**
-     * Gets the list of actions that this Directory Scanner should carry
-     * out when a file is selected. Default is NOTIFY and LOGRESULT.
-
-     * @return The list of actions that this Directory Scanner should carry
-     * out when a file is selected.
-     */
-    @XmlElement(name="Actions",namespace=XmlConfigUtils.NAMESPACE)
-    @XmlList
-    public Action[] getActions() {
-       return  (actions == null)?null:actions.clone();
-    }
-
-    /**
-     * Sets the list of actions that this Directory Scanner should carry
-     * out when a file is selected. Default is NOTIFY and LOGRESULT.
-
-     * @param actions The list of actions that this Directory Scanner should
-     * carry out when a file is selected.
-     */
-    public void setActions(Action[] actions) {
-        this.actions = (actions == null)?null:actions.clone();
-    }
-
-    /**
-     * Builds a {@code FileFilter} from the {@link #getIncludeFiles
-     * includeFiles} and {@link #getExcludeFiles excludeFiles} lists.
-     * A file will be accepted if it is selected by at least one of
-     * the filters in {@link #getIncludeFiles includeFiles}, and is
-     * not excluded by any of the filters in {@link
-     * #getExcludeFiles excludeFiles}. If there's no filter in
-     * {@link #getIncludeFiles includeFiles}, then a file is accepted
-     * simply if it is not excluded by any of the filters in {@link
-     * #getExcludeFiles excludeFiles}.
-     *
-     * @return A new {@code FileFilter}  created from the current snapshot
-     *         of the {@link #getIncludeFiles
-     * includeFiles} and {@link #getExcludeFiles excludeFiles} lists.
-     *         Later modification of these lists will not affect the
-     *         returned {@code FileFilter}.
-     **/
-    public FileFilter buildFileFilter() {
-        final FileFilter[] ins = getIncludeFiles();
-        final FileFilter[] outs = getExcludeFiles();
-        final FileFilter filter = new FileFilter() {
-            public boolean accept(File f) {
-                boolean result = false;
-                // If no include filter, all files are included.
-                if (ins != null) {
-                    for (FileFilter in: ins) {
-                        // if one filter accepts it, file is included
-                        if (!in.accept(f)) continue;
-
-                        // file is accepted, include it
-                        result=true;
-                        break;
-                    }
-                } else result= true;
-                if (result == false) return false;
-
-                // The file is in the include list. Let's see if it's not
-                // in the exclude list...
-                //
-                if (outs != null) {
-                    for (FileFilter out: outs) {
-                        // if one filter accepts it, file is excluded
-                        if (!out.accept(f)) continue;
-
-                        // file is accepted, exclude it.
-                        result=false;
-                        break;
-                    }
-                }
-                return result;
-            }
-        };
-        return filter;
-    }
-
-    // Used for equality - see equals().
-    private Object[] toArray() {
-        final Object[] thisconfig = {
-            name,rootDirectory,actions,excludeFiles,includeFiles
-        };
-        return thisconfig;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (o == this) return true;
-        if (!(o instanceof DirectoryScannerConfig)) return false;
-        final DirectoryScannerConfig other = (DirectoryScannerConfig)o;
-        final Object[] thisconfig = toArray();
-        final Object[] otherconfig = other.toArray();
-        return Arrays.deepEquals(thisconfig,otherconfig);
-    }
-
-    @Override
-    public int hashCode() {
-        final String key = name;
-        if (key == null) return 0;
-        else return key.hashCode();
-    }
-
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/FileMatch.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,323 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir.config;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.logging.Logger;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * The <code>FileMatch</code> Java Bean is used to model
- * the configuration of a {@link FileFilter} which
- * matches {@link File files} against a set of criteria.
- * <p>
- * The <code>FileMatch</code> class also implements
- * {@link FileFilter} - applying an {@code AND} on all
- * its conditions. {@code OR} conditions can be obtained
- * by supplying several instances of <code>FileMatch</code>
- * to the encapsulating {@link DirectoryScannerConfig}, which
- * respectively applies an {@code OR} on all its
- * {@code <FileFilter>} elements.
- * </p>
- *
- * <p>
- * This class is annotated for XML binding.
- * </p>
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-@XmlRootElement(name="FileFilter",
-        namespace=XmlConfigUtils.NAMESPACE)
-public class FileMatch implements FileFilter {
-
-    //
-    // A logger for this class.
-    //
-    // private static final Logger LOG =
-    //        Logger.getLogger(FileMatch.class.getName());
-
-    /**
-     * A regular expression against which directory names should be matched.
-     */
-    private String directoryPattern;
-
-    /**
-     * A regular expression against which file names should be matched.
-     */
-    private String filePattern;
-
-    /**
-     * File whose size in bytes exceeds this limit will be selected.
-     */
-    private long sizeExceedsMaxBytes;
-
-    /**
-     * A file which will be selected only if it was last modified after
-     * this date
-     */
-    private Date lastModifiedAfter;
-
-    /**
-     * A file which will be selected only if it was last modified before
-     * this date
-     */
-    private Date lastModifiedBefore;
-
-    /**
-     * Creates a new instance of FileMatch
-     */
-    public FileMatch() {
-    }
-
-    /**
-     * Getter for property directoryPattern. This is a regular expression
-     * against which directory names should be matched.
-     * Applies only to directory, and tells whether a directory should be
-     * included or excluded from the search.
-     * <p>If File.isDirectory() && directoryPattern!=null &&
-     *    File.getName().matches(directoryPattern),
-     *    then File matches this filter.<br>
-     *    If File.isDirectory() && directoryPattern!=null &&
-     *    File.getName().matches(directoryPattern)==false,
-     *    then File doesn't match this filter.<br>
-     * </p>
-     * @see java.util.regex.Pattern
-     * @see java.lang.String#matches(java.lang.String)
-     * @return Value of property directoryPattern.
-     */
-    @XmlElement(name="DirectoryPattern",namespace=XmlConfigUtils.NAMESPACE)
-    public String getDirectoryPattern() {
-        return this.directoryPattern;
-    }
-
-    /**
-     * Setter for property directoryPattern.
-     * @param directoryPattern New value of property directoryPattern.
-     * This is a regular expression
-     * against which directory names should be {@link #getDirectoryPattern
-     * matched}.
-     * @see java.util.regex.Pattern
-     * @see java.lang.String#matches(java.lang.String)
-     */
-    public void setDirectoryPattern(String directoryPattern) {
-        this.directoryPattern = directoryPattern;
-    }
-
-    /**
-     * Getter for property filePattern. This is a regular expression
-     * against which file names should be matched.
-     * Applies only to files.
-     * <p>
-     *    If File.isDirectory()==false && filePattern!=null &&
-     *    File.getName().matches(filePattern)==false,
-     *    then File doesn't match this filter.
-     * </p>
-     * @see java.util.regex.Pattern
-     * @see java.lang.String#matches(java.lang.String)
-     * @return Value of property filePatern.
-     */
-    @XmlElement(name="FilePattern",namespace=XmlConfigUtils.NAMESPACE)
-    public String getFilePattern() {
-        return this.filePattern;
-    }
-
-    /**
-     * Setter for property filePattern.
-     * @param filePattern New value of property filePattern.
-     * This is a regular expression
-     * against which file names should be {@link #getFilePattern matched}.
-     * @see java.util.regex.Pattern
-     * @see java.lang.String#matches(java.lang.String)
-     */
-    public void setFilePattern(String filePattern) {
-        this.filePattern = filePattern;
-    }
-
-    /**
-     * Getter for property sizeExceedsMaxBytes.
-     * Ignored if 0 or negative. Otherwise, files whose size in bytes does
-     * not exceed this limit will be excluded by this filter.
-     *
-     * @return Value of property sizeExceedsMaxBytes.
-     */
-    @XmlElement(name="SizeExceedsMaxBytes",namespace=XmlConfigUtils.NAMESPACE)
-    public long getSizeExceedsMaxBytes() {
-        return this.sizeExceedsMaxBytes;
-    }
-
-    /**
-     * Setter for property sizeExceedsMaxBytes.
-     * @param sizeLimitInBytes New value of property sizeExceedsMaxBytes.
-     * Ignored if 0 or negative. Otherwise, files whose size in bytes does
-     * not exceed this limit will be excluded by this filter.
-     *
-     */
-    public void setSizeExceedsMaxBytes(long sizeLimitInBytes) {
-        this.sizeExceedsMaxBytes = sizeLimitInBytes;
-    }
-
-    /**
-     * Getter for property {@code lastModifiedAfter}.
-     * A file will be selected only if it was last modified after
-     * {@code lastModifiedAfter}.
-     * <br>This condition is ignored if {@code lastModifiedAfter} is
-     * {@code null}.
-     * @return Value of property {@code lastModifiedAfter}.
-     */
-    @XmlElement(name="LastModifiedAfter",namespace=XmlConfigUtils.NAMESPACE)
-    public Date getLastModifiedAfter() {
-        return (lastModifiedAfter==null)?null:(Date)lastModifiedAfter.clone();
-    }
-
-    /**
-     * Setter for property {@code lastModifiedAfter}.
-     * @param lastModifiedAfter  A file will be selected only if it was
-     * last modified after  {@code lastModifiedAfter}.
-     * <br>This condition is ignored if {@code lastModifiedAfter} is
-     * {@code null}.
-     */
-    public void setLastModifiedAfter(Date lastModifiedAfter) {
-        this.lastModifiedAfter =
-                (lastModifiedAfter==null)?null:(Date)lastModifiedAfter.clone();
-    }
-
-    /**
-     * Getter for property {@code lastModifiedBefore}.
-     * A file will be selected only if it was last modified before
-     * {@code lastModifiedBefore}.
-     * <br>This condition is ignored if {@code lastModifiedBefore} is
-     * {@code null}.
-     * @return Value of property {@code lastModifiedBefore}.
-     */
-    @XmlElement(name="LastModifiedBefore",namespace=XmlConfigUtils.NAMESPACE)
-    public Date getLastModifiedBefore() {
-        return (lastModifiedBefore==null)?null:(Date)lastModifiedBefore.clone();
-    }
-
-    /**
-     * Setter for property {@code lastModifiedBefore}.
-     * @param lastModifiedBefore  A file will be selected only if it was
-     * last modified before {@code lastModifiedBefore}.
-     * <br>This condition is ignored if {@code lastModifiedBefore} is
-     * {@code null}.
-     */
-    public void setLastModifiedBefore(Date lastModifiedBefore) {
-        this.lastModifiedBefore =
-             (lastModifiedBefore==null)?null:(Date)lastModifiedBefore.clone();
-    }
-
-    // Accepts or rejects a file with regards to the values of the fields
-    // configured in this bean. The accept() method is the implementation
-    // of FileFilter.accept(File);
-    //
-    /**
-     * A file is accepted when all the criteria that have been set
-     * are matched.
-     * @param f The file to match against the configured criteria.
-     * @return {@code true} if the file matches all criteria,
-     * {@code false} otherwise.
-     */
-    public boolean accept(File f) {
-
-        // Directories are accepted if they match against the directory pattern.
-        //
-        if (f.isDirectory()) {
-            if (directoryPattern != null
-                && !f.getName().matches(directoryPattern))
-                return false;
-            else return true;
-        }
-
-        // If we reach here, the f is not a directory.
-        //
-        // Files are accepted if they match all other conditions.
-
-        // Check whether f matches filePattern
-        if (filePattern != null
-                && !f.getName().matches(filePattern))
-            return false;
-
-        // Check whether f exceeeds size limit
-        if (sizeExceedsMaxBytes > 0 && f.length() <= sizeExceedsMaxBytes)
-            return false;
-
-        // Check whether f was last modified after lastModifiedAfter
-        if (lastModifiedAfter != null &&
-                lastModifiedAfter.after(new Date(f.lastModified())))
-            return false;
-
-        // Check whether f was last modified before lastModifiedBefore
-        if (lastModifiedBefore != null &&
-                lastModifiedBefore.before(new Date(f.lastModified())))
-            return false;
-
-        // All conditions were met: accept file.
-        return true;
-    }
-
-    // used by equals()
-    private Object[] toArray() {
-        final Object[] thisconfig = {
-            directoryPattern, filePattern, lastModifiedAfter,
-            lastModifiedBefore, sizeExceedsMaxBytes
-        };
-        return thisconfig;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (o == this) return true;
-        if (!(o instanceof FileMatch)) return false;
-        final FileMatch other = (FileMatch)o;
-        final Object[] thisconfig = toArray();
-        final Object[] otherconfig = other.toArray();
-        return Arrays.deepEquals(thisconfig,otherconfig);
-    }
-
-    @Override
-    public int hashCode() {
-        return Arrays.deepHashCode(toArray());
-    }
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/ResultLogConfig.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir.config;
-
-import java.util.Arrays;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * The <code>ResultLogConfig</code> Java Bean is used to model
- * the initial configuration of the {@link
- * com.sun.jmx.examples.scandir.ResultLogManagerMXBean}.
- *
- * <p>
- * This class is annotated for XML binding.
- * </p>
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-@XmlRootElement(name="ResultLogConfig",
-        namespace=XmlConfigUtils.NAMESPACE)
-public class ResultLogConfig {
-
-    //
-    // A logger for this class.
-    //
-    // private static final Logger LOG =
-    //        Logger.getLogger(ResultLogConfig.class.getName());
-
-    /**
-     * The path to the result log file. {@code null} means that logging to
-     * file is disabled.
-     */
-    private String logFileName;
-
-    /**
-     * Maximum number of record that will be logged in the log file before
-     * switching to a new log file.
-     */
-    private long logFileMaxRecords;
-
-    /**
-     * The maximum number of records that can be contained in the memory log.
-     * When this number is reached, the memory log drops its eldest record
-     * to make way for the new one.
-     */
-    private int memoryMaxRecords;
-
-    /**
-     * Creates a new instance of ResultLogConfig
-     */
-    public ResultLogConfig() {
-    }
-
-    /**
-     * Gets the path to the result log file. {@code null} means that logging to
-     * file is disabled.
-     * @return the path to the result log file.
-     */
-    @XmlElement(name="LogFileName",namespace=XmlConfigUtils.NAMESPACE)
-    public String getLogFileName() {
-        return this.logFileName;
-    }
-
-    /**
-     * Sets the path to the result log file. {@code null} means that
-     * logging to file is disabled.
-     * @param logFileName the path to the result log file.
-     */
-    public void setLogFileName(String logFileName) {
-        this.logFileName = logFileName;
-    }
-
-    /**
-     * Gets the maximum number of record that will be logged in the log file
-     * before switching to a new log file.
-     * A 0 or negative value means no limit.
-     * @return the maximum number of record that will be logged in the log file.
-     */
-    @XmlElement(name="LogFileMaxRecords",namespace=XmlConfigUtils.NAMESPACE)
-    public long getLogFileMaxRecords() {
-        return this.logFileMaxRecords;
-    }
-
-    /**
-     * Sets the maximum number of record that will be logged in the log file
-     * before switching to a new log file.
-     * A 0 or negative value means no limit.
-     * @param logFileMaxRecords the maximum number of record that will be
-     * logged in the log file.
-     */
-    public void setLogFileMaxRecords(long logFileMaxRecords) {
-        this.logFileMaxRecords = logFileMaxRecords;
-    }
-
-    /**
-     * Gets the maximum number of records that can be contained in the memory
-     * log.
-     * When this number is reached, the memory log drops its eldest record
-     * to make way for the new one.
-     * @return the maximum number of records that can be contained in the
-     * memory log.
-     */
-    @XmlElement(name="MemoryMaxRecords",namespace=XmlConfigUtils.NAMESPACE)
-    public int getMemoryMaxRecords() {
-        return this.memoryMaxRecords;
-    }
-
-    /**
-     * Sets the maximum number of records that can be contained in the memory
-     * log.
-     * When this number is reached, the memory log drops its eldest record
-     * to make way for the new one.
-     * @param memoryMaxRecords the maximum number of records that can be
-     * contained in the memory log.
-     */
-    public void setMemoryMaxRecords(int memoryMaxRecords) {
-        this.memoryMaxRecords = memoryMaxRecords;
-    }
-
-    private Object[] toArray() {
-        final Object[] thisconfig = {
-            memoryMaxRecords,logFileMaxRecords,logFileName
-        };
-        return thisconfig;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (o == this) return true;
-        if (!(o instanceof ResultLogConfig)) return false;
-        final ResultLogConfig other = (ResultLogConfig)o;
-        return Arrays.deepEquals(toArray(),other.toArray());
-    }
-
-    @Override
-    public int hashCode() {
-        return Arrays.deepHashCode(toArray());
-    }
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/ResultRecord.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,205 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir.config;
-
-import java.util.Date;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlList;
-import javax.xml.bind.annotation.XmlRootElement;
-import com.sun.jmx.examples.scandir.config.DirectoryScannerConfig.Action;
-import java.io.File;
-import java.util.Arrays;
-
-/**
- * The <code>ResultRecord</code> Java Bean is used to write the
- * results of a directory scan to a result log.
- *
- * <p>
- * This class is annotated for XML binding.
- * </p>
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-@XmlRootElement(name="ResultRecord",namespace=XmlConfigUtils.NAMESPACE)
-public class ResultRecord {
-
-    /**
-     * The name of the file for which this result record is built.
-     */
-    private String filename;
-
-    /**
-     * The Date at which this result was obtained.
-     */
-    private Date date;
-
-    /**
-     * The short name of the directory scanner which performed the operation.
-     * @see DirectoryScannerConfig#getName()
-     */
-    private String directoryScanner;
-
-    /**
-     * The list of actions that were successfully carried out.
-     */
-    private Action[] actions;
-
-    /**
-     * Creates a new empty instance of ResultRecord.
-     */
-    public ResultRecord() {
-    }
-
-    /**
-     * Creates a new instance of ResultRecord.
-     * @param scan The DirectoryScannerConfig for which this result was
-     *        obtained.
-     * @param actions The list of actions that were successfully carried out.
-     * @param f The file for which these actions were successfully carried out.
-     */
-    public ResultRecord(DirectoryScannerConfig scan, Action[] actions,
-                     File f) {
-        directoryScanner = scan.getName();
-        this.actions = actions;
-        date = new Date();
-        filename = f.getAbsolutePath();
-    }
-
-    /**
-     * Gets the name of the file for which this result record is built.
-     * @return The name of the file for which this result record is built.
-     */
-    @XmlElement(name="Filename",namespace=XmlConfigUtils.NAMESPACE)
-    public String getFilename() {
-        return this.filename;
-    }
-
-    /**
-     * Sets the name of the file for which this result record is being built.
-     * @param filename the name of the file for which this result record is
-     *        being built.
-     */
-    public void setFilename(String filename) {
-        this.filename = filename;
-    }
-
-    /**
-     * Gets the Date at which this result was obtained.
-     * @return the Date at which this result was obtained.
-     */
-    @XmlElement(name="Date",namespace=XmlConfigUtils.NAMESPACE)
-    public Date getDate() {
-        synchronized(this) {
-            return (date==null)?null:(new Date(date.getTime()));
-        }
-    }
-
-    /**
-     * Sets the Date at which this result was obtained.
-     * @param date the Date at which this result was obtained.
-     */
-    public void setDate(Date date) {
-        synchronized (this) {
-            this.date = (date==null)?null:(new Date(date.getTime()));
-        }
-    }
-
-    /**
-     * Gets the short name of the directory scanner which performed the
-     * operation.
-     * @see DirectoryScannerConfig#getName()
-     * @return the short name of the directory scanner which performed the
-     * operation.
-     */
-    @XmlElement(name="DirectoryScanner",namespace=XmlConfigUtils.NAMESPACE)
-    public String getDirectoryScanner() {
-        return this.directoryScanner;
-    }
-
-    /**
-     * Sets the short name of the directory scanner which performed the
-     * operation.
-     * @see DirectoryScannerConfig#getName()
-     * @param directoryScanner the short name of the directory scanner which
-     * performed the operation.
-     */
-    public void setDirectoryScanner(String directoryScanner) {
-        this.directoryScanner = directoryScanner;
-    }
-
-    /**
-     * Gets the list of actions that were successfully carried out.
-     * @return the list of actions that were successfully carried out.
-     */
-    @XmlElement(name="Actions",namespace=XmlConfigUtils.NAMESPACE)
-    @XmlList
-    public Action[] getActions() {
-        return (actions == null)?null:actions.clone();
-    }
-
-    /**
-     * Sets the list of actions that were successfully carried out.
-     * @param actions the list of actions that were successfully carried out.
-     */
-    public void setActions(Action[] actions) {
-        this.actions = (actions == null)?null:actions.clone();
-    }
-
-    // Used for equality
-    private Object[] toArray() {
-        final Object[] thisconfig = {
-            filename, date, directoryScanner, actions
-        };
-        return thisconfig;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (!(o instanceof ResultRecord)) return false;
-        return Arrays.deepEquals(toArray(),((ResultRecord)o).toArray());
-    }
-
-    @Override
-    public int hashCode() {
-        return Arrays.deepHashCode(toArray());
-    }
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/ScanManagerConfig.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,304 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir.config;
-
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementRef;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-
-
-/**
- * The <code>ScanManagerConfig</code> Java Bean is used to model
- * the configuration of the {@link
- * com.sun.jmx.examples.scandir.ScanManagerMXBean ScanManagerMXBean}.
- *
- * The {@link
- * com.sun.jmx.examples.scandir.ScanManagerMXBean ScanManagerMXBean} will
- * use this configuration to initialize the {@link
- * com.sun.jmx.examples.scandir.ResultLogManagerMXBean ResultLogManagerMXBean}
- * and create the {@link
- * com.sun.jmx.examples.scandir.DirectoryScannerMXBean DirectoryScannerMXBeans}
- * <p>
- * This class is annotated for XML binding.
- * </p>
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- **/
-@XmlRootElement(name="ScanManager",
-        namespace="jmx:com.sun.jmx.examples.scandir.config")
-public class ScanManagerConfig {
-
-    // A logger for this class
-    //
-    // private static final Logger LOG =
-    //        Logger.getLogger(ScanManagerConfig.class.getName());
-
-    /**
-     * A set of DirectoryScannerConfig objects indexed by their names.
-     **/
-    private final Map<String, DirectoryScannerConfig> directoryScanners;
-
-    /**
-     * The initial Result Log configuration.
-     */
-    private ResultLogConfig initialResultLogConfig;
-
-    /**
-     * Holds value of property name. The name of the configuration
-     *       usually corresponds to
-     *       the value of the {@code name=} key of the {@code ObjectName}
-     *       of the {@link
-     *       com.sun.jmx.examples.scandir.ScanDirConfigMXBean
-     *       ScanDirConfigMXBean} which owns this configuration.
-     **/
-    private String name;
-
-    /**
-     * Creates a new instance of ScanManagerConfig.
-     * <p>You should not use this constructor directly, but use
-     *    {@link #ScanManagerConfig(String)} instead.
-     * </p>
-     * <p>This constructor is tagged deprecated so that the compiler
-     *    will generate a warning if it is used by mistake.
-     * </p>
-     * @deprecated Use {@link #ScanManagerConfig(String)} instead. This
-     *             constructor is used through reflection by the XML
-     *             binding framework.
-     */
-    public ScanManagerConfig() {
-        this(null,true);
-    }
-
-    /**
-     * Creates a new instance of ScanManagerConfig.
-     * @param name The name of the configuration which usually corresponds to
-     *       the value of the {@code name=} key of the {@code ObjectName}
-     *       of the {@link
-     *       com.sun.jmx.examples.scandir.ScanDirConfigMXBean
-     *       ScanDirConfigMXBean} which owns this configuration.
-     **/
-    public ScanManagerConfig(String name) {
-        this(name,false);
-    }
-
-    // Our private constructor...
-    private ScanManagerConfig(String name, boolean allowsNull) {
-        if (name == null && allowsNull==false)
-            throw new IllegalArgumentException("name=null");
-        this.name = name;
-        directoryScanners = new LinkedHashMap<String,DirectoryScannerConfig>();
-        this.initialResultLogConfig = new ResultLogConfig();
-        this.initialResultLogConfig.setMemoryMaxRecords(1024);
-    }
-
-    // Creates an array for deep equality.
-    private Object[] toArray() {
-        final Object[] thisconfig = {
-            name,directoryScanners,initialResultLogConfig
-        };
-        return thisconfig;
-    }
-
-    // equals
-    @Override
-    public boolean equals(Object o) {
-        if (o == this) return true;
-        if (!(o instanceof ScanManagerConfig)) return false;
-        final ScanManagerConfig other = (ScanManagerConfig)o;
-        if (this.directoryScanners.size() != other.directoryScanners.size())
-            return false;
-        return Arrays.deepEquals(toArray(),other.toArray());
-    }
-
-    @Override
-    public int hashCode() {
-        final String key = name;
-        if (key == null) return 0;
-        else return key.hashCode();
-    }
-
-    /**
-     * Gets the name of this configuration. The name of the configuration
-     *       usually corresponds to
-     *       the value of the {@code name=} key of the {@code ObjectName}
-     *       of the {@link
-     *       com.sun.jmx.examples.scandir.ScanDirConfigMXBean
-     *       ScanDirConfigMXBean} which owns this configuration.
-     * @return The name of this configuration.
-     */
-    @XmlAttribute(name="name",required=true)
-    public String getName() {
-        return this.name;
-    }
-
-    /**
-     * Sets the name of this configuration. The name of the configuration
-     *       usually corresponds to
-     *       the value of the {@code name=} key of the {@code ObjectName}
-     *       of the {@link
-     *       com.sun.jmx.examples.scandir.ScanDirConfigMXBean
-     *       ScanDirConfigMXBean} which owns this configuration.
-     *       <p>Once set this value cannot change.</p>
-     * @param name The name of this configuration.
-     */
-    public void setName(String name) {
-        if (this.name == null)
-            this.name = name;
-        else if (name == null)
-            throw new IllegalArgumentException("name=null");
-        else if (!name.equals(this.name))
-            throw new IllegalArgumentException("name="+name);
-    }
-
-   /**
-    * Gets the list of Directory Scanner configured by this
-    * configuration. From each element in this list, the
-    * {@link com.sun.jmx.examples.scandir.ScanManagerMXBean ScanManagerMXBean}
-    * will create, initialize, and register a {@link
-    * com.sun.jmx.examples.scandir.DirectoryScannerMXBean}.
-    * @return The list of Directory Scanner configured by this configuration.
-    */
-    @XmlElementWrapper(name="DirectoryScannerList",
-            namespace=XmlConfigUtils.NAMESPACE)
-    @XmlElementRef
-    public DirectoryScannerConfig[] getScanList() {
-        return directoryScanners.values().toArray(new DirectoryScannerConfig[0]);
-    }
-
-   /**
-    * Sets the list of Directory Scanner configured by this
-    * configuration. From each element in this list, the
-    * {@link com.sun.jmx.examples.scandir.ScanManagerMXBean ScanManagerMXBean}
-    * will create, initialize, and register a {@link
-    * com.sun.jmx.examples.scandir.DirectoryScannerMXBean}.
-    * @param scans The list of Directory Scanner configured by this configuration.
-    */
-    public void setScanList(DirectoryScannerConfig[] scans) {
-        directoryScanners.clear();
-        for (DirectoryScannerConfig scan : scans)
-            directoryScanners.put(scan.getName(),scan);
-    }
-
-    /**
-     * Get a directory scanner by its name.
-     *
-     * @param name The name of the directory scanner. This is the
-     *             value returned by {@link
-     *             DirectoryScannerConfig#getName()}.
-     * @return The named {@code DirectoryScannerConfig}
-     */
-    public DirectoryScannerConfig getScan(String name) {
-        return directoryScanners.get(name);
-    }
-
-    /**
-     * Adds a directory scanner to the list.
-     * <p>If a directory scanner
-     * configuration by that name already exists in the list, it will
-     * be replaced by the given <var>scan</var>.
-     * </p>
-     * @param scan The {@code DirectoryScannerConfig} to add to the list.
-     * @return The replaced {@code DirectoryScannerConfig}, or {@code null}
-     *         if there was no {@code DirectoryScannerConfig} by that name
-     *         in the list.
-     */
-    public DirectoryScannerConfig putScan(DirectoryScannerConfig scan) {
-        return this.directoryScanners.put(scan.getName(),scan);
-    }
-
-    // XML value of  this object.
-    public String toString() {
-        return XmlConfigUtils.toString(this);
-    }
-
-    /**
-     * Removes the named directory scanner from the list.
-     *
-     * @param name The name of the directory scanner. This is the
-     *             value returned by {@link
-     *             DirectoryScannerConfig#getName()}.
-     * @return The removed {@code DirectoryScannerConfig}, or {@code null}
-     *         if there was no directory scanner by that name in the list.
-     */
-    public DirectoryScannerConfig removeScan(String name) {
-       return this.directoryScanners.remove(name);
-    }
-
-    /**
-     * Gets the initial Result Log Configuration.
-     * @return The initial Result Log Configuration.
-     */
-    @XmlElement(name="InitialResultLogConfig",namespace=XmlConfigUtils.NAMESPACE)
-    public ResultLogConfig getInitialResultLogConfig() {
-        return this.initialResultLogConfig;
-    }
-
-    /**
-     * Sets the initial Result Log Configuration.
-     * @param initialLogConfig The initial Result Log Configuration.
-     */
-    public void setInitialResultLogConfig(ResultLogConfig initialLogConfig) {
-        this.initialResultLogConfig = initialLogConfig;
-    }
-
-    /**
-     * Creates a copy of this object, with the specified name.
-     * @param newname the name of the copy.
-     * @return A copy of this object.
-     **/
-    public ScanManagerConfig copy(String newname) {
-        return copy(newname,this);
-    }
-
-    // Copy by XML cloning, then change the name.
-    //
-    private static ScanManagerConfig
-            copy(String newname, ScanManagerConfig other) {
-        ScanManagerConfig newbean = XmlConfigUtils.xmlClone(other);
-        newbean.name = newname;
-        return newbean;
-    }
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/XmlConfigUtils.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,393 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir.config;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.logging.Logger;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-
-/**
- * The class XmlConfigUtils is used to deal with XML serialization
- * and XML files.
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public class XmlConfigUtils {
-
-    /**
-     * A URI for our XML configuration namespace. This doesn't start with
-     * http:// because we are not going to publish this private schema
-     * anywhere.
-     **/
-    public static final String NAMESPACE =
-            "jmx:com.sun.jmx.examples.scandir.config";
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(XmlConfigUtils.class.getName());
-
-    // Our JAXBContext.
-    private static JAXBContext context;
-
-    // The file name of the XML file in which an instance of this object
-    // will read and write XML data.
-    final String file;
-
-    /**
-     * Creates a new instance of XmlConfigUtils.
-     * @param file The file name of the XML file in which an instance of this
-     *        object will read and write XML data.
-     */
-    public XmlConfigUtils(String file) {
-        this.file = file;
-    }
-
-    /**
-     * Write the given bean to the XML file.
-     * <p>
-     * Performs an atomic write, first writing in {@code <file>.new}, then
-     * renaming {@code <file>} to {@code <file>~}, then renaming
-     * renaming {@code <file>.new} to {@code <file>}.
-     * </p>
-     * @param bean The configuration to write in the XML file.
-     * @throws IOException if write to file failed.
-     **/
-    public synchronized void writeToFile(ScanManagerConfig bean)
-        throws IOException {
-
-        // Creates a new file named <file>.new
-        final File f = newXmlTmpFile(file);
-        try {
-            final FileOutputStream out = new FileOutputStream(f);
-            boolean failed = true;
-            try {
-                // writes to <file>.new
-                write(bean,out,false);
-
-                // no exception: set failed=false for finaly {} block.
-                failed = false;
-            } finally {
-                out.close();
-                // An exception was raised: delete temporary file.
-                if (failed == true) f.delete();
-            }
-
-            // rename <file> to <file>~ and <file>.new to <file>
-            commit(file,f);
-        } catch (JAXBException x) {
-            final IOException io =
-                    new IOException("Failed to write SessionConfigBean to " +
-                    file+": "+x,x);
-            throw io;
-        }
-    }
-
-    /**
-     * Creates an XML string representation of the given bean.
-     * @throws IllegalArgumentException if the bean class is not known by the
-     *         underlying XMLbinding context.
-     * @return An XML string representation of the given bean.
-     **/
-    public static String toString(Object bean) {
-        try {
-            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            final Marshaller m = createMarshaller();
-            m.setProperty(m.JAXB_FRAGMENT,Boolean.TRUE);
-            m.marshal(bean, baos);
-            return baos.toString();
-        } catch (JAXBException x) {
-            final IllegalArgumentException iae =
-                    new IllegalArgumentException(
-                        "Failed to write SessionConfigBean: "+x,x);
-            throw iae;
-        }
-    }
-
-    /**
-     * Creates an XML clone of the given bean.
-     * <p>
-     * In other words, this method XML-serializes the given bean, and
-     * XML-deserializes a copy of that bean.
-     * </p>
-     * @return A deep-clone of the given bean.
-     * @throws IllegalArgumentException if the bean class is not known by the
-     *         underlying XML binding context.
-     * @param bean The bean to clone.
-     */
-    public static ScanManagerConfig xmlClone(ScanManagerConfig bean) {
-        final Object clone = copy(bean);
-        return (ScanManagerConfig)clone;
-    }
-
-    /**
-     * Creates an XML clone of the given bean.
-     * <p>
-     * In other words, this method XML-serializes the given bean, and
-     * XML-deserializes a copy of that bean.
-     * </p>
-     * @throws IllegalArgumentException if the bean class is not known by the
-     *         underlying XML binding context.
-     * @return A deep-clone of the given bean.
-     **/
-    private static Object copy(Object bean) {
-        try {
-            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            final Marshaller m = createMarshaller();
-            m.marshal(bean, baos);
-            final ByteArrayInputStream bais =
-                    new ByteArrayInputStream(baos.toByteArray());
-            return createUnmarshaller().unmarshal(bais);
-        } catch (JAXBException x) {
-            final IllegalArgumentException iae =
-                    new IllegalArgumentException("Failed to write SessionConfigBean: "+x,x);
-            throw iae;
-        }
-    }
-
-    /**
-     * Creates an XML clone of the given bean.
-     * <p>
-     * In other words, this method XML-serializes the given bean, and
-     * XML-deserializes a copy of that bean.
-     * </p>
-     * @return A deep-clone of the given bean.
-     * @throws IllegalArgumentException if the bean class is not known by the
-     *         underlying XML binding context.
-     * @param bean The bean to clone.
-     */
-    public static DirectoryScannerConfig xmlClone(DirectoryScannerConfig bean) {
-        final Object clone = copy(bean);
-        return (DirectoryScannerConfig)clone;
-    }
-
-    /**
-     * Reads the configuration from the XML configuration file.
-     * @throws IOException if it fails to read the configuration.
-     * @return A {@code ScanManagerConfig} bean read from the
-     *         XML configuration file.
-     **/
-    public synchronized ScanManagerConfig readFromFile() throws IOException {
-        final File f = new File(file);
-        if (!f.exists())
-            throw new IOException("No such file: "+file);
-        if (!f.canRead())
-            throw new IOException("Can't read file: "+file);
-        try {
-            return read(f);
-        } catch (JAXBException x) {
-            final IOException io =
-                    new IOException("Failed to read SessionConfigBean from " +
-                    file+": "+x,x);
-            throw io;
-        }
-    }
-
-    /**
-     * Reads the configuration from the given XML configuration file.
-     * @param f the file to read from.
-     * @return A {@code ScanManagerConfig} bean read from the
-     *         XML configuration file.
-     * @throws javax.xml.bind.JAXBException if it fails to read the configuration.
-     */
-    public static ScanManagerConfig read(File f)
-        throws JAXBException {
-        final Unmarshaller u = createUnmarshaller();
-        return (ScanManagerConfig) u.unmarshal(f);
-
-    }
-
-    /**
-     * Writes the given bean to the given output stream.
-     * @param bean the bean to write.
-     * @param os the output stream to write to.
-     * @param fragment whether the {@code <?xml ... ?>} header should be
-     *        included. The header is not included if the bean is just an
-     *        XML fragment encapsulated in a higher level XML element.
-     * @throws JAXBException An XML Binding exception occurred.
-     **/
-    public static void write(ScanManagerConfig bean, OutputStream os,
-            boolean fragment)
-        throws JAXBException {
-        writeXml((Object)bean,os,fragment);
-    }
-
-    /**
-     * Writes the given bean to the given output stream.
-     * @param bean the bean to write.
-     * @param os the output stream to write to.
-     * @param fragment whether the {@code <?xml ... ?>} header should be
-     *        included. The header is not included if the bean is just an
-     *        XML fragment encapsulated in a higher level XML element.
-     * @throws JAXBException An XML Binding exception occurred.
-     **/
-    public static void write(ResultRecord bean, OutputStream os, boolean fragment)
-        throws JAXBException {
-        writeXml((Object)bean,os,fragment);
-    }
-
-    /**
-     * Writes the given bean to the given output stream.
-     * @param bean the bean to write.
-     * @param os the output stream to write to.
-     * @param fragment whether the {@code <?xml ... ?>} header should be
-     *        included. The header is not included if the bean is just an
-     *        XML fragment encapsulated in a higher level XML element.
-     * @throws JAXBException An XML Binding exception occurred.
-     **/
-    private static void writeXml(Object bean, OutputStream os, boolean fragment)
-        throws JAXBException {
-        final Marshaller m = createMarshaller();
-        if (fragment) m.setProperty(m.JAXB_FRAGMENT,Boolean.TRUE);
-        m.marshal(bean,os);
-    }
-
-    // Creates a JAXB Unmarshaller.
-    private static Unmarshaller createUnmarshaller() throws JAXBException {
-        return getContext().createUnmarshaller();
-    }
-
-    // Creates a JAXB Marshaller - for nicely XML formatted output.
-    private static Marshaller createMarshaller() throws JAXBException {
-        final  Marshaller m = getContext().createMarshaller();
-        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,Boolean.TRUE);
-        return m;
-    }
-
-    // Creates a JAXBContext if needed, and returns it.
-    // The JAXBContext instance we create will be able to handle the
-    // ScanManagerConfig and ResultRecord classes, plus all the property
-    // classes they reference (DirectoryScannerBean etc...).
-    //
-    private static synchronized JAXBContext getContext() throws JAXBException {
-        if (context == null)
-            context = JAXBContext.newInstance(ScanManagerConfig.class,
-                                              ResultRecord.class);
-        return context;
-    }
-
-
-    // Creates a new XML temporary file called <basename>.new
-    // This method is used to implement atomic writing to file.
-    // The usual sequence is:
-    //
-    // Final tmp = newXmlTmpFile(basename);
-    // boolean failed = true;
-    // try {
-    //      ... write to 'tmp' ...
-    //      // no exception: set failed=false for finaly {} block.
-    //      failed = false;
-    // } finally
-    //      // failed==true means there was an exception and
-    //      // commit won't be called...
-    //      if (failed==true) tmp.delete();
-    // }
-    // commit(tmp,basename)
-    //
-    private static File newXmlTmpFile(String basename) throws IOException {
-        final File f = new File(basename+".new");
-        if (!f.createNewFile())
-            throw new IOException("file "+f.getName()+" already exists");
-
-        try {
-            final OutputStream newStream = new FileOutputStream(f);
-            try {
-                final String decl =
-                    "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
-                newStream.write(decl.getBytes("UTF-8"));
-                newStream.flush();
-            } finally {
-                newStream.close();
-            }
-        } catch (IOException x) {
-            f.delete();
-            throw x;
-        }
-        return f;
-    }
-
-    // Commit the temporary file by renaming <basename> to <baesname>~
-    // and tmpFile to <basename>.
-    private static File commit(String basename, File tmpFile)
-        throws IOException {
-        try {
-            final String backupName = basename+"~";
-            final File desired = new File(basename);
-            final File backup = new File(backupName);
-            backup.delete();
-            if (desired.exists()) {
-                if (!desired.renameTo(new File(backupName)))
-                    throw new IOException("can't rename to "+backupName);
-            }
-            if (!tmpFile.renameTo(new File(basename)))
-                throw new IOException("can't rename to "+basename);
-        } catch (IOException x) {
-            tmpFile.delete();
-            throw x;
-        }
-        return new File(basename);
-    }
-
-    /**
-     * Creates a new committed XML file for {@code <basename>}, containing only
-     * the {@code <?xml ...?>} header.
-     * <p>This method will rename {@code <basename>} to {@code <basename>~},
-     * if it exists.
-     * </p>
-     * @return A newly created XML file containing the regular
-     *         {@code <?xml ...?>} header.
-     * @param basename The name of the new file.
-     * @throws IOException if the new XML file couldn't be created.
-     */
-    public static File createNewXmlFile(String basename) throws IOException {
-        return commit(basename,newXmlTmpFile(basename));
-    }
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/config/package.html	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<html>
-  <head>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-    <title>com.sun.jmx.examples.scandir.config</title>
-  </head>
-  <body>
-  <p>
-     This package defines plain Java Beans, annotated for
-     XML bindings, and used to store and model the scandir 
-     application configuration.
-  </p>
-  <p>All the Java Beans defined in this package have been 
-     designed to be <i>naturally serialized</i> by JAXB.
-     Their bean properties were designed to minimize
-     the number of XML annotation required, as well as 
-     making them transparently convertible by the 
-     JMX MXBean framework.
-  </p>
-  <p>The {@link com.sun.jmx.examples.scandir.config.ScanManagerConfig} 
-     bean corresponds to the root element of the application's configuration.
-     From an instance of this element, the 
-     {@link com.sun.jmx.examples.scandir.ScanManagerMXBean} will be
-     able to initialize the 
-     {@link com.sun.jmx.examples.scandir.ResultLogManagerMXBean} and will
-     create, register and initialize 
-     {@link com.sun.jmx.examples.scandir.DirectoryScannerMXBean DirectoryScannerMXBeans}
-  </p>
-  <p>The {@link com.sun.jmx.examples.scandir.config.XmlConfigUtils} class is a simple utility
-     classes used to deal with XML and XML configuration files.
-  </p>
-  <p>The {@link com.sun.jmx.examples.scandir.config.ResultRecord ResultRecords} 
-     are used to store the results of directory scans in the result logs
-     managed by the {@link com.sun.jmx.examples.scandir.ResultLogManagerMXBean}
-  </p>
-  </body>
-</html>
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/com/sun/jmx/examples/scandir/package.html	Thu Apr 20 18:14:05 2017 +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>
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-    <title>com.sun.jmx.examples.scandir</title>
-  </head>
-  <body>
-  <p>
-  This package defines the set of MBeans which compose the
-  management interface of the scandir application.
-  </p>
-  
-  </body>
-</html>
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/etc/access.properties	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-######################################################################
-#     Default Access Control File for Remote JMX(TM) Monitoring
-######################################################################
-#
-# Access control file for Remote JMX API access to monitoring.
-# This file defines the allowed access for different roles.  The
-# password file (jmxremote.password by default) defines the roles and their
-# passwords.  To be functional, a role must have an entry in
-# both the password and the access files.
-#
-# Default location of this file is $JRE/conf/management/jmxremote.access
-# You can specify an alternate location by specifying a property in
-# the management config file $JRE/conf/management/management.properties
-# (See that file for details)
-#
-# The file format for password and access files is syntactically the same
-# as the Properties file format.  The syntax is described in the Javadoc
-# for java.util.Properties.load.
-# Typical access file has multiple  lines, where each line is blank,
-# a comment (like this one), or an access control entry.
-#
-# An access control entry consists of a role name, and an
-# associated access level.  The role name is any string that does not
-# itself contain spaces or tabs.  It corresponds to an entry in the
-# password file (jmxremote.password).  The access level is one of the
-# following:
-#       "readonly" grants access to read attributes of MBeans.
-#                   For monitoring, this means that a remote client in this
-#                   role can read measurements but cannot perform any action
-#                   that changes the environment of the running program.
-#       "readwrite" grants access to read and write attributes of MBeans,
-#                   to invoke operations on them, and to create or remove them.
-#		    This access should be granted to only trusted clients,
-#                   since they can potentially interfere with the smooth
-#		    operation of a running program
-#
-# A given role should have at most one entry in this file.  If a role
-# has no entry, it has no access.
-# If multiple entries are found for the same role name, then the last
-# access entry is used.
-#
-#
-# Default access control entries:
-# o The "monitorRole" role has readonly access.
-# o The "controlRole" role has readwrite access.
-#
-# monitorRole   readonly
-# controlRole   readwrite
-
-guest   readonly
-admin   readwrite
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/etc/management.properties	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,273 +0,0 @@
-#####################################################################
-#	Default Configuration File for Java Platform Management
-#####################################################################
-#
-# The Management Configuration file (in java.util.Properties format)
-# will be read if one of the following system properties is set:
-#    -Dcom.sun.management.jmxremote.port=<port-number>
-# or -Dcom.sun.management.snmp.port=<port-number>
-# or -Dcom.sun.management.config.file=<this-file>
-#
-# The default Management Configuration file is:
-#
-#       $JRE/conf/management/management.properties
-#
-# Another location for the Management Configuration File can be specified
-# by the following property on the Java command line:
-#
-#    -Dcom.sun.management.config.file=<this-file>
-#
-# If -Dcom.sun.management.config.file=<this-file> is set, the port
-# number for the management agent can be specified in the config file
-# using the following lines:
-#
-# ################ Management Agent Port #########################
-#
-# For setting the JMX RMI agent port use the following line
-com.sun.management.jmxremote.port=4545
-#
-# For setting the SNMP agent port use the following line
-# com.sun.management.snmp.port=<port-number>
-
-#####################################################################
-#                   Optional Instrumentation
-#####################################################################
-#
-# By default only the basic instrumentation with low overhead is on.
-# The following properties allow to selectively turn on optional
-# instrumentation which are off by default and may have some
-# additional overhead.
-#
-# com.sun.management.enableThreadContentionMonitoring
-#
-#      This option enables thread contention monitoring if the
-#      Java virtual machine supports such instrumentation.
-#      Refer to the specification for the java.lang.management.ThreadMBean
-#      interface - see isThreadContentionMonitoringSupported() method.
-#
-
-# To enable thread contention monitoring, uncomment the following line
-# com.sun.management.enableThreadContentionMonitoring
-
-#####################################################################
-#			SNMP Management Properties
-#####################################################################
-#
-# If the system property -Dcom.sun.management.snmp.port=<port-number>
-# is set then
-#	- The SNMP agent (with the Java virtual machine MIB) is started
-#	  that listens on the specified port for incoming SNMP requests.
-#	- the following properties for read for SNMP management.
-#
-# The configuration can be specified only at startup time.
-# Later changes to the above system property (e.g. via setProperty method), this
-# config file, or the ACL file has no effect to the running SNMP agent.
-#
-
-#
-# ##################### SNMP Trap Port #########################
-#
-# com.sun.management.snmp.trap=<trap-destination-port-number>
-#      Specifies the remote port number at which managers are expected
-#      to listen for trap. For each host defined in the ACL file,
-#      the SNMP agent will send traps at <host>:<trap-destination-port-number>
-#      Default for this property is 162.
-#
-
-# To set port for sending traps to a different port use the following line
-# com.sun.management.snmp.trap=<trap-destination-port-number>
-
-#
-# ################ SNMP listen interface #########################
-#
-# com.sun.management.snmp.interface=<InetAddress>
-#      Specifies the local interface on which the SNMP agent will bind.
-#      This is usefull when running on machines which have several
-#      interfaces defined. It makes it possible to listen to a specific
-#      subnet accessible through that interface.
-#      Default for this property is "localhost".
-#
-#      The format of the value for that property is any string accepted
-#      by java.net.InetAddress.getByName(String).
-#
-
-# For restricting the port on which SNMP agent listens use the following line
-# com.sun.management.snmp.interface=<InetAddress>
-
-#
-# #################### SNMP ACL file #########################
-#
-# com.sun.management.snmp.acl=true|false
-#      Default for this property is true. (Case for true/false ignored)
-#      If this property is specified as false then the ACL file
-#      is not checked:  all manager hosts are allowed all access.
-#
-
-# For SNMP without checking ACL file uncomment the following line
-# com.sun.management.snmp.acl=false
-
-#
-# com.sun.management.snmp.acl.file=filepath
-#      Specifies location for ACL file
-#      This is optional - default location is
-#      $JRE/conf/management/snmp.acl
-#
-#      If the property "com.sun.management.snmp.acl" is set to false,
-#      then this property and the ACL file are ignored.
-#      Otherwise the ACL file must exist and be in the valid format.
-#      If the ACL file is empty or non existent then no access is allowed.
-#
-#      The SNMP agent will read the ACL file at startup time.
-#      Modification to the ACL file has no effect to any running SNMP
-#      agents which read that ACL file at startup.
-#
-
-# For a non-default acl file location use the following line
-# com.sun.management.snmp.acl.file=filepath
-
-#####################################################################
-#			RMI Management Properties
-#####################################################################
-#
-# If system property -Dcom.sun.management.jmxremote.port=<port-number>
-# is set then
-#     - A MBean server is started
-#     - JRE Platform MBeans are registered in the MBean server
-#     - RMI connector is published  in a private readonly registry at
-#       specified port using a well known name, "jmxrmi"
-#     - the following properties are read for JMX remote management.
-#
-# The configuration can be specified only at startup time.
-# Later changes to above system property (e.g. via setProperty method),
-# this config file, the password file, or the access file have no effect to the
-# running MBean server, the connector, or the registry.
-#
-
-#
-# ###################### RMI SSL #############################
-#
-# com.sun.management.jmxremote.ssl=true|false
-#      Default for this property is true. (Case for true/false ignored)
-#      If this property is specified as false then SSL is not used.
-#
-
-# For RMI monitoring without SSL use the following line
-# com.sun.management.jmxremote.ssl=false
-
-# com.sun.management.jmxremote.ssl.enabled.cipher.suites=<cipher-suites>
-#      The value of this property is a string that is a comma-separated list
-#      of SSL/TLS cipher suites to enable. This property can be specified in
-#      conjunction with the previous property "com.sun.management.jmxremote.ssl"
-#      in order to control which particular SSL/TLS cipher suites are enabled
-#      for use by accepted connections. If this property is not specified then
-#      the SSL/TLS RMI Server Socket Factory uses the SSL/TLS cipher suites that
-#      are enabled by default.
-#
-
-# com.sun.management.jmxremote.ssl.enabled.protocols=<protocol-versions>
-#      The value of this property is a string that is a comma-separated list
-#      of SSL/TLS protocol versions to enable. This property can be specified in
-#      conjunction with the previous property "com.sun.management.jmxremote.ssl"
-#      in order to control which particular SSL/TLS protocol versions are
-#      enabled for use by accepted connections. If this property is not
-#      specified then the SSL/TLS RMI Server Socket Factory uses the SSL/TLS
-#      protocol versions that are enabled by default.
-#
-
-# com.sun.management.jmxremote.ssl.need.client.auth=true|false
-#      Default for this property is false. (Case for true/false ignored)
-#      If this property is specified as true in conjunction with the previous
-#      property "com.sun.management.jmxremote.ssl" then the SSL/TLS RMI Server
-#      Socket Factory will require client authentication.
-#
-
-# For RMI monitoring with SSL client authentication use the following line
-com.sun.management.jmxremote.ssl.need.client.auth=true
-
-# com.sun.management.jmxremote.registry.ssl=true|false
-#      Default for this property is false. (Case for true/false ignored)
-#      If this property is specified as true then the RMI registry used
-#      to bind the RMIServer remote object is protected with SSL/TLS
-#      RMI Socket Factories that can be configured with the properties:
-#          com.sun.management.jmxremote.ssl.enabled.cipher.suites
-#          com.sun.management.jmxremote.ssl.enabled.protocols
-#          com.sun.management.jmxremote.ssl.need.client.auth
-#      If the two properties below are true at the same time, i.e.
-#          com.sun.management.jmxremote.ssl=true
-#          com.sun.management.jmxremote.registry.ssl=true
-#      then the RMIServer remote object and the RMI registry are
-#      both exported with the same SSL/TLS RMI Socket Factories.
-#
-
-# For using an SSL/TLS protected RMI registry use the following line
-com.sun.management.jmxremote.registry.ssl=true
-
-#
-# ################ RMI User authentication ################
-#
-# com.sun.management.jmxremote.authenticate=true|false
-#      Default for this property is true. (Case for true/false ignored)
-#      If this property is specified as false then no authentication is
-#      performed and all users are allowed all access.
-#
-
-# For RMI monitoring without any checking use the following line
-# com.sun.management.jmxremote.authenticate=false
-
-#
-# ################ RMI Login configuration ###################
-#
-# com.sun.management.jmxremote.login.config=<config-name>
-#      Specifies the name of a JAAS login configuration entry to use when
-#      authenticating users of RMI monitoring.
-#
-#      Setting this property is optional - the default login configuration
-#      specifies a file-based authentication that uses the password file.
-#
-#      When using this property to override the default login configuration
-#      then the named configuration entry must be in a file that gets loaded
-#      by JAAS. In addition, the login module(s) specified in the configuration
-#      should use the name and/or password callbacks to acquire the user's
-#      credentials. See the NameCallback and PasswordCallback classes in the
-#      javax.security.auth.callback package for more details.
-#
-#      If the property "com.sun.management.jmxremote.authenticate" is set to
-#      false, then this property and the password & access files are ignored.
-#
-
-# For a non-default login configuration use the following line
-# com.sun.management.jmxremote.login.config=<config-name>
-
-#
-# ################ RMI Password file location ##################
-#
-# com.sun.management.jmxremote.password.file=filepath
-#      Specifies location for password file
-#      This is optional - default location is
-#      $JRE/conf/management/jmxremote.password
-#
-#      If the property "com.sun.management.jmxremote.authenticate" is set to
-#      false, then this property and the password & access files are ignored.
-#      Otherwise the password file must exist and be in the valid format.
-#      If the password file is empty or non-existent then no access is allowed.
-#
-
-# For a non-default password file location use the following line
-com.sun.management.jmxremote.password.file=src/etc/password.properties
-
-#
-# ################ RMI Access file location #####################
-#
-# com.sun.management.jmxremote.access.file=filepath
-#      Specifies location for access  file
-#      This is optional - default location is
-#      $JRE/conf/management/jmxremote.access
-#
-#      If the property "com.sun.management.jmxremote.authenticate" is set to
-#      false, then this property and the password & access files are ignored.
-#      Otherwise, the access file must exist and be in the valid format.
-#      If the access file is empty or non-existent then no access is allowed.
-#
-
-# For a non-default password file location use the following line
-com.sun.management.jmxremote.access.file=src/etc/access.properties
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/etc/password.properties	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-##############################################################
-#        Password File for Remote JMX Monitoring
-##############################################################
-#
-# Password file for Remote JMX API access to monitoring.  This
-# file defines the different roles and their passwords.  The access
-# control file (jmxremote.access by default) defines the allowed
-# access for each role.  To be functional, a role must have an entry
-# in both the password and the access files.
-#
-# Default location of this file is $JRE/conf/management/jmxremote.password
-# You can specify an alternate location by specifying a property in
-# the management config file $JRE/conf/management/management.properties
-# or by specifying a system property (See that file for details).
-
-
-##############################################################
-#    File permissions of the jmxremote.password file
-##############################################################
-#      Since there are cleartext passwords stored in this file,
-#      this file must be readable by ONLY the owner,
-#      otherwise the program will exit with an error.
-#
-# The file format for password and access files is syntactically the same
-# as the Properties file format.  The syntax is described in the Javadoc
-# for java.util.Properties.load.
-# Typical password file has multiple  lines, where each line is blank,
-# a comment (like this one), or a password entry.
-#
-#
-# A password entry consists of a role name and an associated
-# password.  The role name is any string that does not itself contain
-# spaces or tabs.  The password is again any string that does not
-# contain spaces or tabs.  Note that passwords appear in the clear in
-# this file, so it is a good idea not to use valuable passwords.
-#
-# A given role should have at most one entry in this file.  If a role
-# has no entry, it has no access.
-# If multiple entries are found for the same role name, then the last one
-# is used.
-#
-# In a typical installation, this file can be read by anybody on the
-# local machine, and possibly by people on other machines.
-# For # security, you should either restrict the access to this file,
-# or specify another, less accessible file in the management config file
-# as described above.
-#
-# Following are two commented-out entries.  The "measureRole" role has
-# password "QED".  The "controlRole" role has password "R&D".
-#
-# monitorRole  QED
-# controlRole   R&D
-
-guest  guestpasswd
-admin  adminpasswd
--- a/jdk/src/sample/share/jmx/jmx-scandir/src/etc/testconfig.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<ScanManager xmlns="jmx:com.sun.jmx.examples.scandir.config" name="testconfig">
-    <InitialResultLogConfig>
-        <LogFileMaxRecords>2048</LogFileMaxRecords>
-        <LogFileName>build/scandir.log</LogFileName>
-        <MemoryMaxRecords>128</MemoryMaxRecords>
-    </InitialResultLogConfig>
-    <DirectoryScannerList>
-        <DirectoryScanner name="scan-build">
-            <Actions>NOTIFY LOGRESULT</Actions>
-            <ExcludeFiles/>
-            <IncludeFiles>
-                <FileFilter>
-                    <FilePattern>.*\.class</FilePattern>
-                    <SizeExceedsMaxBytes>4096</SizeExceedsMaxBytes>
-                </FileFilter>
-            </IncludeFiles>
-            <RootDirectory>build</RootDirectory>
-        </DirectoryScanner>
-    </DirectoryScannerList>
-</ScanManager>
--- a/jdk/src/sample/share/jmx/jmx-scandir/test/com/sun/jmx/examples/scandir/DirectoryScannerTest.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import com.sun.jmx.examples.scandir.config.DirectoryScannerConfig;
-import com.sun.jmx.examples.scandir.config.ResultRecord;
-import com.sun.jmx.examples.scandir.config.ScanManagerConfig;
-import java.util.LinkedList;
-import java.util.concurrent.BlockingQueue;
-import junit.framework.*;
-import com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState;
-import static com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState.*;
-import com.sun.jmx.examples.scandir.ScanManagerTest.Call;
-import java.util.EnumSet;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import javax.management.AttributeChangeNotification;
-import javax.management.Notification;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-
-import static com.sun.jmx.examples.scandir.ScanManagerTest.*;
-import static com.sun.jmx.examples.scandir.TestUtils.*;
-import java.io.File;
-import java.lang.management.ManagementFactory;
-import java.util.List;
-
-/**
- * Unit tests for {@code DirectoryScanner}
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public class DirectoryScannerTest extends TestCase {
-
-    public DirectoryScannerTest(String testName) {
-        super(testName);
-    }
-
-    protected void setUp() throws Exception {
-    }
-
-    protected void tearDown() throws Exception {
-    }
-
-    public static Test suite() {
-        TestSuite suite = new TestSuite(DirectoryScannerTest.class);
-
-        return suite;
-    }
-
-    private void doTestOperation(
-            DirectoryScannerMXBean proxy,
-            Call op,
-            EnumSet<ScanState> after,
-            String testName)
-        throws Exception {
-        System.out.println("doTestOperation: "+testName);
-
-        final LinkedBlockingQueue<Notification> queue =
-                new LinkedBlockingQueue<Notification>();
-
-        NotificationListener listener = new NotificationListener() {
-            public void handleNotification(Notification notification,
-                        Object handback) {
-                try {
-                    queue.put(notification);
-                } catch (Exception x) {
-                    System.err.println("Failed to queue notif: "+x);
-                }
-            }
-        };
-        NotificationFilter filter = null;
-        Object handback = null;
-        final ScanState before;
-        final NotificationEmitter emitter = (NotificationEmitter)
-                makeNotificationEmitter(proxy,DirectoryScannerMXBean.class);
-        emitter.addNotificationListener(listener, filter, handback);
-        before = proxy.getState();
-        op.call();
-        try {
-            final Notification notification =
-                    queue.poll(3000,TimeUnit.MILLISECONDS);
-            assertEquals(AttributeChangeNotification.ATTRIBUTE_CHANGE,
-                    notification.getType());
-            assertEquals(AttributeChangeNotification.class,
-                    notification.getClass());
-            assertEquals(getObjectName(proxy),
-                    notification.getSource());
-            AttributeChangeNotification acn =
-                    (AttributeChangeNotification)notification;
-            assertEquals("State",acn.getAttributeName());
-            assertEquals(ScanState.class.getName(),acn.getAttributeType());
-            assertEquals(before,ScanState.valueOf((String)acn.getOldValue()));
-            assertContained(after,ScanState.valueOf((String)acn.getNewValue()));
-            emitter.removeNotificationListener(listener,filter,handback);
-        } finally {
-            try {
-                op.cancel();
-            } catch (Exception x) {
-                System.err.println("Failed to cleanup: "+x);
-            }
-        }
-    }
-
-
-    /**
-     * Test of getRootDirectory method, of class com.sun.jmx.examples.scandir.DirectoryScanner.
-     */
-    public void testGetRootDirectory() throws Exception {
-        System.out.println("getRootDirectory");
-
-       final ScanManagerMXBean manager = ScanManager.register();
-        try {
-            final String tmpdir = System.getProperty("java.io.tmpdir");
-            final ScanDirConfigMXBean config = manager.getConfigurationMBean();
-            System.err.println("Configuration MXBean is: " + config);
-            final DirectoryScannerConfig bean =
-                    config.addDirectoryScanner("test",tmpdir,".*",0,0);
-            final String root = bean.getRootDirectory();
-            if (root == null)
-                throw new NullPointerException("bean.getRootDirectory()");
-            if (config.getConfiguration().getScan("test").getRootDirectory() == null)
-                throw new NullPointerException("config.getConfig().getScan(\"test\").getRootDirectory()");
-            manager.applyConfiguration(true);
-            final DirectoryScannerMXBean proxy =
-                    manager.getDirectoryScanners().get("test");
-            final File tmpFile =  new File(tmpdir);
-            final File rootFile = new File(proxy.getRootDirectory());
-            assertEquals(tmpFile,rootFile);
-        } catch (Exception x) {
-            x.printStackTrace();
-            throw x;
-        } finally {
-            try {
-                ManagementFactory.getPlatformMBeanServer().
-                        unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-            } catch (Exception x) {
-                System.err.println("Failed to cleanup: "+x);
-            }
-        }
-    }
-
-
-    /**
-     * Test of scan method, of class com.sun.jmx.examples.scandir.DirectoryScanner.
-     */
-    public void testScan() throws Exception {
-        System.out.println("scan");
-
-        final ScanManagerMXBean manager = ScanManager.register();
-        try {
-            final String tmpdir = System.getProperty("java.io.tmpdir");
-            final ScanDirConfigMXBean config = manager.getConfigurationMBean();
-            final DirectoryScannerConfig bean =
-                    config.addDirectoryScanner("test1",tmpdir,".*",0,0);
-            config.addDirectoryScanner("test2",tmpdir,".*",0,0);
-            config.addDirectoryScanner("test3",tmpdir,".*",0,0);
-            manager.applyConfiguration(true);
-            final DirectoryScannerMXBean proxy =
-                    manager.getDirectoryScanners().get("test1");
-            final Call op = new Call() {
-                public void call() throws Exception {
-                    final BlockingQueue<Notification> queue =
-                            new LinkedBlockingQueue<Notification>();
-                    final NotificationListener listener = new NotificationListener() {
-                        public void handleNotification(Notification notification,
-                                Object handback) {
-                            try {
-                               queue.put(notification);
-                            } catch (Exception e) {
-                                e.printStackTrace();
-                            }
-                        }
-                    };
-                    manager.start();
-                    while(true) {
-                        final Notification n = queue.poll(10,TimeUnit.SECONDS);
-                        if (n == null) break;
-                        final AttributeChangeNotification at =
-                                (AttributeChangeNotification) n;
-                        if (RUNNING == ScanState.valueOf((String)at.getNewValue()))
-                            break;
-                        else {
-                            System.err.println("New state: "+(String)at.getNewValue()
-                            +" isn't "+RUNNING);
-                        }
-                    }
-                    assertContained(EnumSet.of(SCHEDULED,RUNNING,COMPLETED),
-                            proxy.getState());
-                }
-                public void cancel() throws Exception {
-                    manager.stop();
-                }
-            };
-            doTestOperation(proxy,op,
-                    EnumSet.of(RUNNING,SCHEDULED,COMPLETED),
-                    "scan");
-        } catch (Exception x) {
-            x.printStackTrace();
-            throw x;
-        } finally {
-            try {
-                manager.stop();
-            } catch (Exception x) {
-                System.err.println("Failed to stop: "+x);
-            }
-            try {
-                ManagementFactory.getPlatformMBeanServer().
-                        unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-            } catch (Exception x) {
-                System.err.println("Failed to cleanup: "+x);
-            }
-        }
-    }
-
-    /**
-     * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner.
-     */
-    public void testGetState() {
-        System.out.println("getState");
-
-        final DirectoryScannerConfig bean =
-                new DirectoryScannerConfig("test");
-        bean.setRootDirectory(System.getProperty("java.io.tmpdir"));
-        final ResultLogManager log = new ResultLogManager();
-        DirectoryScanner instance =
-                new DirectoryScanner(bean,log);
-
-        ScanState expResult = STOPPED;
-        ScanState result = instance.getState();
-        assertEquals(STOPPED, result);
-        instance.scan();
-        result = instance.getState();
-        assertEquals(COMPLETED, result);
-    }
-
-    /**
-     * Test of addNotificationListener method, of class com.sun.jmx.examples.scandir.DirectoryScanner.
-     */
-    public void testAddNotificationListener() throws Exception {
-        System.out.println("addNotificationListener");
-
-        final ScanManagerMXBean manager = ScanManager.register();
-        final Call op = new Call() {
-            public void call() throws Exception {
-                manager.start();
-            }
-            public void cancel() throws Exception {
-                manager.stop();
-            }
-        };
-        try {
-            final String tmpdir = System.getProperty("java.io.tmpdir");
-            final ScanDirConfigMXBean config = manager.getConfigurationMBean();
-            final DirectoryScannerConfig bean =
-                    config.addDirectoryScanner("test1",tmpdir,".*",0,0);
-            manager.applyConfiguration(true);
-            final DirectoryScannerMXBean proxy =
-                    manager.getDirectoryScanners().get("test1");
-           doTestOperation(proxy,op,
-                            EnumSet.of(RUNNING,SCHEDULED),
-                            "scan");
-        } finally {
-            try {
-                ManagementFactory.getPlatformMBeanServer().
-                        unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-            } catch (Exception x) {
-                System.err.println("Failed to cleanup: "+x);
-            }
-        }
-    }
-
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/test/com/sun/jmx/examples/scandir/ScanDirConfigTest.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,325 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import com.sun.jmx.examples.scandir.config.XmlConfigUtils;
-import com.sun.jmx.examples.scandir.config.FileMatch;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import junit.framework.*;
-import com.sun.jmx.examples.scandir.config.DirectoryScannerConfig;
-import com.sun.jmx.examples.scandir.config.ScanManagerConfig;
-import java.io.File;
-import java.util.concurrent.BlockingQueue;
-import javax.management.*;
-
-/**
- * Unit tests for {@code ScanDirConfig}
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public class ScanDirConfigTest extends TestCase {
-
-    public ScanDirConfigTest(String testName) {
-        super(testName);
-    }
-
-    protected void setUp() throws Exception {
-    }
-
-    protected void tearDown() throws Exception {
-    }
-
-    public static Test suite() {
-        TestSuite suite = new TestSuite(ScanDirConfigTest.class);
-
-        return suite;
-    }
-
-    /**
-     * Test of load method, of class com.sun.jmx.examples.scandir.ScanDirConfig.
-     */
-    public void testLoad() throws Exception {
-        System.out.println("load");
-
-        final File file = File.createTempFile("testconf",".xml");
-        final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath());
-        final ScanManagerConfig bean =
-                new  ScanManagerConfig("testLoad");
-        final DirectoryScannerConfig dir =
-                new DirectoryScannerConfig("tmp");
-        dir.setRootDirectory(file.getParent());
-        bean.putScan(dir);
-        XmlConfigUtils.write(bean,new FileOutputStream(file),false);
-        instance.load();
-
-        assertEquals(bean,instance.getConfiguration());
-        bean.removeScan(dir.getName());
-        XmlConfigUtils.write(bean,new FileOutputStream(file),false);
-
-        assertNotSame(bean,instance.getConfiguration());
-
-        instance.load();
-
-        assertEquals(bean,instance.getConfiguration());
-
-    }
-
-    /**
-     * Test of save method, of class com.sun.jmx.examples.scandir.ScanDirConfig.
-     */
-    public void testSave() throws Exception {
-        System.out.println("save");
-
-        final File file = File.createTempFile("testconf",".xml");
-        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        final ScanManagerMXBean manager = ScanManager.register(mbs);
-
-        try {
-            final ScanDirConfigMXBean instance =
-                    manager.createOtherConfigurationMBean("testSave",file.getAbsolutePath());
-            assertTrue(mbs.isRegistered(
-                    ScanManager.makeScanDirConfigName("testSave")));
-            final ScanManagerConfig bean =
-                new  ScanManagerConfig("testSave");
-            final DirectoryScannerConfig dir =
-                new DirectoryScannerConfig("tmp");
-            dir.setRootDirectory(file.getParent());
-            bean.putScan(dir);
-            instance.setConfiguration(bean);
-            instance.save();
-            final ScanManagerConfig loaded =
-                new XmlConfigUtils(file.getAbsolutePath()).readFromFile();
-            assertEquals(instance.getConfiguration(),loaded);
-            assertEquals(bean,loaded);
-
-            instance.getConfiguration().removeScan("tmp");
-            instance.save();
-            assertNotSame(loaded,instance.getConfiguration());
-            final ScanManagerConfig loaded2 =
-                new XmlConfigUtils(file.getAbsolutePath()).readFromFile();
-            assertEquals(instance.getConfiguration(),loaded2);
-        } finally {
-            manager.close();
-            mbs.unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-        }
-        final ObjectName all =
-                new ObjectName(ScanManager.SCAN_MANAGER_NAME.getDomain()+":*");
-        assertEquals(0,mbs.queryNames(all,null).size());
-    }
-
-    /**
-     * Test of saveTo method, of class com.sun.jmx.examples.scandir.ScanProfile.
-     */
-    /*
-    public void testSaveTo() throws Exception {
-        System.out.println("saveTo");
-
-        String filename = "";
-        ScanDirConfig instance = null;
-
-        instance.saveTo(filename);
-
-        // TODO review the generated test code and remove the default call to fail.
-        fail("The test case is a prototype.");
-    }
-    */
-
-    /**
-     * Test of getXmlConfigString method, of class com.sun.jmx.examples.scandir.ScanDirConfig.
-     */
-    public void testGetXmlConfigString() throws Exception {
-        System.out.println("getXmlConfigString");
-
-        try {
-            final File file = File.createTempFile("testconf",".xml");
-            final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath());
-            final ScanManagerConfig bean =
-                new  ScanManagerConfig("testGetXmlConfigString");
-            final DirectoryScannerConfig dir =
-                new DirectoryScannerConfig("tmp");
-            dir.setRootDirectory(file.getParent());
-            bean.putScan(dir);
-            instance.setConfiguration(bean);
-            System.out.println("Expected: " + XmlConfigUtils.toString(bean));
-            System.out.println("Received: " +
-                    instance.getConfiguration().toString());
-            assertEquals(XmlConfigUtils.toString(bean),
-                instance.getConfiguration().toString());
-        } catch (Exception x) {
-            x.printStackTrace();
-            throw x;
-        }
-    }
-
-
-    /**
-     * Test of addNotificationListener method, of class
-     * com.sun.jmx.examples.scandir.ScanDirConfig.
-     */
-    public void testAddNotificationListener() throws Exception {
-        System.out.println("addNotificationListener");
-
-        final File file = File.createTempFile("testconf",".xml");
-        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        final ScanManagerMXBean manager = ScanManager.register(mbs);
-
-        try {
-            final ScanDirConfigMXBean instance =
-                TestUtils.makeNotificationEmitter(
-                    manager.createOtherConfigurationMBean("testSave",
-                        file.getAbsolutePath()),
-                    ScanDirConfigMXBean.class);
-            assertTrue(mbs.isRegistered(
-                    ScanManager.makeScanDirConfigName("testSave")));
-            DirectoryScannerConfig dir =
-                    instance.addDirectoryScanner("tmp",file.getParent(),".*",0,0);
-
-            final BlockingQueue<Notification> queue =
-                    new LinkedBlockingQueue<Notification>();
-            final NotificationListener listener = new NotificationListener() {
-                public void handleNotification(Notification notification,
-                            Object handback) {
-                    queue.add(notification);
-                }
-            };
-            NotificationFilter filter = null;
-            Object handback = null;
-
-            ((NotificationEmitter)instance).addNotificationListener(listener,
-                    filter, handback);
-
-            instance.save();
-            final ScanManagerConfig loaded =
-                new XmlConfigUtils(file.getAbsolutePath()).readFromFile();
-            assertEquals(instance.getConfiguration(),loaded);
-
-            final ScanManagerConfig newConfig =
-                    instance.getConfiguration();
-            newConfig.removeScan("tmp");
-            instance.setConfiguration(newConfig);
-            instance.save();
-            assertNotSame(loaded,instance.getConfiguration());
-            final ScanManagerConfig loaded2 =
-                new XmlConfigUtils(file.getAbsolutePath()).readFromFile();
-            assertEquals(instance.getConfiguration(),loaded2);
-            instance.load();
-            for (int i=0;i<4;i++) {
-                final Notification n = queue.poll(3,TimeUnit.SECONDS);
-                assertNotNull(n);
-                assertEquals(TestUtils.getObjectName(instance),n.getSource());
-                switch(i) {
-                    case 0: case 2:
-                        assertEquals(ScanDirConfig.NOTIFICATION_SAVED,n.getType());
-                        break;
-                    case 1:
-                        assertEquals(ScanDirConfig.NOTIFICATION_MODIFIED,n.getType());
-                        break;
-                    case 3:
-                        assertEquals(ScanDirConfig.NOTIFICATION_LOADED,n.getType());
-                        break;
-                    default: break;
-                }
-            }
-        } finally {
-            manager.close();
-            mbs.unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-        }
-        final ObjectName all =
-                new ObjectName(ScanManager.SCAN_MANAGER_NAME.getDomain()+":*");
-        assertEquals(0,mbs.queryNames(all,null).size());
-    }
-
-    /**
-     * Test of getConfigFilename method, of class
-     * com.sun.jmx.examples.scandir.ScanDirConfig.
-     */
-    public void testGetConfigFilename() throws Exception {
-        System.out.println("getConfigFilename");
-
-        final File file = File.createTempFile("testconf",".xml");
-        final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath());
-
-        String result = instance.getConfigFilename();
-        assertEquals(file.getAbsolutePath(), new File(result).getAbsolutePath());
-
-    }
-
-    /**
-     * Test of addDirectoryScanner method, of class
-     * com.sun.jmx.examples.scandir.ScanDirConfig.
-     */
-    public void testAddDirectoryScanner() throws IOException {
-        System.out.println("addDirectoryScanner");
-
-        System.out.println("save");
-
-        final File file = File.createTempFile("testconf",".xml");
-        final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath());
-        final ScanManagerConfig bean =
-                new  ScanManagerConfig("testSave");
-        final DirectoryScannerConfig dir =
-                new DirectoryScannerConfig("tmp");
-        dir.setRootDirectory(file.getParent());
-        FileMatch filter = new FileMatch();
-        filter.setFilePattern(".*");
-        dir.setIncludeFiles(new FileMatch[] {
-            filter
-        });
-        instance.setConfiguration(bean);
-        instance.addDirectoryScanner(dir.getName(),
-                                     dir.getRootDirectory(),
-                                     filter.getFilePattern(),
-                                     filter.getSizeExceedsMaxBytes(),
-                                     0);
-        instance.save();
-        final ScanManagerConfig loaded =
-                new XmlConfigUtils(file.getAbsolutePath()).readFromFile();
-        assertNotNull(loaded.getScan(dir.getName()));
-        assertEquals(dir,loaded.getScan(dir.getName()));
-        assertEquals(instance.getConfiguration(),loaded);
-        assertEquals(instance.getConfiguration().getScan(dir.getName()),dir);
-    }
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/test/com/sun/jmx/examples/scandir/ScanManagerTest.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,365 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import javax.management.InstanceNotFoundException;
-import javax.management.Notification;
-import junit.framework.*;
-import static com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState.*;
-import com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.logging.Logger;
-import javax.management.AttributeChangeNotification;
-import javax.management.JMException;
-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.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-import static com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState.*;
-
-/**
- * Unit tests for {@code ScanManager}
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public class ScanManagerTest extends TestCase {
-
-    public ScanManagerTest(String testName) {
-        super(testName);
-    }
-
-    protected void setUp() throws Exception {
-    }
-
-    protected void tearDown() throws Exception {
-    }
-
-    public static Test suite() {
-        TestSuite suite = new TestSuite(ScanManagerTest.class);
-
-        return suite;
-    }
-
-    /**
-     * Test of makeSingletonName method, of class com.sun.jmx.examples.scandir.ScanManager.
-     */
-    public void testMakeSingletonName() {
-        System.out.println("makeSingletonName");
-
-        Class clazz = ScanManagerMXBean.class;
-
-        ObjectName expResult = ScanManager.SCAN_MANAGER_NAME;
-        ObjectName result = ScanManager.makeSingletonName(clazz);
-        assertEquals(expResult, result);
-
-    }
-
-    /**
-     * Test of register method, of class com.sun.jmx.examples.scandir.ScanManager.
-     */
-    public void testRegister() throws Exception {
-        System.out.println("register");
-
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-
-
-        ScanManagerMXBean result = ScanManager.register(mbs);
-        try {
-            assertEquals(STOPPED,result.getState());
-        } finally {
-            try {
-                mbs.unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-            } catch (Exception x) {
-                System.err.println("Failed to cleanup: "+x);
-            }
-        }
-
-    }
-
-    public interface Call {
-        public void call() throws Exception;
-        public void cancel() throws Exception;
-    }
-
-    /**
-     * Test of addNotificationListener method, of class com.sun.jmx.examples.scandir.ScanManager.
-     */
-    public void testAddNotificationListener() throws Exception {
-        System.out.println("addNotificationListener");
-
-        final ScanManagerMXBean manager = ScanManager.register();
-        final Call op = new Call() {
-            public void call() throws Exception {
-                manager.schedule(100000,0);
-            }
-            public void cancel() throws Exception {
-                manager.stop();
-            }
-        };
-        try {
-            doTestOperation(manager,op,
-                            EnumSet.of(RUNNING,SCHEDULED),
-                            "schedule");
-        } finally {
-            try {
-                ManagementFactory.getPlatformMBeanServer().
-                        unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-            } catch (Exception x) {
-                System.err.println("Failed to cleanup: "+x);
-            }
-        }
-    }
-
-    /**
-     * Test of addNotificationListener method, of class com.sun.jmx.examples.scandir.ScanManager.
-     */
-    private void doTestOperation(
-            ScanManagerMXBean proxy,
-            Call op,
-            EnumSet<ScanState> after,
-            String testName)
-        throws Exception {
-        System.out.println("doTestOperation: "+testName);
-
-        final LinkedBlockingQueue<Notification> queue =
-                new LinkedBlockingQueue<Notification>();
-
-        NotificationListener listener = new NotificationListener() {
-            public void handleNotification(Notification notification,
-                        Object handback) {
-                try {
-                    queue.put(notification);
-                } catch (Exception x) {
-                    System.err.println("Failed to queue notif: "+x);
-                }
-            }
-        };
-        NotificationFilter filter = null;
-        Object handback = null;
-        final ScanState before;
-        final NotificationEmitter emitter = (NotificationEmitter)proxy;
-        emitter.addNotificationListener(listener, filter, handback);
-        before = proxy.getState();
-        op.call();
-        try {
-            final Notification notification =
-                    queue.poll(3000,TimeUnit.MILLISECONDS);
-            assertEquals(AttributeChangeNotification.ATTRIBUTE_CHANGE,
-                    notification.getType());
-            assertEquals(AttributeChangeNotification.class,
-                    notification.getClass());
-            assertEquals(ScanManager.SCAN_MANAGER_NAME,
-                    notification.getSource());
-            AttributeChangeNotification acn =
-                    (AttributeChangeNotification)notification;
-            assertEquals("State",acn.getAttributeName());
-            assertEquals(ScanState.class.getName(),acn.getAttributeType());
-            assertEquals(before,ScanState.valueOf((String)acn.getOldValue()));
-            assertContained(after,ScanState.valueOf((String)acn.getNewValue()));
-            emitter.removeNotificationListener(listener,filter,handback);
-        } finally {
-            try {
-                op.cancel();
-            } catch (Exception x) {
-                System.err.println("Failed to cleanup: "+x);
-            }
-        }
-    }
-
-    /**
-     * Test of preRegister method, of class com.sun.jmx.examples.scandir.ScanManager.
-     */
-    public void testPreRegister() throws Exception {
-        System.out.println("preRegister");
-
-        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
-        ObjectName name = new ObjectName("DownUnder:type=Wombat");
-        ScanManager instance = new ScanManager();
-
-        ObjectName expResult = ScanManager.SCAN_MANAGER_NAME;
-        ObjectName result;
-        try {
-            result = instance.preRegister(server, name);
-            throw new RuntimeException("bad name accepted!");
-        } catch (IllegalArgumentException x) {
-            // OK!
-            result = instance.preRegister(server, null);
-        }
-        assertEquals(expResult, result);
-        result = instance.preRegister(server, ScanManager.SCAN_MANAGER_NAME);
-        assertEquals(expResult, result);
-    }
-
-
-    /**
-     * Test of getState method, of class com.sun.jmx.examples.scandir.ScanManager.
-     */
-    public void testGetState() throws IOException, InstanceNotFoundException {
-        System.out.println("getState");
-
-        ScanManager instance = new ScanManager();
-
-        ScanState expResult = ScanState.STOPPED;
-        ScanState result = instance.getState();
-        assertEquals(expResult, result);
-        instance.start();
-        final ScanState afterStart = instance.getState();
-        assertContained(EnumSet.of(RUNNING,SCHEDULED,COMPLETED),afterStart);
-        instance.stop();
-        assertEquals(STOPPED,instance.getState());
-        instance.schedule(1000000L,1000000L);
-        assertEquals(SCHEDULED,instance.getState());
-        instance.stop();
-        assertEquals(STOPPED,instance.getState());
-    }
-
-    /**
-     * Test of schedule method, of class com.sun.jmx.examples.scandir.ScanManager.
-     */
-    public void testSchedule() throws Exception {
-        System.out.println("schedule");
-
-        final long delay = 10000L;
-        final long interval = 10000L;
-
-        final ScanManagerMXBean manager = ScanManager.register();
-        final Call op = new Call() {
-            public void call() throws Exception {
-                manager.schedule(delay,interval);
-                assertEquals(SCHEDULED,manager.getState());
-            }
-            public void cancel() throws Exception {
-                manager.stop();
-            }
-        };
-        try {
-            doTestOperation(manager,op,EnumSet.of(SCHEDULED),
-                    "schedule");
-        } finally {
-            try {
-                ManagementFactory.getPlatformMBeanServer().
-                        unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-            } catch (Exception x) {
-                System.err.println("Failed to cleanup: "+x);
-            }
-        }
-    }
-
-    public static void assertContained(EnumSet<ScanState> allowed,
-            ScanState state) {
-         final String msg = String.valueOf(state) + " is not one of " + allowed;
-         assertTrue(msg,allowed.contains(state));
-    }
-
-    /**
-     * Test of stop method, of class com.sun.jmx.examples.scandir.ScanManager.
-     */
-    public void testStop() throws Exception {
-        System.out.println("stop");
-        final ScanManagerMXBean manager = ScanManager.register();
-        try {
-            manager.schedule(1000000,0);
-            assertContained(EnumSet.of(SCHEDULED),manager.getState());
-            final Call op = new Call() {
-                public void call() throws Exception {
-                    manager.stop();
-                    assertEquals(STOPPED,manager.getState());
-                }
-                public void cancel() throws Exception {
-                    if (manager.getState() != STOPPED)
-                        manager.stop();
-                }
-            };
-            doTestOperation(manager,op,EnumSet.of(STOPPED),"stop");
-        } finally {
-            try {
-                ManagementFactory.getPlatformMBeanServer().
-                        unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-            } catch (Exception x) {
-                System.err.println("Failed to cleanup: "+x);
-            }
-        }
-    }
-
-    /**
-     * Test of start method, of class com.sun.jmx.examples.scandir.ScanManager.
-     */
-    public void testStart() throws Exception {
-        final ScanManagerMXBean manager = ScanManager.register();
-        try {
-            final Call op = new Call() {
-                public void call() throws Exception {
-                    assertEquals(STOPPED,manager.getState());
-                    manager.start();
-                    assertContained(EnumSet.of(RUNNING,SCHEDULED,COMPLETED),
-                            manager.getState());
-                }
-                public void cancel() throws Exception {
-                    manager.stop();
-                }
-            };
-            doTestOperation(manager,op,EnumSet.of(RUNNING,SCHEDULED,COMPLETED),
-                    "start");
-        } finally {
-            try {
-                ManagementFactory.getPlatformMBeanServer().
-                        unregisterMBean(ScanManager.SCAN_MANAGER_NAME);
-            } catch (Exception x) {
-                System.err.println("Failed to cleanup: "+x);
-            }
-        }
-    }
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/test/com/sun/jmx/examples/scandir/TestUtils.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.util.logging.Logger;
-import javax.management.JMX;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.NotificationEmitter;
-import javax.management.ObjectName;
-
-/**
- * A utility class defining static methods used by our tests.
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public class TestUtils {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(TestUtils.class.getName());
-
-    /** Creates a new instance of TestUtils */
-    private TestUtils() {
-    }
-
-    /**
-     * Returns the ObjectName of the MBean that a proxy object
-     * is proxying.
-     **/
-    public static ObjectName getObjectName(Object proxy) {
-        if (!(proxy instanceof Proxy))
-            throw new IllegalArgumentException("not a "+Proxy.class.getName());
-        final Proxy p = (Proxy) proxy;
-        final InvocationHandler handler =
-                Proxy.getInvocationHandler(proxy);
-        if (handler instanceof MBeanServerInvocationHandler)
-            return ((MBeanServerInvocationHandler)handler).getObjectName();
-        throw new IllegalArgumentException("not a JMX Proxy");
-    }
-
-    /**
-     * Transfroms a proxy implementing T in a proxy implementing T plus
-     * NotificationEmitter
-     *
-     **/
-    public static <T> T makeNotificationEmitter(T proxy,
-                        Class<T> mbeanInterface) {
-        if (proxy instanceof NotificationEmitter)
-            return proxy;
-        if (proxy == null) return null;
-        if (!(proxy instanceof Proxy))
-            throw new IllegalArgumentException("not a "+Proxy.class.getName());
-        final Proxy p = (Proxy) proxy;
-        final InvocationHandler handler =
-                Proxy.getInvocationHandler(proxy);
-        if (!(handler instanceof MBeanServerInvocationHandler))
-            throw new IllegalArgumentException("not a JMX Proxy");
-        final MBeanServerInvocationHandler h =
-                (MBeanServerInvocationHandler)handler;
-        final ObjectName name = h.getObjectName();
-        final MBeanServerConnection mbs = h.getMBeanServerConnection();
-        final boolean isMXBean = h.isMXBean();
-        final T newProxy;
-        if (isMXBean)
-            newProxy = JMX.newMXBeanProxy(mbs,name,mbeanInterface,true);
-        else
-            newProxy = JMX.newMBeanProxy(mbs,name,mbeanInterface,true);
-        return newProxy;
-    }
-
-}
--- a/jdk/src/sample/share/jmx/jmx-scandir/test/com/sun/jmx/examples/scandir/config/XmlConfigUtilsTest.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.jmx.examples.scandir.config;
-
-import junit.framework.*;
-import java.io.File;
-
-/**
- * Unit tests for {@code XmlConfigUtils}
- *
- * @author Sun Microsystems, 2006 - All rights reserved.
- */
-public class XmlConfigUtilsTest extends TestCase {
-
-    public XmlConfigUtilsTest(String testName) {
-        super(testName);
-    }
-
-    protected void setUp() throws Exception {
-    }
-
-    protected void tearDown() throws Exception {
-    }
-
-    public static Test suite() {
-        TestSuite suite = new TestSuite(XmlConfigUtilsTest.class);
-
-        return suite;
-    }
-
-
-    /**
-     * Test of writeToFile method, of class XmlConfigUtils.
-     */
-    public void testWriteToFile() throws Exception {
-        System.out.println("writeToFile");
-
-        final File file = File.createTempFile("test",".xml");
-        file.deleteOnExit();
-
-        final String tmp = System.getProperty("java.io.tmpdir");
-
-        DirectoryScannerConfig dir1 =
-                new DirectoryScannerConfig("scan2");
-        dir1.setRootDirectory(tmp);
-        ScanManagerConfig bean = new ScanManagerConfig("session2");
-        bean.putScan(dir1);
-        XmlConfigUtils instance = new XmlConfigUtils(file.getPath());
-
-        instance.writeToFile(bean);
-    }
-
-    /**
-     * Test of readFromFile method, of class com.sun.jmx.examples.scandir.config.XmlConfigUtils.
-     */
-    public void testReadFromFile() throws Exception {
-        System.out.println("readFromFile");
-
-        final String tmp = System.getProperty("java.io.tmpdir");
-        final File file = File.createTempFile("test",".xml");
-        file.deleteOnExit();
-
-        DirectoryScannerConfig dir1 =
-                new DirectoryScannerConfig("scan1");
-        dir1.setRootDirectory(tmp);
-        ScanManagerConfig bean = new ScanManagerConfig("session1");
-        bean.putScan(dir1);
-        XmlConfigUtils instance = new XmlConfigUtils(file.getPath());
-
-        instance.writeToFile(bean);
-
-        ScanManagerConfig expResult = bean;
-        ScanManagerConfig result = instance.readFromFile();
-        System.out.println(result);
-        assertEquals(expResult, result);
-
-
-    }
-
-}
--- a/jdk/src/sample/share/lambda/BulkDataOperations/index.html	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <title>Bulk Data Operations Demo</title>
-</head>
-<body>
-<h2>Bulk Data Operations Demo</h2>
-
-<p>
-    This demo shows how to use bulk data operations with the new JDK8
-    Collections API.
-    The demo also demonstrates new features of JDK8 such as lambda expressions
-    and method/constructor references.
-</p>
-
-<ul>
-    <li><h3>CSV Processor</h3>
-
-        <p>
-            Analyzes a CSV file, finds and collects useful information, computes
-            different statistics. For more information, see the source file.
-        </p>
-        Source: <a href="src/CSVProcessor.java">src/CSVProcessor.java</a>
-    <li><h3>Grep</h3>
-
-        <p>
-            Behaves like the standard Linux tool Grep. For more information, see
-            the source file.
-        </p>
-        Source: <a href="src/Grep.java">src/Grep.java</a>
-    <li><h3>PasswordGenerator</h3>
-
-        <p>
-            Produces a password of desired length. For more information see
-            source file.
-        </p>
-        Source: <a
-                href="src/PasswordGenerator.java">src/PasswordGenerator.java</a>
-    <li><h3>WC</h3>
-
-        <p>
-            Counts newlines, words, characters, and the maximum line length of a
-            text file. For more information, see the source
-            file.
-        </p>
-        Source: <a href="src/WC.java">src/WC.java</a>
-</ul>
-</body>
-</html>
--- a/jdk/src/sample/share/lambda/BulkDataOperations/src/CSVProcessor.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,368 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation, and proper error handling, might not be present in
- * this sample code.
- */
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.*;
-import java.util.function.*;
-import java.util.regex.Pattern;
-import java.util.stream.Collector;
-import java.util.stream.Collectors;
-
-import static java.lang.Double.parseDouble;
-import static java.util.stream.Collectors.*;
-
-/**
- * CSVProcessor is a tool for processing CSV files. There are several
- * command-line options. Consult the {@link #printUsageAndExit} method for
- * instructions and command line parameters. This sample shows examples of the
- * following features:
- * <ul>
- * <li>Lambda and bulk operations. Working with streams: map(...), filter(...),
- * sorted(...) methods. The collect(...) method with different collectors:
- * Collectors.maxBy(...), Collectors.minBy(...), Collectors.toList(),
- * Collectors.toCollection(...), Collectors.groupingBy(...),
- * Collectors.toDoubleSummaryStatistics(...), and a custom Collector.</li>
- * <li>Static method reference for printing values.</li>
- * <li>Try-with-resources feature for closing files.</li>
- * <li>Switch by String feature.</li>
- * <li>Other new APIs: Pattern.asPredicate(), BinaryOperator
- * BufferedReader.lines(), Collection.forEach(...), Comparator.comparing(...),
- * Comparator.reversed(), Arrays.stream(...).</li>
- * </ul>
- *
- */
-public class CSVProcessor {
-
-    //Number of characters that may be read
-    private static final int READ_AHEAD_LIMIT = 100_000_000;
-
-    /**
-     * The main method for the CSVProcessor program. Run the program with an
-     * empty argument list to see possible arguments.
-     *
-     * @param args the argument list for CSVProcessor.
-     */
-    public static void main(String[] args) {
-        if (args.length < 2) {
-            printUsageAndExit();
-        }
-        try (BufferedReader br = new BufferedReader(
-                Files.newBufferedReader(Paths.get(args[args.length - 1])))) {
-            //Assume that the first line contains column names.
-            List<String> header = Arrays.stream(br.readLine().split(","))
-                    .map(String::trim).collect(toList());
-            //Calculate an index of the column in question.
-            int column = getColumnNumber(header, args[1]);
-            switch (args[0]) {
-                case "sort":
-                    verifyArgumentNumber(args, 4);
-                    //Define the sort order.
-                    boolean isAsc;
-                    switch (args[2].toUpperCase()) {
-                        case "ASC":
-                            isAsc = true;
-                            break;
-                        case "DESC":
-                            isAsc = false;
-                            break;
-                        default:
-                            printUsageAndExit("Illegal argument" + args[2]);
-                            return;//Should not be reached.
-                    }
-                    /*
-                     * Create a comparator that compares lines by comparing
-                     * values in the specified column.
-                     */
-                    Comparator<String> cmp
-                            = Comparator.comparing(str -> getCell(str, column),
-                                    String.CASE_INSENSITIVE_ORDER);
-                    /*
-                     * sorted(...) is used to sort records.
-                     * forEach(...) is used to output sorted records.
-                     */
-                    br.lines().sorted(isAsc ? cmp : cmp.reversed())
-                            .forEach(System.out::println);
-                    break;
-                case "search":
-                    verifyArgumentNumber(args, 4);
-                    /*
-                     * Records are filtered by a regex.
-                     * forEach(...) is used to output filtered records.
-                     */
-                    Predicate<String> pattern
-                            = Pattern.compile(args[2]).asPredicate();
-                    br.lines().filter(str -> pattern.test(getCell(str, column)))
-                            .forEach(System.out::println);
-                    break;
-                case "groupby":
-                    verifyArgumentNumber(args, 3);
-                    /*
-                     * Group lines by values in the column with collect(...), and
-                     * print with forEach(...) for every distinct value within
-                     * the column.
-                     */
-                    br.lines().collect(
-                            Collectors.groupingBy(str -> getCell(str, column),
-                                    toCollection(TreeSet::new)))
-                            .forEach((str, set) -> {
-                                System.out.println(str + ":");
-                                set.forEach(System.out::println);
-                            });
-                    break;
-                case "stat":
-                    verifyArgumentNumber(args, 3);
-
-                    /*
-                     * BufferedReader will be read several times.
-                     * Mark this point to return here after each pass.
-                     * BufferedReader will be read right after the headers line
-                     * because it is already read.
-                     */
-                    br.mark(READ_AHEAD_LIMIT);
-
-                    /*
-                     * Statistics can be collected by a custom collector in one
-                     * pass. One pass is preferable.
-                     */
-                    System.out.println(
-                            br.lines().collect(new Statistics(column)));
-
-                    /*
-                     * Alternatively, statistics can be collected
-                     * by a built-in API in several passes.
-                     * This method demonstrates how separate operations can be
-                     * implemented using a built-in API.
-                     */
-                    br.reset();
-                    statInSeveralPasses(br, column);
-                    break;
-                default:
-                    printUsageAndExit("Illegal argument" + args[0]);
-            }
-        } catch (IOException e) {
-            printUsageAndExit(e.toString());
-        }
-    }
-
-    private static void statInSeveralPasses(BufferedReader br, int column)
-            throws IOException {
-        System.out.println("#-----Statistics in several passes-------#");
-        //Create a comparator to compare records by the column.
-        Comparator<String> comparator
-                = Comparator.comparing(
-                        (String str) -> parseDouble(getCell(str, column)));
-        //Find max record by using Collectors.maxBy(...)
-        System.out.println(
-                "Max: " + br.lines().collect(maxBy(comparator)).get());
-        br.reset();
-        //Find min record by using Collectors.minBy(...)
-        System.out.println(
-                "Min: " + br.lines().collect(minBy(comparator)).get());
-        br.reset();
-        //Compute the average value and sum with
-        //Collectors.toDoubleSummaryStatistics(...)
-        DoubleSummaryStatistics doubleSummaryStatistics
-                = br.lines().collect(summarizingDouble(
-                    str -> parseDouble(getCell(str, column))));
-        System.out.println("Average: " + doubleSummaryStatistics.getAverage());
-        System.out.println("Sum: " + doubleSummaryStatistics.getSum());
-    }
-
-    private static void verifyArgumentNumber(String[] args, int n) {
-        if (args.length != n) {
-            printUsageAndExit("Expected " + n + " arguments but was "
-                    + args.length);
-        }
-    }
-
-    private static int getColumnNumber(List<String> header, String name) {
-        int column = header.indexOf(name);
-        if (column == -1) {
-            printUsageAndExit("There is no column with name " + name);
-        }
-        return column;
-    }
-
-    private static String getCell(String record, int column) {
-        return record.split(",")[column].trim();
-    }
-
-    private static void printUsageAndExit(String... str) {
-        System.out.println("Usages:");
-
-        System.out.println("CSVProcessor sort COLUMN_NAME ASC|DESC FILE");
-        System.out.println("Sort lines by column COLUMN_NAME in CSV FILE\n");
-
-        System.out.println("CSVProcessor search COLUMN_NAME REGEX FILE");
-        System.out.println("Search for REGEX in column COLUMN_NAME in CSV FILE\n");
-
-        System.out.println("CSVProcessor groupby COLUMN_NAME FILE");
-        System.out.println("Split lines into different groups according to column "
-                + "COLUMN_NAME value\n");
-
-        System.out.println("CSVProcessor stat COLUMN_NAME FILE");
-        System.out.println("Compute max/min/average/sum  statistics by column "
-                + "COLUMN_NAME\n");
-
-        Arrays.asList(str).forEach(System.err::println);
-        System.exit(1);
-    }
-
-    /*
-     * This is a custom implementation of the Collector interface.
-     * Statistics are objects gather max,min,sum,average statistics.
-     */
-    private static class Statistics
-            implements Collector<String, Statistics, Statistics> {
-
-
-        /*
-         * This implementation does not need to be thread safe because
-         * the parallel implementation of
-         * {@link java.util.stream.Stream#collect Stream.collect()}
-         * provides the necessary partitioning and isolation for safe parallel
-         * execution.
-         */
-        private String maxRecord;
-        private String minRecord;
-
-        private double sum;
-        private int lineCount;
-        private final BinaryOperator<String> maxOperator;
-        private final BinaryOperator<String> minOperator;
-        private final int column;
-
-        public Statistics(int column) {
-            this.column = column;
-            Comparator<String> cmp = Comparator.comparing(
-                    (String str) -> parseDouble(getCell(str, column)));
-            maxOperator = BinaryOperator.maxBy(cmp);
-            minOperator = BinaryOperator.minBy(cmp);
-        }
-
-        /*
-         * Process line.
-         */
-        public Statistics accept(String line) {
-            maxRecord = maxRecord == null
-                    ? line : maxOperator.apply(maxRecord, line);
-            minRecord = minRecord == null
-                    ? line : minOperator.apply(minRecord, line);
-
-            sum += parseDouble(getCell(line, column));
-            lineCount++;
-            return this;
-        }
-
-
-        /*
-         * Merge two Statistics.
-         */
-        public Statistics combine(Statistics stat) {
-            maxRecord = maxOperator.apply(maxRecord, stat.getMaxRecord());
-            minRecord = minOperator.apply(minRecord, stat.getMinRecord());
-            sum += stat.getSum();
-            lineCount += stat.getLineCount();
-            return this;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder sb = new StringBuilder();
-            sb.append("#------Statistics------#\n");
-            sb.append("Max: ").append(getMaxRecord()).append("\n");
-            sb.append("Min: ").append(getMinRecord()).append("\n");
-            sb.append("Sum = ").append(getSum()).append("\n");
-            sb.append("Average = ").append(average()).append("\n");
-            sb.append("#------Statistics------#\n");
-            return sb.toString();
-        }
-
-        @Override
-        public Supplier<Statistics> supplier() {
-            return () -> new Statistics(column);
-        }
-
-        @Override
-        public BiConsumer<Statistics, String> accumulator() {
-            return Statistics::accept;
-        }
-
-        @Override
-        public BinaryOperator<Statistics> combiner() {
-            return Statistics::combine;
-
-        }
-
-        @Override
-        public Function<Statistics, Statistics> finisher() {
-            return stat -> stat;
-        }
-
-        @Override
-        public Set<Characteristics> characteristics() {
-            return EnumSet.of(Characteristics.IDENTITY_FINISH);
-        }
-
-        private String getMaxRecord() {
-            return maxRecord;
-        }
-
-        private String getMinRecord() {
-            return minRecord;
-        }
-
-        private double getSum() {
-            return sum;
-        }
-
-        private double average() {
-            return sum / lineCount;
-        }
-
-        private int getLineCount() {
-            return lineCount;
-        }
-
-    }
-
-}
--- a/jdk/src/sample/share/lambda/BulkDataOperations/src/Grep.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation, and proper error handling, might not be present in
- * this sample code.
- */
-
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.List;
-import java.util.regex.Pattern;
-import java.util.stream.Stream;
-
-import static java.util.stream.Collectors.toList;
-
-/**
- * Grep prints lines matching a regex. See {@link #printUsageAndExit(String...)}
- * method for instructions and command line parameters. This sample shows
- * examples of using next features:
- * <ul>
- * <li>Lambda and bulk operations. Working with streams:
- * map(...),filter(...),flatMap(...),limit(...) methods.</li>
- * <li>Static method reference for printing values.</li>
- * <li>New Collections API forEach(...) method.</li>
- * <li>Try-with-resources feature.</li>
- * <li>new Files.walk(...), Files.lines(...) API.</li>
- * <li>Streams that need to be closed.</li>
- * </ul>
- *
- */
-public class Grep {
-
-    private static void printUsageAndExit(String... str) {
-        System.out.println("Usage: " + Grep.class.getSimpleName()
-                + " [OPTION]... PATTERN FILE...");
-        System.out.println("Search for PATTERN in each FILE. "
-                + "If FILE is a directory then whole file tree of the directory"
-                + " will be processed.");
-        System.out.println("Example: grep -m 100 'hello world' menu.h main.c");
-        System.out.println("Options:");
-        System.out.println("    -m NUM: stop analysis after NUM matches");
-        Arrays.asList(str).forEach(System.err::println);
-        System.exit(1);
-    }
-
-    /**
-     * The main method for the Grep program. Run program with empty argument
-     * list to see possible arguments.
-     *
-     * @param args the argument list for Grep.
-     * @throws java.io.IOException If an I/O error occurs.
-     */
-    public static void main(String[] args) throws IOException {
-        long maxCount = Long.MAX_VALUE;
-        if (args.length < 2) {
-            printUsageAndExit();
-        }
-        int i = 0;
-        //parse OPTIONS
-        while (args[i].startsWith("-")) {
-            switch (args[i]) {
-                case "-m":
-                    try {
-                        maxCount = Long.parseLong(args[++i]);
-                    } catch (NumberFormatException ex) {
-                        printUsageAndExit(ex.toString());
-                    }
-                    break;
-                default:
-                    printUsageAndExit("Unexpected option " + args[i]);
-            }
-            i++;
-        }
-        //parse PATTERN
-        Pattern pattern = Pattern.compile(args[i++]);
-        if (i == args.length) {
-            printUsageAndExit("There are no files for input");
-        }
-
-        try {
-            /*
-            * First obtain the list of all paths.
-            * For a small number of arguments there is little to be gained
-            * by producing this list in parallel. For one argument
-            * there will be no parallelism.
-            *
-            * File names are converted to paths. If a path is a directory then
-            * Stream is populated with whole file tree of the directory by
-            * flatMap() method. Files are filtered from directories.
-            */
-            List<Path> files = Arrays.stream(args, i, args.length)
-                    .map(Paths::get)
-                    // flatMap will ensure each I/O-based stream will be closed
-                    .flatMap(Grep::getPathStream)
-                    .filter(Files::isRegularFile)
-                    .collect(toList());
-            /*
-            * Then operate on that list in parallel.
-            * This is likely to give a more even distribution of work for
-            * parallel execution.
-            *
-            * Lines are extracted from files. Lines are filtered by pattern.
-            * Stream is limited by number of matches. Each remaining string is
-            * displayed in std output by method reference System.out::println.
-            */
-            files.parallelStream()
-                    // flatMap will ensure each I/O-based stream will be closed
-                    .flatMap(Grep::path2Lines)
-                    .filter(pattern.asPredicate())
-                    .limit(maxCount)
-                    .forEachOrdered(System.out::println);
-        } catch (UncheckedIOException ioe) {
-            printUsageAndExit(ioe.toString());
-        }
-    }
-
-    /**
-     * Flattens file system hierarchy into a stream. This code is not inlined
-     * for the reason of Files.walk() throwing a checked IOException that must
-     * be caught.
-     *
-     * @param path - the file or directory
-     * @return Whole file tree starting from path, a stream with one element -
-     * the path itself - if it is a file.
-     */
-    private static Stream<Path> getPathStream(Path path) {
-        try {
-            return Files.walk(path);
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    }
-
-    /**
-     * Produces a stream of lines from a file. The result is a stream in order
-     * to close it later. This code is not inlined for the reason of
-     * Files.lines() throwing a checked IOException that must be caught.
-     *
-     * @param path - the file to read
-     * @return stream of lines from the file
-     */
-    private static Stream<String> path2Lines(Path path) {
-        try {
-            return Files.lines(path);
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    }
-}
--- a/jdk/src/sample/share/lambda/BulkDataOperations/src/PasswordGenerator.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation, and proper error handling, might not be present in
- * this sample code.
- */
-
-import java.security.SecureRandom;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.IntStream;
-
-/**
- * Generates password of desired length. See {@link #usage} method
- * for instructions and command line parameters. This sample shows usages of:
- * <ul>
- * <li>Method references.</li>
- * <li>Lambda and bulk operations. A stream of random integers is mapped to
- * chars, limited by desired length and printed in standard output as password
- * string.</li>
- * </ul>
- *
- */
-public class PasswordGenerator {
-
-    private static void usage() {
-        System.out.println("Usage: PasswordGenerator LENGTH");
-        System.out.println(
-                "Password Generator produces password of desired LENGTH.");
-    }
-
-    private static final List<Integer> PASSWORD_CHARS = new ArrayList<>();
-
-    //Valid symbols.
-    static {
-        IntStream.rangeClosed('0', '9').forEach(PASSWORD_CHARS::add);    // 0-9
-        IntStream.rangeClosed('A', 'Z').forEach(PASSWORD_CHARS::add);    // A-Z
-        IntStream.rangeClosed('a', 'z').forEach(PASSWORD_CHARS::add);    // a-z
-    }
-
-    /**
-     * The main method for the PasswordGenerator program. Run program with empty
-     * argument list to see possible arguments.
-     *
-     * @param args the argument list for PasswordGenerator.
-     */
-    public static void main(String[] args) {
-
-        if (args.length != 1) {
-            usage();
-            return;
-        }
-
-        long passwordLength;
-        try {
-            passwordLength = Long.parseLong(args[0]);
-            if (passwordLength < 1) {
-                printMessageAndUsage("Length has to be positive");
-                return;
-            }
-        } catch (NumberFormatException ex) {
-            printMessageAndUsage("Unexpected number format" + args[0]);
-            return;
-        }
-        /*
-         * Stream of random integers is created containing Integer values
-         * in range from 0 to PASSWORD_CHARS.size().
-         * The stream is limited by passwordLength.
-         * Valid chars are selected by generated index.
-         */
-        new SecureRandom().ints(passwordLength, 0, PASSWORD_CHARS.size())
-                .map(PASSWORD_CHARS::get)
-                .forEach(i -> System.out.print((char) i));
-    }
-
-    private static void printMessageAndUsage(String message) {
-        System.err.println(message);
-        usage();
-    }
-
-}
--- a/jdk/src/sample/share/lambda/BulkDataOperations/src/WC.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation, and proper error handling, might not be present in
- * this sample code.
- */
-
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.function.Consumer;
-import java.util.regex.Pattern;
-
-/**
- * WC - Prints newline, word, and character counts for each file. See
- * the {@link #usage} method for instructions and command line parameters. This
- * sample shows usages of:
- * <ul>
- * <li>Lambda and bulk operations. Shows how to create a custom collector to
- * gather custom statistics. Implements the collection of statistics using a
- * built-in API.</li>
- * <li>Constructor reference.</li>
- * <li>Try-with-resources feature.</li>
- * </ul>
- *
- */
-public class WC {
-
-    //The number of characters that may be read.
-    private static final int READ_AHEAD_LIMIT = 100_000_000;
-
-    //The pattern for splitting strings by non word characters to get words.
-    private static final Pattern nonWordPattern = Pattern.compile("\\W");
-
-    /**
-     * The main method for the WC program. Run the program with an empty
-     * argument list to see possible arguments.
-     *
-     * @param args the argument list for WC
-     * @throws java.io.IOException If an input exception occurred.
-     */
-    public static void main(String[] args) throws IOException {
-
-        if (args.length != 1) {
-            usage();
-            return;
-        }
-
-        try (BufferedReader reader = new BufferedReader(
-                new FileReader(args[0]))) {
-            reader.mark(READ_AHEAD_LIMIT);
-            /*
-             * Statistics can be gathered in four passes using a built-in API.
-             * The method demonstrates how separate operations can be
-             * implemented using a built-in API.
-             */
-            collectInFourPasses(reader);
-            /*
-             * Usage of several passes to collect data is not the best way.
-             * Statistics can be gathered by a custom collector in one pass.
-             */
-            reader.reset();
-            collectInOnePass(reader);
-        } catch (FileNotFoundException e) {
-            usage();
-            System.err.println(e);
-        }
-    }
-
-    private static void collectInFourPasses(BufferedReader reader)
-            throws IOException {
-        /*
-         * Input is read as a stream of lines by lines().
-         * Every line is turned into a stream of chars by the flatMapToInt(...)
-         * method.
-         * Length of the stream is counted by count().
-         */
-        System.out.println("Character count = "
-                + reader.lines().flatMapToInt(String::chars).count());
-        /*
-         * Input is read as a stream of lines by lines().
-         * Every line is split by nonWordPattern into words by flatMap(...)
-         * method.
-         * Empty lines are removed by the filter(...) method.
-         * Length of the stream is counted by count().
-         */
-        reader.reset();
-        System.out.println("Word count = "
-                + reader.lines()
-                .flatMap(nonWordPattern::splitAsStream)
-                .filter(str -> !str.isEmpty()).count());
-
-        reader.reset();
-        System.out.println("Newline count = " + reader.lines().count());
-        /*
-         * Input is read as a stream of lines by lines().
-         * Every line is mapped to its length.
-         * Maximum of the lengths is calculated.
-         */
-        reader.reset();
-        System.out.println("Max line length = "
-                + reader.lines().mapToInt(String::length).max().getAsInt());
-    }
-
-    private static void collectInOnePass(BufferedReader reader) {
-        /*
-         * The collect() method has three parameters:
-         * The first parameter is the {@code WCStatistic} constructor reference.
-         * collect() will create {@code WCStatistics} instances, where
-         * statistics will be aggregated.
-         * The second parameter shows how {@code WCStatistics} will process
-         * String.
-         * The third parameter shows how to merge two {@code WCStatistic}
-         * instances.
-         *
-         * Also {@code Collector} can be used, which would be more reusable
-         * solution. See {@code CSVProcessor} example for how {@code Collector}
-         * can be implemented.
-         *
-         * Note that the any performance increase when going parallel will
-         * depend on the size of the input (lines) and the cost per-element.
-         */
-        WCStatistics wc = reader.lines().parallel()
-                .collect(WCStatistics::new,
-                        WCStatistics::accept,
-                        WCStatistics::combine);
-        System.out.println(wc);
-    }
-
-    private static void usage() {
-        System.out.println("Usage: " + WC.class.getSimpleName() + " FILE");
-        System.out.println("Print newline, word,"
-                + "  character counts and max line length for FILE.");
-    }
-
-    private static class WCStatistics implements Consumer<String> {
-        /*
-         * @implNote This implementation does not need to be thread safe because
-         * the parallel implementation of
-         * {@link java.util.stream.Stream#collect Stream.collect()}
-         * provides the necessary partitioning and isolation for safe parallel
-         * execution.
-         */
-
-        private long characterCount;
-        private long lineCount;
-        private long wordCount;
-        private long maxLineLength;
-
-
-        /*
-         * Processes line.
-         */
-        @Override
-        public void accept(String line) {
-            characterCount += line.length();
-            lineCount++;
-            wordCount += nonWordPattern.splitAsStream(line)
-                    .filter(str -> !str.isEmpty()).count();
-            maxLineLength = Math.max(maxLineLength, line.length());
-        }
-
-        /*
-         * Merges two WCStatistics.
-         */
-        public void combine(WCStatistics stat) {
-            wordCount += stat.wordCount;
-            lineCount += stat.lineCount;
-            characterCount += stat.characterCount;
-            maxLineLength = Math.max(maxLineLength, stat.maxLineLength);
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder sb = new StringBuilder();
-            sb.append("#------WCStatistic------#\n");
-            sb.append("Character count = ").append(characterCount).append('\n');
-            sb.append("Word count = ").append(wordCount).append('\n');
-            sb.append("Newline count = ").append(lineCount).append('\n');
-            sb.append("Max line length = ").append(maxLineLength).append('\n');
-            return sb.toString();
-        }
-    }
-}
--- a/jdk/src/sample/share/lambda/DefaultMethods/ArrayIterator.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * The code sample illustrates the usage of default methods in the JDK 8. Most
- * implementations of {@link Iterator} don't provide a useful
- * {@link Iterator#remove()} method, however,
- * they still have to implement this method to throw
- * an UnsupportedOperationException. With the default method, the same
- * default behavior in interface Iterator itself can be provided.
- */
-public class ArrayIterator {
-
-    /** Close the constructor because ArrayIterator is part of the utility
-     * class.
-     */
-    protected ArrayIterator() {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * Returns an iterator that goes over the elements in the array.
-     *
-     * @param <E> type of an array element
-     * @param array source array to iterate over it
-     * @return an iterator that goes over the elements in the array
-     */
-    public static <E> Iterator<E> iterator(final E[] array) {
-        return new Iterator<E>() {
-            /**
-             * Index of the current position
-             *
-             */
-            private int index = 0;
-
-            /**
-             * Returns the next element in the iteration
-             *
-             * @return the next element in the iteration
-             * @throws NoSuchElementException if the iteration has no more
-             * elements
-             */
-            @Override
-            public boolean hasNext() {
-                return (index < array.length);
-            }
-
-            /**
-             * Returns {@code true} if the iteration has more elements. (In
-             * other words, returns {@code true} if {@link #next} returns
-             * an element, rather than throwing an exception.)
-             *
-             * @return {@code true} if the iteration has more elements
-             */
-            @Override
-            public E next() {
-                if (!hasNext()) {
-                    throw new NoSuchElementException();
-                }
-                return array[index++];
-            }
-
-            /**
-             * This method does not need to be overwritten in JDK 8.
-             */
-            //@Override
-            //public void remove() {
-            //    throw UnsupportedOperationException(
-            //            "Arrays don't support remove.")
-            //}
-        };
-    }
-
-    /**
-     * Sample usage of the ArrayIterator
-     *
-     * @param args command-line arguments
-     */
-    public static void main(final String[] args) {
-        Iterator<String> it = ArrayIterator.iterator(
-                new String[]{"one", "two", "three"});
-
-        while (it.hasNext()) {
-            System.out.println(it.next());
-        }
-    }
-}
--- a/jdk/src/sample/share/lambda/DefaultMethods/DiamondInheritance.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * This sample diamond interface inheritance with <b>default methods</b>.
- * If there's not already a unique method implementation to inherit,
- * you must provide it. The inheritance diagram is similar to the following:
- * <pre>
- *                   Animal
- *                    /   \
- *                 Horse   Bird
- *                    \   /
- *                   Pegasus
- * </pre>
- *
- * Both {@link Horse} and {@link Bird} interfaces implements the <code>go</code>
- * method. The {@link Pegasus} class have to overrides the
- * <code>go</code> method.
- *
- * The new syntax of super-call is used here:
- * <pre>
- *     &lt;interface_name&gt;.super.&lt;method&gt;(...);
- *     For example:  Horse.super.go();
- * </pre> So, Pegasus moves like a horse.
- */
-public class DiamondInheritance {
-
-    /**
-     * Base interface to illustrate the diamond inheritance.
-     *
-     * @see DiamondInheritance
-     */
-    public interface Animal {
-
-        /**
-         * Return string representation of the "go" action for concrete animal
-         *
-         * @return string representation of the "go" action for concrete animal
-         */
-        String go();
-    }
-
-    /**
-     * Interface to illustrate the diamond inheritance.
-     *
-     * @see DiamondInheritance
-     */
-    public interface Horse extends Animal {
-
-        /**
-         * Return string representation of the "go" action for horse
-         *
-         * @return string representation of the "go" action for horse
-         */
-        @Override
-        default String go() {
-            return this.getClass().getSimpleName() + " walks on four legs";
-        }
-    }
-
-    /**
-     * Interface to illustrate the diamond inheritance.
-     *
-     * @see DiamondInheritance
-     */
-    public interface Bird extends Animal {
-
-        /**
-         * Return string representation of the "go" action for bird
-         *
-         * @return string representation of the "go" action for bird
-         */
-        @Override
-        default String go() {
-            return this.getClass().getSimpleName() + " walks on two legs";
-        }
-
-        /**
-         * Return string representation of the "fly" action for bird
-         *
-         * @return string representation of the "fly" action for bird
-         */
-        default String fly() {
-            return "I can fly";
-        }
-    }
-
-    /**
-     * Class to illustrate the diamond inheritance. Pegasus must mix horse and
-     * bird behavior.
-     *
-     * @see DiamondInheritance
-     */
-    public static class Pegasus implements Horse, Bird {
-
-        /**
-         * Return string representation of the "go" action for the fictitious
-         * creature Pegasus
-         *
-         * @return string representation of the "go" action for the fictitious
-         * creature Pegasus
-         */
-        @Override
-        public String go() {
-            return Horse.super.go();
-        }
-    }
-
-    /**
-     * Illustrate the behavior of the {@link Pegasus} class
-     *
-     * @param args command line arguments
-     */
-    public static void main(final String[] args) {
-        System.out.println(new Pegasus().go());
-    }
-}
--- a/jdk/src/sample/share/lambda/DefaultMethods/Inheritance.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * The sample illustrates rules to resolve conflicts between inheritance
- * candidates with <b>default methods</b>. There are two simple rules:
- * <ul>
- * <li>Class wins. If the superclass has a concrete or abstract declaration of
- * this method, then it is preferred over all defaults.</li>
- * <li>Subtype wins. If an interface extends another interface, and both provide
- * a default, then the more specific interface wins. </li>
- * </ul>
- */
-public class Inheritance {
-
-    /**
-     * The behavior of an creature that can swim
-     */
-    public interface Swimable {
-
-        /**
-         * Return string representation of the swim action for a creature that
-         * can swim
-         *
-         * @return string representation of the swim action for a creature
-         * that can swim
-         */
-        default String swim() {
-            return "I can swim.";
-        }
-    }
-
-    /**
-     * The abstract class that overrides {@link #swim} method
-     */
-    public abstract static class Fish implements Swimable {
-
-        /**
-         * Return string representation of the swim action for a fish
-         *
-         * @return string representation of the swim action for a fish
-         */
-        @Override
-        public String swim() {
-            return this.getClass().getSimpleName() + " swims under water";
-        }
-    }
-
-    /**
-     * This class is used for the illustration rule of 1. See the source code
-     * of the {@link #main} method.
-     * <pre>
-     *      System.out.println(new Tuna().swim()); //"Tuna swims under water" output is suspected here
-     * </pre>
-     */
-    public static class Tuna extends Fish implements Swimable {
-    }
-
-    /**
-     * The behavior of an creature that can dive: the interface that overrides
-     * {@link #swim} method (subtype of {@link Swimable})
-     */
-    public interface Diveable extends Swimable {
-
-        /**
-         * Return string representation of the swim action for a creature that
-         * can dive
-         *
-         * @return string representation of the swim action for a creature
-         * that can dive
-         */
-        @Override
-        default String swim() {
-            return "I can swim on the surface of the water.";
-        }
-
-        /**
-         * Return string representation of the dive action for a creature that
-         * can dive
-         *
-         * @return string representation of the dive action for a creature
-         * that can dive
-         */
-        default String dive() {
-            return "I can dive.";
-        }
-    }
-
-    /**
-     * This class is used for the illustration of rule 2. See the source code
-     * of the {@link #main} method
-     * <pre>
-     *      //"I can swim on the surface of the water." output is suspected here
-     *      System.out.println(new Duck().swim());
-     * </pre>
-     */
-    public static class Duck implements Swimable, Diveable {
-    }
-
-    /**
-     * Illustrate behavior of the classes: {@link Tuna} and {@link Duck}
-     *
-     * @param args command line arguments
-     */
-    public static void main(final String[] args) {
-        // Illustrates rule 1. The Fish.swim() implementation wins
-        //"Tuna swims under water" is output
-        System.out.println(new Tuna().swim());
-
-        // Illustrates rule 2. The Diveable.swim() implementation wins
-        //"I can swim on the surface of the water." is output
-        System.out.println(new Duck().swim());
-    }
-}
--- a/jdk/src/sample/share/lambda/DefaultMethods/MixIn.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-/**
- * The example illustrates how to use the default method for mixin.
- * @see BuildType
- * @see Debuggable
- */
-public class MixIn {
-
-    /**
-     * Implement this interface for a class that must be in debug print
-     */
-    public interface Debuggable {
-
-        /**
-         * Print the class name and all fields to a string. Uses reflection to
-         * obtain and access fields of this object.
-         *
-         * @return the string formatted like the following: <pre>
-         * State of the: &lt;Class Name&gt;
-         * &lt;member name&gt; : &lt;value&gt;
-         * ...
-         * </pre>
-         */
-        default String toDebugString() {
-            StringBuilder sb = new StringBuilder();
-            sb.append("State of the: ").append(
-                    this.getClass().getSimpleName()).append("\n");
-            for (Class cls = this.getClass();
-                    cls != null;
-                    cls = cls.getSuperclass()) {
-                for (Field f : cls.getDeclaredFields()) {
-                    try {
-                        f.setAccessible(true);
-                        sb.append(f.getName()).append(" : ").
-                                append(f.get(this)).append("\n");
-                    } catch (IllegalAccessException e) {
-                    }
-                }
-            }
-            return sb.toString();
-        }
-    }
-
-    /**
-     * Sample exception class to demonstrate mixin. This enum inherits the
-     * behavior of the {@link Debuggable}
-     */
-    public static enum BuildType implements Debuggable {
-
-        BUILD(0, "-build"),
-        PLAN(0, "-plan"),
-        EXCLUDE(1, "-exclude"),
-        TOTAL(2, "-total");
-
-        private final int compareOrder;
-        private final String pathSuffix;
-
-        private BuildType(int compareOrder, String pathSuffix) {
-            this.compareOrder = compareOrder;
-            this.pathSuffix = pathSuffix;
-        }
-
-        public int getCompareOrder() {
-            return compareOrder;
-        }
-
-        public String getPathSuffix() {
-            return pathSuffix;
-        }
-    }
-
-    /**
-     * Illustrate the behavior of the MixClass
-     *
-     * @param args command-line arguments
-     * @throws java.io.IOException internal demo error
-     */
-    public static void main(final String[] args) throws IOException {
-        System.out.println(BuildType.BUILD.toDebugString());
-    }
-}
--- a/jdk/src/sample/share/lambda/DefaultMethods/Reflection.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.stream.Stream;
-
-/**
- * The code sample illustrates changes in the reflection API linked
- * <b>default methods</b>. Since Java SE 8, a new method is added into the class
- * <b><code>java.lang.reflect.Method</code></b>, with which you can reflectively
- * determine whether or not a default method provided by an interface
- * (<b><code>Method.isDefault()</code></b>).
- */
-public class Reflection {
-
-    /**
-     * Base interface to illustrate the new reflection API.
-     *
-     * @see Dog
-     */
-    public interface Animal {
-
-        /**
-         * Return string representation of the eat action for Animal
-         *
-         * @return string representation of the eat action for Animal
-         */
-        default String eat() {
-            return this.getClass().getSimpleName()
-                    + " eats like an ordinary animal";
-        }
-
-        /**
-         * Return string representation of the sleep action for Animal
-         *
-         * @return string representation of the sleep action for Animal
-         */
-        default String sleep() {
-            return this.getClass().getSimpleName()
-                    + " sleeps like an ordinary animal";
-        }
-
-        /**
-         * Return string representation of the go action for Animal
-         *
-         * @return string representation of the go action for Animal
-         */
-        String go();
-    }
-
-    /**
-     * Dog class to illustrate the new reflection API. You can see that:
-     * <ul>
-     * <li> the {@link #go} and {@link #sleep} methods are not default.
-     * {@link #go} is not the default implementation and the {@link #sleep}
-     * method implementation wins as subtype (according with {@link Inheritance}
-     * rule. 2) </li>
-     * <li> the {@link #eat} is a simple default method that is not overridden
-     * in this class.
-     * </li>
-     * </ul>
-     */
-    public static class Dog implements Animal {
-
-        /**
-         * Return string representation of the go action for Dog
-         *
-         * @return string representation of the go action for Dog
-         */
-        @Override
-        public String go() {
-            return "Dog walks on four legs";
-        }
-
-        /**
-         * Return string representation of the sleep action for Dog
-         *
-         * @return string representation of the sleep action for Dog
-         */
-        @Override
-        public String sleep() {
-            return "Dog sleeps";
-        }
-    }
-
-    /**
-     * Illustrate the usage of the method java.lang.reflect.Method.isDefault()
-     *
-     * @param args command-line arguments
-     * @throws NoSuchMethodException internal demo error
-     */
-    public static void main(final String[] args) throws NoSuchMethodException {
-        Dog dog = new Dog();
-        Stream.of(Dog.class.getMethod("eat"), Dog.class.getMethod("go"), Dog.class.getMethod("sleep"))
-                .forEach((m) -> {
-                    System.out.println("Method name:   " + m.getName());
-                    System.out.println("    isDefault: " + m.isDefault());
-                    System.out.print("    invoke:    ");
-                    try {
-                        m.invoke(dog);
-                    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
-                    }
-                    System.out.println();
-                });
-    }
-}
--- a/jdk/src/sample/share/lambda/DefaultMethods/SimplestUsage.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * The sample illustrates the simplest use case of the <b>default methods</b>.
- */
-public class SimplestUsage {
-
-    /**
-     * The Animal interface provides the default implementation
-     * of the {@link #eat} method.
-     */
-    public interface Animal {
-
-        /**
-         * Return string representation of the eat action for Animal
-         *
-         * @return string representation of the eat action for Animal
-         */
-        default String eat() {
-            return this.getClass().getSimpleName()
-                    + " eats like an ordinary animal";
-        }
-    }
-
-    /**
-     * The Dog class doesn't have its own implementation of the {@link #eat}
-     * method and uses the default implementation.
-     */
-    public static class Dog implements Animal {
-    }
-
-    /**
-     * The Mosquito class implements {@link #eat} method, its own implementation
-     * overrides the default implementation.
-     *
-     */
-    public static class Mosquito implements Animal {
-
-        /**
-         * Return string representation of the eat action for Mosquito
-         *
-         * @return string representation of the eat action for Mosquito
-         */
-        @Override
-        public String eat() {
-            return "Mosquito consumes blood";
-        }
-    }
-
-    /**
-     * Illustrate behavior of the classes: {@link Dog} and {@link Mosquito}
-     *
-     * @param args command-line arguments
-     */
-    public static void main(String[] args) {
-        // "Dog eats like an ordinary animal" is output
-        System.out.println(new Dog().eat());
-
-        // "Mosquito consumes blood" is output
-        System.out.println(new Mosquito().eat());
-    }
-}
--- a/jdk/src/sample/share/nbproject/project.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<project xmlns="http://www.netbeans.org/ns/project/1">
-    <type>org.netbeans.modules.ant.freeform</type>
-    <configuration>
-        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
-            <name>JDK Samples</name>
-            <view>
-                <items/>
-            </view>
-            <subprojects>
-                <project>jmx/jmx-scandir</project>
-                <project>scripting/scriptpad</project>
-                <project>webservices/EbayClient</project>
-                <project>webservices/EbayServer</project>
-            </subprojects>
-        </general-data>
-    </configuration>
-</project>
--- a/jdk/src/sample/share/nio/chatserver/ChatServer.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.net.StandardSocketOptions;
-import java.nio.channels.*;
-import java.util.*;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Implements a chat server, this class holds the list of {@code clients} connected to the server.
- * It sets up a server socket using AsynchronousServerSocketChannel listening to a specified port.
- */
-public class ChatServer implements Runnable {
-    private final List<Client> connections = Collections.synchronizedList(new ArrayList<Client>());
-    private int port;
-    private final AsynchronousServerSocketChannel listener;
-    private final AsynchronousChannelGroup channelGroup;
-
-    /**
-     *
-     * @param port to listen to
-     * @throws java.io.IOException when failing to start the server
-     */
-    public ChatServer(int port) throws IOException {
-        channelGroup = AsynchronousChannelGroup.withFixedThreadPool(Runtime.getRuntime().availableProcessors(),
-                Executors.defaultThreadFactory());
-        this.port = port;
-        listener = createListener(channelGroup);
-    }
-
-    /**
-     *
-     * @return The socket address that the server is bound to
-     * @throws java.io.IOException if an I/O error occurs
-     */
-    public SocketAddress getSocketAddress() throws IOException {
-        return listener.getLocalAddress();
-    }
-
-    /**
-     * Start accepting connections
-     */
-    public void run() {
-
-        // call accept to wait for connections, tell it to call our CompletionHandler when there
-        // is a new incoming connection
-        listener.accept(null, new CompletionHandler<AsynchronousSocketChannel, Void>() {
-            @Override
-            public void completed(AsynchronousSocketChannel result, Void attachment) {
-                // request a new accept and handle the incoming connection
-                listener.accept(null, this);
-                handleNewConnection(result);
-            }
-
-            @Override
-            public void failed(Throwable exc, Void attachment) {
-            }
-        });
-    }
-
-    /**
-     * Shuts down the server
-     * @throws InterruptedException if terminated while waiting for shutdown
-     * @throws IOException if failing to shutdown the channel group
-     */
-    public void shutdown() throws InterruptedException, IOException {
-        channelGroup.shutdownNow();
-        channelGroup.awaitTermination(1, TimeUnit.SECONDS);
-    }
-
-    /*
-    * Creates a listener and starts accepting connections
-    */
-    private AsynchronousServerSocketChannel createListener(AsynchronousChannelGroup channelGroup) throws IOException {
-        final AsynchronousServerSocketChannel listener = openChannel(channelGroup);
-        listener.setOption(StandardSocketOptions.SO_REUSEADDR, true);
-        listener.bind(new InetSocketAddress(port));
-        return listener;
-    }
-
-    private AsynchronousServerSocketChannel openChannel(AsynchronousChannelGroup channelGroup) throws IOException {
-        return AsynchronousServerSocketChannel.open(channelGroup);
-    }
-
-    /**
-     * Creates a new client and adds it to the list of connections.
-     * Sets the clients handler to the initial state of NameReader
-     *
-     * @param channel the newly accepted channel
-     */
-    private void handleNewConnection(AsynchronousSocketChannel channel) {
-        Client client = new Client(channel, new ClientReader(this, new NameReader(this)));
-        try {
-            channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
-        } catch (IOException e) {
-            // ignore
-        }
-        connections.add(client);
-        client.run();
-    }
-
-    /**
-     * Sends a message to all clients except the source.
-     * The method is synchronized as it is desired that messages are sent to
-     * all clients in the same order as received.
-     *
-     * @param client the message source
-     * @param message the message to be sent
-     */
-    public void writeMessageToClients(Client client, String message) {
-        synchronized (connections) {
-            for (Client clientConnection : connections) {
-                if (clientConnection != client) {
-                    clientConnection.writeMessageFrom(client, message);
-                }
-            }
-        }
-    }
-
-    public void removeClient(Client client) {
-        connections.remove(client);
-    }
-
-    private static void usage() {
-        System.err.println("ChatServer [-port <port number>]");
-        System.exit(1);
-    }
-
-    public static void main(String[] args) throws IOException {
-        int port = 5000;
-        if (args.length != 0 && args.length != 2) {
-            usage();
-        } else if (args.length == 2) {
-            try {
-                if (args[0].equals("-port")) {
-                    port = Integer.parseInt(args[1]);
-                } else {
-                    usage();
-                }
-            } catch (NumberFormatException e) {
-                usage();
-            }
-        }
-        System.out.println("Running on port " + port);
-        new ChatServer(port).run();
-    }
-}
--- a/jdk/src/sample/share/nio/chatserver/Client.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.AsynchronousSocketChannel;
-import java.nio.channels.CompletionHandler;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * Client represents a remote connection to the chat server.
- * It contains methods for reading and writing messages from the
- * channel.
- * Messages are considered to be separated by newline, so incomplete
- * messages are buffered in the {@code Client}.
- *
- * All reads and writes are asynchronous and uses the nio2 asynchronous
- * elements.
- */
-class Client {
-    private final AsynchronousSocketChannel channel;
-    private AtomicReference<ClientReader> reader;
-    private String userName;
-    private final StringBuilder messageBuffer = new StringBuilder();
-
-    private final Queue<ByteBuffer> queue = new LinkedList<ByteBuffer>();
-    private boolean writing = false;
-
-    public Client(AsynchronousSocketChannel channel, ClientReader reader) {
-        this.channel = channel;
-        this.reader = new AtomicReference<ClientReader>(reader);
-    }
-
-    /**
-     * Enqueues a write of the buffer to the channel.
-     * The call is asynchronous so the buffer is not safe to modify after
-     * passing the buffer here.
-     *
-     * @param buffer the buffer to send to the channel
-     */
-    private void writeMessage(final ByteBuffer buffer) {
-        boolean threadShouldWrite = false;
-
-        synchronized(queue) {
-            queue.add(buffer);
-            // Currently no thread writing, make this thread dispatch a write
-            if (!writing) {
-                writing = true;
-                threadShouldWrite = true;
-            }
-        }
-
-        if (threadShouldWrite) {
-            writeFromQueue();
-        }
-    }
-
-    private void writeFromQueue() {
-        ByteBuffer buffer;
-
-        synchronized (queue) {
-            buffer = queue.poll();
-            if (buffer == null) {
-                writing = false;
-            }
-        }
-
-        // No new data in buffer to write
-        if (writing) {
-            writeBuffer(buffer);
-        }
-    }
-
-    private void writeBuffer(ByteBuffer buffer) {
-        channel.write(buffer, buffer, new CompletionHandler<Integer, ByteBuffer>() {
-            @Override
-            public void completed(Integer result, ByteBuffer buffer) {
-                if (buffer.hasRemaining()) {
-                    channel.write(buffer, buffer, this);
-                } else {
-                    // Go back and check if there is new data to write
-                    writeFromQueue();
-                }
-            }
-
-            @Override
-            public void failed(Throwable exc, ByteBuffer attachment) {
-            }
-        });
-    }
-
-    /**
-     * Sends a message
-     * @param string the message
-     */
-    public void writeStringMessage(String string) {
-        writeMessage(ByteBuffer.wrap(string.getBytes()));
-    }
-
-    /**
-     * Send a message from a specific client
-     * @param client the message is sent from
-     * @param message to send
-     */
-    public void writeMessageFrom(Client client, String message) {
-        if (reader.get().acceptsMessages()) {
-            writeStringMessage(client.getUserName() + ": " + message);
-        }
-    }
-
-    /**
-     * Enqueue a read
-     * @param completionHandler callback on completed read
-     */
-    public void read(CompletionHandler<Integer, ? super ByteBuffer> completionHandler) {
-        ByteBuffer input = ByteBuffer.allocate(256);
-        if (!channel.isOpen()) {
-            return;
-        }
-        channel.read(input, input, completionHandler);
-    }
-
-    /**
-     * Closes the channel
-     */
-    public void close() {
-        try {
-            channel.close();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Run the current states actions.
-     */
-    public void run() {
-        reader.get().run(this);
-    }
-
-    public void setUserName(String userName) {
-        this.userName = userName;
-    }
-
-    public void setReader(ClientReader reader) {
-        this.reader.set(reader);
-    }
-
-    public String getUserName() {
-        return userName;
-    }
-
-    public void appendMessage(String message) {
-        synchronized (messageBuffer) {
-            messageBuffer.append(message);
-        }
-    }
-
-    /**
-     * @return the next newline separated message in the buffer. null is returned if the buffer
-     * doesn't contain any newline.
-     */
-    public String nextMessage() {
-        synchronized(messageBuffer) {
-            int nextNewline = messageBuffer.indexOf("\n");
-            if (nextNewline == -1) {
-                return null;
-            }
-            String message = messageBuffer.substring(0, nextNewline + 1);
-            messageBuffer.delete(0, nextNewline + 1);
-            return message;
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/chatserver/ClientReader.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.ByteBuffer;
-import java.nio.channels.CompletionHandler;
-
-/**
- * Handles a cycle of reading / writing on the {@code Client}.
- */
-class ClientReader {
-    private final DataReader callback;
-    private final ChatServer chatServer;
-
-    ClientReader(ChatServer chatServer, DataReader callback) {
-        this.chatServer = chatServer;
-        this.callback = callback;
-    }
-
-    public boolean acceptsMessages() {
-        return callback.acceptsMessages();
-    }
-
-    /**
-     * Runs a cycle of doing a beforeRead action and then enqueuing a new
-     * read on the client. Handles closed channels and errors while reading.
-     * If the client is still connected a new round of actions are called.
-     */
-    public void run(final Client client) {
-        callback.beforeRead(client);
-        client.read(new CompletionHandler<Integer, ByteBuffer>() {
-            @Override
-            public void completed(Integer result, ByteBuffer buffer) {
-                // if result is negative or zero the connection has been closed or something gone wrong
-                if (result < 1) {
-                    client.close();
-                    System.out.println("Closing connection to " + client);
-                    chatServer.removeClient(client);
-                } else {
-                    callback.onData(client, buffer, result);
-                    // enqueue next round of actions
-                    client.run();
-                }
-            }
-
-            @Override
-            public void failed(Throwable exc, ByteBuffer buffer) {
-                client.close();
-                chatServer.removeClient(client);
-            }
-        });
-    }
-}
--- a/jdk/src/sample/share/nio/chatserver/DataReader.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.ByteBuffer;
-
-public interface DataReader {
-    void beforeRead(Client client);
-    void onData(Client client, ByteBuffer buffer, int bytes);
-    boolean acceptsMessages();
-}
--- a/jdk/src/sample/share/nio/chatserver/MessageReader.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.ByteBuffer;
-
-/**
- * Writes all messages in our buffer to the other clients
- * and appends new data read from the socket to our buffer
- */
-class MessageReader implements DataReader {
-    private final ChatServer chatServer;
-
-    public MessageReader(ChatServer chatServer) {
-        this.chatServer = chatServer;
-    }
-
-    public boolean acceptsMessages() {
-        return true;
-    }
-
-    /**
-     * Write all full messages in our buffer to
-     * the other clients
-     *
-     * @param client the client to read messages from
-     */
-    @Override
-    public void beforeRead(Client client) {
-        // Check if we have any messages buffered and send them
-        String message = client.nextMessage();
-        while (message != null) {
-            chatServer.writeMessageToClients(client, message);
-            message = client.nextMessage();
-        }
-    }
-
-    /**
-     * Append the read buffer to the clients message buffer
-     * @param client the client to append messages to
-     * @param buffer the buffer we received from the socket
-     * @param bytes the number of bytes read into the buffer
-     */
-    @Override
-    public void onData(Client client, ByteBuffer buffer, int bytes) {
-        buffer.flip();
-        // Just append the message on the buffer
-        client.appendMessage(new String(buffer.array(), 0, bytes));
-    }
-}
--- a/jdk/src/sample/share/nio/chatserver/NameReader.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.ByteBuffer;
-
-/**
- * The first state a newly connected {@code Client} is in, this
- * handles writing out the welcoming message and reads the response
- * up to a newline. When a newline character have been received
- * it changes the handler from NameReader to MessageReader on the
- * client.
- */
-class NameReader implements DataReader {
-    private final StringBuilder buffer = new StringBuilder();
-    private final ChatServer chatServer;
-    private boolean once = true;
-    private static final String NEWLINE = "\n";
-
-    public NameReader(ChatServer chatServer) {
-        this.chatServer = chatServer;
-    }
-
-    /**
-     * Writes the welcoming message to the client the first time this method
-     * is called.
-     *
-     * @param client the client to receive the message
-     */
-    @Override
-    public void beforeRead(Client client) {
-        // if it is a long name that takes more than one read we only want to display Name: once.
-        if (once) {
-            client.writeStringMessage("Name: ");
-            once = false;
-        }
-    }
-
-    public boolean acceptsMessages() {
-        return false;
-    }
-
-    /**
-     * Receives incoming data from the socket, searches for a newline
-     * and tries to set the username if one is found
-     */
-    @Override
-    public void onData(Client client, ByteBuffer buffer, int bytes) {
-        buffer.flip();
-        String name;
-        name = this.buffer.append(new String(buffer.array(), 0, bytes)).toString();
-        if (name.contains(NEWLINE)) {
-            onUserNameRead(client, name);
-        }
-    }
-
-    /**
-     * Splits the name on the newlines, takes the first as the username
-     * and appends everything else to the clients message buffer.
-     * Sets the clients handler to MessageReader.
-     *
-     * @param client the client to set the username for
-     * @param name the string containing the buffered input
-     */
-    private void onUserNameRead(Client client, String name) {
-        String[] strings = name.split(NEWLINE, 2);
-        client.setUserName(strings[0].trim());
-        sendRemainingParts(client, strings);
-        client.setReader(new ClientReader(chatServer, new MessageReader(chatServer)));
-        client.writeStringMessage("Welcome " + client.getUserName() + "\n");
-    }
-
-    /**
-     * Appends the remaining parts to the clients message buffer
-     *
-     * @param client the client
-     * @param strings the messages to append to the buffer
-     */
-    private void sendRemainingParts(Client client, String[] strings) {
-        for (int i = 1; i < strings.length; ++i) {
-            client.appendMessage(strings[i]);
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/chatserver/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-A Simple Chat Server Example
-
-INTRODUCTION
-============
-This directory contains a very simple chat server, the server takes input from a
-socket ("user") and sends it to all other connected sockets ("users") along with
-the provided name the user was asked for when first connecting.
-
-The server was written to demonstrate the asynchronous I/O API in JDK 7. 
-The sample assumes the reader has some familiarity with the subject matter.
-
-SETUP
-=====
-
-The server must be built with version 7 (or later) of the JDK.
-The server is built with:
-
-    % mkdir build
-    % javac -source 7 -target 7 -d build *.java
-
-EXECUTION
-=========
-
-    % java -classpath build ChatServer [-port <port number>]
-
-    Usage:  ChatServer [options]
-        options:
-            -port port      port number
-                default: 5000
-
-CLIENT EXECUTION
-================
-
-No client binary is included in the sample.
-Connections can be made using for example the telnet command or any program
-that supports a raw TCP connection to a port.
-
-SOURCE CODE OVERVIEW
-====================
-ChatServer is the main class, it handles the startup and handles incoming
-connections on the listening sockets. It keeps a list of connected client
-and provides methods for sending a message to them.
-
-Client represents a connected user, it provides methods for reading/writing
-from/to the underlying socket. It also contains a buffer of input read from
-the user.
-
-DataReader provides the interface of the two states a user can
-be in. Waiting for a name (and not receiving any messages while doing so, implemented
-by NameReader) and waiting for messages from the user (implemented by MessageReader).
-
-ClientReader contains the "main loop" for a connected client. 
-
-NameReader is the initial state for a new client, it sends the user a string and
-waits for a response before changing the state to MessageReader.
-
-MessageReader is the main state for a client, it checks for new messages to send to
-other clients and reads messages from the client.
-
-FINALLY
-=======
-This is a sample: it is not production quality and isn't optimized for performance.
--- a/jdk/src/sample/share/nio/file/AclEdit.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,305 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-import java.util.*;
-import java.util.regex.Pattern;
-
-/**
- * Sample utility for editing a file's ACL.
- */
-
-public class AclEdit {
-
-    // parse string as list of ACE permissions separated by /
-    static Set<AclEntryPermission> parsePermissions(String permsString) {
-        Set<AclEntryPermission> perms = new HashSet<AclEntryPermission>();
-        String[] result = permsString.split("/");
-        for (String s : result) {
-            if (s.equals(""))
-                continue;
-            try {
-                perms.add(AclEntryPermission.valueOf(s.toUpperCase()));
-            } catch (IllegalArgumentException x) {
-                System.err.format("Invalid permission '%s'\n", s);
-                System.exit(-1);
-            }
-        }
-        return perms;
-    }
-
-    // parse string as list of ACE flags separated by /
-    static Set<AclEntryFlag> parseFlags(String flagsString) {
-        Set<AclEntryFlag> flags = new HashSet<AclEntryFlag>();
-        String[] result = flagsString.split("/");
-        for (String s : result) {
-            if (s.equals(""))
-                continue;
-            try {
-                flags.add(AclEntryFlag.valueOf(s.toUpperCase()));
-            } catch (IllegalArgumentException x) {
-                System.err.format("Invalid flag '%s'\n", s);
-                System.exit(-1);
-            }
-        }
-        return flags;
-    }
-
-    // parse ACE type
-    static AclEntryType parseType(String typeString) {
-        // FIXME: support audit and alarm types in the future
-        if (typeString.equalsIgnoreCase("allow"))
-            return AclEntryType.ALLOW;
-        if (typeString.equalsIgnoreCase("deny"))
-            return AclEntryType.DENY;
-        System.err.format("Invalid type '%s'\n", typeString);
-        System.exit(-1);
-        return null;    // keep compiler happy
-    }
-
-    /**
-     * Parse string of the form:
-     *   [user|group:]<username|groupname>:<perms>[:flags]:<allow|deny>
-     */
-    static AclEntry parseAceString(String s,
-                                   UserPrincipalLookupService lookupService)
-    {
-        String[] result = s.split(":");
-
-        // must have at least 3 components (username:perms:type)
-        if (result.length < 3)
-            usage();
-
-        int index = 0;
-        int remaining = result.length;
-
-        // optional first component can indicate user or group type
-        boolean isGroup = false;
-        if (result[index].equalsIgnoreCase("user") ||
-            result[index].equalsIgnoreCase("group"))
-        {
-            if (--remaining < 3)
-                usage();
-            isGroup = result[index++].equalsIgnoreCase("group");
-        }
-
-        // user and permissions required
-        String userString = result[index++]; remaining--;
-        String permsString = result[index++]; remaining--;
-
-        // flags are optional
-        String flagsString = "";
-        String typeString = null;
-        if (remaining == 1) {
-            typeString = result[index++];
-        } else {
-            if (remaining == 2) {
-                flagsString = result[index++];
-                typeString = result[index++];
-            } else {
-                usage();
-            }
-        }
-
-        // lookup UserPrincipal
-        UserPrincipal user = null;
-        try {
-            user = (isGroup) ?
-                lookupService.lookupPrincipalByGroupName(userString) :
-                lookupService.lookupPrincipalByName(userString);
-        } catch (UserPrincipalNotFoundException x) {
-            System.err.format("Invalid %s '%s'\n",
-                ((isGroup) ? "group" : "user"),
-                userString);
-            System.exit(-1);
-        } catch (IOException x) {
-            System.err.format("Lookup of '%s' failed: %s\n", userString, x);
-            System.exit(-1);
-        }
-
-        // map string representation of permissions, flags, and type
-        Set<AclEntryPermission> perms = parsePermissions(permsString);
-        Set<AclEntryFlag> flags = parseFlags(flagsString);
-        AclEntryType type = parseType(typeString);
-
-        // build the ACL entry
-        return AclEntry.newBuilder()
-            .setType(type)
-            .setPrincipal(user)
-            .setPermissions(perms).setFlags(flags).build();
-    }
-
-    static void usage() {
-        System.err.println("usage: java AclEdit [ACL-operation] file");
-        System.err.println("");
-        System.err.println("Example 1: Prepends access control entry to the begining of the myfile's ACL");
-        System.err.println("       java AclEdit A+alice:read_data/read_attributes:allow myfile");
-        System.err.println("");
-        System.err.println("Example 2: Remove the entry at index 6 of myfile's ACL");
-        System.err.println("       java AclEdit A6- myfile");
-        System.err.println("");
-        System.err.println("Example 3: Replace the entry at index 2 of myfile's ACL");
-        System.err.println("       java AclEdit A2=bob:write_data/append_data:deny myfile");
-        System.exit(-1);
-    }
-
-    static enum Action {
-        PRINT,
-        ADD,
-        REMOVE,
-        REPLACE;
-    }
-
-    /**
-     * Main class: parses arguments and prints or edits ACL
-     */
-    public static void main(String[] args) throws IOException {
-        Action action = null;
-        int index = -1;
-        String entryString = null;
-
-        // parse arguments
-        if (args.length < 1 || args[0].equals("-help") || args[0].equals("-?"))
-            usage();
-
-        if (args.length == 1) {
-            action = Action.PRINT;
-        } else {
-            String s = args[0];
-
-            // A[index]+entry
-            if (Pattern.matches("^A[0-9]*\\+.*", s)) {
-                String[] result = s.split("\\+", 2);
-                if (result.length == 2) {
-                    if (result[0].length() < 2) {
-                        index = 0;
-                    } else {
-                        index = Integer.parseInt(result[0].substring(1));
-                    }
-                    entryString = result[1];
-                    action = Action.ADD;
-                }
-            }
-
-            // Aindex-
-            if (Pattern.matches("^A[0-9]+\\-", s)) {
-                String[] result = s.split("\\-", 2);
-                if (result.length == 2) {
-                    index = Integer.parseInt(result[0].substring(1));
-                    entryString = result[1];
-                    action = Action.REMOVE;
-                }
-            }
-
-            // Aindex=entry
-            if (Pattern.matches("^A[0-9]+=.*", s)) {
-                String[] result = s.split("=", 2);
-                if (result.length == 2) {
-                    index = Integer.parseInt(result[0].substring(1));
-                    entryString = result[1];
-                    action = Action.REPLACE;
-                }
-            }
-        }
-        if (action == null)
-            usage();
-
-        int fileArg = (action == Action.PRINT) ? 0 : 1;
-        Path file = Paths.get(args[fileArg]);
-
-        // read file's ACL
-        AclFileAttributeView view =
-            Files.getFileAttributeView(file, AclFileAttributeView.class);
-        if (view == null) {
-            System.err.println("ACLs not supported on this platform");
-            System.exit(-1);
-        }
-        List<AclEntry> acl = view.getAcl();
-
-        switch (action) {
-            // print ACL
-            case PRINT : {
-                for (int i=0; i<acl.size(); i++) {
-                    System.out.format("%5d: %s\n", i, acl.get(i));
-                }
-                break;
-            }
-
-            // add ACE to existing ACL
-            case ADD: {
-                AclEntry entry = parseAceString(entryString, file
-                    .getFileSystem().getUserPrincipalLookupService());
-                if (index >= acl.size()) {
-                    acl.add(entry);
-                } else {
-                    acl.add(index, entry);
-                }
-                view.setAcl(acl);
-                break;
-            }
-
-            // remove ACE
-            case REMOVE: {
-                if (index >= acl.size()) {
-                    System.err.format("Index '%d' is invalid", index);
-                    System.exit(-1);
-                }
-                acl.remove(index);
-                view.setAcl(acl);
-                break;
-            }
-
-            // replace ACE
-            case REPLACE: {
-                if (index >= acl.size()) {
-                    System.err.format("Index '%d' is invalid", index);
-                    System.exit(-1);
-                }
-                AclEntry entry = parseAceString(entryString, file
-                    .getFileSystem().getUserPrincipalLookupService());
-                acl.set(index, entry);
-                view.setAcl(acl);
-                break;
-            }
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/file/Chmod.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,349 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import static java.nio.file.attribute.PosixFilePermission.*;
-import static java.nio.file.FileVisitResult.*;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Sample code that changes the permissions of files in a similar manner to the
- * chmod(1) program.
- */
-
-public class Chmod {
-
-    /**
-     * Compiles a list of one or more <em>symbolic mode expressions</em> that
-     * may be used to change a set of file permissions. This method is
-     * intended for use where file permissions are required to be changed in
-     * a manner similar to the UNIX <i>chmod</i> program.
-     *
-     * <p> The {@code exprs} parameter is a comma separated list of expressions
-     * where each takes the form:
-     * <blockquote>
-     * <i>who operator</i> [<i>permissions</i>]
-     * </blockquote>
-     * where <i>who</i> is one or more of the characters {@code 'u'}, {@code 'g'},
-     * {@code 'o'}, or {@code 'a'} meaning the owner (user), group, others, or
-     * all (owner, group, and others) respectively.
-     *
-     * <p> <i>operator</i> is the character {@code '+'}, {@code '-'}, or {@code
-     * '='} signifying how permissions are to be changed. {@code '+'} means the
-     * permissions are added, {@code '-'} means the permissions are removed, and
-     * {@code '='} means the permissions are assigned absolutely.
-     *
-     * <p> <i>permissions</i> is a sequence of zero or more of the following:
-     * {@code 'r'} for read permission, {@code 'w'} for write permission, and
-     * {@code 'x'} for execute permission. If <i>permissions</i> is omitted
-     * when assigned absolutely, then the permissions are cleared for
-     * the owner, group, or others as identified by <i>who</i>. When omitted
-     * when adding or removing then the expression is ignored.
-     *
-     * <p> The following examples demonstrate possible values for the {@code
-     * exprs} parameter:
-     *
-     * <table border="0">
-     * <tr>
-     *   <td> {@code u=rw} </td>
-     *   <td> Sets the owner permissions to be read and write. </td>
-     * </tr>
-     * <tr>
-     *   <td> {@code ug+w} </td>
-     *   <td> Sets the owner write and group write permissions. </td>
-     * </tr>
-     * <tr>
-     *   <td> {@code u+w,o-rwx} </td>
-     *   <td> Sets the owner write, and removes the others read, others write
-     *     and others execute permissions. </td>
-     * </tr>
-     * <tr>
-     *   <td> {@code o=} </td>
-     *   <td> Sets the others permission to none (others read, others write and
-     *     others execute permissions are removed if set) </td>
-     * </tr>
-     * </table>
-     *
-     * @param   exprs
-     *          List of one or more <em>symbolic mode expressions</em>
-     *
-     * @return  A {@code Changer} that may be used to changer a set of
-     *          file permissions
-     *
-     * @throws  IllegalArgumentException
-     *          If the value of the {@code exprs} parameter is invalid
-     */
-    public static Changer compile(String exprs) {
-        // minimum is who and operator (u= for example)
-        if (exprs.length() < 2)
-            throw new IllegalArgumentException("Invalid mode");
-
-        // permissions that the changer will add or remove
-        final Set<PosixFilePermission> toAdd = new HashSet<PosixFilePermission>();
-        final Set<PosixFilePermission> toRemove = new HashSet<PosixFilePermission>();
-
-        // iterate over each of expression modes
-        for (String expr: exprs.split(",")) {
-            // minimum of who and operator
-            if (expr.length() < 2)
-                throw new IllegalArgumentException("Invalid mode");
-
-            int pos = 0;
-
-            // who
-            boolean u = false;
-            boolean g = false;
-            boolean o = false;
-            boolean done = false;
-            for (;;) {
-                switch (expr.charAt(pos)) {
-                    case 'u' : u = true; break;
-                    case 'g' : g = true; break;
-                    case 'o' : o = true; break;
-                    case 'a' : u = true; g = true; o = true; break;
-                    default : done = true;
-                }
-                if (done)
-                    break;
-                pos++;
-            }
-            if (!u && !g && !o)
-                throw new IllegalArgumentException("Invalid mode");
-
-            // get operator and permissions
-            char op = expr.charAt(pos++);
-            String mask = (expr.length() == pos) ? "" : expr.substring(pos);
-
-            // operator
-            boolean add = (op == '+');
-            boolean remove = (op == '-');
-            boolean assign = (op == '=');
-            if (!add && !remove && !assign)
-                throw new IllegalArgumentException("Invalid mode");
-
-            // who= means remove all
-            if (assign && mask.length() == 0) {
-                assign = false;
-                remove = true;
-                mask = "rwx";
-            }
-
-            // permissions
-            boolean r = false;
-            boolean w = false;
-            boolean x = false;
-            for (int i=0; i<mask.length(); i++) {
-                switch (mask.charAt(i)) {
-                    case 'r' : r = true; break;
-                    case 'w' : w = true; break;
-                    case 'x' : x = true; break;
-                    default:
-                        throw new IllegalArgumentException("Invalid mode");
-                }
-            }
-
-            // update permissions set
-            if (add) {
-                if (u) {
-                    if (r) toAdd.add(OWNER_READ);
-                    if (w) toAdd.add(OWNER_WRITE);
-                    if (x) toAdd.add(OWNER_EXECUTE);
-                }
-                if (g) {
-                    if (r) toAdd.add(GROUP_READ);
-                    if (w) toAdd.add(GROUP_WRITE);
-                    if (x) toAdd.add(GROUP_EXECUTE);
-                }
-                if (o) {
-                    if (r) toAdd.add(OTHERS_READ);
-                    if (w) toAdd.add(OTHERS_WRITE);
-                    if (x) toAdd.add(OTHERS_EXECUTE);
-                }
-            }
-            if (remove) {
-                if (u) {
-                    if (r) toRemove.add(OWNER_READ);
-                    if (w) toRemove.add(OWNER_WRITE);
-                    if (x) toRemove.add(OWNER_EXECUTE);
-                }
-                if (g) {
-                    if (r) toRemove.add(GROUP_READ);
-                    if (w) toRemove.add(GROUP_WRITE);
-                    if (x) toRemove.add(GROUP_EXECUTE);
-                }
-                if (o) {
-                    if (r) toRemove.add(OTHERS_READ);
-                    if (w) toRemove.add(OTHERS_WRITE);
-                    if (x) toRemove.add(OTHERS_EXECUTE);
-                }
-            }
-            if (assign) {
-                if (u) {
-                    if (r) toAdd.add(OWNER_READ);
-                      else toRemove.add(OWNER_READ);
-                    if (w) toAdd.add(OWNER_WRITE);
-                      else toRemove.add(OWNER_WRITE);
-                    if (x) toAdd.add(OWNER_EXECUTE);
-                      else toRemove.add(OWNER_EXECUTE);
-                }
-                if (g) {
-                    if (r) toAdd.add(GROUP_READ);
-                      else toRemove.add(GROUP_READ);
-                    if (w) toAdd.add(GROUP_WRITE);
-                      else toRemove.add(GROUP_WRITE);
-                    if (x) toAdd.add(GROUP_EXECUTE);
-                      else toRemove.add(GROUP_EXECUTE);
-                }
-                if (o) {
-                    if (r) toAdd.add(OTHERS_READ);
-                      else toRemove.add(OTHERS_READ);
-                    if (w) toAdd.add(OTHERS_WRITE);
-                      else toRemove.add(OTHERS_WRITE);
-                    if (x) toAdd.add(OTHERS_EXECUTE);
-                      else toRemove.add(OTHERS_EXECUTE);
-                }
-            }
-        }
-
-        // return changer
-        return new Changer() {
-            @Override
-            public Set<PosixFilePermission> change(Set<PosixFilePermission> perms) {
-                perms.addAll(toAdd);
-                perms.removeAll(toRemove);
-                return perms;
-            }
-        };
-    }
-
-    /**
-     * A task that <i>changes</i> a set of {@link PosixFilePermission} elements.
-     */
-    public interface Changer {
-        /**
-         * Applies the changes to the given set of permissions.
-         *
-         * @param   perms
-         *          The set of permissions to change
-         *
-         * @return  The {@code perms} parameter
-         */
-        Set<PosixFilePermission> change(Set<PosixFilePermission> perms);
-    }
-
-    /**
-     * Changes the permissions of the file using the given Changer.
-     */
-    static void chmod(Path file, Changer changer) {
-        try {
-            Set<PosixFilePermission> perms = Files.getPosixFilePermissions(file);
-            Files.setPosixFilePermissions(file, changer.change(perms));
-        } catch (IOException x) {
-            System.err.println(x);
-        }
-    }
-
-    /**
-     * Changes the permission of each file and directory visited
-     */
-    static class TreeVisitor implements FileVisitor<Path> {
-        private final Changer changer;
-
-        TreeVisitor(Changer changer) {
-            this.changer = changer;
-        }
-
-        @Override
-        public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
-            chmod(dir, changer);
-            return CONTINUE;
-        }
-
-        @Override
-        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
-            chmod(file, changer);
-            return CONTINUE;
-        }
-
-        @Override
-        public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
-            if (exc != null)
-                System.err.println("WARNING: " + exc);
-            return CONTINUE;
-        }
-
-        @Override
-        public FileVisitResult visitFileFailed(Path file, IOException exc) {
-            System.err.println("WARNING: " + exc);
-            return CONTINUE;
-        }
-    }
-
-    static void usage() {
-        System.err.println("java Chmod [-R] symbolic-mode-list file...");
-        System.exit(-1);
-    }
-
-    public static void main(String[] args) throws IOException {
-        if (args.length < 2)
-            usage();
-        int argi = 0;
-        int maxDepth = 0;
-        if (args[argi].equals("-R")) {
-            if (args.length < 3)
-                usage();
-            argi++;
-            maxDepth = Integer.MAX_VALUE;
-        }
-
-        // compile the symbolic mode expressions
-        Changer changer = compile(args[argi++]);
-        TreeVisitor visitor = new TreeVisitor(changer);
-
-        Set<FileVisitOption> opts = Collections.emptySet();
-        while (argi < args.length) {
-            Path file = Paths.get(args[argi]);
-            Files.walkFileTree(file, opts, maxDepth, visitor);
-            argi++;
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/file/Copy.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.file.*;
-import static java.nio.file.StandardCopyOption.*;
-import java.nio.file.attribute.*;
-import static java.nio.file.FileVisitResult.*;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Sample code that copies files in a similar manner to the cp(1) program.
- */
-
-public class Copy {
-
-    /**
-     * Returns {@code true} if okay to overwrite a  file ("cp -i")
-     */
-    static boolean okayToOverwrite(Path file) {
-        String answer = System.console().readLine("overwrite %s (yes/no)? ", file);
-        return (answer.equalsIgnoreCase("y") || answer.equalsIgnoreCase("yes"));
-    }
-
-    /**
-     * Copy source file to target location. If {@code prompt} is true then
-     * prompt user to overwrite target if it exists. The {@code preserve}
-     * parameter determines if file attributes should be copied/preserved.
-     */
-    static void copyFile(Path source, Path target, boolean prompt, boolean preserve) {
-        CopyOption[] options = (preserve) ?
-            new CopyOption[] { COPY_ATTRIBUTES, REPLACE_EXISTING } :
-            new CopyOption[] { REPLACE_EXISTING };
-        if (!prompt || Files.notExists(target) || okayToOverwrite(target)) {
-            try {
-                Files.copy(source, target, options);
-            } catch (IOException x) {
-                System.err.format("Unable to copy: %s: %s%n", source, x);
-            }
-        }
-    }
-
-    /**
-     * A {@code FileVisitor} that copies a file-tree ("cp -r")
-     */
-    static class TreeCopier implements FileVisitor<Path> {
-        private final Path source;
-        private final Path target;
-        private final boolean prompt;
-        private final boolean preserve;
-
-        TreeCopier(Path source, Path target, boolean prompt, boolean preserve) {
-            this.source = source;
-            this.target = target;
-            this.prompt = prompt;
-            this.preserve = preserve;
-        }
-
-        @Override
-        public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
-            // before visiting entries in a directory we copy the directory
-            // (okay if directory already exists).
-            CopyOption[] options = (preserve) ?
-                new CopyOption[] { COPY_ATTRIBUTES } : new CopyOption[0];
-
-            Path newdir = target.resolve(source.relativize(dir));
-            try {
-                Files.copy(dir, newdir, options);
-            } catch (FileAlreadyExistsException x) {
-                // ignore
-            } catch (IOException x) {
-                System.err.format("Unable to create: %s: %s%n", newdir, x);
-                return SKIP_SUBTREE;
-            }
-            return CONTINUE;
-        }
-
-        @Override
-        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
-            copyFile(file, target.resolve(source.relativize(file)),
-                     prompt, preserve);
-            return CONTINUE;
-        }
-
-        @Override
-        public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
-            // fix up modification time of directory when done
-            if (exc == null && preserve) {
-                Path newdir = target.resolve(source.relativize(dir));
-                try {
-                    FileTime time = Files.getLastModifiedTime(dir);
-                    Files.setLastModifiedTime(newdir, time);
-                } catch (IOException x) {
-                    System.err.format("Unable to copy all attributes to: %s: %s%n", newdir, x);
-                }
-            }
-            return CONTINUE;
-        }
-
-        @Override
-        public FileVisitResult visitFileFailed(Path file, IOException exc) {
-            if (exc instanceof FileSystemLoopException) {
-                System.err.println("cycle detected: " + file);
-            } else {
-                System.err.format("Unable to copy: %s: %s%n", file, exc);
-            }
-            return CONTINUE;
-        }
-    }
-
-    static void usage() {
-        System.err.println("java Copy [-ip] source... target");
-        System.err.println("java Copy -r [-ip] source-dir... target");
-        System.exit(-1);
-    }
-
-    public static void main(String[] args) throws IOException {
-        boolean recursive = false;
-        boolean prompt = false;
-        boolean preserve = false;
-
-        // process options
-        int argi = 0;
-        while (argi < args.length) {
-            String arg = args[argi];
-            if (!arg.startsWith("-"))
-                break;
-            if (arg.length() < 2)
-                usage();
-            for (int i=1; i<arg.length(); i++) {
-                char c = arg.charAt(i);
-                switch (c) {
-                    case 'r' : recursive = true; break;
-                    case 'i' : prompt = true; break;
-                    case 'p' : preserve = true; break;
-                    default : usage();
-                }
-            }
-            argi++;
-        }
-
-        // remaining arguments are the source files(s) and the target location
-        int remaining = args.length - argi;
-        if (remaining < 2)
-            usage();
-        Path[] source = new Path[remaining-1];
-        int i=0;
-        while (remaining > 1) {
-            source[i++] = Paths.get(args[argi++]);
-            remaining--;
-        }
-        Path target = Paths.get(args[argi]);
-
-        // check if target is a directory
-        boolean isDir = Files.isDirectory(target);
-
-        // copy each source file/directory to target
-        for (i=0; i<source.length; i++) {
-            Path dest = (isDir) ? target.resolve(source[i].getFileName()) : target;
-
-            if (recursive) {
-                // follow links when copying files
-                EnumSet<FileVisitOption> opts = EnumSet.of(FileVisitOption.FOLLOW_LINKS);
-                TreeCopier tc = new TreeCopier(source[i], dest, prompt, preserve);
-                Files.walkFileTree(source[i], opts, Integer.MAX_VALUE, tc);
-            } else {
-                // not recursive so source must not be a directory
-                if (Files.isDirectory(source[i])) {
-                    System.err.format("%s: is a directory%n", source[i]);
-                    continue;
-                }
-                copyFile(source[i], dest, prompt, preserve);
-            }
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/file/DiskUsage.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-
-/**
- * Example utility that works like the df(1M) program to print out disk space
- * information
- */
-
-public class DiskUsage {
-
-    static final long K = 1024;
-
-    static void printFileStore(FileStore store) throws IOException {
-        long total = store.getTotalSpace() / K;
-        long used = (store.getTotalSpace() - store.getUnallocatedSpace()) / K;
-        long avail = store.getUsableSpace() / K;
-
-        String s = store.toString();
-        if (s.length() > 20) {
-            System.out.println(s);
-            s = "";
-        }
-        System.out.format("%-20s %12d %12d %12d\n", s, total, used, avail);
-    }
-
-    public static void main(String[] args) throws IOException {
-        System.out.format("%-20s %12s %12s %12s\n", "Filesystem", "kbytes", "used", "avail");
-        if (args.length == 0) {
-            FileSystem fs = FileSystems.getDefault();
-            for (FileStore store: fs.getFileStores()) {
-                printFileStore(store);
-            }
-        } else {
-            for (String file: args) {
-                FileStore store = Files.getFileStore(Paths.get(file));
-                printFileStore(store);
-            }
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/file/FileType.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.file.*;
-import java.io.IOException;
-
-public class FileType {
-    public static void main(String[] args) throws IOException {
-        if (args.length == 0) {
-            System.err.println("usage: java FileType file...");
-            System.exit(-1);
-        }
-        for (String arg: args) {
-            Path file = Paths.get(arg);
-            String type;
-            if (Files.isDirectory(file)) {
-                type = "directory";
-            } else {
-                type = Files.probeContentType(file);
-                if (type == null)
-                    type = "<not recognized>";
-            }
-            System.out.format("%s\t%s%n", file, type);
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/file/WatchDir.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.file.*;
-import static java.nio.file.StandardWatchEventKinds.*;
-import static java.nio.file.LinkOption.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-
-/**
- * Example to watch a directory (or tree) for changes to files.
- */
-
-public class WatchDir {
-
-    private final WatchService watcher;
-    private final boolean recursive;
-    private boolean trace = false;
-    private int count;
-
-    @SuppressWarnings("unchecked")
-    static <T> WatchEvent<T> cast(WatchEvent<?> event) {
-        return (WatchEvent<T>)event;
-    }
-
-    /**
-     * Register the given directory with the WatchService
-     */
-    private void register(Path dir) throws IOException {
-        WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
-        count++;
-        if (trace)
-            System.out.format("register: %s\n", dir);
-    }
-
-    /**
-     * Register the given directory, and all its sub-directories, with the
-     * WatchService.
-     */
-    private void registerAll(final Path start) throws IOException {
-        // register directory and sub-directories
-        Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
-            @Override
-            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
-                throws IOException
-            {
-                register(dir);
-                return FileVisitResult.CONTINUE;
-            }
-        });
-    }
-
-    /**
-     * Creates a WatchService and registers the given directory
-     */
-    WatchDir(Path dir, boolean recursive) throws IOException {
-        this.watcher = FileSystems.getDefault().newWatchService();
-        this.recursive = recursive;
-
-        if (recursive) {
-            System.out.format("Scanning %s ...\n", dir);
-            registerAll(dir);
-            System.out.println("Done.");
-        } else {
-            register(dir);
-        }
-
-        // enable trace after initial registration
-        this.trace = true;
-    }
-
-    /**
-     * Process all events for keys queued to the watcher
-     */
-    void processEvents() {
-        for (;;) {
-
-            // wait for key to be signalled
-            WatchKey key;
-            try {
-                key = watcher.take();
-            } catch (InterruptedException x) {
-                return;
-            }
-
-            for (WatchEvent<?> event: key.pollEvents()) {
-                WatchEvent.Kind kind = event.kind();
-
-                // TBD - provide example of how OVERFLOW event is handled
-                if (kind == OVERFLOW) {
-                    continue;
-                }
-
-                // Context for directory entry event is the file name of entry
-                WatchEvent<Path> ev = cast(event);
-                Path name = ev.context();
-                Path child = ((Path)key.watchable()).resolve(name);
-
-                // print out event
-                System.out.format("%s: %s\n", event.kind().name(), child);
-
-                // if directory is created, and watching recursively, then
-                // register it and its sub-directories
-                if (recursive && (kind == ENTRY_CREATE)) {
-                    try {
-                        if (Files.isDirectory(child, NOFOLLOW_LINKS)) {
-                            registerAll(child);
-                        }
-                    } catch (IOException x) {
-                        // ignore to keep sample readbale
-                    }
-                }
-            }
-
-            // reset key
-            boolean valid = key.reset();
-            if (!valid) {
-                // directory no longer accessible
-                count--;
-                if (count == 0)
-                    break;
-            }
-        }
-    }
-
-    static void usage() {
-        System.err.println("usage: java WatchDir [-r] dir");
-        System.exit(-1);
-    }
-
-    public static void main(String[] args) throws IOException {
-        // parse arguments
-        if (args.length == 0 || args.length > 2)
-            usage();
-        boolean recursive = false;
-        int dirArg = 0;
-        if (args[0].equals("-r")) {
-            if (args.length < 2)
-                usage();
-            recursive = true;
-            dirArg++;
-        }
-
-        // register directory and process its events
-        Path dir = Paths.get(args[dirArg]);
-        new WatchDir(dir, recursive).processEvents();
-    }
-}
--- a/jdk/src/sample/share/nio/file/Xdd.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-
-/**
- * Example code to list/set/get/delete the user-defined attributes of a file.
- */
-
-public class Xdd {
-
-    static void usage() {
-        System.out.println("Usage: java Xdd <file>");
-        System.out.println("       java Xdd -set <name>=<value> <file>");
-        System.out.println("       java Xdd -get <name> <file>");
-        System.out.println("       java Xdd -del <name> <file>");
-        System.exit(-1);
-    }
-
-    public static void main(String[] args) throws IOException {
-        // one or three parameters
-        if (args.length != 1 && args.length != 3)
-            usage();
-
-        Path file = (args.length == 1) ?
-            Paths.get(args[0]) : Paths.get(args[2]);
-
-        // check that user defined attributes are supported by the file store
-        FileStore store = Files.getFileStore(file);
-        if (!store.supportsFileAttributeView(UserDefinedFileAttributeView.class)) {
-            System.err.format("UserDefinedFileAttributeView not supported on %s\n", store);
-            System.exit(-1);
-
-        }
-        UserDefinedFileAttributeView view =
-            Files.getFileAttributeView(file, UserDefinedFileAttributeView.class);
-
-        // list user defined attributes
-        if (args.length == 1) {
-            System.out.println("    Size  Name");
-            System.out.println("--------  --------------------------------------");
-            for (String name: view.list()) {
-                System.out.format("%8d  %s\n", view.size(name), name);
-            }
-            return;
-        }
-
-        // Add/replace a file's user defined attribute
-        if (args[0].equals("-set")) {
-            // name=value
-            String[] s = args[1].split("=");
-            if (s.length != 2)
-                usage();
-            String name = s[0];
-            String value = s[1];
-            view.write(name, Charset.defaultCharset().encode(value));
-            return;
-        }
-
-        // Print out the value of a file's user defined attribute
-        if (args[0].equals("-get")) {
-            String name = args[1];
-            int size = view.size(name);
-            ByteBuffer buf = ByteBuffer.allocateDirect(size);
-            view.read(name, buf);
-            buf.flip();
-            System.out.println(Charset.defaultCharset().decode(buf).toString());
-            return;
-        }
-
-        // Delete a file's user defined attribute
-        if (args[0].equals("-del")) {
-            view.delete(args[1]);
-            return;
-        }
-
-        // option not recognized
-        usage();
-    }
- }
--- a/jdk/src/sample/share/nio/multicast/MulticastAddress.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.net.SocketException;
-
-/**
- * Parses and represents a multicast address.
- */
-
-class MulticastAddress {
-    private final InetAddress group;
-    private final int port;
-    private final NetworkInterface interf;
-
-    private MulticastAddress(InetAddress group, int port, NetworkInterface interf) {
-        this.group = group;
-        this.port = port;
-        this.interf = interf;
-    }
-
-    InetAddress group() {
-        return group;
-    }
-
-    int port() {
-        return port;
-    }
-
-    /**
-     * @return  The network interface, may be {@code null}
-     */
-    NetworkInterface interf() {
-        return interf;
-    }
-
-    /**
-     * Parses a string of the form "group:port[@interface]", returning
-     * a MulticastAddress representing the address
-     */
-    static MulticastAddress parse(String s) {
-        String[] components = s.split("@");
-        if (components.length > 2)
-            throw new IllegalArgumentException("At most one '@' expected");
-
-        // get group and port
-        String target = components[0];
-        int len = components[0].length();
-        int colon = components[0].lastIndexOf(':');
-        if ((colon < 1) || (colon > (len-2)))
-            throw new IllegalArgumentException("group:port expected");
-        String groupString = target.substring(0, colon);
-        int port = -1;
-        try {
-            port = Integer.parseInt(target.substring(colon+1, len));
-        } catch (NumberFormatException x) {
-             throw new IllegalArgumentException(x);
-        }
-
-        // handle IPv6 literal address
-        if (groupString.charAt(0) == '[') {
-            len = groupString.length();
-            if (groupString.charAt(len-1) != ']')
-                throw new IllegalArgumentException("missing ']'");
-            groupString = groupString.substring(1,len-1);
-            if (groupString.length() == 0)
-                throw new IllegalArgumentException("missing IPv6 address");
-        }
-
-        // get group address
-        InetAddress group = null;
-        try {
-            group = InetAddress.getByName(groupString);
-        } catch (UnknownHostException x) {
-            throw new IllegalArgumentException(x);
-        }
-        if (!group.isMulticastAddress()) {
-            throw new IllegalArgumentException("'" + group.getHostAddress() +
-                "' is not multicast address");
-        }
-
-        // optional interface
-        NetworkInterface interf = null;
-        if (components.length == 2) {
-            try {
-                interf = NetworkInterface.getByName(components[1]);
-            } catch (SocketException x) {
-                throw new IllegalArgumentException(x);
-            }
-            if (interf == null) {
-                throw new IllegalArgumentException("'" + components[1] +
-                   "' is not valid interface");
-            }
-        }
-        return new MulticastAddress(group, port, interf);
-    }
-}
--- a/jdk/src/sample/share/nio/multicast/Reader.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.channels.*;
-import java.nio.charset.*;
-import java.nio.ByteBuffer;
-import java.net.*;
-import java.io.IOException;
-import java.util.*;
-
-public class Reader {
-
-    static void usage() {
-        System.err.println("usage: java Reader group:port@interf [-only source...] [-block source...]");
-        System.exit(-1);
-    }
-
-    static void printDatagram(SocketAddress sa, ByteBuffer buf) {
-        System.out.format("-- datagram from %s --\n",
-            ((InetSocketAddress)sa).getAddress().getHostAddress());
-        System.out.println(Charset.defaultCharset().decode(buf));
-    }
-
-    static void parseAddessList(String s, List<InetAddress> list)
-        throws UnknownHostException
-    {
-        String[] sources = s.split(",");
-        for (int i=0; i<sources.length; i++) {
-            list.add(InetAddress.getByName(sources[i]));
-        }
-    }
-
-    public static void main(String[] args) throws IOException {
-        if (args.length == 0)
-            usage();
-
-        // first parameter is the multicast address (interface required)
-        MulticastAddress target = MulticastAddress.parse(args[0]);
-        if (target.interf() == null)
-            usage();
-
-        // addition arguments are source addresses to include or exclude
-        List<InetAddress> includeList = new ArrayList<InetAddress>();
-        List<InetAddress> excludeList = new ArrayList<InetAddress>();
-        int argc = 1;
-        while (argc < args.length) {
-            String option = args[argc++];
-            if (argc >= args.length)
-                usage();
-            String value = args[argc++];
-            if (option.equals("-only")) {
-                 parseAddessList(value, includeList);
-                continue;
-            }
-            if (option.equals("-block")) {
-                parseAddessList(value, excludeList);
-                continue;
-            }
-            usage();
-        }
-        if (!includeList.isEmpty() && !excludeList.isEmpty()) {
-            usage();
-        }
-
-        // create and bind socket
-        ProtocolFamily family = StandardProtocolFamily.INET;
-        if (target.group() instanceof Inet6Address) {
-            family = StandardProtocolFamily.INET6;
-        }
-        DatagramChannel dc = DatagramChannel.open(family)
-            .setOption(StandardSocketOptions.SO_REUSEADDR, true)
-            .bind(new InetSocketAddress(target.port()));
-
-        if (includeList.isEmpty()) {
-            // join group and block addresses on the exclude list
-            MembershipKey key = dc.join(target.group(), target.interf());
-            for (InetAddress source: excludeList) {
-                key.block(source);
-            }
-        } else {
-            // join with source-specific membership for each source
-            for (InetAddress source: includeList) {
-                dc.join(target.group(), target.interf(), source);
-            }
-        }
-
-        // register socket with Selector
-        Selector sel = Selector.open();
-        dc.configureBlocking(false);
-        dc.register(sel, SelectionKey.OP_READ);
-
-        // print out each datagram that we receive
-        ByteBuffer buf = ByteBuffer.allocateDirect(4096);
-        for (;;) {
-            int updated = sel.select();
-            if (updated > 0) {
-                Iterator<SelectionKey> iter = sel.selectedKeys().iterator();
-                while (iter.hasNext()) {
-                    SelectionKey sk = iter.next();
-                    iter.remove();
-
-                    DatagramChannel ch = (DatagramChannel)sk.channel();
-                    SocketAddress sa = ch.receive(buf);
-                    if (sa != null) {
-                        buf.flip();
-                        printDatagram(sa, buf);
-                        buf.rewind();
-                        buf.limit(buf.capacity());
-                    }
-                }
-            }
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/multicast/Sender.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.channels.*;
-import java.nio.charset.Charset;
-import java.net.*;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Sample multicast sender to send a message in a multicast datagram
- * to a given group.
- */
-
-public class Sender {
-
-    private static void usage() {
-        System.err.println("usage: java Sender group:port[@interface] message");
-        System.exit(-1);
-    }
-
-    public static void main(String[] args) throws IOException {
-        if (args.length < 2)
-            usage();
-
-        MulticastAddress target = MulticastAddress.parse(args[0]);
-
-        // create socket
-        ProtocolFamily family = StandardProtocolFamily.INET;
-        if (target.group() instanceof Inet6Address)
-            family = StandardProtocolFamily.INET6;
-        DatagramChannel dc = DatagramChannel.open(family).bind(new InetSocketAddress(0));
-        if (target.interf() != null) {
-            dc.setOption(StandardSocketOptions.IP_MULTICAST_IF, target.interf());
-        }
-
-        // send multicast packet
-        dc.send(Charset.defaultCharset().encode(args[1]),
-                new InetSocketAddress(target.group(), target.port()));
-        dc.close();
-    }
-
-}
--- a/jdk/src/sample/share/nio/server/AcceptHandler.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.channels.*;
-import javax.net.ssl.*;
-
-/**
- * A single threaded Handler that performs accepts SocketChannels and
- * registers the Channels with the read/write Selector.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class AcceptHandler implements Handler {
-
-    private ServerSocketChannel channel;
-    private Dispatcher dsp;
-
-    private SSLContext sslContext;
-
-    AcceptHandler(ServerSocketChannel ssc, Dispatcher dsp,
-            SSLContext sslContext) {
-        channel = ssc;
-        this.dsp = dsp;
-        this.sslContext = sslContext;
-    }
-
-    public void handle(SelectionKey sk) throws IOException {
-
-        if (!sk.isAcceptable())
-            return;
-
-        SocketChannel sc = channel.accept();
-        if (sc == null) {
-            return;
-        }
-
-        ChannelIO cio = (sslContext != null ?
-            ChannelIOSecure.getInstance(
-                sc, false /* non-blocking */, sslContext) :
-            ChannelIO.getInstance(
-                sc, false /* non-blocking */));
-
-        RequestHandler rh = new RequestHandler(cio);
-        dsp.register(cio.getSocketChannel(), SelectionKey.OP_READ, rh);
-    }
-}
--- a/jdk/src/sample/share/nio/server/Acceptor.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.channels.*;
-import javax.net.ssl.*;
-
-/**
- * A Runnable class which sits in a loop accepting SocketChannels,
- * then registers the Channels with the read/write Selector.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class Acceptor implements Runnable {
-
-    private ServerSocketChannel ssc;
-    private Dispatcher d;
-
-    private SSLContext sslContext;
-
-    Acceptor(ServerSocketChannel ssc, Dispatcher d, SSLContext sslContext) {
-        this.ssc = ssc;
-        this.d = d;
-        this.sslContext = sslContext;
-    }
-
-    public void run() {
-        for (;;) {
-            try {
-                SocketChannel sc = ssc.accept();
-
-                ChannelIO cio = (sslContext != null ?
-                    ChannelIOSecure.getInstance(
-                        sc, false /* non-blocking */, sslContext) :
-                    ChannelIO.getInstance(
-                        sc, false /* non-blocking */));
-
-                RequestHandler rh = new RequestHandler(cio);
-
-                d.register(cio.getSocketChannel(), SelectionKey.OP_READ, rh);
-
-            } catch (IOException x) {
-                x.printStackTrace();
-                break;
-            }
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/server/B1.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.channels.*;
-
-/**
- * A blocking/single-threaded server which completely services
- * each connection before moving to the next.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-public class B1 extends Server {
-
-    B1(int port, int backlog, boolean secure) throws Exception {
-        super(port, backlog, secure);
-    }
-
-    void runServer() throws Exception {
-        for (;;) {
-
-            SocketChannel sc = ssc.accept();
-
-            ChannelIO cio = (sslContext != null ?
-                ChannelIOSecure.getInstance(
-                    sc, true /* blocking */, sslContext) :
-                ChannelIO.getInstance(
-                    sc, true /* blocking */));
-
-            RequestServicer svc = new RequestServicer(cio);
-            svc.run();
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/server/BN.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.channels.*;
-
-/**
- * A Blocking/Multi-threaded Server which creates a new thread for each
- * connection.  This is not efficient for large numbers of connections.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-public class BN extends Server {
-
-    BN(int port, int backlog, boolean secure) throws Exception {
-        super(port, backlog, secure);
-    }
-
-    void runServer() throws IOException {
-        for (;;) {
-
-            SocketChannel sc = ssc.accept();
-
-            ChannelIO cio = (sslContext != null ?
-                ChannelIOSecure.getInstance(
-                    sc, true /* blocking */, sslContext) :
-                ChannelIO.getInstance(
-                    sc, true /* blocking */));
-
-            RequestServicer svc = new RequestServicer(cio);
-            Thread th = new Thread(svc);
-            th.start();
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/server/BP.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.channels.*;
-import java.util.concurrent.*;
-
-/**
- * A multi-threaded server which creates a pool of threads for use
- * by the server.  The Thread pool decides how to schedule those threads.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-public class BP extends Server {
-
-    private static final int POOL_MULTIPLE = 4;
-
-    BP(int port, int backlog, boolean secure) throws Exception {
-        super(port, backlog, secure);
-    }
-
-    void runServer() throws Exception {
-
-        ExecutorService xec = Executors.newFixedThreadPool(
-            Runtime.getRuntime().availableProcessors() * POOL_MULTIPLE);
-
-        for (;;) {
-
-            SocketChannel sc = ssc.accept();
-
-            ChannelIO cio = (sslContext != null ?
-                ChannelIOSecure.getInstance(
-                    sc, true /* blocking */, sslContext) :
-                ChannelIO.getInstance(
-                    sc, true /* blocking */));
-
-            RequestServicer svc = new RequestServicer(cio);
-            xec.execute(svc);
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/server/ChannelIO.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
-
-/**
- * A helper class for properly sizing inbound byte buffers and
- * redirecting I/O calls to the proper SocketChannel call.
- * <P>
- * Many of these calls may seem unnecessary until you consider
- * that they are placeholders for the secure variant, which is much
- * more involved.  See ChannelIOSecure for more information.
- *
- * @author Brad R. Wetmore
- * @author Mark Reinhold
- */
-class ChannelIO {
-
-    protected SocketChannel sc;
-
-    /*
-     * All of the inbound request data lives here until we determine
-     * that we've read everything, then we pass that data back to the
-     * caller.
-     */
-    protected ByteBuffer requestBB;
-    static private int requestBBSize = 4096;
-
-    protected ChannelIO(SocketChannel sc, boolean blocking)
-            throws IOException {
-        this.sc = sc;
-        sc.configureBlocking(blocking);
-    }
-
-    static ChannelIO getInstance(SocketChannel sc, boolean blocking)
-            throws IOException {
-        ChannelIO cio = new ChannelIO(sc, blocking);
-        cio.requestBB = ByteBuffer.allocate(requestBBSize);
-
-        return cio;
-    }
-
-    SocketChannel getSocketChannel() {
-        return sc;
-    }
-
-    /*
-     * Return a ByteBuffer with "remaining" space to work.  If you have to
-     * reallocate the ByteBuffer, copy the existing info into the new buffer.
-     */
-    protected void resizeRequestBB(int remaining) {
-        if (requestBB.remaining() < remaining) {
-            // Expand buffer for large request
-            ByteBuffer bb = ByteBuffer.allocate(requestBB.capacity() * 2);
-            requestBB.flip();
-            bb.put(requestBB);
-            requestBB = bb;
-        }
-    }
-
-    /*
-     * Perform any handshaking processing.
-     * <P>
-     * This variant is for Servers without SelectionKeys (e.g.
-     * blocking).
-     * <P>
-     * return true when we're done with handshaking.
-     */
-    boolean doHandshake() throws IOException {
-        return true;
-    }
-
-    /*
-     * Perform any handshaking processing.
-     * <P>
-     * This variant is for Servers with SelectionKeys, so that
-     * we can register for selectable operations (e.g. selectable
-     * non-blocking).
-     * <P>
-     * return true when we're done with handshaking.
-     */
-    boolean doHandshake(SelectionKey sk) throws IOException {
-        return true;
-    }
-
-    /*
-     * Resize (if necessary) the inbound data buffer, and then read more
-     * data into the read buffer.
-     */
-    int read() throws IOException {
-        /*
-         * Allocate more space if less than 5% remains
-         */
-        resizeRequestBB(requestBBSize/20);
-        return sc.read(requestBB);
-    }
-
-    /*
-     * All data has been read, pass back the request in one buffer.
-     */
-    ByteBuffer getReadBuf() {
-        return requestBB;
-    }
-
-    /*
-     * Write the src buffer into the socket channel.
-     */
-    int write(ByteBuffer src) throws IOException {
-        return sc.write(src);
-    }
-
-    /*
-     * Perform a FileChannel.TransferTo on the socket channel.
-     */
-    long transferTo(FileChannel fc, long pos, long len) throws IOException {
-        return fc.transferTo(pos, len, sc);
-    }
-
-    /*
-     * Flush any outstanding data to the network if possible.
-     * <P>
-     * This isn't really necessary for the insecure variant, but needed
-     * for the secure one where intermediate buffering must take place.
-     * <P>
-     * Return true if successful.
-     */
-    boolean dataFlush() throws IOException {
-        return true;
-    }
-
-    /*
-     * Start any connection shutdown processing.
-     * <P>
-     * This isn't really necessary for the insecure variant, but needed
-     * for the secure one where intermediate buffering must take place.
-     * <P>
-     * Return true if successful, and the data has been flushed.
-     */
-    boolean shutdown() throws IOException {
-        return true;
-    }
-
-    /*
-     * Close the underlying connection.
-     */
-    void close() throws IOException {
-        sc.close();
-    }
-
-}
--- a/jdk/src/sample/share/nio/server/ChannelIOSecure.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,650 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
-import javax.net.ssl.*;
-import javax.net.ssl.SSLEngineResult.*;
-
-/**
- * A helper class which performs I/O using the SSLEngine API.
- * <P>
- * Each connection has a SocketChannel and a SSLEngine that is
- * used through the lifetime of the Channel.  We allocate byte buffers
- * for use as the outbound and inbound network buffers.
- *
- * <PRE>
- *               Application Data
- *               src      requestBB
- *                |           ^
- *                |     |     |
- *                v     |     |
- *           +----+-----|-----+----+
- *           |          |          |
- *           |       SSL|Engine    |
- *   wrap()  |          |          |  unwrap()
- *           | OUTBOUND | INBOUND  |
- *           |          |          |
- *           +----+-----|-----+----+
- *                |     |     ^
- *                |     |     |
- *                v           |
- *            outNetBB     inNetBB
- *                   Net data
- * </PRE>
- *
- * These buffers handle all of the intermediary data for the SSL
- * connection.  To make things easy, we'll require outNetBB be
- * completely flushed before trying to wrap any more data, but we
- * could certainly remove that restriction by using larger buffers.
- * <P>
- * There are many, many ways to handle compute and I/O strategies.
- * What follows is a relatively simple one.  The reader is encouraged
- * to develop the strategy that best fits the application.
- * <P>
- * In most of the non-blocking operations in this class, we let the
- * Selector tell us when we're ready to attempt an I/O operation (by the
- * application repeatedly calling our methods).  Another option would be
- * to attempt the operation and return from the method when no forward
- * progress can be made.
- * <P>
- * There's lots of room for enhancements and improvement in this example.
- * <P>
- * We're checking for SSL/TLS end-of-stream truncation attacks via
- * sslEngine.closeInbound().  When you reach the end of a input stream
- * via a read() returning -1 or an IOException, we call
- * sslEngine.closeInbound() to signal to the sslEngine that no more
- * input will be available.  If the peer's close_notify message has not
- * yet been received, this could indicate a trucation attack, in which
- * an attacker is trying to prematurely close the connection.   The
- * closeInbound() will throw an exception if this condition were
- * present.
- *
- * @author Brad R. Wetmore
- * @author Mark Reinhold
- */
-class ChannelIOSecure extends ChannelIO {
-
-    private SSLEngine sslEngine = null;
-
-    private int appBBSize;
-    private int netBBSize;
-
-    /*
-     * All I/O goes through these buffers.
-     * <P>
-     * It might be nice to use a cache of ByteBuffers so we're
-     * not alloc/dealloc'ing ByteBuffer's for each new SSLEngine.
-     * <P>
-     * We use our superclass' requestBB for our application input buffer.
-     * Outbound application data is supplied to us by our callers.
-     */
-    private ByteBuffer inNetBB;
-    private ByteBuffer outNetBB;
-
-    /*
-     * An empty ByteBuffer for use when one isn't available, say
-     * as a source buffer during initial handshake wraps or for close
-     * operations.
-     */
-    private static ByteBuffer hsBB = ByteBuffer.allocate(0);
-
-    /*
-     * The FileChannel we're currently transferTo'ing (reading).
-     */
-    private ByteBuffer fileChannelBB = null;
-
-    /*
-     * During our initial handshake, keep track of the next
-     * SSLEngine operation that needs to occur:
-     *
-     *     NEED_WRAP/NEED_UNWRAP
-     *
-     * Once the initial handshake has completed, we can short circuit
-     * handshake checks with initialHSComplete.
-     */
-    private HandshakeStatus initialHSStatus;
-    private boolean initialHSComplete;
-
-    /*
-     * We have received the shutdown request by our caller, and have
-     * closed our outbound side.
-     */
-    private boolean shutdown = false;
-
-    /*
-     * Constructor for a secure ChannelIO variant.
-     */
-    protected ChannelIOSecure(SocketChannel sc, boolean blocking,
-            SSLContext sslc) throws IOException {
-        super(sc, blocking);
-
-        /*
-         * We're a server, so no need to use host/port variant.
-         *
-         * The first call for a server is a NEED_UNWRAP.
-         */
-        sslEngine = sslc.createSSLEngine();
-        sslEngine.setUseClientMode(false);
-        initialHSStatus = HandshakeStatus.NEED_UNWRAP;
-        initialHSComplete = false;
-
-        // Create a buffer using the normal expected packet size we'll
-        // be getting.  This may change, depending on the peer's
-        // SSL implementation.
-        netBBSize = sslEngine.getSession().getPacketBufferSize();
-        inNetBB = ByteBuffer.allocate(netBBSize);
-        outNetBB = ByteBuffer.allocate(netBBSize);
-        outNetBB.position(0);
-        outNetBB.limit(0);
-    }
-
-    /*
-     * Static factory method for creating a secure ChannelIO object.
-     * <P>
-     * We need to allocate different sized application data buffers
-     * based on whether we're secure or not.  We can't determine
-     * this until our sslEngine is created.
-     */
-    static ChannelIOSecure getInstance(SocketChannel sc, boolean blocking,
-            SSLContext sslc) throws IOException {
-
-        ChannelIOSecure cio = new ChannelIOSecure(sc, blocking, sslc);
-
-        // Create a buffer using the normal expected application size we'll
-        // be getting.  This may change, depending on the peer's
-        // SSL implementation.
-        cio.appBBSize = cio.sslEngine.getSession().getApplicationBufferSize();
-        cio.requestBB = ByteBuffer.allocate(cio.appBBSize);
-
-        return cio;
-    }
-
-    /*
-     * Calls up to the superclass to adjust the buffer size
-     * by an appropriate increment.
-     */
-    protected void resizeRequestBB() {
-        resizeRequestBB(appBBSize);
-    }
-
-    /*
-     * Adjust the inbount network buffer to an appropriate size.
-     */
-    private void resizeResponseBB() {
-        ByteBuffer bb = ByteBuffer.allocate(netBBSize);
-        inNetBB.flip();
-        bb.put(inNetBB);
-        inNetBB = bb;
-    }
-
-    /*
-     * Writes bb to the SocketChannel.
-     * <P>
-     * Returns true when the ByteBuffer has no remaining data.
-     */
-    private boolean tryFlush(ByteBuffer bb) throws IOException {
-        super.write(bb);
-        return !bb.hasRemaining();
-    }
-
-    /*
-     * Perform any handshaking processing.
-     * <P>
-     * This variant is for Servers without SelectionKeys (e.g.
-     * blocking).
-     */
-    boolean doHandshake() throws IOException {
-        return doHandshake(null);
-    }
-
-    /*
-     * Perform any handshaking processing.
-     * <P>
-     * If a SelectionKey is passed, register for selectable
-     * operations.
-     * <P>
-     * In the blocking case, our caller will keep calling us until
-     * we finish the handshake.  Our reads/writes will block as expected.
-     * <P>
-     * In the non-blocking case, we just received the selection notification
-     * that this channel is ready for whatever the operation is, so give
-     * it a try.
-     * <P>
-     * return:
-     *          true when handshake is done.
-     *          false while handshake is in progress
-     */
-    boolean doHandshake(SelectionKey sk) throws IOException {
-
-        SSLEngineResult result;
-
-        if (initialHSComplete) {
-            return initialHSComplete;
-        }
-
-        /*
-         * Flush out the outgoing buffer, if there's anything left in
-         * it.
-         */
-        if (outNetBB.hasRemaining()) {
-
-            if (!tryFlush(outNetBB)) {
-                return false;
-            }
-
-            // See if we need to switch from write to read mode.
-
-            switch (initialHSStatus) {
-
-            /*
-             * Is this the last buffer?
-             */
-            case FINISHED:
-                initialHSComplete = true;
-                // Fall-through to reregister need for a Read.
-
-            case NEED_UNWRAP:
-                if (sk != null) {
-                    sk.interestOps(SelectionKey.OP_READ);
-                }
-                break;
-            }
-
-            return initialHSComplete;
-        }
-
-
-        switch (initialHSStatus) {
-
-        case NEED_UNWRAP:
-            if (sc.read(inNetBB) == -1) {
-                sslEngine.closeInbound();
-                return initialHSComplete;
-            }
-
-needIO:
-            while (initialHSStatus == HandshakeStatus.NEED_UNWRAP) {
-                resizeRequestBB();    // expected room for unwrap
-                inNetBB.flip();
-                result = sslEngine.unwrap(inNetBB, requestBB);
-                inNetBB.compact();
-
-                initialHSStatus = result.getHandshakeStatus();
-
-                switch (result.getStatus()) {
-
-                case OK:
-                    switch (initialHSStatus) {
-                    case NOT_HANDSHAKING:
-                        throw new IOException(
-                            "Not handshaking during initial handshake");
-
-                    case NEED_TASK:
-                        initialHSStatus = doTasks();
-                        break;
-
-                    case FINISHED:
-                        initialHSComplete = true;
-                        break needIO;
-                    }
-
-                    break;
-
-                case BUFFER_UNDERFLOW:
-                    // Resize buffer if needed.
-                    netBBSize = sslEngine.getSession().getPacketBufferSize();
-                    if (netBBSize > inNetBB.capacity()) {
-                        resizeResponseBB();
-                    }
-
-                    /*
-                     * Need to go reread the Channel for more data.
-                     */
-                    if (sk != null) {
-                        sk.interestOps(SelectionKey.OP_READ);
-                    }
-                    break needIO;
-
-                case BUFFER_OVERFLOW:
-                    // Reset the application buffer size.
-                    appBBSize =
-                        sslEngine.getSession().getApplicationBufferSize();
-                    break;
-
-                default: //CLOSED:
-                    throw new IOException("Received" + result.getStatus() +
-                        "during initial handshaking");
-                }
-            }  // "needIO" block.
-
-            /*
-             * Just transitioned from read to write.
-             */
-            if (initialHSStatus != HandshakeStatus.NEED_WRAP) {
-                break;
-            }
-
-            // Fall through and fill the write buffers.
-
-        case NEED_WRAP:
-            /*
-             * The flush above guarantees the out buffer to be empty
-             */
-            outNetBB.clear();
-            result = sslEngine.wrap(hsBB, outNetBB);
-            outNetBB.flip();
-
-            initialHSStatus = result.getHandshakeStatus();
-
-            switch (result.getStatus()) {
-            case OK:
-
-                if (initialHSStatus == HandshakeStatus.NEED_TASK) {
-                    initialHSStatus = doTasks();
-                }
-
-                if (sk != null) {
-                    sk.interestOps(SelectionKey.OP_WRITE);
-                }
-
-                break;
-
-            default: // BUFFER_OVERFLOW/BUFFER_UNDERFLOW/CLOSED:
-                throw new IOException("Received" + result.getStatus() +
-                        "during initial handshaking");
-            }
-            break;
-
-        default: // NOT_HANDSHAKING/NEED_TASK/FINISHED
-            throw new RuntimeException("Invalid Handshaking State" +
-                    initialHSStatus);
-        } // switch
-
-        return initialHSComplete;
-    }
-
-    /*
-     * Do all the outstanding handshake tasks in the current Thread.
-     */
-    private SSLEngineResult.HandshakeStatus doTasks() {
-
-        Runnable runnable;
-
-        /*
-         * We could run this in a separate thread, but
-         * do in the current for now.
-         */
-        while ((runnable = sslEngine.getDelegatedTask()) != null) {
-            runnable.run();
-        }
-        return sslEngine.getHandshakeStatus();
-    }
-
-    /*
-     * Read the channel for more information, then unwrap the
-     * (hopefully application) data we get.
-     * <P>
-     * If we run out of data, we'll return to our caller (possibly using
-     * a Selector) to get notification that more is available.
-     * <P>
-     * Each call to this method will perform at most one underlying read().
-     */
-    int read() throws IOException {
-        SSLEngineResult result;
-
-        if (!initialHSComplete) {
-            throw new IllegalStateException();
-        }
-
-        int pos = requestBB.position();
-
-        if (sc.read(inNetBB) == -1) {
-            sslEngine.closeInbound();  // probably throws exception
-            return -1;
-        }
-
-        do {
-            resizeRequestBB();    // expected room for unwrap
-            inNetBB.flip();
-            result = sslEngine.unwrap(inNetBB, requestBB);
-            inNetBB.compact();
-
-            /*
-             * Could check here for a renegotation, but we're only
-             * doing a simple read/write, and won't have enough state
-             * transitions to do a complete handshake, so ignore that
-             * possibility.
-             */
-            switch (result.getStatus()) {
-
-            case BUFFER_OVERFLOW:
-                // Reset the application buffer size.
-                appBBSize = sslEngine.getSession().getApplicationBufferSize();
-                break;
-
-            case BUFFER_UNDERFLOW:
-                // Resize buffer if needed.
-                netBBSize = sslEngine.getSession().getPacketBufferSize();
-                if (netBBSize > inNetBB.capacity()) {
-                    resizeResponseBB();
-
-                    break; // break, next read will support larger buffer.
-                }
-            case OK:
-                if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
-                    doTasks();
-                }
-                break;
-
-            default:
-                throw new IOException("sslEngine error during data read: " +
-                    result.getStatus());
-            }
-        } while ((inNetBB.position() != 0) &&
-            result.getStatus() != Status.BUFFER_UNDERFLOW);
-
-        return (requestBB.position() - pos);
-    }
-
-    /*
-     * Try to write out as much as possible from the src buffer.
-     */
-    int write(ByteBuffer src) throws IOException {
-
-        if (!initialHSComplete) {
-            throw new IllegalStateException();
-        }
-
-        return doWrite(src);
-    }
-
-    /*
-     * Try to flush out any existing outbound data, then try to wrap
-     * anything new contained in the src buffer.
-     * <P>
-     * Return the number of bytes actually consumed from the buffer,
-     * but the data may actually be still sitting in the output buffer,
-     * waiting to be flushed.
-     */
-    private int doWrite(ByteBuffer src) throws IOException {
-        int retValue = 0;
-
-        if (outNetBB.hasRemaining() && !tryFlush(outNetBB)) {
-            return retValue;
-        }
-
-        /*
-         * The data buffer is empty, we can reuse the entire buffer.
-         */
-        outNetBB.clear();
-
-        SSLEngineResult result = sslEngine.wrap(src, outNetBB);
-        retValue = result.bytesConsumed();
-
-        outNetBB.flip();
-
-        switch (result.getStatus()) {
-
-        case OK:
-            if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
-                doTasks();
-            }
-            break;
-
-        default:
-            throw new IOException("sslEngine error during data write: " +
-                result.getStatus());
-        }
-
-        /*
-         * Try to flush the data, regardless of whether or not
-         * it's been selected.  Odds of a write buffer being full
-         * is less than a read buffer being empty.
-         */
-        if (outNetBB.hasRemaining()) {
-            tryFlush(outNetBB);
-        }
-
-        return retValue;
-    }
-
-    /*
-     * Perform a FileChannel.TransferTo on the socket channel.
-     * <P>
-     * We have to copy the data into an intermediary app ByteBuffer
-     * first, then send it through the SSLEngine.
-     * <P>
-     * We return the number of bytes actually read out of the
-     * filechannel.  However, the data may actually be stuck
-     * in the fileChannelBB or the outNetBB.  The caller
-     * is responsible for making sure to call dataFlush()
-     * before shutting down.
-     */
-    long transferTo(FileChannel fc, long pos, long len) throws IOException {
-
-        if (!initialHSComplete) {
-            throw new IllegalStateException();
-        }
-
-        if (fileChannelBB == null) {
-            fileChannelBB = ByteBuffer.allocate(appBBSize);
-            fileChannelBB.limit(0);
-        }
-
-        fileChannelBB.compact();
-        int fileRead = fc.read(fileChannelBB);
-        fileChannelBB.flip();
-
-        /*
-         * We ignore the return value here, we return the
-         * number of bytes actually consumed from the file.
-         * We'll flush the output buffer before we start shutting down.
-         */
-        doWrite(fileChannelBB);
-
-        return fileRead;
-    }
-
-    /*
-     * Flush any remaining data.
-     * <P>
-     * Return true when the fileChannelBB and outNetBB are empty.
-     */
-    boolean dataFlush() throws IOException {
-        boolean fileFlushed = true;
-
-        if ((fileChannelBB != null) && fileChannelBB.hasRemaining()) {
-            doWrite(fileChannelBB);
-            fileFlushed = !fileChannelBB.hasRemaining();
-        } else if (outNetBB.hasRemaining()) {
-            tryFlush(outNetBB);
-        }
-
-        return (fileFlushed && !outNetBB.hasRemaining());
-    }
-
-    /*
-     * Begin the shutdown process.
-     * <P>
-     * Close out the SSLEngine if not already done so, then
-     * wrap our outgoing close_notify message and try to send it on.
-     * <P>
-     * Return true when we're done passing the shutdown messsages.
-     */
-    boolean shutdown() throws IOException {
-
-        if (!shutdown) {
-            sslEngine.closeOutbound();
-            shutdown = true;
-        }
-
-        if (outNetBB.hasRemaining() && tryFlush(outNetBB)) {
-            return false;
-        }
-
-        /*
-         * By RFC 2616, we can "fire and forget" our close_notify
-         * message, so that's what we'll do here.
-         */
-        outNetBB.clear();
-        SSLEngineResult result = sslEngine.wrap(hsBB, outNetBB);
-        if (result.getStatus() != Status.CLOSED) {
-            throw new SSLException("Improper close state");
-        }
-        outNetBB.flip();
-
-        /*
-         * We won't wait for a select here, but if this doesn't work,
-         * we'll cycle back through on the next select.
-         */
-        if (outNetBB.hasRemaining()) {
-            tryFlush(outNetBB);
-        }
-
-        return (!outNetBB.hasRemaining() &&
-                (result.getHandshakeStatus() != HandshakeStatus.NEED_WRAP));
-    }
-
-    /*
-     * close() is not overridden
-     */
-}
--- a/jdk/src/sample/share/nio/server/Content.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/**
- * An Sendable interface extension that adds additional
- * methods for additional information, such as Files
- * or Strings.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-interface Content extends Sendable {
-
-    String type();
-
-    // Returns -1 until prepare() invoked
-    long length();
-
-}
--- a/jdk/src/sample/share/nio/server/Dispatcher.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.channels.*;
-
-/**
- * Base class for the Dispatchers.
- * <P>
- * Servers use these to obtain ready status, and then to dispatch jobs.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-interface Dispatcher extends Runnable {
-
-    void register(SelectableChannel ch, int ops, Handler h)
-        throws IOException;
-
-}
--- a/jdk/src/sample/share/nio/server/Dispatcher1.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.channels.*;
-import java.util.*;
-
-/**
- * A single-threaded dispatcher.
- * <P>
- * When a SelectionKey is ready, it dispatches the job in this
- * thread.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class Dispatcher1 implements Dispatcher {
-
-    private Selector sel;
-
-    Dispatcher1() throws IOException {
-        sel = Selector.open();
-    }
-
-    // Doesn't really need to be runnable
-    public void run() {
-        for (;;) {
-            try {
-                dispatch();
-            } catch (IOException x) {
-                x.printStackTrace();
-            }
-        }
-    }
-
-    private void dispatch() throws IOException {
-        sel.select();
-        for (Iterator i = sel.selectedKeys().iterator(); i.hasNext(); ) {
-            SelectionKey sk = (SelectionKey)i.next();
-            i.remove();
-            Handler h = (Handler)sk.attachment();
-            h.handle(sk);
-        }
-    }
-
-    public void register(SelectableChannel ch, int ops, Handler h)
-            throws IOException {
-        ch.register(sel, ops, h);
-    }
-}
--- a/jdk/src/sample/share/nio/server/DispatcherN.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.channels.*;
-import java.util.*;
-
-/**
- * A Multi-threaded dispatcher.
- * <P>
- * In this example, one thread does accepts, and the second
- * does read/writes.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class DispatcherN implements Dispatcher {
-
-    private Selector sel;
-
-    DispatcherN() throws IOException {
-        sel = Selector.open();
-    }
-
-    public void run() {
-        for (;;) {
-            try {
-                dispatch();
-            } catch (IOException x) {
-                x.printStackTrace();
-            }
-        }
-    }
-
-    private Object gate = new Object();
-
-    private void dispatch() throws IOException {
-        sel.select();
-        for (Iterator i = sel.selectedKeys().iterator(); i.hasNext(); ) {
-            SelectionKey sk = (SelectionKey)i.next();
-            i.remove();
-            Handler h = (Handler)sk.attachment();
-            h.handle(sk);
-        }
-        synchronized (gate) { }
-    }
-
-    public void register(SelectableChannel ch, int ops, Handler h)
-            throws IOException {
-        synchronized (gate) {
-            sel.wakeup();
-            ch.register(sel, ops, h);
-        }
-    }
-
-}
--- a/jdk/src/sample/share/nio/server/FileContent.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.net.*;
-import java.nio.channels.*;
-import java.nio.charset.*;
-
-/**
- * A Content type that provides for transferring files.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class FileContent implements Content {
-
-    private static File ROOT = new File("root");
-
-    private File fn;
-
-    FileContent(URI uri) {
-        fn = new File(ROOT,
-                      uri.getPath()
-                      .replace('/',
-                               File.separatorChar));
-    }
-
-    private String type = null;
-
-    public String type() {
-        if (type != null)
-            return type;
-        String nm = fn.getName();
-        if (nm.endsWith(".html"))
-            type = "text/html; charset=iso-8859-1";
-        else if ((nm.indexOf('.') < 0) || nm.endsWith(".txt"))
-            type = "text/plain; charset=iso-8859-1";
-        else
-            type = "application/octet-stream";
-        return type;
-    }
-
-    private FileChannel fc = null;
-    private long length = -1;
-    private long position = -1;         // NB only; >= 0 if transferring
-
-    public long length() {
-        return length;
-    }
-
-    public void prepare() throws IOException {
-        if (fc == null)
-            fc = new RandomAccessFile(fn, "r").getChannel();
-        length = fc.size();
-        position = 0;                   // NB only
-    }
-
-    public boolean send(ChannelIO cio) throws IOException {
-        if (fc == null)
-            throw new IllegalStateException();
-        if (position < 0)               // NB only
-            throw new IllegalStateException();
-
-        /*
-         * Short-circuit if we're already done.
-         */
-        if (position >= length) {
-            return false;
-        }
-
-        position += cio.transferTo(fc, position, length - position);
-        return (position < length);
-    }
-
-    public void release() throws IOException {
-        if (fc != null) {
-            fc.close();
-            fc = null;
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/server/Handler.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.channels.*;
-
-/**
- * Base class for the Handlers.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-interface Handler {
-
-    void handle(SelectionKey sk) throws IOException;
-
-}
--- a/jdk/src/sample/share/nio/server/MalformedRequestException.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/**
- * Exception class used when a request can't be properly parsed.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class MalformedRequestException extends Exception {
-
-    MalformedRequestException() { }
-
-    MalformedRequestException(String msg) {
-        super(msg);
-    }
-
-    MalformedRequestException(Exception x) {
-        super(x);
-    }
-}
--- a/jdk/src/sample/share/nio/server/N1.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.nio.channels.*;
-
-/**
- * A non-blocking/single-threaded server.  All accept() and
- * read()/write() operations are performed by a single thread, but only
- * after being selected for those operations by a Selector.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-public class N1 extends Server {
-
-    N1(int port, int backlog, boolean secure) throws Exception {
-        super(port, backlog, secure);
-        ssc.configureBlocking(false);
-    }
-
-    void runServer() throws Exception {
-        Dispatcher d = new Dispatcher1();
-        d.register(ssc, SelectionKey.OP_ACCEPT,
-                   new AcceptHandler(ssc, d, sslContext));
-        d.run();
-    }
-}
--- a/jdk/src/sample/share/nio/server/N2.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/**
- * A non-blocking/dual-threaded which performs accept()s in one thread,
- * and services requests in a second.  Both threads use select().
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-public class N2 extends Server {
-
-    N2(int port, int backlog, boolean secure) throws Exception {
-        super(port, backlog, secure);
-    }
-
-    void runServer() throws Exception {
-        Dispatcher d = new DispatcherN();
-        Acceptor a = new Acceptor(ssc, d, sslContext);
-        new Thread(a).start();
-        d.run();
-    }
-}
--- a/jdk/src/sample/share/nio/server/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,279 +0,0 @@
-        A Simple NIO-based HTTP/HTTPS Server Example
-
-
-INTRODUCTION
-============
-This directory contains a simple HTTP/HTTPS server.  HTTP/HTTPS are two
-common network protocols that provide for data transfer, and are more
-fully described in RFC 2616 and RFC 2818 (Available at
-http://www.ietf.org ). HTTPS is essentially HTTP after the connection
-has been secured with SSL/TLS.  TLS is the successor to SSL, and is
-described in RFC 2246.
-
-This server was written to demonstrate some of the functionality new to
-the Java 2 platform.  The demo is not meant to be a full tutorial, and
-assumes the reader has some familiarity with the subject matter.
-
-In particular, it shows:
-
-    New I/O (java.nio, java.nio.channels, java.util.regex, java.nio.charset)
-
-        Introduced in version 1.4 of the platform, NIO was designed to
-        overcome some of the scalability limitations found in the
-        existing blocking java.net.* API's, and to address other
-        concepts such as Regular Expression parsing and Character
-        Sets.
-
-        This server demonstrates:
-
-            ByteBuffer
-            Blocking and Non-Blocking I/O
-            SocketChannel
-            ServerSocketChannel
-            Selector
-            CharacterSet
-            Pattern matching using Regular Expressions
-
-    JSSE (javax.net.ssl)
-
-	Introduced in version 1.4 of the platform, JSSE provides
-	network security using SSL/TLS for java.net.Socket-based
-	traffic.  In version 1.5, the SSLEngine API was introduced
-	which separates the SSL/TLS functionality from the underlying
-	I/O model.  By making this separation, applications can adapt
-	I/O and compute strategies to best fit their circumstances.
-
-        This server demonstrates:
-
-            Using SSLEngine to create a HTTPS server
-	    Creating simple key material for use with HTTPS
-
-    Concurrency Library (java.util.concurrent)
-
-        Introduced in version 1.5 of the platform, the concurrency
-        library provides a mechanism which decouples task submission
-        from the mechanics of how each task will be run.
-
-        This server demonstrates:
-
-            A ThreadPool with a fixed number of threads, which is
-            based on the number of available processors.
-
-
-SETUP
-=====
-
-The server must be built on version 1.5 (or later) of the platform.
-Invoking the following should be sufficient:
-
-    % mkdir build
-    % javac -d build *.java
-
-The following creates the document root:
-
-    % mkdir root
-
-All documents should be placed in this directory.
-
-For HTTPS, the server authenticates itself to clients by using simple
-Public Key Infrastructure (PKI) credentials in the form of
-X509Certificates.  You must create the server's credentials before
-attempting to run the server in "-secure" mode.  The server is
-currently hardcoded to look for its credentials in a file called
-"testkeys".
-
-In this example, we'll create credentials for a fictional widget web
-site owned by the ubiquitous "Xyzzy, Inc.".  When you run this in your
-own environment, replace "widgets.xyzzy.com" with the hostname of your
-server.
-
-The easiest way to create the SSL/TLS credentials is to use the
-java keytool, by doing the following:
-
-        (<CR> represents your end-of-line key)
-
-    % keytool -genkey -keyalg rsa -keystore testkeys -alias widgets
-    Enter keystore password:  passphrase
-    What is your first and last name?
-    [Unknown]:  widgets.xyzzy.com<CR>
-    What is the name of your organizational unit?
-    [Unknown]:  Consumer Widgets Group<CR>
-    What is the name of your organization?
-    [Unknown]:  Xyzzy, Inc.<CR>
-    What is the name of your City or Locality?
-    [Unknown]:  Arcata<CR>
-    What is the name of your State or Province?
-    [Unknown]:  CA<CR>
-    What is the two-letter country code for this unit?
-    [Unknown]:  US<CR>
-    Is CN=widgets.xyzzy.com, OU=Consumer Widgets Group, O="Xyzzy, Inc.",
-    L=Arcata, ST=CA, C=US correct?
-    [no]:  yes<CR>
-
-    Enter key password for <mykey>
-    (RETURN if same as keystore password):  <CR>
-
-This directory also contain a very simple URL reader (URLDumper), which
-connects to a specified URL and places all output into a specified file.
-
-
-SERVER EXECUTION
-================
-
-    % java -classpath build Server N1
-
-    Usage:  Server <type> [options]
-        type:
-                B1      Blocking/Single-threaded Server
-                BN      Blocking/Multi-threaded Server
-                BP      Blocking/Pooled-thread Server
-                N1      Nonblocking/Single-threaded Server
-                N2      Nonblocking/Dual-threaded Server
-
-        options:
-                -port port                port number
-                    default:  8000
-                -backlog backlog          backlog
-                    default:  1024
-                -secure                   encrypt with SSL/TLS
-		    default is insecure
-
-"http://" URLs should be used with insecure mode, and
-"https://" for secure mode.
-
-The "B*" servers use classic blocking I/O:  in other words, calls to
-read()/write() will not return until the I/O operation has completed.  The
-"N*" servers use non-blocking mode and Selectors to determine which
-Channels are ready to perform I/O.
-
-B1:	A single-threaded server which completely services each
-	connection before moving to the next.
-
-B2:	A multi-threaded server which creates a new thread for each
-	connection.  This is not efficient for large numbers of
-	connections.
-
-BP:	A multi-threaded server which creates a pool of threads for use
-	by the server.  The Thread pool decides how to schedule those
-	threads.
-
-N1:	A single-threaded server.  All accept() and read()/write()
-	operations are performed by a single thread, but only after
-	being selected for those operations by a Selector.
-
-N2:	A dual-threaded server which performs accept()s in one thread, and
-	services requests in a second.  Both threads use select().
-
-
-CLIENT EXECUTION
-================
-You can test the server using any standard browser such as Internet
-Explorer or Mozilla, but since the browser will not trust the
-credentials you just created, you may need to accept the credentials
-via the browser's pop-up dialog box.
-
-Alternatively, to use the certificates using the simple included JSSE
-client URLDumper, export the server certificate into a new truststore,
-and then run the application using the new truststore.
-
-    % keytool -export -keystore testkeys -alias widgets -file widgets.cer
-    Enter keystore password:  passphrase<CR>
-    Certificate stored in file <widgets.cer>
-
-    % keytool -import -keystore trustCerts -alias widgetServer \
-            -file widgets.cer
-    Enter keystore password:  passphrase<CR>
-    Owner: CN=widgets.xyzzy.com, OU=Consumer, O="xyzzy, inc.", L=Arcata,
-    ST=CA, C=US
-    Issuer: CN=widgets.xyzzy.com, OU=Consumer, O="xyzzy, inc.",
-    L=Arcata, ST=CA, C=US
-    Serial number: 4086cc7a
-    Valid from: Wed Apr 21 12:33:14 PDT 2004 until: Tue Jul 20 12:33:14
-    PDT 2004
-    Certificate fingerprints:
-        MD5:  39:71:42:CD:BF:0D:A9:8C:FB:8B:4A:CD:F8:6D:19:1F
-        SHA1: 69:5D:38:E9:F4:6C:E5:A7:4C:EA:45:8E:FB:3E:F3:9A:84:01:6F:22
-    Trust this certificate? [no]:  yes<CR>
-    Certificate was added to keystore
-
-    % java -classpath build -Djavax.net.ssl.trustStore=trustCerts \
-        -Djavax.net.ssl.TrustStorePassword=passphrase \
-        URLDumper https://widgets.xyzzy.com:8000/ outputFile
-
-NOTE:  The server must be run with "-secure" in order to receive
-"https://" URLs.
-
-WARNING:  This is just a simple example for code exposition, you should
-spend more time understanding PKI security concerns.
-
-
-SOURCE CODE OVERVIEW
-====================
-
-The main class is Server, which handles program startup, and is
-subclassed by the "B*" and "N*" server classes.
-
-Following a successful accept(), the "B*" variants each create a
-RequestServicer object to perform the actual request/reply operations.  The
-primary differences between the different "B*" servers is how the
-RequestServicer is actually run:
-
-    B1:	RequestServicer.run() is directly called.
-    BN:	A new thread is started, and the thread calls RequestServicer.run().
-    BP:	A ThreadPool is created, and the pool framework is given Runnable
-	tasks to complete.
-
-In the "N*" variations, a Dispatcher object is created, which is
-responsible for performing the select, and then issuing the
-corresponding handler:
-
-    N1:	A single thread is used for all accept()/read()/write() operations
-    N2:	Similar to N1, but a separate thread is used for the accept()
-	operations.
-
-In all cases, once the connection has been accepted, a ChannelIO object
-is created to handle all I/O.  In the insecure case, the corresponding
-SocketChannel methods are directly called.  However in the secure case,
-more manipulations are needed to first secure the channel, then
-encrypt/decrypt the data, and finally properly send any shutdown
-messages.  ChannelIOSecure extends ChannelIO, and provides the secure
-variants of the corresponding ChannelIO calls.
-
-RequestServicer and RequestHandler are the main drivers for the
-blocking and non-blocking variants, respectively.  They are responsible
-for:
-
-    Performing any initial handshaking
-
-    Reading the request data
-        All data is stored in a local buffer in the ChannelIO
-        structure.
-
-    Parsing the request
-        The request data is obtained from the ChannelIO object, and
-        is processed by Request class, which represents the
-        parsed URI address.
-
-    Locating/preparing/sending the data or reporting error conditions.
-        A Reply object is created which represents the entire object to send,
-        including the HTTP/HTTPS headers.
-
-    Shutdown/closing the channel.
-
-
-CLOSING THOUGHTS
-================
-This example represents a simple server: it is not production quality.
-It was primarily meant to demonstrate the new APIs in versions 1.4 and
-1.5 of the platform.
-
-This example could certainly be expanded to address other areas of
-concern: for example, assigning multiple threads to handle the selected
-Channels, or delegating SSLEngine tasks to multiple threads.  There are
-so many ways to implement compute and I/O strategies, we encourage you
-to experiment and find what works best for your situation.
-
-To steal a phrase from many textbooks:
-
-    "It is left as an exercise for the reader..."
-
--- a/jdk/src/sample/share/nio/server/Reply.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.*;
-import java.nio.charset.*;
-
-/**
- * An object used for sending Content to the requestor.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class Reply implements Sendable {
-
-    /**
-     * A helper class which define the HTTP response codes
-     */
-    static class Code {
-
-        private int number;
-        private String reason;
-        private Code(int i, String r) { number = i; reason = r; }
-        public String toString() { return number + " " + reason; }
-
-        static Code OK = new Code(200, "OK");
-        static Code BAD_REQUEST = new Code(400, "Bad Request");
-        static Code NOT_FOUND = new Code(404, "Not Found");
-        static Code METHOD_NOT_ALLOWED = new Code(405, "Method Not Allowed");
-
-    }
-
-    private Code code;
-    private Content content;
-    private boolean headersOnly;
-
-    Reply(Code rc, Content c) {
-        this(rc, c, null);
-    }
-
-    Reply(Code rc, Content c, Request.Action head) {
-        code = rc;
-        content = c;
-        headersOnly = (head == Request.Action.HEAD);
-    }
-
-    private static String CRLF = "\r\n";
-    private static Charset ascii = Charset.forName("US-ASCII");
-
-    private ByteBuffer hbb = null;
-
-    private ByteBuffer headers() {
-        CharBuffer cb = CharBuffer.allocate(1024);
-        for (;;) {
-            try {
-                cb.put("HTTP/1.0 ").put(code.toString()).put(CRLF);
-                cb.put("Server: niossl/0.1").put(CRLF);
-                cb.put("Content-type: ").put(content.type()).put(CRLF);
-                cb.put("Content-length: ")
-                    .put(Long.toString(content.length())).put(CRLF);
-                cb.put(CRLF);
-                break;
-            } catch (BufferOverflowException x) {
-                assert(cb.capacity() < (1 << 16));
-                cb = CharBuffer.allocate(cb.capacity() * 2);
-                continue;
-            }
-        }
-        cb.flip();
-        return ascii.encode(cb);
-    }
-
-    public void prepare() throws IOException {
-        content.prepare();
-        hbb = headers();
-    }
-
-    public boolean send(ChannelIO cio) throws IOException {
-
-        if (hbb == null)
-            throw new IllegalStateException();
-
-        if (hbb.hasRemaining()) {
-            if (cio.write(hbb) <= 0)
-                return true;
-        }
-
-        if (!headersOnly) {
-            if (content.send(cio))
-                return true;
-        }
-
-        if (!cio.dataFlush())
-            return true;
-
-        return false;
-    }
-
-    public void release() throws IOException {
-        content.release();
-    }
-}
--- a/jdk/src/sample/share/nio/server/Request.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.net.*;
-import java.nio.*;
-import java.nio.charset.*;
-import java.util.regex.*;
-
-/**
- * An encapsulation of the request received.
- * <P>
- * The static method parse() is responsible for creating this
- * object.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class Request {
-
-    /**
-     * A helper class for parsing HTTP command actions.
-     */
-    static class Action {
-
-        private String name;
-        private Action(String name) { this.name = name; }
-        public String toString() { return name; }
-
-        static Action GET = new Action("GET");
-        static Action PUT = new Action("PUT");
-        static Action POST = new Action("POST");
-        static Action HEAD = new Action("HEAD");
-
-        static Action parse(String s) {
-            if (s.equals("GET"))
-                return GET;
-            if (s.equals("PUT"))
-                return PUT;
-            if (s.equals("POST"))
-                return POST;
-            if (s.equals("HEAD"))
-                return HEAD;
-            throw new IllegalArgumentException(s);
-        }
-    }
-
-    private Action action;
-    private String version;
-    private URI uri;
-
-    Action action() { return action; }
-    String version() { return version; }
-    URI uri() { return uri; }
-
-    private Request(Action a, String v, URI u) {
-        action = a;
-        version = v;
-        uri = u;
-    }
-
-    public String toString() {
-        return (action + " " + version + " " + uri);
-    }
-
-    static boolean isComplete(ByteBuffer bb) {
-        int p = bb.position() - 4;
-        if (p < 0)
-            return false;
-        return (((bb.get(p + 0) == '\r') &&
-                 (bb.get(p + 1) == '\n') &&
-                 (bb.get(p + 2) == '\r') &&
-                 (bb.get(p + 3) == '\n')));
-    }
-
-    private static Charset ascii = Charset.forName("US-ASCII");
-
-    /*
-     * The expected message format is first compiled into a pattern,
-     * and is then compared against the inbound character buffer to
-     * determine if there is a match.  This convienently tokenizes
-     * our request into usable pieces.
-     *
-     * This uses Matcher "expression capture groups" to tokenize
-     * requests like:
-     *
-     *     GET /dir/file HTTP/1.1
-     *     Host: hostname
-     *
-     * into:
-     *
-     *     group[1] = "GET"
-     *     group[2] = "/dir/file"
-     *     group[3] = "1.1"
-     *     group[4] = "hostname"
-     *
-     * The text in between the parens are used to captured the regexp text.
-     */
-    private static Pattern requestPattern
-        = Pattern.compile("\\A([A-Z]+) +([^ ]+) +HTTP/([0-9\\.]+)$"
-                          + ".*^Host: ([^ ]+)$.*\r\n\r\n\\z",
-                          Pattern.MULTILINE | Pattern.DOTALL);
-
-    static Request parse(ByteBuffer bb) throws MalformedRequestException {
-
-        CharBuffer cb = ascii.decode(bb);
-        Matcher m = requestPattern.matcher(cb);
-        if (!m.matches())
-            throw new MalformedRequestException();
-        Action a;
-        try {
-            a = Action.parse(m.group(1));
-        } catch (IllegalArgumentException x) {
-            throw new MalformedRequestException();
-        }
-        URI u;
-        try {
-            u = new URI("http://"
-                        + m.group(4)
-                        + m.group(2));
-        } catch (URISyntaxException x) {
-            throw new MalformedRequestException();
-        }
-        return new Request(a, m.group(3), u);
-    }
-}
--- a/jdk/src/sample/share/nio/server/RequestHandler.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
-
-/**
- * Primary driver class used by non-blocking Servers to receive,
- * prepare, send, and shutdown requests.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class RequestHandler implements Handler {
-
-    private ChannelIO cio;
-    private ByteBuffer rbb = null;
-
-    private boolean requestReceived = false;
-    private Request request = null;
-    private Reply reply = null;
-
-    private static int created = 0;
-
-    RequestHandler(ChannelIO cio) {
-        this.cio = cio;
-
-        // Simple heartbeat to let user know we're alive.
-        synchronized (RequestHandler.class) {
-            created++;
-            if ((created % 50) == 0) {
-                System.out.println(".");
-                created = 0;
-            } else {
-                System.out.print(".");
-            }
-        }
-    }
-
-    // Returns true when request is complete
-    // May expand rbb if more room required
-    //
-    private boolean receive(SelectionKey sk) throws IOException {
-        ByteBuffer tmp = null;
-
-        if (requestReceived) {
-            return true;
-        }
-
-        if (!cio.doHandshake(sk)) {
-            return false;
-        }
-
-        if ((cio.read() < 0) || Request.isComplete(cio.getReadBuf())) {
-            rbb = cio.getReadBuf();
-            return (requestReceived = true);
-        }
-        return false;
-    }
-
-    // When parse is successfull, saves request and returns true
-    //
-    private boolean parse() throws IOException {
-        try {
-            request = Request.parse(rbb);
-            return true;
-        } catch (MalformedRequestException x) {
-            reply = new Reply(Reply.Code.BAD_REQUEST,
-                              new StringContent(x));
-        }
-        return false;
-    }
-
-    // Ensures that reply field is non-null
-    //
-    private void build() throws IOException {
-        Request.Action action = request.action();
-        if ((action != Request.Action.GET) &&
-                (action != Request.Action.HEAD)) {
-            reply = new Reply(Reply.Code.METHOD_NOT_ALLOWED,
-                              new StringContent(request.toString()));
-        }
-        reply = new Reply(Reply.Code.OK,
-                          new FileContent(request.uri()), action);
-    }
-
-    public void handle(SelectionKey sk) throws IOException {
-        try {
-
-            if (request == null) {
-                if (!receive(sk))
-                    return;
-                rbb.flip();
-                if (parse())
-                    build();
-                try {
-                    reply.prepare();
-                } catch (IOException x) {
-                    reply.release();
-                    reply = new Reply(Reply.Code.NOT_FOUND,
-                                      new StringContent(x));
-                    reply.prepare();
-                }
-                if (send()) {
-                    // More bytes remain to be written
-                    sk.interestOps(SelectionKey.OP_WRITE);
-                } else {
-                    // Reply completely written; we're done
-                    if (cio.shutdown()) {
-                        cio.close();
-                        reply.release();
-                    }
-                }
-            } else {
-                if (!send()) {  // Should be rp.send()
-                    if (cio.shutdown()) {
-                        cio.close();
-                        reply.release();
-                    }
-                }
-            }
-        } catch (IOException x) {
-            String m = x.getMessage();
-            if (!m.equals("Broken pipe") &&
-                    !m.equals("Connection reset by peer")) {
-                System.err.println("RequestHandler: " + x.toString());
-            }
-
-            try {
-                /*
-                 * We had a failure here, so we'll try to be nice
-                 * before closing down and send off a close_notify,
-                 * but if we can't get the message off with one try,
-                 * we'll just shutdown.
-                 */
-                cio.shutdown();
-            } catch (IOException e) {
-                // ignore
-            }
-
-            cio.close();
-            if (reply !=  null) {
-                reply.release();
-            }
-        }
-
-    }
-
-    private boolean send() throws IOException {
-        try {
-            return reply.send(cio);
-        } catch (IOException x) {
-            if (x.getMessage().startsWith("Resource temporarily")) {
-                System.err.println("## RTA");
-                return true;
-            }
-            throw x;
-        }
-    }
-}
--- a/jdk/src/sample/share/nio/server/RequestServicer.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.*;
-
-/**
- * Primary driver class used by blocking Servers to receive,
- * prepare, send, and shutdown requests.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class RequestServicer implements Runnable {
-
-    private ChannelIO cio;
-
-    private static int created = 0;
-
-    RequestServicer(ChannelIO cio) {
-        this.cio = cio;
-
-        // Simple heartbeat to let user know we're alive.
-        synchronized (RequestServicer.class) {
-            created++;
-            if ((created % 50) == 0) {
-                System.out.println(".");
-                created = 0;
-            } else {
-                System.out.print(".");
-            }
-        }
-    }
-
-    private void service() throws IOException {
-        Reply rp = null;
-        try {
-            ByteBuffer rbb = receive();         // Receive
-            Request rq = null;
-            try {                               // Parse
-                rq = Request.parse(rbb);
-            } catch (MalformedRequestException x) {
-                rp = new Reply(Reply.Code.BAD_REQUEST,
-                               new StringContent(x));
-            }
-            if (rp == null) rp = build(rq);     // Build
-            do {} while (rp.send(cio));         // Send
-            do {} while (!cio.shutdown());
-            cio.close();
-            rp.release();
-        } catch (IOException x) {
-            String m = x.getMessage();
-            if (!m.equals("Broken pipe") &&
-                    !m.equals("Connection reset by peer")) {
-                System.err.println("RequestHandler: " + x.toString());
-            }
-
-            try {
-                /*
-                 * We had a failure here, so we'll try to be nice
-                 * before closing down and send off a close_notify,
-                 * but if we can't get the message off with one try,
-                 * we'll just shutdown.
-                 */
-                cio.shutdown();
-            } catch (IOException e) {
-                // ignore
-            }
-
-            cio.close();
-            if (rp != null) {
-                rp.release();
-            }
-        }
-    }
-
-    public void run() {
-        try {
-            service();
-        } catch (IOException x) {
-            x.printStackTrace();
-        }
-    }
-
-    ByteBuffer receive() throws IOException {
-
-        do {} while (!cio.doHandshake());
-
-        for (;;) {
-            int read = cio.read();
-            ByteBuffer bb = cio.getReadBuf();
-            if ((read < 0) || (Request.isComplete(bb))) {
-                bb.flip();
-                return bb;
-            }
-        }
-    }
-
-    Reply build(Request rq) throws IOException {
-
-        Reply rp = null;
-        Request.Action action = rq.action();
-        if ((action != Request.Action.GET) &&
-                (action != Request.Action.HEAD))
-            rp = new Reply(Reply.Code.METHOD_NOT_ALLOWED,
-                           new StringContent(rq.toString()));
-        else
-            rp = new Reply(Reply.Code.OK,
-                           new FileContent(rq.uri()), action);
-        try {
-            rp.prepare();
-        } catch (IOException x) {
-            rp.release();
-            rp = new Reply(Reply.Code.NOT_FOUND,
-                           new StringContent(x));
-            rp.prepare();
-        }
-        return rp;
-    }
-}
--- a/jdk/src/sample/share/nio/server/Sendable.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-
-/**
- * Method definitions used for preparing, sending, and release
- * content.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-interface Sendable {
-
-    void prepare() throws IOException;
-
-    // Sends (some) content to the given channel.
-    // Returns true if more bytes remain to be written.
-    // Throws IllegalStateException if not prepared.
-    //
-    boolean send(ChannelIO cio) throws IOException;
-
-    void release() throws IOException;
-}
--- a/jdk/src/sample/share/nio/server/Server.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.net.*;
-import java.nio.channels.*;
-import java.security.*;
-import javax.net.ssl.*;
-
-/**
- * The main server base class.
- * <P>
- * This class is responsible for setting up most of the server state
- * before the actual server subclasses take over.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-public abstract class Server {
-
-    ServerSocketChannel ssc;
-    SSLContext sslContext = null;
-
-    static private int PORT = 8000;
-    static private int BACKLOG = 1024;
-    static private boolean SECURE = false;
-
-    Server(int port, int backlog,
-            boolean secure) throws Exception {
-
-        if (secure) {
-            createSSLContext();
-        }
-
-        ssc = ServerSocketChannel.open();
-        ssc.socket().setReuseAddress(true);
-        ssc.socket().bind(new InetSocketAddress(port), backlog);
-    }
-
-    /*
-     * If this is a secure server, we now setup the SSLContext we'll
-     * use for creating the SSLEngines throughout the lifetime of
-     * this process.
-     */
-    private void createSSLContext() throws Exception {
-
-        char[] passphrase = "passphrase".toCharArray();
-
-        KeyStore ks = KeyStore.getInstance("JKS");
-        ks.load(new FileInputStream("testkeys"), passphrase);
-
-        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
-        kmf.init(ks, passphrase);
-
-        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
-        tmf.init(ks);
-
-        sslContext = SSLContext.getInstance("TLS");
-        sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-    }
-
-    abstract void runServer() throws Exception;
-
-    static private void usage() {
-        System.out.println(
-            "Usage:  Server <type> [options]\n"
-                + "     type:\n"
-                + "             B1      Blocking/Single-threaded Server\n"
-                + "             BN      Blocking/Multi-threaded Server\n"
-                + "             BP      Blocking/Pooled-Thread Server\n"
-                + "             N1      Nonblocking/Single-threaded Server\n"
-                + "             N2      Nonblocking/Dual-threaded Server\n"
-                + "\n"
-                + "     options:\n"
-                + "             -port port              port number\n"
-                + "                 default:  " + PORT + "\n"
-                + "             -backlog backlog        backlog\n"
-                + "                 default:  " + BACKLOG + "\n"
-                + "             -secure                 encrypt with SSL/TLS");
-        System.exit(1);
-    }
-
-    /*
-     * Parse the arguments, decide what type of server to run,
-     * see if there are any defaults to change.
-     */
-    static private Server createServer(String args[]) throws Exception {
-        if (args.length < 1) {
-            usage();
-        }
-
-        int port = PORT;
-        int backlog = BACKLOG;
-        boolean secure = SECURE;
-
-        for (int i = 1; i < args.length; i++) {
-            if (args[i].equals("-port")) {
-                checkArgs(i, args.length);
-                port = Integer.valueOf(args[++i]);
-            } else if (args[i].equals("-backlog")) {
-                checkArgs(i, args.length);
-                backlog = Integer.valueOf(args[++i]);
-            } else if (args[i].equals("-secure")) {
-                secure = true;
-            } else {
-                usage();
-            }
-        }
-
-        Server server = null;
-
-        if (args[0].equals("B1")) {
-            server = new B1(port, backlog, secure);
-        } else if (args[0].equals("BN")) {
-            server = new BN(port, backlog, secure);
-        } else if (args[0].equals("BP")) {
-            server = new BP(port, backlog, secure);
-        } else if (args[0].equals("N1")) {
-            server = new N1(port, backlog, secure);
-        } else if (args[0].equals("N2")) {
-            server = new N2(port, backlog, secure);
-        }
-
-        return server;
-    }
-
-    static private void checkArgs(int i, int len) {
-        if ((i + 1) >= len) {
-           usage();
-        }
-    }
-
-    static public void main(String args[]) throws Exception {
-        Server server = createServer(args);
-
-        if (server == null) {
-            usage();
-        }
-
-        System.out.println("Server started.");
-        server.runServer();
-    }
-}
--- a/jdk/src/sample/share/nio/server/StringContent.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.nio.*;
-import java.nio.charset.*;
-
-/**
- * A Content type that provides for transferring Strings.
- *
- * @author Mark Reinhold
- * @author Brad R. Wetmore
- */
-class StringContent implements Content {
-
-    private static Charset ascii = Charset.forName("US-ASCII");
-
-    private String type;                // MIME type
-    private String content;
-
-    StringContent(CharSequence c, String t) {
-        content = c.toString();
-        if (!content.endsWith("\n"))
-            content += "\n";
-        type = t + "; charset=iso-8859-1";
-    }
-
-    StringContent(CharSequence c) {
-        this(c, "text/plain");
-    }
-
-    StringContent(Exception x) {
-        StringWriter sw = new StringWriter();
-        x.printStackTrace(new PrintWriter(sw));
-        type = "text/plain; charset=iso-8859-1";
-        content = sw.toString();
-    }
-
-    public String type() {
-        return type;
-    }
-
-    private ByteBuffer bb = null;
-
-    private void encode() {
-        if (bb == null)
-            bb = ascii.encode(CharBuffer.wrap(content));
-    }
-
-    public long length() {
-        encode();
-        return bb.remaining();
-    }
-
-    public void prepare() {
-        encode();
-        bb.rewind();
-    }
-
-    public boolean send(ChannelIO cio) throws IOException {
-        if (bb == null)
-            throw new IllegalStateException();
-        cio.write(bb);
-
-        return bb.hasRemaining();
-    }
-
-    public void release() throws IOException {
-    }
-}
--- a/jdk/src/sample/share/nio/server/URLDumper.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-import java.io.*;
-import java.net.*;
-
-/**
- * A simple example to illustrate using a URL to access a resource
- * and then store the result to a File.
- * <P>
- * Any type of URL can be used:  http, https, ftp, etc.
- *
- * @author Brad R. Wetmore
- * @author Mark Reinhold
- */
-public class URLDumper {
-    public static void main(String[] args) throws Exception {
-
-        if (args.length != 2) {
-            System.out.println("Usage:  URLDumper <URL> <file>");
-            System.exit(1);
-        }
-
-        String location = args[0];
-        String file = args[1];
-
-        URL url = new URL(location);
-        FileOutputStream fos = new FileOutputStream(file);
-
-        byte [] bytes = new byte [4096];
-
-        InputStream is = url.openStream();
-
-        int read;
-
-        while ((read = is.read(bytes)) != -1) {
-            fos.write(bytes, 0, read);
-        }
-
-        is.close();
-        fos.close();
-    }
-}
--- a/jdk/src/sample/share/scripting/scriptpad/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-Scriptpad Sample
-
-* Introduction
-
-Scriptpad is a notepad like editor to open/edit/save and run 
-script (JavaScript) files. This sample demonstrates the use of 
-javax.script (JSR-223) API and JavaScript engine that is bundled 
-with JDK 6.
-
-Scriptpad sample demonstrates how to use Javascript to use Java 
-classes and objects to perform various tasks such as to modify,
-customize Swing GUI or to connect to a running application and 
-monitor it using JMX (Java Management Extensions) API.
-
-* How to run Scriptpad?
-
-Scriptpad can be run with the following command:
-    
-    java -jar ./build/scriptpad.jar
-
-(be sure to use the correct version of java).  You can
-open/edit/save scripts using menu items under "File" menu.
-To run currently edited script, you can use "Tools->Run" menu.
-
-For example, you may enter
-
-    alert("hello, world");
-
-in the editor and run the same with "Tools->Run" menu. 
-You will see an alert box with the message "hello, world".
-
-In addition to being a simple script editor/runner, scriptpad 
-can be used to connect to a JMX MBean server ("Tools->JMX Connect" 
-menu). User can specify JMX hostname and port. After connecting, 
-user can use "monitoring and management" script functions defined 
-in "mm.js" (see below).
-
-* Scriptpad Sources
-
-com.sun.demo.scriptpad.Main class is the entry point of this
-sample. This class creates ScriptEngine and evaluates few
-JavaScript "files" -- which are stored as resources (please
-refer to src/resources/*.js). Actual code for the scriptpad's
-main functionality lives in these JavaScript files.
-
-1. conc.js
- -- simple concurrency utilities for JavaScript
-
-2. gui.js
- -- simple GUI utilities for JavaScript
-
-3. mm.js
- -- Monitoring and Management utilities for JavaScript
-
-4. scriptpad.js
- -- This creates main "notepad"-like GUI for open/edit/save
-    and run script files
-
-5. Main.js
- -- This script file can be used under "jrunscript" tool.
-    jrunscript is an experimental tool shipped with JDK (under
-    $JDK_HOME/bin directory). The scriptpad application can be
-    run by the following commands:
-
-    cd ./src/resources
-    $JDK_HOME/bin/jrunscript -f Main.js -f -
-
-
-* Extending Scriptpad:
-
-It is possible to extend scriptpad using scripts. There is a global
-object called "application". This object has 2 fields and a method.
-
-    Fields of the application object:
-
-        frame  -> JFrame of the scriptpad
-        editor -> editor pane of the scriptpad
- 
-    Method of the application object:
-
-        addTool -> adds a menu item under "Tools" menu
-
-    Example script to add "Tools->Hello" menu item:
-
-        application.addTool("Hello", 
-            function() { alert("hello, world"); });
-
-After running the above script, you can click Tools->Hello menu item
-and you'll see an alert box.
-
-Scriptpad customization may also be done by defining a file named 
-"scriptpad.js" under your home directory,. If this file is found, 
-scriptpad loads this file just after initializating everything. 
-In your initialization file, you can additional script functions 
-by "load" function.
-
-* Script Samples:
-
-On clicking the menu items under "Examples" menu, scriptpad shows 
-built-in examples in the editor. Also, there are few script samples
-under the ./src/scripts directory.
-
-* Monitoring and Management with Scriptpad:
-
-(1) Start the application with the JMX agent - here's an example of 
-    how the Java2D demo is started
-   
-      java -Dcom.sun.management.jmxremote.port=1090          \
-           -Dcom.sun.management.jmxremote.ssl=false          \
-           -Dcom.sun.management.jmxremote.authenticate=false \
-           -jar $JDK_HOME/demo/jfc/Font2DTest/Font2DTest.jar
-
-(2) Start scriptpad and click on "Tools->JMX Connect" menu.
-    In the prompt, enter "localhost:1090" to connect to the above
-    program.
-
-After connecting to a MBeanServer (using "Tools->JMX Connect"),
-you can run any script that uses functions defined in "mm.js". 
-For example, it is possible to load and run management scripts that
-are part of JConsole script shell plugin under the directory:
-
-    $JDK_HOME/demo/scripting/jconsole-plugin/src/scripts
--- a/jdk/src/sample/share/scripting/scriptpad/build.properties	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-main.dir=.
-
-src.dir=${main.dir}/src
-
-build.dir=build
-classes.dir=${build.dir}/classes
-jar=${build.dir}/scriptpad.jar
-javadoc.dir=${build.dir}/javadoc
-
-build.sysclasspath=ignore
-# E.g.: cp=lib/x.jar:lib/y.jar
-cp=
-extra.run.cp=
-
-main.class=com.sun.sample.scriptpad.Main
-
-run.cp=${cp}:${classes.dir}:${extra.run.cp}
-
-debug=true
-deprecation=false
-
-nbjdk.home=${basedir}/../../..
--- a/jdk/src/sample/share/scripting/scriptpad/build.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-
-<!-- 
-  This is ant (http://ant.apache.org) build script to build the
-  "Scriptpad" sample. Either this build.xml can be used standalone 
-  with "ant" tool or can be opened as a project with NetBeans IDE
-  (http://www.netbeans.org).
--->
-
-<project name="Scriptpad" default="jar" basedir=".">
-
-    <import file="nbproject/jdk.xml"/>
-
-    <target name="-prop-init">
-        <property file="user.build.properties"/>
-        <property file="build.properties"/>
-    </target>
-
-    <target name="-init" depends="-prop-init,-jdk-init"/>
-
-    <target name="compile" depends="-init" description="Compile main sources.">
-        <mkdir dir="${classes.dir}"/>
-        <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="${debug}" deprecation="${deprecation}">
-            <classpath path="${cp}"/>
-        </javac>
-        <copy todir="${classes.dir}">
-            <fileset dir="${src.dir}"/>
-        </copy>
-    </target>
-
-    <target name="jar" depends="compile" description="Build JAR file for main sources.">
-        <jar jarfile="${jar}" compress="true">
-            <manifest>
-                <attribute name="Main-Class" value="${main.class}"/>
-            </manifest>
-            <fileset dir="${classes.dir}"/>
-        </jar>
-    </target>
-
-    <target name="run" depends="compile" description="Run application.">
-        <fail unless="main.class">Must set property 'main.class' (e.g. in build.properties)</fail>
-        <java classname="${main.class}" fork="true" failonerror="true">
-            <classpath path="${run.cp}"/>
-        </java>
-    </target>
-
-    <target name="javadoc" depends="-init" description="Build Javadoc.">
-        <mkdir dir="${javadoc.dir}"/>
-        <javadoc destdir="${javadoc.dir}">
-            <classpath path="${cp}"/>
-            <sourcepath>
-                <pathelement location="${src.dir}"/>
-            </sourcepath>
-            <fileset dir="${src.dir}"/>
-        </javadoc>
-    </target>
-
-    <target name="clean" depends="-init" description="Clean build products.">
-        <delete dir="${build.dir}"/>
-        <delete file="${jar}"/>
-    </target>
-
-    <target name="profile">
-        <ant antfile="nbproject/netbeans-targets.xml" target="profile"/>
-    </target>
-</project>
--- a/jdk/src/sample/share/scripting/scriptpad/nbproject/file-targets.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<project basedir=".." name="scriptpad/file">
-    
-    <import file="../build.xml"/>
-    
-    <target name="compile-selected" depends="-init">
-        <fail unless="includes">Must set property 'includes'</fail>
-        <mkdir dir="${classes.dir}"/>
-        <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="${debug}" deprecation="${deprecation}" includes="${includes}">
-            <classpath path="${cp}"/>
-        </javac>
-    </target>
-    
-</project>
--- a/jdk/src/sample/share/scripting/scriptpad/nbproject/jdk.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<project name="jdk" basedir=".">
-
-    <target name="-jdk-preinit">
-        <condition property=".exe" value=".exe">
-            <os family="windows"/>
-        </condition>
-        <property name=".exe" value=""/>
-        <property name="nbjdk.javac" value="${nbjdk.home}/bin/javac${.exe}"/>
-        <property name="nbjdk.java" value="${nbjdk.home}/bin/java${.exe}"/>
-        <property name="nbjdk.javadoc" value="${nbjdk.home}/bin/javadoc${.exe}"/>
-        <property name="nbjdk.appletviewer" value="${nbjdk.home}/bin/appletviewer${.exe}"/>
-        <property name="nbjdk.bootclasspath" value="${nbjdk.home}/jre/lib/rt.jar"/>
-    </target>
-
-    <target name="-jdk-presetdef-basic" depends="-jdk-preinit" unless="nbjdk.presetdef.basic.done">
-        <macrodef name="javac-presetdef">
-            <attribute name="javacval"/>
-            <sequential>
-                <presetdef name="javac">
-                    <javac fork="yes" executable="@{javacval}"/>
-                </presetdef>
-            </sequential>
-        </macrodef>
-        <javac-presetdef javacval="${nbjdk.javac}"/>
-        <macrodef name="java-presetdef">
-            <attribute name="javaval"/>
-            <sequential>
-                <presetdef name="java">
-                    <java fork="yes" jvm="@{javaval}"/>
-                </presetdef>
-            </sequential>
-        </macrodef>
-        <java-presetdef javaval="${nbjdk.java}"/>
-        <macrodef name="javadoc-presetdef">
-            <attribute name="javadocval"/>
-            <sequential>
-                <presetdef name="javadoc">
-                    <javadoc executable="@{javadocval}"/>
-                </presetdef>
-            </sequential>
-        </macrodef>
-        <javadoc-presetdef javadocval="${nbjdk.javadoc}"/>
-        <property name="nbjdk.presetdef.basic.done" value="true"/>
-    </target>
-
-    <target name="-jdk-presetdef-nbjpdastart" depends="-jdk-preinit" unless="nbjdk.presetdef.nbjpdastart.done">
-        <macrodef name="nbjpdastart-presetdef">
-            <attribute name="bootcpval"/>
-            <sequential>
-                <presetdef name="nbjpdastart">
-                    <nbjpdastart>
-                        <bootclasspath>
-                            <path path="@{bootcpval}"/>
-                        </bootclasspath>
-                    </nbjpdastart>
-                </presetdef>
-            </sequential>
-        </macrodef>
-        <nbjpdastart-presetdef bootcpval="${nbjdk.bootclasspath}"/>
-        <property name="nbjdk.presetdef.nbjpdastart.done" value="true"/>
-    </target>
-
-    <target name="-jdk-init" depends="-jdk-preinit,-jdk-presetdef-basic"/>
-
-</project>
--- a/jdk/src/sample/share/scripting/scriptpad/nbproject/netbeans-targets.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<project basedir=".." name="scriptpad/NB">
-
-    <import file="../build.xml"/>
-    
-    <target name="debug" depends="compile,-jdk-presetdef-nbjpdastart">
-        <nbjpdastart addressproperty="jpda.address" name="scriptpad" transport="dt_socket">
-            <classpath path="${run.cp}"/>
-        </nbjpdastart>
-        <java classname="${main.class}" failonerror="true" fork="true">
-            <classpath path="${run.cp}"/>
-            <jvmarg value="-Xdebug"/>
-            <jvmarg value="-Xnoagent"/>
-            <jvmarg value="-Djava.compiler=none"/>
-            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
-        </java>
-    </target>
-    
-    <target name="debug-fix" depends="-init">
-        <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true" deprecation="${deprecation}">
-            <classpath path="${cp}"/>
-            <include name="${class}.java"/>
-        </javac>
-        <nbjpdareload>
-            <fileset dir="${classes.dir}">
-                <include name="${class}.class"/>
-            </fileset>
-        </nbjpdareload>
-    </target>
-    
-    <target name="show-javadoc" depends="javadoc">
-        <nbbrowse file="${javadoc.dir}/index.html"/>
-    </target>
-    
-    <target name="profile" depends="compile">
-        <nbprofiledirect>
-            <classpath path="${run.cp}"/>
-        </nbprofiledirect>
-        <property environment="env"/>
-        <java classname="${main.class}" fork="true" failonerror="true" dir="${profiler.session.working.dir}" jvm="${profiler.info.jvm}">
-            <classpath path="${run.cp}"/>
-            <jvmarg value="${profiler.info.jvmargs.agent}"/>
-            <jvmarg line="${profiler.info.jvmargs}"/>
-            <env key="LD_LIBRARY_PATH" path="${profiler.info.agentpath}:${env.LD_LIBRARY_PATH}"/>
-            <env key="Path" path="${profiler.info.agentpath}:${env.Path}"/>
-        </java>
-    </target>
-    
-</project>
--- a/jdk/src/sample/share/scripting/scriptpad/nbproject/project.xml	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Oracle nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<project xmlns="http://www.netbeans.org/ns/project/1">
-    <type>org.netbeans.modules.ant.freeform</type>
-    <configuration>
-        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
-            <name>Scriptpad</name>
-            <properties>
-                <property-file>user.build.properties</property-file>
-                <property-file>build.properties</property-file>
-                <property name="nbjdk.bootclasspath">${nbjdk.home}/jre/lib/rt.jar</property>
-            </properties>
-            <folders>
-                <source-folder>
-                    <label>JDK Demo</label>
-                    <location>${main.dir}</location>
-                </source-folder>
-                <source-folder>
-                    <label>Sources</label>
-                    <type>java</type>
-                    <location>${src.dir}</location>
-                </source-folder>
-                <build-folder>
-                    <location>${build.dir}</location>
-                </build-folder>
-            </folders>
-            <ide-actions>
-                <action name="build">
-                    <target>jar</target>
-                </action>
-                <action name="clean">
-                    <target>clean</target>
-                </action>
-                <action name="rebuild">
-                    <target>clean</target>
-                    <target>jar</target>
-                </action>
-                <action name="run">
-                    <target>run</target>
-                </action>
-                <action name="javadoc">
-                    <script>nbproject/netbeans-targets.xml</script>
-                    <target>show-javadoc</target>
-                </action>
-                <action name="debug">
-                    <script>nbproject/netbeans-targets.xml</script>
-                    <target>debug</target>
-                </action>
-                <action name="compile.single">
-                    <script>nbproject/file-targets.xml</script>
-                    <target>compile-selected</target>
-                    <context>
-                        <property>includes</property>
-                        <folder>${src.dir}</folder>
-                        <pattern>\.java$</pattern>
-                        <format>relative-path</format>
-                        <arity>
-                            <separated-files>,</separated-files>
-                        </arity>
-                    </context>
-                </action>
-                <action name="run.single">
-                    <target>run</target>
-                    <context>
-                        <property>main.class</property>
-                        <folder>${src.dir}</folder>
-                        <pattern>\.java$</pattern>
-                        <format>java-name</format>
-                        <arity>
-                            <one-file-only/>
-                        </arity>
-                    </context>
-                </action>
-                <action name="debug.single">
-                    <script>nbproject/netbeans-targets.xml</script>
-                    <target>debug</target>
-                    <context>
-                        <property>main.class</property>
-                        <folder>${src.dir}</folder>
-                        <pattern>\.java$</pattern>
-                        <format>java-name</format>
-                        <arity>
-                            <one-file-only/>
-                        </arity>
-                    </context>
-                </action>
-                <action name="debug.fix">
-                    <script>nbproject/netbeans-targets.xml</script>
-                    <target>debug-fix</target>
-                    <context>
-                        <property>class</property>
-                        <folder>${src.dir}</folder>
-                        <pattern>\.java$</pattern>
-                        <format>relative-path-noext</format>
-                        <arity>
-                            <one-file-only/>
-                        </arity>
-                    </context>
-                </action>
-            </ide-actions>
-            <export>
-                <type>jar</type>
-                <location>${jar}</location>
-                <build-target>jar</build-target>
-                <clean-target>clean</clean-target>
-            </export>
-            <view>
-                <items>
-                    <source-folder style="packages">
-                        <label>Sources</label>
-                        <location>${src.dir}</location>
-                    </source-folder>
-                    <source-file>
-                        <location>${main.dir}/README.txt</location>
-                    </source-file>
-                </items>
-                <context-menu>
-                    <ide-action name="build"/>
-                    <ide-action name="rebuild"/>
-                    <ide-action name="clean"/>
-                    <ide-action name="javadoc"/>
-                    <separator/>
-                    <ide-action name="run"/>
-                    <ide-action name="debug"/>
-                </context-menu>
-            </view>
-            <subprojects/>
-        </general-data>
-        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
-            <compilation-unit>
-                <package-root>${src.dir}</package-root>
-                <classpath mode="compile">${cp}</classpath>
-                <classpath mode="execute">${run.cp}</classpath>
-                <classpath mode="boot">${nbjdk.bootclasspath}</classpath>
-                <built-to>${classes.dir}</built-to>
-                <built-to>${jar}</built-to>
-                <javadoc-built-to>${javadoc.dir}</javadoc-built-to>
-                <source-level>1.5</source-level>
-            </compilation-unit>
-        </java-data>
-    </configuration>
-</project>
--- a/jdk/src/sample/share/scripting/scriptpad/src/META-INF/manifest.mf	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-Main-Class: com.sun.sample.scriptpad.Main
-
--- a/jdk/src/sample/share/scripting/scriptpad/src/com/sun/sample/scriptpad/Main.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.sample.scriptpad;
-
-import javax.script.*;
-import java.io.*;
-
-/**
- * This is the entry point of "Scriptpad" sample. This class creates
- * ScriptEngine and evaluates few JavaScript "files" -- which are stored
- * as resources (please refer to src/resources/*.js). Actual code for the
- * scriptpad's main functionality lives in these JavaScript files.
- */
-public class Main {
-    public static void main(String[] args) throws Exception {
-
-        // create a ScriptEngineManager
-        ScriptEngineManager m = new ScriptEngineManager();
-        // get an instance of JavaScript script engine
-        ScriptEngine engine = m.getEngineByName("js");
-
-        // expose the current script engine as a global variable
-        engine.put("engine", engine);
-
-        // evaluate few scripts that are bundled in "resources"
-        eval(engine, "conc.js");
-        eval(engine, "gui.js");
-        eval(engine, "scriptpad.js");
-        eval(engine, "mm.js");
-    }
-
-    private static void eval(ScriptEngine engine, String name)
-                            throws Exception {
-        /*
-         * This class is compiled into a jar file. The jar file
-         * contains few scripts under /resources URL.
-         */
-        InputStream is = Main.class.getResourceAsStream("/resources/" + name);
-        // current script file name for better error messages
-        engine.put(ScriptEngine.FILENAME, name);
-        // evaluate the script in the InputStream
-        engine.eval(new InputStreamReader(is));
-    }
-}
--- a/jdk/src/sample/share/scripting/scriptpad/src/resources/Main.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * This script can be loaded in jrunscript to start scriptpad.
- *
- *    jrunscript -f Main.js -f -
- */
-
-load("conc.js");
-load("gui.js");
-load("scriptpad.js");
-load("mm.js");
--- a/jdk/src/sample/share/scripting/scriptpad/src/resources/conc.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,329 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * Concurrency utilities for JavaScript. These are based on
- * java.lang and java.util.concurrent API. The following functions
- * provide a simpler API for scripts. Instead of directly using java.lang
- * and java.util.concurrent classes, scripts can use functions and
- * objects exported from here.
- */
-
-// shortcut for j.u.c lock classes
-var Lock = java.util.concurrent.locks.ReentrantLock;
-var RWLock = java.util.concurrent.locks.ReentrantReadWriteLock;
-
-// check if there is a build in sync function, define one if missing
-if (typeof sync === "undefined") {
-    var sync = function(func, obj) {
-        if (arguments.length < 1 || arguments.length > 2 ) {
-            throw "sync(function [,object]) parameter count mismatch";
-        }
-
-        var syncobj = (arguments.length == 2 ? obj : this);
-
-        if (!syncobj._syncLock) {
-            syncobj._syncLock = new Lock();
-        }
-
-        return function() {
-            syncobj._syncLock.lock();
-            try {
-                func.apply(null, arguments);
-            } finally {
-                syncobj._syncLock.unlock();
-            }
-        };
-    };
-    sync.docString = "synchronize a function, optionally on an object";
-}
-
-/**
- * Wrapper for java.lang.Object.wait
- *
- * can be called only within a sync method
- */
-function wait(object) {
-    var objClazz = java.lang.Class.forName('java.lang.Object');
-    var waitMethod = objClazz.getMethod('wait', null);
-    waitMethod.invoke(object, null);
-}
-wait.docString = "convenient wrapper for java.lang.Object.wait method";
-
-/**
- * Wrapper for java.lang.Object.notify
- *
- * can be called only within a sync method
- */
-function notify(object) {
-    var objClazz = java.lang.Class.forName('java.lang.Object');
-    var notifyMethod = objClazz.getMethod('notify', null);
-    notifyMethod.invoke(object, null);
-}
-notify.docString = "convenient wrapper for java.lang.Object.notify method";
-
-/**
- * Wrapper for java.lang.Object.notifyAll
- *
- * can be called only within a sync method
- */
-function notifyAll(object)  {
-    var objClazz = java.lang.Class.forName('java.lang.Object');
-    var notifyAllMethod = objClazz.getMethod('notifyAll', null);
-    notifyAllMethod.invoke(object, null);
-}
-notifyAll.docString = "convenient wrapper for java.lang.Object.notifyAll method";
-
-/**
- * Creates a java.lang.Runnable from a given script
- * function.
- */
-Function.prototype.runnable = function() {
-    var args = arguments;
-    var func = this;
-    return new java.lang.Runnable() {
-        run: function() {
-            func.apply(null, args);
-        }
-    }
-};
-
-/**
- * Executes the function on a new Java Thread.
- */
-Function.prototype.thread = function() {
-    var t = new java.lang.Thread(this.runnable.apply(this, arguments));
-    t.start();
-    return t;
-};
-
-/**
- * Executes the function on a new Java daemon Thread.
- */
-Function.prototype.daemon = function() {
-    var t = new java.lang.Thread(this.runnable.apply(this, arguments));
-    t.setDaemon(true);
-    t.start();
-    return t;
-};
-
-/**
- * Creates a java.util.concurrent.Callable from a given script
- * function.
- */
-Function.prototype.callable = function() {
-    var args = arguments;
-    var func = this;
-    return new java.util.concurrent.Callable() {
-          call: function() { return func.apply(null, args); }
-    }
-};
-
-/**
- * Registers the script function so that it will be called exit.
- */
-Function.prototype.atexit = function () {
-    var args = arguments;
-    java.lang.Runtime.getRuntime().addShutdownHook(
-         new java.lang.Thread(this.runnable.apply(this, args)));
-};
-
-/**
- * Executes the function asynchronously.
- *
- * @return a java.util.concurrent.FutureTask
- */
-Function.prototype.future = (function() {
-    // default executor for future
-    var juc = java.util.concurrent;
-    var theExecutor = juc.Executors.newSingleThreadExecutor();
-    // clean-up the default executor at exit
-    (function() { theExecutor.shutdown(); }).atexit();
-    return function() {
-        return theExecutor.submit(this.callable.apply(this, arguments));
-    };
-})();
-
-/**
- * Executes a function after acquiring given lock. On return,
- * (normal or exceptional), lock is released.
- *
- * @param lock lock that is locked and unlocked
- */
-Function.prototype.sync = function (lock) {
-    if (arguments.length == 0) {
-        throw "lock is missing";
-    }
-    var res = new Array(arguments.length - 1);
-    for (var i = 0; i < res.length; i++) {
-        res[i] = arguments[i + 1];
-    }
-    lock.lock();
-    try {
-        this.apply(null, res);
-    } finally {
-        lock.unlock();
-    }
-};
-
-/**
- * Causes current thread to sleep for specified
- * number of milliseconds
- *
- * @param interval in milliseconds
- */
-function sleep(interval) {
-    java.lang.Thread.sleep(interval);
-}
-sleep.docString = "wrapper for java.lang.Thread.sleep method";
-
-/**
- * Schedules a task to be executed once in N milliseconds specified.
- *
- * @param callback function or expression to evaluate
- * @param interval in milliseconds to sleep
- * @return timeout ID (which is nothing but Thread instance)
- */
-function setTimeout(callback, interval) {
-    if (! (callback instanceof Function)) {
-        callback = new Function(callback);
-    }
-
-    // start a new thread that sleeps given time
-    // and calls callback in an infinite loop
-    return (function() {
-         try {
-             sleep(interval);
-         } catch (x) { }
-         callback();
-    }).daemon();
-}
-setTimeout.docString = "calls given callback once after specified interval";
-
-/**
- * Cancels a timeout set earlier.
- * @param tid timeout ID returned from setTimeout
- */
-function clearTimeout(tid) {
-    // we just interrupt the timer thread
-    tid.interrupt();
-}
-clearTimeout.docString = "interrupt a setTimeout timer";
-
-/**
- * Schedules a task to be executed once in
- * every N milliseconds specified.
- *
- * @param callback function or expression to evaluate
- * @param interval in milliseconds to sleep
- * @return timeout ID (which is nothing but Thread instance)
- */
-function setInterval(callback, interval) {
-    if (! (callback instanceof Function)) {
-        callback = new Function(callback);
-    }
-
-    // start a new thread that sleeps given time
-    // and calls callback in an infinite loop
-    return (function() {
-         while (true) {
-             try {
-                 sleep(interval);
-             } catch (x) {
-                 break;
-             }
-             callback();
-         }
-    }).daemon();
-}
-setInterval.docString = "calls given callback every specified interval";
-
-/**
- * Cancels a timeout set earlier.
- * @param tid timeout ID returned from setTimeout
- */
-function clearInterval(tid) {
-    // we just interrupt the timer thread
-    tid.interrupt();
-}
-clearInterval.docString = "interrupt a setInterval timer";
-
-/**
- * Simple access to thread local storage.
- *
- * Script sample:
- *
- *  __thread.x = 44;
- *  function f() {
- *      __thread.x = 'hello';
- *      print(__thread.x);
- *  }
- *  f.thread();       // prints 'hello'
- * print(__thread.x); // prints 44 in main thread
- */
-var __thread = (function () {
-    var map = new Object();
-    return new JSAdapter({
-        __has__: function(name) {
-            return map[name] != undefined;
-        },
-        __get__: function(name) {
-            if (map[name] != undefined) {
-                return map[name].get();
-            } else {
-                return undefined;
-            }
-        },
-        __put__: sync(function(name, value) {
-            if (map[name] == undefined) {
-                var tmp = new java.lang.ThreadLocal();
-                tmp.set(value);
-                map[name] = tmp;
-            } else {
-                map[name].set(value);
-            }
-        }),
-        __delete__: function(name) {
-            if (map[name] != undefined) {
-                map[name].set(null);
-            }
-        }
-    });
-})();
-
--- a/jdk/src/sample/share/scripting/scriptpad/src/resources/gui.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,292 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * Few user interface utilities.
- */
-
-if (this.window === undefined) {
-    this.window = null;
-}
-
-/**
- * Swing invokeLater - invokes given function in AWT event thread
- */
-Function.prototype.invokeLater = function() {
-    var SwingUtilities = javax.swing.SwingUtilities;
-    var func = this;
-    var args = arguments;
-    SwingUtilities.invokeLater(new java.lang.Runnable() {
-                       run: function() {
-                           func.apply(func, args);
-                       }
-                  });
-};
-
-/**
- * Swing invokeAndWait - invokes given function in AWT event thread
- * and waits for it's completion
- */
-Function.prototype.invokeAndWait = function() {
-    var SwingUtilities = javax.swing.SwingUtilities;
-    var func = this;
-    var args = arguments;
-    SwingUtilities.invokeAndWait(new java.lang.Runnable() {
-                       run: function() {
-                           func.apply(func, args);
-                       }
-                  });
-};
-
-/**
- * Am I running in AWT event dispatcher thread?
- */
-function isEventThread() {
-    var SwingUtilities = javax.swing.SwingUtilities;
-    return SwingUtilities.isEventDispatchThread();
-}
-isEventThread.docString = "returns whether the current thread is GUI thread";
-
-/**
- * Opens a file dialog box
- *
- * @param curDir current directory [optional]
- * @param save flag tells whether this is a save dialog or not
- * @return selected file or else null
- */
-function fileDialog(curDir, save) {
-    var result;
-    function _fileDialog() {
-        if (curDir == undefined) {
-            curDir = new java.io.File(".");
-        }
-
-        var JFileChooser = javax.swing.JFileChooser;
-        var dialog = new JFileChooser(curDir);
-        var res = save ? dialog.showSaveDialog(window):
-            dialog.showOpenDialog(window);
-
-        if (res == JFileChooser.APPROVE_OPTION) {
-           result = dialog.getSelectedFile();
-        } else {
-           result = null;
-        }
-    }
-
-    if (isEventThread()) {
-        _fileDialog();
-    } else {
-        _fileDialog.invokeAndWait();
-    }
-
-    return result;
-}
-fileDialog.docString = "show a file dialog box";
-
-/**
- * Opens a color chooser dialog box
- *
- * @param title of the dialog box [optional]
- * @param color default color [optional]
- * @return chosen color or default color
- */
-function colorDialog(title, color) {
-    var result;
-
-    function _colorDialog() {
-        if (title == undefined) {
-            title = "Choose Color";
-        }
-
-        if (color == undefined) {
-            color = java.awt.Color.BLACK;
-        }
-
-        var chooser = new javax.swing.JColorChooser();
-        var res = chooser.showDialog(window, title, color);
-        result = res ? res : color;
-    }
-
-    if (isEventThread()) {
-        _colorDialog();
-    } else {
-        _colorDialog.invokeAndWait();
-    }
-
-    return result;
-}
-colorDialog.docString = "shows a color chooser dialog box";
-
-/**
- * Shows a message box
- *
- * @param msg message to be shown
- * @param title title of message box [optional]
- * @param msgType type of message box [constants in JOptionPane]
- */
-function msgBox(msg, title, msgType) {
-    function _msgBox() {
-        var JOptionPane = javax.swing.JOptionPane;
-        if (msg === undefined) msg = "undefined";
-        if (msg === null) msg = "null";
-        if (title == undefined) title = msg;
-        if (msgType == undefined) msgType = JOptionPane.INFORMATION_MESSAGE;
-        JOptionPane.showMessageDialog(window, msg, title, msgType);
-    }
-
-    if (isEventThread()) {
-        _msgBox();
-    } else {
-        _msgBox.invokeAndWait();
-    }
-}
-msgBox.docString = "shows MessageBox to the user";
-
-/**
- * Shows an information alert box
- *
- * @param msg message to be shown
- * @param title title of message box [optional]
- */
-function alert(msg, title) {
-    var JOptionPane = javax.swing.JOptionPane;
-    msgBox(msg, title, JOptionPane.INFORMATION_MESSAGE);
-}
-alert.docString = "shows an alert message box to the user";
-
-/**
- * Shows an error alert box
- *
- * @param msg message to be shown
- * @param title title of message box [optional]
- */
-function error(msg, title) {
-    var JOptionPane = javax.swing.JOptionPane;
-    msgBox(msg, title, JOptionPane.ERROR_MESSAGE);
-}
-error.docString = "shows an error message box to the user";
-
-/**
- * Shows a warning alert box
- *
- * @param msg message to be shown
- * @param title title of message box [optional]
- */
-function warn(msg, title) {
-    var JOptionPane = javax.swing.JOptionPane;
-    msgBox(msg, title, JOptionPane.WARNING_MESSAGE);
-}
-warn.docString = "shows a warning message box to the user";
-
-/**
- * Shows a prompt dialog box
- *
- * @param question question to be asked
- * @param answer default answer suggested [optional]
- * @return answer given by user
- */
-function prompt(question, answer) {
-    var result;
-    function _prompt() {
-        var JOptionPane = javax.swing.JOptionPane;
-        if (answer == undefined) answer = "";
-        result = JOptionPane.showInputDialog(window, question, answer);
-    }
-
-    if (isEventThread()) {
-        _prompt();
-    } else {
-        _prompt.invokeAndWait();
-    }
-
-    return result;
-}
-prompt.docString = "shows a prompt box to the user and returns the answer";
-
-/**
- * Shows a confirmation dialog box
- *
- * @param msg message to be shown
- * @param title title of message box [optional]
- * @return boolean (yes->true, no->false)
- */
-function confirm(msg, title) {
-    var result;
-    var JOptionPane = javax.swing.JOptionPane;
-
-    function _confirm() {
-        if (title == undefined) title = msg;
-        var optionType = JOptionPane.YES_NO_OPTION;
-        result = JOptionPane.showConfirmDialog(window, msg, title, optionType);
-    }
-
-    if (isEventThread()) {
-        _confirm();
-    } else {
-        _confirm.invokeAndWait();
-    }
-
-    return result == JOptionPane.YES_OPTION;
-}
-confirm.docString = "shows a confirmation message box to the user";
-
-/**
- * Exit the process after confirmation from user
- *
- * @param exitCode return code to OS [optional]
- */
-function exit(exitCode) {
-    if (exitCode == undefined) exitCode = 0;
-    if (confirm("Do you really want to exit?")) {
-        java.lang.System.exit(exitCode);
-    }
-}
-exit.docString = "exits jconsole";
-
-// synonym to exit
-var quit = exit;
-
-// if echo function is not defined, define it as synonym
-// for println function
-if (this.echo == undefined) {
-    function echo(str) {
-        println(str);
-    }
-}
-
--- a/jdk/src/sample/share/scripting/scriptpad/src/resources/mm.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,339 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * This is a collection of utilities for Monitoring
- * and management API.
- *
- * File dependency:
- *    conc.js -> for concurrency utilities
- */
-
-// At any time, we maintain atmost one MBeanServer
-// connection. And so, we store the same as a global
-// variable.
-var mmConnection = null;
-
-function jmxConnect(hostport) {
-    if (mmConnection != null) {
-        // close the existing connection
-        try {
-            mmConnection.close();
-        } catch (e) {
-        }
-    }
-
-    var JMXServiceURL = javax.management.remote.JMXServiceURL;
-    var JMXConnectorFactory = javax.management.remote.JMXConnectorFactory;
-
-    var urlPath = "/jndi/rmi://" + hostport + "/jmxrmi";
-    var url = new JMXServiceURL("rmi", "", 0, urlPath);
-    var jmxc = JMXConnectorFactory.connect(url);
-    // note that the "mmConnection" is a global variable!
-    mmConnection = jmxc.getMBeanServerConnection();
-}
-jmxConnect.docString = "connects to the given host, port (specified as name:port)";
-
-function mbeanConnection() {
-    if (mmConnection == null) {
-        throw "Not connected to MBeanServer yet!";
-    }
-
-    return mmConnection;
-}
-mbeanConnection.docString = "returns the current MBeanServer connection";
-
-/**
- * Returns a platform MXBean proxy for given MXBean name and interface class
- */
-function newPlatformMXBeanProxy(name, intf) {
-    var factory = java.lang.management.ManagementFactory;
-    return factory.newPlatformMXBeanProxy(mbeanConnection(), name, intf);
-}
-newPlatformMXBeanProxy.docString = "returns a proxy for a platform MXBean";
-
-/**
- * Wraps a string to ObjectName if needed.
- */
-function objectName(objName) {
-    var ObjectName = Packages.javax.management.ObjectName;
-    if (objName instanceof ObjectName) {
-        return objName;
-    } else {
-        return new ObjectName(objName);
-    }
-}
-objectName.docString = "creates JMX ObjectName for a given String";
-
-/**
- * Creates a new (M&M) Attribute object
- *
- * @param name name of the attribute
- * @param value value of the attribute
- */
-function attribute(name, value) {
-    var Attribute = Packages.javax.management.Attribute;
-    return new Attribute(name, value);
-}
-attribute.docString = "returns a new JMX Attribute using name and value given";
-
-/**
- * Returns MBeanInfo for given ObjectName. Strings are accepted.
- */
-function mbeanInfo(objName) {
-    objName = objectName(objName);
-    return mbeanConnection().getMBeanInfo(objName);
-}
-mbeanInfo.docString = "returns MBeanInfo of a given ObjectName";
-
-/**
- * Returns ObjectInstance for a given ObjectName.
- */
-function objectInstance(objName) {
-    objName = objectName(objName);
-    return mbeanConnection().objectInstance(objectName);
-}
-objectInstance.docString = "returns ObjectInstance for a given ObjectName";
-
-/**
- * Queries with given ObjectName and QueryExp.
- * QueryExp may be null.
- *
- * @return set of ObjectNames.
- */
-function queryNames(objName, query) {
-    objName = objectName(objName);
-    if (query == undefined) query = null;
-    return mbeanConnection().queryNames(objName, query);
-}
-queryNames.docString = "returns QueryNames using given ObjectName and optional query";
-
-/**
- * Queries with given ObjectName and QueryExp.
- * QueryExp may be null.
- *
- * @return set of ObjectInstances.
- */
-function queryMBeans(objName, query) {
-    objName = objectName(objName);
-    if (query == undefined) query = null;
-    return mbeanConnection().queryMBeans(objName, query);
-}
-queryMBeans.docString = "return MBeans using given ObjectName and optional query";
-
-// wraps a script array as java.lang.Object[]
-function objectArray(array) {
-    return Java.to(array, "java.lang.Object[]");
-}
-
-// wraps a script (string) array as java.lang.String[]
-function stringArray(array) {
-    return Java.to(array, "java.lang.String[]");
-}
-
-// script array to Java List
-function toAttrList(array) {
-    var AttributeList = Packages.javax.management.AttributeList;
-    if (array instanceof AttributeList) {
-        return array;
-    }
-    var list = new AttributeList(array.length);
-    for (var index = 0; index < array.length; index++) {
-        list.add(array[index]);
-    }
-    return list;
-}
-
-// Java Collection (Iterable) to script array
-function toArray(collection) {
-    if (collection instanceof Array) {
-        return collection;
-    }
-    var itr = collection.iterator();
-    var array = new Array();
-    while (itr.hasNext()) {
-        array[array.length] = itr.next();
-    }
-    return array;
-}
-
-// gets MBean attributes
-function getMBeanAttributes(objName, attributeNames) {
-    objName = objectName(objName);
-    return mbeanConnection().getAttributes(objName,stringArray(attributeNames));
-}
-getMBeanAttributes.docString = "returns specified Attributes of given ObjectName";
-
-// gets MBean attribute
-function getMBeanAttribute(objName, attrName) {
-    objName = objectName(objName);
-    return mbeanConnection().getAttribute(objName, attrName);
-}
-getMBeanAttribute.docString = "returns a single Attribute of given ObjectName";
-
-// sets MBean attributes
-function setMBeanAttributes(objName, attrList) {
-    objName = objectName(objName);
-    attrList = toAttrList(attrList);
-    return mbeanConnection().setAttributes(objName, attrList);
-}
-setMBeanAttributes.docString = "sets specified Attributes of given ObjectName";
-
-// sets MBean attribute
-function setMBeanAttribute(objName, attrName, attrValue) {
-    var Attribute = Packages.javax.management.Attribute;
-    objName = objectName(objName);
-    mbeanConnection().setAttribute(objName, new Attribute(attrName, attrValue));
-}
-setMBeanAttribute.docString = "sets a single Attribute of given ObjectName";
-
-// invokes an operation on given MBean
-function invokeMBean(objName, operation, params, signature) {
-    objName = objectName(objName);
-    params = objectArray(params);
-    signature = stringArray(signature);
-    return mbeanConnection().invoke(objName, operation, params, signature);
-}
-invokeMBean.docString = "invokes MBean operation on given ObjectName";
-
-/**
- * Wraps a MBean specified by ObjectName as a convenient
- * script object -- so that setting/getting MBean attributes
- * and invoking MBean method can be done with natural syntax.
- *
- * @param objName ObjectName of the MBean
- * @param async asynchornous mode [optional, default is false]
- * @return script wrapper for MBean
- *
- * With async mode, all field, operation access is async. Results
- * will be of type FutureTask. When you need value, call 'get' on it.
- */
-function mbean(objName, async) {
-    var index;
-    objName = objectName(objName);
-    var info = mbeanInfo(objName);
-    var attrs = info.attributes;
-    var attrMap = new Object;
-    for (index in attrs) {
-        attrMap[attrs[index].name] = attrs[index];
-    }
-    var opers = info.operations;
-    var operMap = new Object;
-    for (index in opers) {
-        operMap[opers[index].name] = opers[index];
-    }
-
-    function isAttribute(name) {
-        return name in attrMap;
-    }
-
-    function isOperation(name) {
-        return name in operMap;
-    }
-
-    return new JSAdapter() {
-        __has__: function (name) {
-            return isAttribute(name) || isOperation(name);
-        },
-        __get__: function (name) {
-            if (isAttribute(name)) {
-                if (async) {
-                    return getMBeanAttribute.future(objName, name); 
-                } else {
-                    return getMBeanAttribute(objName, name); 
-                }
-            } else {
-                return undefined;
-            }
-        },
-        __call__: function(name) {
-            if (isOperation(name)) {
-                var oper = operMap[name];
-
-                var params = [];
-                for (var j = 1; j < arguments.length; j++) {
-                    params[j-1]= arguments[j];
-                }
-
-                var sigs = oper.signature;
-
-                var sigNames = new Array(sigs.length);
-                for (var index in sigs) {
-                    sigNames[index] = sigs[index].getType();
-                }
-
-                if (async) {
-                    return invokeMBean.future(objName, name, params, sigNames);
-                } else {
-                    return invokeMBean(objName, name, params, sigNames);
-                }
-            } else {
-                return undefined;
-            }
-        },
-        __put__: function (name, value) {
-            if (isAttribute(name)) {
-                if (async) {
-                    setMBeanAttribute.future(objName, name, value);
-                } else {
-                    setMBeanAttribute(objName, name, value);
-                }
-            } else {
-                return undefined;
-            }
-        }
-    };
-}
-mbean.docString = "returns a conveninent script wrapper for a MBean of given ObjectName";
-
-if (this.application != undefined) {
-    this.application.addTool("JMX Connect",
-        // connect to a JMX MBean Server
-        function () {
-            var url = prompt("Connect to JMX server (host:port)");
-            if (url != null) {
-                try {
-                    jmxConnect(url);
-                    alert("connected!");
-                } catch (e) {
-                    error(e, "Can not connect to " + url);
-                }
-            }
-        });
-}
--- a/jdk/src/sample/share/scripting/scriptpad/src/resources/scriptpad.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,662 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * This script creates a simple Notepad-like interface, which
- * serves as a simple script editor, runner.
- *
- * File dependency:
- *
- *    gui.js -> for basic GUI functions
- */
-
-/*
- * globalThis is used for actionHelpGlobals() and showFrame().
- */
-var globalThis = this;
-
-/*
- * JavaImporter helps in avoiding pollution of JavaScript
- * global namespace. We can import multiple Java packages
- * with this and use the JavaImporter object with "with"
- * statement.
- */
-var guiPkgs = new JavaImporter(java.awt, java.awt.event,
-                               javax.swing, javax.swing.undo,
-                               javax.swing.event, javax.swing.text);
-
-// main entry point of the scriptpad application
-var main = function() {
-    function createEditor() {
-        var c = new guiPkgs.JTextArea();
-        c.setDragEnabled(true);
-        c.setFont(new guiPkgs.Font("monospaced", guiPkgs.Font.PLAIN, 12));
-        return c;
-    }
-
-    /*const*/ var titleSuffix = "- Scriptpad";
-    /*const*/ var defaultTitle = "Untitled" + titleSuffix;
-
-    // Scriptpad's main frame
-    var frame;
-    // Scriptpad's main editor
-    var editor;
-
-    // To track the current file name
-    var curFileName = null;
-
-    // To track whether the current document
-    // has been modified or not
-    var docChanged = false;
-
-    // check and alert user for unsaved
-    // but modified document
-    function checkDocChanged() {
-        if (docChanged) {
-            // ignore zero-content untitled document
-            if (curFileName == null &&
-                editor.document.length == 0) {
-                return;
-            }
-
-            if (confirm("Do you want to save the changes?",
-                        "The document has changed")) {
-                actionSave();
-            }
-        }
-    }
-
-    // set a document listener to track
-    // whether that is modified or not
-    function setDocListener() {
-        var doc = editor.getDocument();
-        docChanged = false;
-        doc.addDocumentListener( new guiPkgs.DocumentListener() {
-                                     equals: function(o) {
-                                         return this === o; },
-                                     toString: function() {
-                                         return "doc listener"; },
-                                     changeUpdate: function() {
-                                         docChanged = true; },
-                                     insertUpdate: function() {
-                                         docChanged = true; },
-                                     removeUpdate: function() {
-                                         docChanged = true; }
-                                 });
-    }
-
-    // menu action functions
-
-    // "File" menu
-
-    // create a "new" document
-    function actionNew() {
-        checkDocChanged();
-        curFileName = null;
-        editor.setDocument(new guiPkgs.PlainDocument());
-        setDocListener();
-        frame.setTitle(defaultTitle);
-        editor.revalidate();
-    }
-
-    // open an existing file
-    function actionOpen() {
-        checkDocChanged();
-        var f = fileDialog();
-        if (f == null) {
-            return;
-        }
-
-        if (f.isFile() && f.canRead()) {
-            frame.setTitle(f.getName() + titleSuffix);
-            editor.setDocument(new guiPkgs.PlainDocument());
-            var progress = new guiPkgs.JProgressBar();
-            progress.setMinimum(0);
-            progress.setMaximum(f.length());
-            var doc = editor.getDocument();
-            var inp = new java.io.FileReader(f);
-            var buff = java.lang.reflect.Array.newInstance(
-                java.lang.Character.TYPE, 4096);
-            var nch;
-            while ((nch = inp.read(buff, 0, buff.length)) != -1) {
-                doc.insertString(doc.getLength(),
-                                 new java.lang.String(buff, 0, nch), null);
-                progress.setValue(progress.getValue() + nch);
-            }
-            inp.close();
-            curFileName = f.getAbsolutePath();
-            setDocListener();
-        } else {
-            error("Can not open file: " + f,
-                  "Error opening file: " + f);
-        }
-    }
-
-    // open script from a URL
-    function actionOpenURL() {
-        checkDocChanged();
-        var url = prompt("Address:");
-        if (url == null) {
-            return;
-        }
-
-        try {
-            var u = new java.net.URL(url);
-            editor.setDocument(new guiPkgs.PlainDocument());
-            frame.setTitle(url + titleSuffix);
-            var progress = new guiPkgs.JProgressBar();
-            progress.setMinimum(0);
-            progress.setIndeterminate(true);
-            var doc = editor.getDocument();
-            var inp = new java.io.InputStreamReader(u.openStream());
-            var buff = java.lang.reflect.Array.newInstance(
-                java.lang.Character.TYPE, 4096);
-            var nch;
-            while ((nch = inp.read(buff, 0, buff.length)) != -1) {
-                doc.insertString(doc.getLength(),
-                                 new java.lang.String(buff, 0, nch), null);
-                progress.setValue(progress.getValue() + nch);
-            }
-            curFileName = null;
-            setDocListener();
-        } catch (e) {
-            error("Error opening URL: " + e,
-                  "Can not open URL: " + url);
-        }
-    }
-
-    // factored out "save" function used by
-    // save, save as menu actions
-    function save(file) {
-        var doc = editor.getDocument();
-        frame.setTitle(file.getName() + titleSuffix);
-        curFileName = file;
-        var progress = new guiPkgs.JProgressBar();
-        progress.setMinimum(0);
-        progress.setMaximum(file.length());
-        var out = new java.io.FileWriter(file);
-        var text = new guiPkgs.Segment();
-        text.setPartialReturn(true);
-        var charsLeft = doc.getLength();
-        var offset = 0;
-        var min;
-
-        while (charsLeft > 0) {
-            doc.getText(offset, Math.min(4096, charsLeft), text);
-            out.write(text.array, text.offset, text.count);
-            charsLeft -= text.count;
-            offset += text.count;
-            progress.setValue(offset);
-            java.lang.Thread.sleep(10);
-        }
-
-        out.flush();
-        out.close();
-        docChanged = false;
-    }
-
-    // file-save as menu
-    function actionSaveAs() {
-        var ret = fileDialog(null, true);
-        if (ret == null) {
-            return;
-        }
-        save(ret);
-    }
-
-    // file-save menu
-    function actionSave() {
-        if (curFileName) {
-            save(new java.io.File(curFileName));
-        } else {
-            actionSaveAs();
-        }
-    }
-
-    // exit from scriptpad
-    function actionExit() {
-        checkDocChanged();
-        java.lang.System.exit(0);
-    }
-
-    // "Edit" menu
-
-    // cut the currently selected text
-    function actionCut() {
-        editor.cut();
-    }
-
-    // copy the currently selected text to clipboard
-    function actionCopy() {
-        editor.copy();
-    }
-
-    // paste clipboard content to document
-    function actionPaste() {
-        editor.paste();
-    }
-
-    // select all the text in editor
-    function actionSelectAll() {
-        editor.selectAll();
-    }
-
-    // "Tools" menu
-
-    // run the current document as JavaScript
-    function actionRun() {
-        var doc = editor.getDocument();
-        var script = doc.getText(0, doc.getLength());
-        var oldFile = engine.get(javax.script.ScriptEngine.FILENAME);
-        try {
-            if (engine == undefined) {
-                var m = new javax.script.ScriptEngineManager();
-                engine = m.getEngineByName("nashorn");
-            }
-            engine.put(javax.script.ScriptEngine.FILENAME, frame.title);
-            engine.eval(script, context);
-        } catch (e) {
-            error(e, "Script Error");
-            e.printStackTrace();
-        } finally {
-            engine.put(javax.script.ScriptEngine.FILENAME, oldFile);
-        }
-    }
-
-    // "Examples" menu
-
-    // show given script as new document
-    function showScript(title, str) {
-        actionNew();
-        frame.setTitle("Example - " + title + titleSuffix);
-        var doc = editor.document;
-        doc.insertString(0, str, null);
-    }
-
-    // "hello world"
-    function actionHello() {
-        showScript(actionEval.title,
-                   "alert('Hello, world');");
-    }
-    actionHello.title = "Hello, World";
-
-    // eval the "hello world"!
-    function actionEval() {
-        showScript(actionEval.title,
-                   "eval(\"alert('Hello, world')\");");
-    }
-    actionEval.title = "Eval";
-
-    // show how to access Java static methods
-    function actionJavaStatic() {
-        showScript(arguments.callee.title,
-                   "// Just use Java syntax\n" +
-                   "var props = java.lang.System.getProperties();\n" +
-                   "alert(props.get('os.name'));");
-    }
-    actionJavaStatic.title = "Java Static Calls";
-
-    // show how to access Java classes, methods
-    function actionJavaAccess() {
-        showScript(arguments.callee.title,
-                   "// just use new JavaClass();\n" +
-                   "var fr = new javax.swing.JFrame();\n" +
-                   "// call all public methods as in Java\n" +
-                   "fr.setTitle('hello');\n" +
-                   "fr.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\n" +
-                   "fr.setSize(200, 200);\n" +
-                   "fr.setVisible(true);");
-    }
-    actionJavaAccess.title = "Java Object Access";
-
-    // show how to use Java bean conventions
-    function actionJavaBean() {
-        showScript(arguments.callee.title,
-                   "var fr = new javax.swing.JFrame();\n" +
-                   "fr.setSize(200, 200);\n" +
-                   "// access public get/set methods as fields\n" +
-                   "fr.defaultCloseOperation = javax.swing.WindowConstants.DISPOSE_ON_CLOSE;\n" +
-                   "fr.title = 'hello';\n" +
-                   "fr.visible = true;");
-    }
-    actionJavaBean.title = "Java Beans";
-
-    // show how to implement Java interface
-    function actionJavaInterface() {
-        showScript(arguments.callee.title,
-                   "// use Java anonymizer class-like syntax!\n" +
-                   "var r = new java.lang.Runnable() {\n" +
-                   "            run: function() {\n" +
-                   "                    alert('hello');\n" +
-                   "            }\n" +
-                   "    };\n" +
-                   "// use the above Runnable to create a Thread\n" +
-                   "new java.lang.Thread(r).start();\n" +
-                   "// For simple one method interfaces, just pass script function\n" +
-                   "new java.lang.Thread(function() { alert('world'); }).start();");
-    }
-    actionJavaInterface.title = "Java Interfaces";
-
-    // show how to import Java classes, packages
-    function actionJavaImport() {
-        showScript(arguments.callee.title,
-                   "// use Java-like import *...\n" +
-                   "//    importPackage(java.io);\n" +
-                   "// or import a specific class\n" +
-                   "//    importClass(java.io.File);\n" +
-                   "// or better - import just within a scope!\n" +
-                   "var ioPkgs = JavaImporter(java.io);\n" +
-                   "with (ioPkgs) { alert(new File('.').absolutePath); }");
-    }
-    actionJavaImport.title = "Java Import";
-
-    // "Help" menu
-
-    /*
-     * Shows a one liner help message for each
-     * global function. Note that this function
-     * depends on docString meta-data for each
-     * function.
-     */
-    function actionHelpGlobals() {
-        var names = new java.util.ArrayList();
-        for (var i in globalThis) {
-            var func = globalThis[i];
-            if (typeof(func) == "function" &&
-                ("docString" in func)) {
-                names.add(i);
-            }
-        }
-        java.util.Collections.sort(names);
-        var helpDoc = new java.lang.StringBuffer();
-        helpDoc.append("<table border='1'>");
-        var itr = names.iterator();
-        while (itr.hasNext()) {
-            var name = itr.next();
-            helpDoc.append("<tr><td>");
-            helpDoc.append(name);
-            helpDoc.append("</td><td>");
-            helpDoc.append(globalThis[name].docString);
-            helpDoc.append("</td></tr>");
-        }
-        helpDoc.append("</table>");
-
-        var helpEditor = new guiPkgs.JEditorPane();
-        helpEditor.setContentType("text/html");
-        helpEditor.setEditable(false);
-        helpEditor.setText(helpDoc.toString());
-
-        var scroller = new guiPkgs.JScrollPane();
-        var port = scroller.getViewport();
-        port.add(helpEditor);
-
-        var helpFrame = new guiPkgs.JFrame("Help - Global Functions");
-        helpFrame.getContentPane().add("Center", scroller);
-        helpFrame.setDefaultCloseOperation(guiPkgs.WindowConstants.DISPOSE_ON_CLOSE);
-        helpFrame.pack();
-        helpFrame.setSize(500, 600);
-        helpFrame.setVisible(true);
-    }
-
-    // show a simple about message for scriptpad
-    function actionAbout() {
-        alert("Scriptpad\nVersion 1.1", "Scriptpad");
-    }
-
-    /*
-     * This data is used to construct menu bar.
-     * This way adding a menu is easier. Just add
-     * top level menu or add an item to an existing
-     * menu. "action" should be a function that is
-     * called back on clicking the correponding menu.
-     */
-    var menuData = [
-        {
-            menu: "File",
-            items: [
-                { name: "New",  action: actionNew , accel: guiPkgs.KeyEvent.VK_N },
-                { name: "Open...", action: actionOpen, accel: guiPkgs.KeyEvent.VK_O },
-                { name: "Open URL...", action: actionOpenURL, accel: guiPkgs.KeyEvent.VK_U },
-                { name: "Save", action: actionSave, accel: guiPkgs.KeyEvent.VK_S },
-                { name: "Save As...", action: actionSaveAs },
-                { name: "-" },
-                { name: "Exit", action: actionExit, accel: guiPkgs.KeyEvent.VK_Q }
-            ]
-        },
-
-        {
-            menu: "Edit",
-            items: [
-                { name: "Cut", action: actionCut, accel: guiPkgs.KeyEvent.VK_X },
-                { name: "Copy", action: actionCopy, accel: guiPkgs.KeyEvent.VK_C },
-                { name: "Paste", action: actionPaste, accel: guiPkgs.KeyEvent.VK_V },
-                { name: "-" },
-                { name: "Select All", action: actionSelectAll, accel: guiPkgs.KeyEvent.VK_A }
-            ]
-        },
-
-        {
-            menu: "Tools",
-            items: [
-                { name: "Run", action: actionRun, accel: guiPkgs.KeyEvent.VK_R }
-            ]
-        },
-
-        {
-            menu: "Examples",
-            items: [
-                { name: actionHello.title, action: actionHello },
-                { name: actionEval.title, action: actionEval },
-                { name: actionJavaStatic.title, action: actionJavaStatic },
-                { name: actionJavaAccess.title, action: actionJavaAccess },
-                { name: actionJavaBean.title, action: actionJavaBean },
-                { name: actionJavaInterface.title, action: actionJavaInterface },
-                { name: actionJavaImport.title, action: actionJavaImport }
-            ]
-        },
-
-        {
-            menu: "Help",
-            items: [
-                { name: "Global Functions", action: actionHelpGlobals },
-                { name: "-" },
-                { name: "About Scriptpad", action: actionAbout }
-            ]
-        }
-    ];
-
-    function setMenuAccelerator(mi, accel) {
-        var keyStroke = guiPkgs.KeyStroke.getKeyStroke(accel,
-                                                       guiPkgs.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
-        mi.setAccelerator(keyStroke);
-    }
-
-    // create a menubar using the above menu data
-    function createMenubar() {
-        var mb = new guiPkgs.JMenuBar();
-        for (var m in menuData) {
-            var items = menuData[m].items;
-            var menu = new guiPkgs.JMenu(menuData[m].menu);
-
-            for (var i in items) {
-                if (items[i].name.equals("-")) {
-                    menu.addSeparator();
-                } else {
-                    var mi = new guiPkgs.JMenuItem(items[i].name);
-                    var action = items[i].action;
-                    mi.addActionListener(action);
-                    var accel = items[i].accel;
-                    if (accel) {
-                        setMenuAccelerator(mi, accel);
-                    }
-                    menu.add(mi);
-                }
-	        }
-
-	        mb.add(menu);
-        }
-
-        return mb;
-    }
-
-    // function to add a new menu item under "Tools" menu
-    function addTool(menuItem, action, accel) {
-        if (typeof(action) != "function") {
-            return;
-        }
-
-        var toolsIndex = -1;
-        // find the index of the "Tools" menu
-        for (var i in menuData) {
-            if (menuData[i].menu.equals("Tools")) {
-                toolsIndex = i;
-                break;
-            }
-        }
-        if (toolsIndex == -1) {
-            return;
-        }
-        var toolsMenu = frame.getJMenuBar().getMenu(toolsIndex);
-        var mi = new guiPkgs.JMenuItem(menuItem);
-        mi.addActionListener(action);
-        if (accel) {
-            setMenuAccelerator(mi, accel);
-        }
-        toolsMenu.add(mi);
-    }
-
-    // create Scriptpad frame
-    function createFrame() {
-        frame = new guiPkgs.JFrame();
-        frame.setTitle(defaultTitle);
-        frame.setBackground(guiPkgs.Color.lightGray);
-        frame.getContentPane().setLayout(new guiPkgs.BorderLayout());
-
-        // create notepad panel
-        var notepad = new guiPkgs.JPanel();
-        notepad.setBorder(guiPkgs.BorderFactory.createEtchedBorder());
-        notepad.setLayout(new guiPkgs.BorderLayout());
-
-        // create editor
-        editor = createEditor();
-        var scroller = new guiPkgs.JScrollPane();
-        var port = scroller.getViewport();
-        port.add(editor);
-
-        // add editor to notepad panel
-        var panel = new guiPkgs.JPanel();
-        panel.setLayout(new guiPkgs.BorderLayout());
-        panel.add("Center", scroller);
-        notepad.add("Center", panel);
-
-        // add notepad panel to frame
-        frame.getContentPane().add("Center", notepad);
-
-        // set menu bar to frame and show the frame
-        frame.setJMenuBar(createMenubar());
-        frame.setDefaultCloseOperation(guiPkgs.JFrame.EXIT_ON_CLOSE);
-        frame.pack();
-        frame.setSize(500, 600);
-    }
-
-    // show Scriptpad frame
-    function showFrame() {
-        // set global variable by the name "window"
-        globalThis.window = frame;
-
-        // open new document
-        actionNew();
-
-        frame.setVisible(true);
-    }
-
-    // create and show Scriptpad frame
-    createFrame();
-    showFrame();
-
-    /*
-     * Application object has two fields "frame", "editor"
-     * which are current JFrame and editor and a method
-     * called "addTool" to add new menu item to "Tools" menu.
-     */
-    return {
-        frame: frame,
-        editor: editor,
-        addTool: addTool
-    };
-};
-
-/*
- * Call the main and store Application object
- * in a global variable named "application".
- */
-var application = main();
-
-if (this.load == undefined) {
-    function load(file) {
-        var ioPkgs = new JavaImporter(java.io);
-        with (ioPkgs) {
-            var stream = new FileInputStream(file);
-            var bstream = new BufferedInputStream(stream);
-            var reader = new BufferedReader(new InputStreamReader(bstream));
-            var oldFilename = engine.get(engine.FILENAME);
-            engine.put(engine.FILENAME, file);
-            try {
-                engine.eval(reader, context);
-            } finally {
-                engine.put(engine.FILENAME, oldFilename);
-            }
-            stream.close();
-        }
-    }
-    load.docString = "loads the given script file";
-}
-
-/*
- * Load user specific init file under home dir, if found.
- */
-function loadUserInit() {
-    var home = java.lang.System.getProperty("user.home");
-    var f = new java.io.File(home, "scriptpad.js");
-    if (f.exists()) {
-        engine.eval(new java.io.FileReader(f));
-    }
-}
-
-loadUserInit();
--- a/jdk/src/sample/share/scripting/scriptpad/src/scripts/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-Sample scripts:
-
-(1) browse.js 
-
- -- Open and run this script in scriptpad. You will see 
-    Tools->Browse menu. Using this you can start your
-    desktop default browser with the given URL.
-
-(2) insertfile.js
-
- -- Open and run this script in scriptpad. You will see 
-    "Tools->Insert File..." menu. Using this you can start 
-    insert content of a selected file into currently
-    edited document
-
-(3) linewrap.js
-
- -- Open and run this script in scriptpad. You will see 
-    "Tools->Line Wrap" menu. Using this you can toggle
-    the line wrapping mode of the editor
-
-(4) mail.js
-
- -- Open and run this script in scriptpad. You will see 
-    Tools->Mail menu. Using this you can start your
-    desktop default mail client with the given "To" mail id.
-
-(5) memmonitor.js
-
- -- This is a simple Monitoring & Management script. To use this,
-    you need an application to monitor. You can use memory.bat
-    or memory.sh in the current directory to start an application
-    that will be monitored. After that please follow these steps:
-
-   1. Start the target application using memory.sh or memory.bat
-   2. Start scriptpad 
-   3. Use "Tools->JMX Connect" menu and specify "localhost:1090"
-      to connect
-   4. Open "memmonitor.js" and run it (using "Tools->Run")       
-      in scriptpad
-   5. A new "Tools-Memory Monitor" menu appears. Use this menu
-      and specify 4 and 500 as threshold and interval values.
-   6. In the target application shell (where memory.bat/.sh was
-      started), enter an integer value and press "enter".
-   7. You'll see an alert box from scriptpad -- alerting you for
-      memory threshold exceeded!
-
-(6) textcolor.js
-
- -- Open and run this script in scriptpad. You will see 
-    "Tools->Selected Text Color..." menu. Using this you
-    change the color of "selected text" in the editor.
--- a/jdk/src/sample/share/scripting/scriptpad/src/scripts/browse.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * This function uses new Swing Desktop API in JDK 6.
- * To use this with scriptpad, open this in scriptpad
- * and use "Tools->Run Script" menu.
- */
-function browse() {
-    var desktop = null;
-    // Before more Desktop API is used, first check
-    // whether the API is supported by this particular
-    // virtual machine (VM) on this particular host.
-    if (java.awt.Desktop.isDesktopSupported()) {
-        desktop = java.awt.Desktop.getDesktop();
-    } else {
-        alert("no desktop support");
-        return;
-    }
-
-    if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
-        var url = prompt("Address:");
-        if (url != null) {
-            desktop.browse(new java.net.URI(url));
-        }
-    } else {
-        alert("no browser support");
-    }
-}
-
-if (this.application != undefined) {
-    // add "Browse" menu item under "Tools" menu
-    this.application.addTool("Browse", browse);
-}
--- a/jdk/src/sample/share/scripting/scriptpad/src/scripts/insertfile.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * This script adds "Insert File" mode menu item to "Tools" menu.
- * When selected, this menu shows a file dialog box and inserts
- * contents of the selected file into current document (at the
- * current caret position).
- */
-if (this.application) {
-    application.addTool("Insert File...",
-        function() {
-            var file = fileDialog();
-
-            if (file) {
-                var reader = new java.io.FileReader(file);
-                var arr = java.lang.reflect.Array.newInstance(
-                      java.lang.Character.TYPE, 8*1024); // 8K at a time
-                var buf = new java.lang.StringBuffer();
-                var numChars;
-
-                while ((numChars = reader.read(arr, 0, arr.length)) > 0) {
-                    buf.append(arr, 0, numChars);
-                }
-
-                var pos = application.editor.caretPosition;
-                var doc = application.editor.document;
-
-                doc.insertString(pos, buf.toString(), null);
-           }
-        });
-}
--- a/jdk/src/sample/share/scripting/scriptpad/src/scripts/linewrap.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * This script adds "Line Wrap" mode menu item to "Tools" menu.
- * When selected, this menu toggles the current word wrap mode
- * of the editor.
- */
-
-function toggleLineWrap() {
-    var wrap = application.editor.lineWrap;
-    application.editor.lineWrap = !wrap;
-}
-
-application.addTool("Line Wrap",  toggleLineWrap);
--- a/jdk/src/sample/share/scripting/scriptpad/src/scripts/mail.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * This function uses new Swing Desktop API in JDK 6.
- * To use this with scriptpad, open this in scriptpad
- * and use "Tools->Run Script" menu.
- */
-function mail() {
-    var desktop = null;
-    // Before more Desktop API is used, first check
-    // whether the API is supported by this particular
-    // virtual machine (VM) on this particular host.
-    if (java.awt.Desktop.isDesktopSupported()) {
-        desktop = java.awt.Desktop.getDesktop();
-    } else {
-        alert("no desktop support");
-        return;
-    }
-
-    if (desktop.isSupported(java.awt.Desktop.Action.MAIL)) {
-        var mailTo = prompt("Mail To:");
-        if (mailTo != null) {
-            desktop.mail(new java.net.URI("mailto", mailTo, null));
-        }
-    }
-}
-
-if (this.application != undefined) {
-    // add "Mail" menu item under "Tools" menu
-    this.application.addTool("Mail", mail);
-}
--- a/jdk/src/sample/share/scripting/scriptpad/src/scripts/memmonitor.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-// this checker function runs asynchronously
-function memoryChecker(memoryBean, threshold, interval) {
-    while (true) {
-        var memUsage = memoryBean.HeapMemoryUsage;
-        var usage = memUsage.get("used") / (1024 * 1024);
-
-        println("usage: " + usage);
-
-        if (usage > threshold) {
-            alert("Hey! heap usage threshold exceeded!");
-            // after first alert just return.
-            return;
-        }
-
-        java.lang.Thread.sleep(interval);
-    }
-}
-
-// add "Tools->Memory Monitor" menu item
-if (this.application != undefined) {
-    this.application.addTool("Memory Monitor",
-        function () {
-            // show threshold box with default of 50 MB
-            var threshold = prompt("Threshold (mb)", 50);
-
-            // show interval box with default of 1000 millisec.
-            var interval = prompt("Sample Interval (ms):", 1000);
-            var memoryBean = mbean("java.lang:type=Memory");
-
-            // ".future" makes the function to be called
-            // asynchronously in a separate thread.
-            memoryChecker.future(memoryBean, threshold, interval);
-        });
-}
--- a/jdk/src/sample/share/scripting/scriptpad/src/scripts/memory.bat	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-@echo off
-REM
-REM Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-REM
-REM Redistribution and use in source and binary forms, with or without
-REM modification, are permitted provided that the following conditions
-REM are met:
-REM
-REM   - Redistributions of source code must retain the above copyright
-REM     notice, this list of conditions and the following disclaimer.
-REM
-REM   - Redistributions in binary form must reproduce the above copyright
-REM     notice, this list of conditions and the following disclaimer in the
-REM     documentation and/or other materials provided with the distribution.
-REM
-REM   - Neither the name of Oracle nor the names of its
-REM     contributors may be used to endorse or promote products derived
-REM     from this software without specific prior written permission.
-REM
-REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-REM IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-REM THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-REM PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-REM CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-REM EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-REM PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-REM PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-REM LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-REM NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-REM SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-REM
-
-
-jrunscript -J-Dcom.sun.management.jmxremote.port=1090 -J-Dcom.sun.management.jmxremote.ssl=false -J-Dcom.sun.management.jmxremote.authenticate=false memory.js
-
--- a/jdk/src/sample/share/scripting/scriptpad/src/scripts/memory.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * This script serves as a simple "monitored application".
- * Start this script using memory.bat or memory.sh in the
- * current directory.
- */
-
-java.lang.System.out.print("Enter a number and press enter:");
-var input = java.lang.System["in"].read();
-
-// allocate an integer array of "big enough" size!
-var a = java.lang.reflect.Array.newInstance(
-    java.lang.Integer.TYPE, input * 1024 * 1024);
-
-// sleep some time...
-java.lang.Thread.sleep(10*60*1000);
--- a/jdk/src/sample/share/scripting/scriptpad/src/scripts/memory.sh	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#
-# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-jrunscript -J-Dcom.sun.management.jmxremote.port=1090 -J-Dcom.sun.management.jmxremote.ssl=false -J-Dcom.sun.management.jmxremote.authenticate=false memory.js
--- a/jdk/src/sample/share/scripting/scriptpad/src/scripts/textcolor.js	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-/*
- * This script adds "Selected Text Color" menu item to "Tools" menu.
- * When selected, this menu changes the "selected text" color.
- */
-if (this.application) {
-    application.addTool("Selected Text Color...",
-        function() {
-            var color = application.editor.selectedTextColor;
-            color = colorDialog("Selected Text Color", color);
-            application.editor.selectedTextColor = color;
-        });
-}
--- a/jdk/src/sample/share/try-with-resources/index.html	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-
-<html>
-<head>
-    <title>Try-with-Resources Feature Demo</title>
-</head>
-<body>
-<h2>Try-with-Resources Feature Demo</h2>
-
-<p>
-    This demo shows how to use the try-with-resources feature introduced in JDK7.
-</p>
-
-<ul>
-    <li><h3>Custom AutoCloseable.</h3>
-
-        <p>
-            Shows how to use a custom resource with the try-with-resources construct.
-            For more information, see the source file.
-        </p>
-        Source: <a href="src/CustomAutoCloseableSample.java">src/CustomAutoCloseableSample.java</a>
-
-    <li><h3>Unzip</h3>
-
-        <p>
-            Extracts archived files. For more information, see the source file.
-        </p>
-        Source: <a href="src/Unzip.java">src/Unzip.java</a>
-    <li><h3>ZipCat</h3>
-
-        <p>Prints data about a specified file from an archive. For more information, see the source file.</p>
-        Source: <a href="src/ZipCat.java">src/ZipCat.java</a>
-
-</ul>
-</body>
-</html>
--- a/jdk/src/sample/share/try-with-resources/src/CustomAutoCloseableSample.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation, and proper error handling, might not be present in
- * this sample code.
- */
-
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-/**
- * This sample demonstrates the ability to create custom resource that
- * implements the {@code AutoCloseable} interface. This resource can be used in
- * the try-with-resources construct.
- */
-public class CustomAutoCloseableSample {
-
-    /**
-     * The main method for the CustomAutoCloseableSample program.
-     *
-     * @param args is not used.
-     */
-    public static void main(String[] args) {
-        /*
-         * TeeStream will be closed automatically after the try block.
-         */
-        try (TeeStream teeStream = new TeeStream(System.out, Paths.get("out.txt"));
-             PrintStream out = new PrintStream(teeStream)) {
-            out.print("Hello, world");
-        } catch (Exception e) {
-            e.printStackTrace();
-            System.exit(1);
-        }
-    }
-
-    /**
-     * Passes the output through to the specified output stream while copying it into a file.
-     * The TeeStream functionality is similar to the Unix tee utility.
-     * TeeStream implements AutoCloseable interface. See OutputStream for details.
-     */
-    public static class TeeStream extends OutputStream {
-
-        private final OutputStream fileStream;
-        private final OutputStream outputStream;
-
-        /**
-         * Creates a TeeStream.
-         *
-         * @param outputStream an output stream.
-         * @param outputFile   an path to file.
-         * @throws IOException If an I/O error occurs.
-         */
-        public TeeStream(OutputStream outputStream, Path outputFile) throws IOException {
-            this.fileStream = new BufferedOutputStream(Files.newOutputStream(outputFile));
-            this.outputStream = outputStream;
-        }
-
-        /**
-         * Writes the specified byte to the specified output stream
-         * and copies it to the file.
-         *
-         * @param b the byte to be written.
-         * @throws IOException If an I/O error occurs.
-         */
-        @Override
-        public void write(int b) throws IOException {
-            fileStream.write(b);
-            outputStream.write(b);
-        }
-
-        /**
-         * Flushes this output stream and forces any buffered output bytes
-         * to be written out.
-         * The <code>flush</code> method of <code>TeeStream</code> flushes
-         * the specified output stream and the file output stream.
-         *
-         * @throws IOException if an I/O error occurs.
-         */
-        @Override
-        public void flush() throws IOException {
-            outputStream.flush();
-            fileStream.flush();
-        }
-
-        /**
-         * Closes underlying streams and resources.
-         * The external output stream won't be closed.
-         * This method is the member of AutoCloseable interface and
-         * it will be invoked automatically after the try-with-resources block.
-         *
-         * @throws IOException If an I/O error occurs.
-         */
-        @Override
-        public void close() throws IOException {
-            try (OutputStream file = fileStream) {
-                flush();
-            }
-        }
-    }
-}
--- a/jdk/src/sample/share/try-with-resources/src/Unzip.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation, and proper error handling, might not be present in
- * this sample code.
- */
-
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.file.*;
-
-import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
-
-/**
- * Extract (unzip) a file to the current directory.
- */
-public class Unzip {
-
-    /**
-     * The main method for the Unzip program. Run the program with an empty
-     * argument list to see possible arguments.
-     *
-     * @param args the argument list for {@code Unzip}.
-     */
-    public static void main(String[] args) {
-        if (args.length != 1) {
-            System.out.println("Usage: Unzip zipfile");
-        }
-        final Path destDir = Paths.get(".");
-        /*
-         * Create AutoCloseable FileSystem. It will be closed automatically
-         * after the try block.
-         */
-        try (FileSystem zipFileSystem = FileSystems.newFileSystem(Paths.get(args[0]), null)) {
-
-            Path top = zipFileSystem.getPath("/");
-            Files.walk(top).skip(1).forEach(file -> {
-                Path target = destDir.resolve(top.relativize(file).toString());
-                System.out.println("Extracting " + target);
-                try {
-                    Files.copy(file, target, REPLACE_EXISTING);
-                } catch (IOException e) {
-                    throw new UncheckedIOException(e);
-                }
-            });
-        } catch (UncheckedIOException | IOException e) {
-            e.printStackTrace();
-            System.exit(1);
-        }
-    }
-}
--- a/jdk/src/sample/share/try-with-resources/src/ZipCat.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation, and proper error handling, might not be present in
- * this sample code.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-/**
- * Prints data of the specified file to standard output from a zip archive.
- */
-public class ZipCat {
-
-    /**
-     * The main method for the ZipCat program. Run the program with an empty
-     * argument list to see possible arguments.
-     *
-     * @param args the argument list for ZipCat
-     */
-    public static void main(String[] args) {
-        if (args.length != 2) {
-            System.out.println("Usage: ZipCat zipfile fileToPrint");
-        }
-        /*
-         * Creates AutoCloseable FileSystem and BufferedReader.
-         * They will be closed automatically after the try block.
-         * If reader initialization fails, then zipFileSystem will be closed
-         * automatically.
-         */
-        try (FileSystem zipFileSystem
-                = FileSystems.newFileSystem(Paths.get(args[0]),null);
-                InputStream input
-                = Files.newInputStream(zipFileSystem.getPath(args[1]))) {
-                    byte[] buffer = new byte[1024];
-                    int len;
-                    while ((len = input.read(buffer)) != -1) {
-                        System.out.write(buffer, 0, len);
-                    }
-
-        } catch (IOException e) {
-            e.printStackTrace();
-            System.exit(1);
-        }
-    }
-}
--- a/jdk/src/sample/share/vm/clr-jvm/Makefile	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-#
-# Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-all: jinvoker.dll invoked.class invoker.exe
-
-jinvoker.dll: jinvoker.obj Makefile
-	cl /LD /o jinvoker.dll jinvoker.obj
-
-jinvoker.obj: jinvoker.cpp jinvokerExp.h Makefile
-	cl /Fojinvoker.obj /DJINVOKEREEXPORT /c jinvoker.cpp
-
-invoked.class: invoked.java Makefile
-	javac invoked.java
-
-invoker.exe: invoker.cs Makefile
-	csc /unsafe invoker.cs
--- a/jdk/src/sample/share/vm/clr-jvm/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-This sample provides Java "Hello World" program that is invoked
-from C# application in the same process.
-
-The problem of direct call of the JVM API from CLR applications
-by PInvoke interface is the JVM API functions do not have static
-adresses, they need to be got by JNI_CreateJavaVM() call.
-The sample contains C++ libraty that wraps JVM API calls by the
-static functions that are called from the C# application by
-PInvoke interface.
-
-The sample contains the following files:
-
-Makefile      - make file
-README.txt    - this readme
-invoked.java  - the invoked HelloWorld Java program
-invoker.cs    - C# invoker application
-jinvoker.cpp  - C++ wrapper
-jinvokerExp.h - wrapper library exports
-
-After the success making the following files are produced:
-
-invoked.class - the compiled HelloWorld class
-invoker.exe   - the executable .NET program that invokes Java
-jinvoker.dll  - the wrapper library
-
-The following environment needs to be set for the correct sample
-build and execution:
-
-INCLUDE must contain the paths to:
-  1. MS Visual C++ standard include
-  2. .NET SDK include
-  3. Java includes
-  Example: %MSDEV%/VC98/Include;%DOTNET%/Include;%JAVA_HOME%/include;%JAVA_HOME%/include/win32
-
-LIB must contain the paths to:
-  1. MS Visual C++ standard libraries
-  2. .NET SDK libraries
-  3. jvm.dll
-  Example: %MSDEV%/VC98/Lib;%DOTNET%/Lib;%JAVA_HOME%/jre/bin/client
-
-PATH must contain the paths to:
-  1. MS Visual C++ standard bin
-  2. MS Dev common bin
-  3. .NET SDK libraries
-  4. Java bin
-  5. jvm.dll
-  Example: %MSDEV%/VC98/Bin;%MSDEV%/Common/MSDev98/Bin;%DOTNET%/Lib;%JAVA_HOME%/bin;%JAVA_HOME%/jre/bin/client;%PATH%
-
-To run the sample please do:
-
-  invoker.exe invoked
-
-
---Dmitry Ryashchentsev
--- a/jdk/src/sample/share/vm/clr-jvm/invoked.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-public class invoked {
-    public static void main(String args[]) {
-
-        // Print Hello to show we are in JVM
-        System.out.println("Hello from Java!!!");
-        System.exit(0);
-    }
-}
--- a/jdk/src/sample/share/vm/clr-jvm/invoker.cs	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-using System;
-using System.Runtime.InteropServices;
-
-class jinvoker{
-
-    public static int Main(string[] aArgs){
-        
-        // Print Hello to show we are in CLR
-        Console.WriteLine("Hello from C#");
-        if(aArgs.Length > 0)
-            // invoke JVM
-            return InvokeMain(aArgs[0]);
-        else
-            return -1;
-    }
-
-    // Link the JVM API functions and the wrappers
-
-    [DllImport("jvm.dll")]      public unsafe static extern int  JNI_CreateJavaVM(void** ppVm, void** ppEnv, void* pArgs);
-    [DllImport("jinvoker.dll")] public unsafe static extern int  MakeJavaVMInitArgs( void** ppArgs );
-    [DllImport("jinvoker.dll")] public unsafe static extern void FreeJavaVMInitArgs( void* pArgs );
-    [DllImport("jinvoker.dll")] public unsafe static extern int  FindClass( void* pEnv, String sClass, void** ppClass );
-    [DllImport("jinvoker.dll")] public unsafe static extern int  GetStaticMethodID( void*  pEnv,
-                                                                                    void*  pClass, 
-                                                                                    String szName, 
-                                                                                    String szArgs, 
-                                                                                    void** ppMid);
-	
-    [DllImport("jinvoker.dll")] public unsafe static extern int NewObjectArray( void*  pEnv,
-                                                                                int    nDimension,
-                                                                                String sType,
-                                                                                void** ppArray );
-
-    [DllImport("jinvoker.dll")] public unsafe static extern int CallStaticVoidMethod( void* pEnv,
-                                                                                      void* pClass,
-                                                                                      void* pMid,
-                                                                                      void* pArgs);
-
-    [DllImport("jinvoker.dll")] public unsafe static extern int DestroyJavaVM( void* pJVM );
-
-	public unsafe static int InvokeMain( String sClass ){
-	    
-        void*  pJVM;    // JVM struct
-        void*  pEnv;    // JVM environment
-        void*  pVMArgs; // VM args
-        void*  pClass;  // Class struct of the executed method
-        void*  pMethod; // The executed method struct
-        void*  pArgs;   // The executed method arguments struct
-
-        // Fill the pVMArgs structs
-        MakeJavaVMInitArgs( &pVMArgs );
-
-        // Create JVM
-        int nRes = JNI_CreateJavaVM( &pJVM, &pEnv, pVMArgs );
-        if( nRes == 0 ){
-			
-            // Find the executed method class 
-            if(FindClass( pEnv, sClass, &pClass) == 0 )
-				
-                // Find the executed method
-                if( GetStaticMethodID( pEnv, pClass, "main", "([Ljava/lang/String;)V", &pMethod ) == 0 )
-					
-                    // Create empty String[] array to pass to the main()
-                    if( NewObjectArray( pEnv, 0, "java/lang/String", &pArgs ) == 0 ){
-
-                        // Call main()
-                        nRes = CallStaticVoidMethod( pEnv, pClass, pMethod, pArgs );
-                        if( nRes != -1 )
-                            Console.WriteLine("Result:"+nRes);
-                        else
-                            Console.WriteLine("Exception");
-                        
-                    }else{
-                        Console.WriteLine("Error while making args array");
-                        nRes = -100;
-                    }
-                else{
-                    Console.WriteLine("can not find method main(String[])");
-                    nRes = -101;
-                }
-            else{
-                Console.WriteLine("can not find class:"+sClass);
-                nRes = -102;
-            }
-			
-            // Destroy the JVM
-            DestroyJavaVM( pJVM );
-
-        }else
-            Console.WriteLine("Can not create Java VM");
-
-        // Free the JVM args structs
-        FreeJavaVMInitArgs(pVMArgs);
-		
-        return nRes;
-    }
-}
--- a/jdk/src/sample/share/vm/clr-jvm/jinvoker.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include <memory.h>
-#include <stdlib.h>
-#include "jinvokerExp.h"
-
-static int g_nExitCode = 0;
-
-void system_exit(jint nCode){
-    g_nExitCode = nCode;
-}
-
-/*
-Allocating and providing the JVM init argumets.
-By MakeJavaVMInitArgs() it is provided two options: providing CLASSPATH
-environment variable value and function java.lang.System.exit()
-redefinition in order to get the exit code.
-See the description of the JNI API in
-http://jre.sfbay/java/re/jdk/6/promoted/latest/docs/technotes/guides/jni/spec/invocation.html#wp9502
-*/
-
-int MakeJavaVMInitArgs( void** ppArgs ){
-
-    int nOptSize = 2;
-    JavaVMInitArgs* pArgs    = new JavaVMInitArgs();
-    JavaVMOption*   pOptions = new JavaVMOption[nOptSize];
-
-    //provide CLASSPATH value to java.class.path
-
-    char* szClassPath = getenv("CLASSPATH");
-    if( szClassPath == NULL )
-        szClassPath = ".";
-
-    pOptions[0].optionString = new char[strlen("-Djava.class.path=")+
-                                        strlen(szClassPath)+1];
-    sprintf( pOptions[0].optionString, "-Djava.class.path=%s", szClassPath );
-
-    //redefine java.lang.System.exit()
-
-    pOptions[1].optionString = "exit";
-    pOptions[1].extraInfo    = system_exit;
-
-    //Fill the arguments
-
-    memset(pArgs, 0, sizeof(JavaVMInitArgs));
-    pArgs->version = 0x00010002;
-    pArgs->options = pOptions;
-    pArgs->nOptions = nOptSize;
-    pArgs->ignoreUnrecognized = JNI_TRUE;
-
-    *ppArgs = pArgs;
-
-    return 0;
-}
-
-/*
-Free the allocated JVM init argumets
-*/
-
-void FreeJavaVMInitArgs( void* pArgs ){
-    delete ((JavaVMInitArgs*)pArgs)->options[0].optionString;
-    delete ((JavaVMInitArgs*)pArgs)->options;
-    delete pArgs;
-}
-
-/*
-Static wrapper on FindClass() JNI function.
-See the description in
-http://jre.sfbay/java/re/jdk/6/promoted/latest/docs/technotes/guides/jni/spec/functions.html#wp16027
-*/
-
-int FindClass( JNIEnv*     pEnv,
-               const char* szClass,
-               jclass*     pClass ){
-
-    *pClass = pEnv->FindClass( szClass );
-
-    if(pEnv->ExceptionCheck() == JNI_TRUE){
-        pEnv->ExceptionDescribe();
-        return -1;
-    }
-    if(*pClass != NULL)
-        return 0;
-    else
-        return -2;
-
-}
-
-/*
-Static wrapper on GetStaticMethodID() JNI function.
-See the description in
-http://jre.sfbay/java/re/jdk/6/promoted/latest/docs/technotes/guides/jni/spec/functions.html#wp20949
-*/
-
-int GetStaticMethodID(JNIEnv*     pEnv,
-                      jclass      pClass,
-                      const char* szName,
-                      const char* szArgs,
-                      jmethodID*  pMid){
-
-    *pMid = pEnv->GetStaticMethodID( pClass, szName, szArgs);
-
-    if(pEnv->ExceptionCheck() == JNI_TRUE){
-        pEnv->ExceptionDescribe();
-        return -1;
-    }
-
-    if( *pMid != NULL )
-        return 0;
-    else
-        return -2;
-}
-
-/*
-Static wrapper on NewObjectArray() JNI function.
-See the description in
-http://jre.sfbay/java/re/jdk/6/promoted/latest/docs/technotes/guides/jni/spec/functions.html#wp21619
-*/
-
-int NewObjectArray( JNIEnv*       pEnv,
-                    int           nDimension,
-                    const char*   szType,
-                    jobjectArray* pArray ){
-
-    *pArray = pEnv->NewObjectArray( nDimension, pEnv->FindClass( szType ), NULL);
-
-    if(pEnv->ExceptionCheck() == JNI_TRUE){
-        pEnv->ExceptionDescribe();
-        return -1;
-    }
-
-    if( pArray != NULL )
-        return 0;
-    else
-        return -2;
-
-}
-
-/*
-Static wrapper on CallStaticVoidMethod() JNI function.
-See the description in
-http://jre.sfbay/java/re/jdk/6/promoted/latest/docs/technotes/guides/jni/spec/functions.html#wp4796
-*/
-
-int CallStaticVoidMethod( JNIEnv*   pEnv,
-                          jclass    pClass,
-                          jmethodID pMid,
-                          void*     pArgs){
-
-    g_nExitCode = 0;
-    pEnv->CallStaticVoidMethod( pClass, pMid, pArgs);
-    if( pEnv->ExceptionCheck() == JNI_TRUE ){
-        pEnv->ExceptionDescribe();
-        return -1;
-    }else
-        return g_nExitCode;
-}
-
-/*
-Static wrapper on DestroyJavaVM() JNI function.
-See the description in
-http://jre.sfbay/java/re/jdk/6/promoted/latest/docs/technotes/guides/jni/spec/invocation.html#destroy_java_vm
-*/
-
-int DestroyJavaVM( JavaVM* pJVM ){
-    pJVM->DestroyJavaVM();
-    return 0;
-}
--- a/jdk/src/sample/share/vm/clr-jvm/jinvokerExp.h	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#include <windows.h>
-#include <jni.h>
-
-#ifdef JINVOKEREEXPORT
-#define JINVOKERAPI __declspec(dllexport)
-#else
-#define JINVOKERAPI __declspec(dllimport)
-#endif
-
-// Create JNI_CreateJavaVM() args structures
-extern "C" int  JINVOKERAPI MakeJavaVMInitArgs( void** ppArgs );
-
-// Free JNI_CreateJavaVM() args structures
-extern "C" void JINVOKERAPI FreeJavaVMInitArgs( void* pArgs );
-
-// Static wrapper on FindClass() JNI function.
-extern "C" int  JINVOKERAPI FindClass( JNIEnv* pEnv,
-                                       const char* szName,
-                                       jclass*     ppClass );
-
-// Static wrapper on GetStaticMethodID() JNI function.
-extern "C" int JINVOKERAPI GetStaticMethodID( JNIEnv*     pEnv,
-                                              jclass      pClass,
-                                              const char* szName,
-                                              const char* szArgs,
-                                              jmethodID*  ppMid );
-
-// Static wrapper on NewObjectArray() JNI function.
-extern "C" int JINVOKERAPI NewObjectArray( JNIEnv*       pEnv,
-                                           int           nDimension,
-                                           const char*   szType,
-                                           jobjectArray* pArray );
-
-// Static wrapper on CallStaticVoidMethod() JNI function.
-extern "C" int JINVOKERAPI CallStaticVoidMethod( JNIEnv*   pEnv,
-                                                 jclass    pClass,
-                                                 jmethodID pMid,
-                                                 void*     pArgs);
-
-// Static wrapper on DestroyJavaVM() JNI function.
-extern "C" int JINVOKERAPI DestroyJavaVM( JavaVM* pEnv );
--- a/jdk/src/sample/share/vm/jvm-clr/Makefile	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-#
-# Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#   - Neither the name of Oracle nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-all: invoker.dll invoker.class invoked.exe
-
-invoker.dll: invoker.obj Makefile
-	cl /LD /o invoker.dll invoker.obj mscoree.lib
-
-invoker.obj: invoker.cpp invokerExp.h invoker.h Makefile
-	cl /Foinvoker.obj /DINVOKEREXPORT /c invoker.cpp
-
-invoker.class: invoker.java Makefile
-	javac invoker.java
-
-invoked.exe: invoked.cs Makefile
-	csc invoked.cs
--- a/jdk/src/sample/share/vm/jvm-clr/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-This sample provides C# "Hello World" program that is invoked
-from Java application in the same process.
-
-There is no way to invoke .NET methods from Java classes directly,
-it is necessary to use native code level.
-The sample contains C++ library that can invoke any .NET program by mscorlib library.
-Using the JNI the Java application invokes the C# "Hello World".
-
-The sample contains the following files:
-
-Makefile     - make file
-README.txt   - this readme
-invoked.cs   - the invoked HelloWorld Java program
-invoker.java - C# invoker application
-invoker.cpp  - C++ wrapper
-invokerExp.h - wrapper library exports
-invoker.h    - javah generated file with the native method definition
-
-After the success making the following files are produced:
-
-invoked.exe   - the executable HelloWorld .NET program
-invoker.class - the compiled Java class that invokes the .NET program
-invoker.dll   - the wrapper library
-
-The following environment needs to be set for the correct sample
-build and execution:
-
-INCLUDE must contain the paths to:
-  1. MS Visual C++ standard include
-  2. .NET SDK include
-  3. Java includes
-  Example: %MSDEV%/VC98/Include;%DOTNET%/Include;%JAVA_HOME%/include;%JAVA_HOME%/include/win32
-
-LIB must contain the paths to:
-  1. MS Visual C++ standard libraries
-  2. .NET SDK libraries
-  Example: %MSDEV%/VC98/Lib;%DOTNET%/Lib
-
-PATH must contain the paths to:
-  1. MS Visual C++ standard bin
-  2. MS Dev common bin
-  3. .NET SDK libraries
-  4. Java bin
-  Example: %MSDEV%/VC98/Bin;%MSDEV%/Common/MSDev98/Bin;%DOTNET%/Lib;%JAVA_HOME%/bin;%PATH%
-
-To run the sample please do:
-
-java invoker invoked.exe
-
-
---Dmitry Ryashchentsev
--- a/jdk/src/sample/share/vm/jvm-clr/invoked.cs	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-
-using System;
-
-class App{
-
-    public static int Main(){
-
-        // Print Hello to show we are in CLR
-        Console.WriteLine("Hello from C#!!!");
-        return 0;
-    }
-}
--- a/jdk/src/sample/share/vm/jvm-clr/invoker.cpp	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#define _WIN32_WINNT 0x0400
-#include "windows.h"
-#include "Oleauto.h"
-#include "stdio.h"
-#include "mscoree.h"
-#include "corerror.h"
-#include "jni.h"
-#include "invokerExp.h"
-#include "invoker.h"
-
-#import  <mscorlib.tlb> raw_interfaces_only
-
-using namespace mscorlib;
-
-// The CLR assembly invocation function
-
-int __stdcall invokeCLR( WCHAR* wszApplication){
-
-    //Initializes the COM library
-
-    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
-
-    ICorRuntimeHost* pHost           = NULL;
-    IUnknown*        pAppDomainThunk = NULL;
-    _AppDomain*      pAppDomain      = NULL;
-    long             lReturn         = 0;
-
-    // Load CLR into the process
-
-    HRESULT hr = CorBindToRuntimeEx(NULL,NULL,0,CLSID_CorRuntimeHost,IID_ICorRuntimeHost,(VOID**)&pHost);
-
-    if(!FAILED(hr)) {
-
-        // Start the CLR
-
-        hr = pHost->Start();
-        if(!FAILED(hr)) {
-
-            // Get the _AppDomain interface
-
-            hr = pHost->GetDefaultDomain(&pAppDomainThunk);
-            if(!FAILED(hr)) {
-
-                hr = pAppDomainThunk->QueryInterface(__uuidof(_AppDomain), (void**)&pAppDomain);
-                if(!FAILED(hr)) {
-
-                    // Execute assembly
-
-                    hr = pAppDomain->ExecuteAssembly_2(_bstr_t(wszApplication), &lReturn);
-                    if (FAILED(hr)) {
-
-                        printf("_AppDomain::ExecuteAssembly_2 failed with hr=0x%x.\n", hr);
-                        lReturn = -1;
-                    }
-
-                }else{
-                    printf("Can't get System::_AppDomain interface\n");
-                    lReturn = -2;
-                }
-
-            }else{
-                printf("ICorRuntimeHost->GetDefaultDomain failed with hr=0x%x.\n", hr);
-                lReturn = -3;
-            }
-        }else{
-            printf("ICorRuntimeHost->Start failed with hr=0x%x.\n", hr);
-            lReturn = -4;
-        }
-
-    }else{
-        printf("CorBindToRuntimeHost failed with hr=0x%x.\n", hr);
-        lReturn = -5;
-    }
-
-    // print the error message description if needed
-
-    if(FAILED(hr)){
-        LPVOID lpMsgBuf = NULL;
-
-        FormatMessage(
-                FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                FORMAT_MESSAGE_FROM_SYSTEM |
-                FORMAT_MESSAGE_IGNORE_INSERTS,
-                NULL,
-                hr,
-                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                (LPTSTR) &lpMsgBuf,
-                0,
-                NULL );
-        if(lpMsgBuf != NULL)
-            printf("Message:%s\n",lpMsgBuf);
-        else
-            printf("No translation of 0x%x\n",hr);
-    }
-
-    // close COM library
-
-    CoUninitialize();
-
-    return lReturn;
-}
-
-// Wrapper function that allows to ASCIZ string to provide the assemble path
-
-int __stdcall invokeCLR( const char* szApplication){
-
-    int    nLength = strlen(szApplication)+1;
-
-    WCHAR* wszApplication = new WCHAR[nLength];
-
-    mbstowcs(wszApplication, szApplication, nLength);
-
-    int nReturn = invokeCLR( wszApplication);
-
-    delete wszApplication;
-
-    return nReturn;
-}
-
-// native method enter-point
-
-JNIEXPORT jint JNICALL Java_invoker_invokeCLR( JNIEnv* pEnv,
-                                               jclass  pClass,
-                                               jstring jsApplication) {
-
-    const char* szApplication = pEnv->GetStringUTFChars(jsApplication, NULL);
-
-    int nResult = invokeCLR( szApplication);
-
-    pEnv->ReleaseStringUTFChars(jsApplication,szApplication);
-
-    return nResult;
-}
--- a/jdk/src/sample/share/vm/jvm-clr/invoker.h	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class invoker */
-
-#ifndef _Included_invoker
-#define _Included_invoker
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class:     invoker
- * Method:    invokeCLR
- * Signature: (Ljava/lang/String;)I
- */
-JNIEXPORT jint JNICALL Java_invoker_invokeCLR
-  (JNIEnv *, jclass, jstring);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
--- a/jdk/src/sample/share/vm/jvm-clr/invoker.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-public class invoker {
-
-    static {
-
-        // Load the wrapper library
-        System.loadLibrary("invoker");
-    }
-
-    // the native enter-pointer to invoke the CLR assembly
-    public static native int invokeCLR(String sApplication);
-
-    public static void main(String args[]) {
-
-        // Print Hello to show we are in JVM
-        System.out.println("Hello from JVM!!!");
-
-        if( args.length >= 1 ){
-            String sApplication = args[0];
-
-            // Invoke CLR assembly
-            int nResult = invokeCLR(sApplication);
-
-            System.exit(nResult);
-
-        }else
-            System.out.println("Usage: java invoker <application>");
-    }
-}
--- a/jdk/src/sample/share/vm/jvm-clr/invokerExp.h	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-#ifndef _invoker_h
-#define _invoker_h
-
-#ifdef INVOKEREXPORT
-#define INVOKERAPI __declspec(dllexport)
-#else
-#define INVOKERAPI __declspec(dllimport)
-#endif
-
-// The CLR assembly invocation function
-
-INVOKERAPI int __stdcall invokeCLR( const char* szApplication );
-#endif
--- a/jdk/src/sample/solaris/dtrace/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-DTrace HotSpot probes samples
-=============================
-
-This directory contains the list of D scripts which could be used to trace
-Java application with help of Solaris(tm) 10 Dynamic Tracing (DTrace)
-probes.
-
-The directory is organized as:
-
-* helpers/
-
-  This directory contains the auxiliary script to launch Java application
-  with D script to debug. See more comments in the scripts.
-
-* hotspot/
-  
-  This directory contains D scripts which demonstrate usage of 'hotspot'
-  provider probes.
-
-
-* hotspot_jni/
-
-  This directory contains D scripts which demonstrate usage of 'hotspot_jni'
-  provider probes.
-
-
-
-Requirements to run DTrace
-==========================
-
-1. dtrace framework should be installed; (check if /usr/sbin/dtrace exists)
-
-2. the user should have the following rights: 
-   dtrace_proc, dtrace_user, dtrace_kernel
-
-    To give a user a privilege on login, insert a line into the 
-    /etc/user_attr file of the form: 
-    user-name::::defaultpriv=basic,dtrace_proc,dtrace_user,dtrace_kernel
-
-    or
-
-    To give a running process an DTrace privilege, use the ppriv(1) command:
-    # ppriv -s A+privilege process-ID
--- a/jdk/src/sample/solaris/dtrace/helpers/dtrace_helper.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-#!/usr/sbin/dtrace -s
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Description:
- * dtrace -c option launches the command specified in the -c argument and
- * starts tracing the process. Typically, you can run a D script and trace
- * a Java application as follows:
- *    dscript.d -Zc "java HelloWorld"
- *
- * The -Z option is needed to permit probe descriptions that match zero
- * probes because Hotspot probes definitions are located in libjvm.so which
- * has not been yet loaded and thus can't be enabled until the application
- * is started.
- *
- * Straightforward attempt to run D script may fail, e.g.: 
- *    dscript.d -c "java HelloWorld" 
- *    "probe description hotspotPID:::probename does not match any probes"
- *
- * This is because DTrace tries to enable probes before libjvm.so is loaded.
- * The -Z option requires Solaris patch 118822-30 installed on your system.
- *
- * In case you don't have this Solaris patch use dtrace_helper.d script.
- * This script waits until the Hotspot DTrace probes are loaded and then
- * stops the Java process (passed as '-c' options). After the process is
- * stopped, another D script (passed as first argument) is called to do real
- * trace of Java process.
- *
- * Usage example:
- *   dtrace_helper.d -c "java ..." ../hotspot/class_loading_stat.d
- */
-
-#pragma D option quiet
-#pragma D option destructive
-
-
-pid$target::dlopen:entry
-{
-    self->filename = arg0;
-}
-
-
-pid$target::dlopen:return
-/self->filename && basename(copyinstr(self->filename)) == "libjvm.so"/
-{
-    printf(" loaded %s\n", basename(copyinstr(self->filename)));
-    self->filename = 0;
-
-    stop();
-    printf(" stopped java process with pid=%d \n", $target);
-
-    printf(" run: %s -p %d &", $1, $target);
-    system("(%s -p %d) &", $1, $target);
-    exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-============================
-'hotspot' PROBES DESCRIPTION
-============================
-
-This directory contains D scripts which demonstrate usage of 'hotspot' provider probes.
-
-The 'hotspot' provider makes available probes that can be used to track the
-lifespan of the VM, thread start and stop events, GC and memory pool
-statistics, method compilations, and monitor activity. With a startup flag,
-additional probes are enabled which can be used to monitor the running Java
-program, such as method enter and return probes, and object allocations. All
-of the hotspot probes originate in the VM library (libjvm.so), so they are
-also provided from programs which embed the VM.
-
-Many of the probes in the provider have arguments that can be examined to
-provide further details on the state of the VM. Many of these probes'
-arguments are opaque IDs which can be used to link probe firings to each
-other, however strings and other data are also provided. When string values
-are provided, they are always present as a pair: a pointer to unterminated
-modified UTF-8 data (see JVM spec: 4.4.7) , and a length value which
-indicates the extent of that data. Because the string data (even when none
-of the characters are outside the ASCII range) is not guaranteed to be
-terminated by a NULL character, it is necessary to use the length-terminated
-copyinstr() intrinsic to read the string data from the process.
-
-You can find more information about HotSpot probes here:
-http://java.sun.com/javase/6/docs/technotes/guides/vm/dtrace.html
-
-
-===========
-THE SCRIPTS
-===========
-
-The following scripts/samples which demonstrate 'hotspot' probes usage are
-available:
-
-- class_loading_stat.d 
-  The script collects statistics about loaded and unloaded Java classes and
-  dump current state to stdout every N seconds.
-
-- gc_time_stat.d
-  The script measures the duration of a time spent in GC.
-  The duration is measured for every memory pool every N seconds.
-
-- hotspot_calls_tree.d
-  The script prints calls tree of fired 'hotspot' probes.
-
-- method_compile_stat.d
-  The script prints statistics about N methods with largest/smallest
-  compilation time every M seconds.
-
-- method_invocation_stat.d
-  The script collects statistics about Java method invocations.
-
-- method_invocation_stat_filter.d
-  The script collects statistics about Java method invocations.
-  You can specify package, class or method name to trace.
-
-- method_invocation_tree.d
-  The script prints tree of Java and JNI method invocations.
-
-- monitors.d
-  The script traces monitor related probes.
-
-- object_allocation_stat.d
-  The script collects statistics about N object allocations every M seconds.
-
-
-==========
-HOW TO RUN
-==========
-
-To run any D script from hotspot directory you can do either:
-
- # dscript.d -c "java ..."
-
- or if you don't have Solaris 10 patch which allows to specify probes that
- don't yet exist ( Hotspot DTrace probes are defined in libjvm.so and as
- result they could be not been yet loaded when you try to attach D script to
- the Java process) do:
-
- # ../helpers/dtrace_helper.d -c "java ..." dscript.d
-
- or if your application is already running you can just simply attach
- the D script like:
-
- # dscript.d -p JAVA_PID 
--- a/jdk/src/sample/solaris/dtrace/hotspot/class_loading_stat.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *    1. class_loading_stat.d -c "java ..." INTERVAL_SECS
- *    2. class_loading_stat.d -p JAVA_PID INTERVAL_SECS
- *
- * This script collects statistics about loaded and unloaded Java classes
- * and dump current state to stdout every INTERVAL_SECS seconds.  If
- * INTERVAL_SECS is not set then 10 seconds interval is used.
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option aggrate=100ms
-
-
-self char *str_ptr;
-self string class_name;
-self string package_name;
-
-int INTERVAL_SECS;
-
-:::BEGIN
-{
-    SAMPLE_NAME = "hotspot class loadin tracing";
-
-    INTERVAL_SECS = $1 ? $1 : 10;
-    SAMPLING_TIME = timestamp + INTERVAL_SECS * 1000000000ull;
-
-    LOADED_CLASSES_CNT = 0;
-    UNLOADED_CLASSES_CNT = 0;
-
-    LINE_SEP =
-    "------------------------------------------------------------------------";
-
-    printf("BEGIN %s\n\n", SAMPLE_NAME);
-}
-
-/*
- * hotspot:::class-loaded, hotspot:::class-unloaded probe arguments:
- *  arg0: char*,        class name passed as mUTF8 string
- *  arg1: uintptr_t,    class name length
- *  arg2: void*,        class loader ID, which is unique identifier for
- *                      a class loader in the VM.
- *  arg3: uintptr_t,    class is shared or not
- */
-hotspot$target:::class-loaded
-{
-    LOADED_CLASSES_CNT ++;
-
-    self->str_ptr = (char*) copyin(arg0, arg1+1);
-    self->str_ptr[arg1] = '\0';
-    self->class_name = (string) self->str_ptr;
-
-    self->package_name = dirname(self->class_name);
-
-    @classes_loaded[self->package_name] = count();
-}
-
-hotspot$target:::class-unloaded
-{
-    UNLOADED_CLASSES_CNT ++;
-
-    self->str_ptr = (char*) copyin(arg0, arg1+1);
-    self->str_ptr[arg1] = '\0';
-    self->class_name = (string) self->str_ptr;
-
-    self->package_name = dirname(self->class_name);
-
-    @classes_unloaded[self->package_name] = count();
-}
-
-
-tick-1sec
-/timestamp > SAMPLING_TIME/
-{
-    printf("%s\n", LINE_SEP);
-    printf("%Y\n", walltimestamp);
-    printf("%s\n", LINE_SEP);
-
-    printf("Loaded classes by package:\n");
-    printa("%10@d %s\n", @classes_loaded);
-
-    printf("\n");
-    printf("Unloaded classes by package:\n");
-    printa("%10@d %s\n", @classes_unloaded);
-
-    printf("\n");
-    printf("Number of loaded classes: %10d\n", LOADED_CLASSES_CNT);
-    printf("Number of unloaded classes: %10d\n", UNLOADED_CLASSES_CNT);
-
-    SAMPLING_TIME = timestamp + INTERVAL_SECS * 1000000000ull;
-}
-
-
-:::END
-{
-    printf("%s\n", LINE_SEP);
-    printf("%Y\n", walltimestamp);
-    printf("%s\n", LINE_SEP);
-
-    printf("Loaded classes by package:\n");
-    printa("%10@d %s\n", @classes_loaded);
-
-    printf("\n");
-    printf("Unloaded classes by package:\n");
-    printa("%10@d %s\n", @classes_unloaded);
-
-    printf("\n");
-    printf("Number of loaded classes: %10d\n", LOADED_CLASSES_CNT);
-    printf("Number of unloaded classes: %10d\n", UNLOADED_CLASSES_CNT);
-
-    printf("\nEND of %s\n", SAMPLE_NAME);
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-   exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot/gc_time_stat.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,203 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *    1. gc_time_stat.d -c "java ..." INTERVAL_SECS
- *    2. gc_time_stat.d -p JAVA_PID INTERVAL_SECS
- *
- * This script measures the duration of a time spent in GC.  The duration is
- * measured for every memory pool every INTERVAL_SECS seconds.  If
- * INTERVAL_SECS is not set then 10 seconds interval is used.
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option aggrate=100ms
-
-
-string TEST_NAME;
-self char *str_ptr;
-self string mgr_name;
-self string pool_name;
-
-int INTERVAL_SECS;
-
-:::BEGIN
-{
-    SAMPLE_NAME = "hotspot GC tracing";
-
-    START_TIME = timestamp;
-    gc_total_time = 0;
-    gc_total_count = 0;
-
-    INTERVAL_SECS = $1 ? $1 : 10;
-    SAMPLING_TIME = timestamp + INTERVAL_SECS * 1000000000ull;
-
-    LINE_SEP = "--------------------------------------------------------";
-
-    printf("BEGIN %s\n\n", SAMPLE_NAME);
-}
-
-
-/*
- * hotspot:::gc-begin
- *  arg0: uintptr_t,    boolean value which indicates
- *                      if this is to be a full GC or not
- */
-hotspot$target:::gc-begin
-{
-    self->gc_ts = timestamp;
-    printf("\nGC started: %Y\n", walltimestamp);
-    printf("%20s | %-20s | %10s\n", "manager", "pool", "time (ms)");
-    printf(" %s\n", LINE_SEP);
-}
-
-hotspot$target:::gc-end
-/self->gc_ts/
-{
-    self->time = (timestamp - self->gc_ts) / 1000;
-
-    printf(" %s\n", LINE_SEP);
-    printf("   %40s | %10d\n", "GC total", self->time);
-
-    gc_total_time += self->time;
-    gc_total_count ++;
-    self->gc_ts = 0;
-}
-
-/*
- * hotspot:::mem-pool-gc-begin, hotspot:::mem-pool-gc-end
- *  arg0: char*,        a pointer to mUTF-8 string data which contains the name
- *                          of the manager which manages this memory pool
- *  arg1: uintptr_t,    the length of the manager name (in bytes
- *  arg2: char*,        a pointer to mUTF-8 string data which contains the name
- *                          of the memory pool
- *  arg3: uintptr_t,    the length of the memory pool name (in bytes)
- *  arg4: uintptr_t,    the initial size of the memory pool (in bytes)
- *  arg5: uintptr_t,    the amount of memory in use in the memory pool
- *                          (in bytes)
- *  arg6: uintptr_t,    the number of committed pages in the memory pool
- *  arg7: uintptr_t,    the maximum size of the memory pool
- */
-hotspot$target:::mem-pool-gc-begin
-{
-    self->str_ptr = (char*) copyin(arg0, arg1+1);
-    self->str_ptr[arg1] = '\0';
-    self->mgr_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg2, arg3+1);
-    self->str_ptr[arg3] = '\0';
-    self->pool_name = (string) self->str_ptr;
-
-    self->mem_pool_ts[self->mgr_name, self->pool_name] = timestamp;
-}
-
-hotspot$target:::mem-pool-gc-end
-{
-    self->str_ptr = (char*) copyin(arg0, arg1+1);
-    self->str_ptr[arg1] = '\0';
-    self->mgr_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg2, arg3+1);
-    self->str_ptr[arg3] = '\0';
-    self->pool_name = (string) self->str_ptr;
-
-    self->time =
-        (timestamp - self->mem_pool_ts[self->mgr_name, self->pool_name]) / 1000;
-
-    printf(
-        "%20s | %-20s | %10d\n", self->mgr_name, self->pool_name, self->time);
-
-    @mem_pool_total_time[self->mgr_name, self->pool_name] = sum(self->time);
-    self->mem_pool_ts[self->mgr_name, self->pool_name] = 0;
-
-    @mem_pool_count[self->mgr_name, self->pool_name] = count();
-}
-
-tick-1sec
-/timestamp > SAMPLING_TIME/
-{
-    trace_time = (timestamp - START_TIME) / 1000;
-
-    printf(" %s\n", LINE_SEP);
-    printf("\nGC statistics, time: %Y\n\n", walltimestamp);
-    printf("%20s | %-20s | %10s\n", "manager", "pool", "total time");
-    printf(" %s\n", LINE_SEP);
-    printa("%20s | %-20s | %10@d\n", @mem_pool_total_time);
-    printf(" %s\n", LINE_SEP);
-    printf("   %40s | %10d\n", "total", gc_total_time);
-
-    printf("\n");
-    printf("%20s | %-20s | %10s\n", "manager", "pool", "# of calls");
-    printf(" %s\n", LINE_SEP);
-    printa("%20s | %-20s | %10@d\n", @mem_pool_count);
-    printf(" %s\n", LINE_SEP);
-    printf("   %40s | %10d\n", "total", gc_total_count);
-
-    SAMPLING_TIME = timestamp + INTERVAL_SECS * 1000000000ull;
-}
-
-:::END
-{
-    trace_time = (timestamp - START_TIME) / 1000;
-
-    printf(" %s\n", LINE_SEP);
-    printf("\nGC statistics, time: %Y\n\n", walltimestamp);
-    printf("%20s | %-20s | %10s\n", "manager", "pool", "total time");
-    printf(" %s\n", LINE_SEP);
-    printa("%20s | %-20s | %10@d\n", @mem_pool_total_time);
-    printf(" %s\n", LINE_SEP);
-    printf("   %40s | %10d\n", "total", gc_total_time);
-
-    printf("\n");
-    printf("%20s | %-20s | %10s\n", "manager", "pool", "# of calls");
-    printf(" %s\n", LINE_SEP);
-    printa("%20s | %-20s | %10@d\n", @mem_pool_count);
-    printf(" %s\n", LINE_SEP);
-    printf("   %40s | %10d\n", "total", gc_total_count);
-
-
-    printf("\nEND of %s\n", SAMPLE_NAME);
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-   exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot/hotspot_calls_tree.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *   1. hotspot_calls_tree.d -c "java ..."
- *   2. hotspot_calls_tree.d -p JAVA_PID
- *
- * This script prints calls tree of fired 'hotspot' probes.
- *
- * Notes: 
- *    The script uses 'monitors' probes which are disabled by default since
- *    it incurs performance overhead to the application. To enable them, you
- *    need to turn on the ExtendedDTraceProbes VM option. You can either
- *    start the application with -XX:+ExtendedDTraceProbes option or use the
- *    jinfo command to enable it at runtime as follows:
- *
- *       jinfo -flag +ExtendedDTraceProbes <java_pid>
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option aggrate=100ms
-
-self int indent;
-string PAUSE_AT_STARTUP_FILE;
-
-:::BEGIN
-{
-    SAMPLE_NAME = "hotspot probes tracing";
-
-    printf("BEGIN %s\n\n", SAMPLE_NAME);
-
-    self->indent = 10;
-}
-
-hotspot$target:::class-loaded,
-hotspot$target:::class-unloaded,
-hotspot$target:::compiled-method-load,
-hotspot$target:::compiled-method-unload,
-hotspot$target:::monitor-notify,
-hotspot$target:::monitor-notifyAll
-{
-    printf("%d %*s <-> %s\n", curcpu->cpu_id, self->indent, "", probename);
-}
-
-hotspot$target:::vm-init-begin,
-hotspot$target:::gc-begin,
-hotspot$target:::mem-pool-gc-begin,
-hotspot$target:::thread-start,
-hotspot$target:::method-compile-begin,
-hotspot$target:::monitor-contended-enter,
-hotspot$target:::monitor-wait
-{
-    self->indent ++;
-    printf("%d %*s -> %s\n", curcpu->cpu_id, self->indent, "", probename);
-}
-
-hotspot$target:::vm-init-end,
-hotspot$target:::vm-shutdown,
-hotspot$target:::gc-end,
-hotspot$target:::mem-pool-gc-end,
-hotspot$target:::thread-stop,
-hotspot$target:::method-compile-end,
-hotspot$target:::monitor-contended-entered,
-hotspot$target:::monitor-contended-exit,
-hotspot$target:::monitor-waited
-{
-    printf("%d %*s <- %s\n", curcpu->cpu_id, self->indent, "", probename);
-    self->indent --;
-}
-
-:::END
-{
-    printf("\nEND of %s\n", SAMPLE_NAME);
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-    exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot/method_compile_stat.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,274 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *   1. method_compile_stat.d -c "java ..." TOP_RESULTS_COUNT INTERVAL_SECS
- *   2. method_compile_stat.d -p JAVA_PID TOP_RESULTS_COUNT INTERVAL_SECS
- *
- * This script prints statistics about TOP_RESULTS_COUNT (default is 25)
- * methods with largest/smallest compilation time every INTERVAL_SECS
- * (default is 60) seconds.
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option aggrate=100ms
-
-
-self char *str_ptr;
-self string class_name;
-self string method_name;
-self string signature;
-
-int INTERVAL_SECS;
-
-:::BEGIN
-{
-    SAMPLE_NAME = "hotspot methods compilation tracing";
-
-    TOP_RESULTS_COUNT = $1 ? $1 : 25;
-    INTERVAL_SECS = $2 ? $2 : 60;
-
-    COMPILED_METHODS_COUNT = 0;
-    LOADED_METHODS_CNT = 0;
-    UNLOADED_METHODS_CNT = 0;
-
-    SAMPLING_TIME = timestamp + INTERVAL_SECS * 1000000000ull;
-
-    LINE_SEP =
-    "------------------------------------------------------------------------";
-
-    printf("BEGIN %s\n\n", SAMPLE_NAME);
-}
-
-/*
- * hotspot:::method-compile-begin
- *  arg0: char*,        a pointer to mUTF-8 string containing the name of
- *                          the compiler
- *  arg1: uintptr_t,    the length of the compiler name (in bytes)
- *  arg2: char*,        a pointer to mUTF-8 string containing the class name of
- *                          the method being compiled
- *  arg3: uintptr_t,    the length of the class name (in bytes)
- *  arg4: char*,        a pointer to mUTF-8 string containing the method name of
- *                          the method being compiled
- *  arg5: uintptr_t,    the length of the method name (in bytes)
- *  arg6: char*,        a pointer to mUTF-8 string containing the signature of
- *                          the method being compiled
- *  arg7: uintptr_t,    the length of the signature(in bytes)
- */
-hotspot$target:::method-compile-begin
-{
-    /*compiler_name, len, class_name, len, method_name, len, signature, len*/
-
-    self->str_ptr = (char*) copyin(arg0, arg1+1);
-    self->str_ptr[arg1] = '\0';
-    compiler_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg2, arg3+1);
-    self->str_ptr[arg3] = '\0';
-    self->class_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg4, arg5+1);
-    self->str_ptr[arg5] = '\0';
-    self->method_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg6, arg7+1);
-    self->str_ptr[arg7] = '\0';
-    self->signature = (string) self->str_ptr;
-
-    self->ts[self->class_name, self->method_name, self->signature] = timestamp;
-}
-
-/*
- * hotspot:::method-compile-end
- *  arg0: char*,        a pointer to mUTF-8 string containing the name of
- *                          the compiler
- *  arg1: uintptr_t,    the length of the compiler name (in bytes)
- *  arg2: char*,        a pointer to mUTF-8 string containing the class name of
- *                          the method being compiled
- *  arg3: uintptr_t,    the length of the class name (in bytes)
- *  arg4: char*,        a pointer to mUTF-8 string containing the method name of
- *                          the method being compiled
- *  arg5: uintptr_t,    the length of the method name (in bytes)
- *  arg6: char*,        a pointer to mUTF-8 string containing the signature of
- *                          the method being compiled
- *  arg7: uintptr_t,    the length of the signature(in bytes)
- *  arg8: uintptr_t,    boolean value which indicates if method
- *                          has been compiled successfuly
- */
-hotspot$target:::method-compile-end
-{
-    /* compiler_name, len, class_name, len, method_name, len,
-       signature, len, isSuccess */
-
-    self->str_ptr = (char*) copyin(arg0, arg1+1);
-    self->str_ptr[arg1] = '\0';
-    compiler_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg2, arg3+1);
-    self->str_ptr[arg3] = '\0';
-    self->class_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg4, arg5+1);
-    self->str_ptr[arg5] = '\0';
-    self->method_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg6, arg7+1);
-    self->str_ptr[arg7] = '\0';
-    self->signature = (string) self->str_ptr;
-}
-
-/*
- * Method was successfuly compiled
- */
-hotspot$target:::method-compile-end
-/arg8 && self->ts[self->class_name, self->method_name, self->signature]/
-{
-    /* compiler_name, len, class_name, len, method_name, len,
-       signature, len, isSuccess */
-
-    COMPILED_METHODS_COUNT++;
-
-    @compile_time_top[self->class_name, self->method_name, self->signature] =
-     avg((timestamp -
-      self->ts[self->class_name, self->method_name, self->signature]) / 1000);
-
-    @compile_time_last[self->class_name, self->method_name, self->signature] =
-     avg((timestamp -
-      self->ts[self->class_name, self->method_name, self->signature]) / 1000);
-
-    self->ts[self->class_name, self->method_name, self->signature] = 0;
-}
-
-/*
- * Method compilation was failed
- */
-hotspot$target:::method-compile-end
-/arg8 != 1 && self->ts[self->class_name, self->method_name, self->signature]/
-{
-    /* compiler_name, len, class_name, len, method_name, len,
-       signature, len, isSuccess */
-
-    @fail_compile_count[self->class_name,
-                        self->method_name, self->signature] = count();
-}
-
-hotspot$target:::compiled-method-load
-{
-    /* class_name, len, method_name, len, signature, len, code_address, size */
-
-    LOADED_METHODS_CNT ++;
-}
-
-hotspot$target:::compiled-method-unload
-{
-    /* class_name, len, method_name, len, signature, len, code_address, size */
-
-    UNLOADED_METHODS_CNT ++;
-}
-
-
-tick-1sec
-/timestamp > SAMPLING_TIME/
-{
-    trunc(@compile_time_top, TOP_RESULTS_COUNT);
-    trunc(@compile_time_last, -TOP_RESULTS_COUNT);
-
-    printf("\n");
-    printf("%s\n", LINE_SEP);
-    printf("%Y\n", walltimestamp);
-    printf("%s\n", LINE_SEP);
-
-    printf(
-        "\nTop %d methods with largest compilation time (in milleseconds):\n",
-        TOP_RESULTS_COUNT);
-    printa("%10@d %s::%s%s\n", @compile_time_top);
-
-    printf(
-        "\nTop %d methods with smallest compilation time (in milleseconds):\n",
-        TOP_RESULTS_COUNT);
-    printa("%10@d %s::%s%s\n", @compile_time_last);
-
-    printf("\n");
-    printf("Compiled methods:         %10d\n", COMPILED_METHODS_COUNT);
-    printf("Loaded compiled methods:  %10d\n", LOADED_METHODS_CNT);
-    printf("Unoaded compiled methods: %10d\n", UNLOADED_METHODS_CNT);
-
-    printf("\nFailed compilation:\n");
-    printa("%10@d %s::%s%s\n", @fail_compile_count);
-
-    SAMPLING_TIME = timestamp + INTERVAL_SECS * 1000000000ull;
-}
-
-:::END
-{
-    trunc(@compile_time_top, TOP_RESULTS_COUNT);
-    trunc(@compile_time_last, -TOP_RESULTS_COUNT);
-
-    printf("\n");
-    printf("%s\n", LINE_SEP);
-    printf("%Y\n", walltimestamp);
-    printf("%s\n", LINE_SEP);
-
-    printf(
-        "\nTop %d methods with largest compilation time (in milleseconds):\n",
-        TOP_RESULTS_COUNT);
-    printa("%10@d %s::%s%s\n", @compile_time_top);
-
-    printf(
-        "\nTop %d methods with smallest compilation time (in milleseconds):\n",
-        TOP_RESULTS_COUNT);
-    printa("%10@d %s::%s%s\n", @compile_time_last);
-
-    printf("\n");
-    printf("Compiled methods:         %10d\n", COMPILED_METHODS_COUNT);
-    printf("Loaded compiled methods:  %10d\n", LOADED_METHODS_CNT);
-    printf("Unoaded compiled methods: %10d\n", UNLOADED_METHODS_CNT);
-
-    printf("\nFailed compilations:\n");
-    printa("%10@d %s::%s%s\n", @fail_compile_count);
-
-    printf("\nEND of %s\n", SAMPLE_NAME);
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-   exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot/method_invocation_stat.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,210 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *    1. method_invocation_stat.d -c "java ..."
- *    2. method_invocation_stat.d -p JAVA_PID
- *
- * This script collects statistics about Java method invocations.
- *
- * Notes:
- *  - These probes are disabled by default since it incurs performance
- *    overhead to the application. To trace the method-entry and
- *    method-exit probes, you need to turn on the ExtendedDTraceProbes VM
- *    option.  
- *    You can either start the application with -XX:+ExtendedDTraceProbes
- *    option or use the jinfo command to enable it at runtime as follows:
- *
- *       jinfo -flag +ExtendedDTraceProbes <java_pid>
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option bufsize=16m
-#pragma D option aggrate=100ms
-
-
-self char *str_ptr;
-self string class_name;
-self string method_name;
-self string signature;
-self string package_name;
-self string last_class_name;
-
-long long JAVA_CALLS;
-long long JNI_CALLS;
-long long SYS_CALLS;
-
-int SYS_DEEP;
-long long LAST_SYS_TS;
-
-long long START_TIME;
-long long JAVA_TIME;
-long long RUN_TIME;
-long long SYS_TIME;
-
-BEGIN
-{
-    SAMPLE_NAME = "hotspot method invocation tracing";
-
-    START_TIME = timestamp;
-    SYS_TIME = 0;
-
-    printf("BEGIN %s\n\n", SAMPLE_NAME);
-}
-
-/*
- * hotspot:::method-entry, hotspot:::method-return probe arguments:
- *  arg0: uintptr_t,    Java thread id
- *  arg1: char*,        a pointer to mUTF-8 string containing the name of
- *                          the class of the method being entered
- *  arg2: uintptr_t,    the length of the class name (in bytes)
- *  arg3: char*,        a pointer to mUTF-8 string data which contains the
- *                          name of the method being entered
- *  arg4: uintptr_t,    the length of the method name (in bytes)
- *  arg5: char*,        a pointer to mUTF-8 string data which contains the
- *                          signature of the method being entered
- *  arg6: uintptr_t,    the length of the signature(in bytes)
- */
-hotspot$target:::method-entry
-{
-    self->str_ptr = (char*) copyin(arg1, arg2+1);
-    self->str_ptr[arg2] = '\0';
-    self->class_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg3, arg4+1);
-    self->str_ptr[arg4] = '\0';
-    self->method_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg5, arg6+1);
-    self->str_ptr[arg6] = '\0';
-    self->signature = (string) self->str_ptr;
-
-
-    self->package_name = dirname(self->class_name);
-
-    JAVA_CALLS ++;
-    @method_calls[self->class_name,
-                  self->method_name, self->signature] = count();
-    @class_calls[self->class_name] = count();
-    @package_calls[self->package_name] = count();
-}
-
-
-hotspot_jni$target:::*-entry
-{
-    JNI_CALLS ++;
-
-    @jni_calls[probename] = count();
-}
-
-syscall:::entry
-/pid == $target && SYS_DEEP == 0/
-{
-    LAST_SYS_TS = timestamp;
-}
-
-syscall:::entry
-/pid == $target/
-{
-    SYS_DEEP ++;
-    @sys_calls[probefunc] = count();
-    SYS_CALLS ++;
-}
-
-syscall:::return
-/pid == $target/
-{
-    SYS_DEEP --;
-}
-
-syscall:::return
-/pid == $target && SYS_DEEP == 0/
-{
-    SYS_TIME += (timestamp - LAST_SYS_TS);
-}
-
-
-:::END
-{
-    RUN_TIME = (timestamp - START_TIME);
-    JAVA_TIME = (RUN_TIME - SYS_TIME);
-
-    printf("System calls:\n");
-    printa("%10@d %s\n", @sys_calls);
-    printf("\n");
-
-    printf("JNI calls:\n");
-    printa("%10@d %s\n", @jni_calls);
-    printf("\n");
-
-    printf("Top packages calls:\n");
-    printa("%10@d %s\n", @package_calls);
-    printf("\n");
-
-    printf("Top class calls:\n");
-    printa("%10@d %s\n", @class_calls);
-    printf("\n");
-
-    printf("Top method calls:\n");
-    printa("%10@d %s:%s:%s\n", @method_calls);
-    printf("\n");
-
-    printf("=======================================\n");
-    printf("JAVA_CALLS: %10d\n", JAVA_CALLS);
-    printf(" JNI_CALLS: %10d\n", JNI_CALLS);
-    printf(" SYS_CALLS: %10d\n", SYS_CALLS);
-    printf("\n");
-
-    printf("Run time:       %15d\n", RUN_TIME);
-    printf("Syscall time:   %15d\n", SYS_TIME);
-    printf("Java+JNI time:  %15d\n", JAVA_TIME);
-    printf("\n");
-}
-
-:::END
-{
-    printf("\nEND %s\n", SAMPLE_NAME);
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-    exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot/method_invocation_stat_filter.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,204 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *   1. method_invocation_stat_filter.d -c "java ..." p|c|m package|class_name|method_name
- *   2. method_invocation_stat_filter.d -p JAVA_PID  p|c|m package|class_name|method_name
- *
- * example:
- *      method_invocation_stat_filter.d -c "java -version" '"p"' '"sun/util"'
- *
- * This script collects statistics about Java method invocations.
- *
- * Notes:
- *  - These probes are disabled by default since it incurs performance
- *    overhead to the application. To trace the method-entry and
- *    method-exit probes, you need to turn on the ExtendedDTraceProbes VM
- *    option.  
- *    You can either start the application with -XX:+ExtendedDTraceProbes
- *    option or use the jinfo command to enable it at runtime as follows:
- *
- *       jinfo -flag +ExtendedDTraceProbes <java_pid>
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option bufsize=16m
-#pragma D option aggrate=100ms
-
-
-self char *str_ptr;
-self string class_name;
-self string method_name;
-self string signature;
-self string package_name;
-self string last_class_name;
-
-long long JAVA_CALLS;
-
-long long START_TIME;
-long long JAVA_TIME;
-long long RUN_TIME;
-
-string FILTER_TYPE;
-string FILTER_VALUE;
-
-
-:::BEGIN
-{
-    SAMPLE_NAME = "hotspot method invocation tracing";
-
-    START_TIME = timestamp;
-
-    FILTER_TYPE = $1;
-    FILTER_VALUE = $2;
-
-    START_TIME = timestamp;
-
-    printf("BEGIN %s\n\n", SAMPLE_NAME);
-}
-
-/*
- * hotspot:::method-entry, hotspot:::method-return probe arguments:
- *  arg0: uintptr_t,    Java thread id
- *  arg1: char*,        a pointer to mUTF-8 string containing the name of
- *                          the class of the method being entered
- *  arg2: uintptr_t,    the length of the class name (in bytes)
- *  arg3: char*,        a pointer to mUTF-8 string data which contains the
- *                          name of the method being entered
- *  arg4: uintptr_t,    the length of the method name (in bytes)
- *  arg5: char*,        a pointer to mUTF-8 string data which contains the
- *                          signature of the method being entered
- *  arg6: uintptr_t,    the length of the signature(in bytes)
- */
-hotspot$target:::method-entry
-{
-    self->str_ptr = (char*) copyin(arg1, arg2+1);
-    self->str_ptr[arg2] = '\0';
-    self->class_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg3, arg4+1);
-    self->str_ptr[arg4] = '\0';
-    self->method_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg5, arg6+1);
-    self->str_ptr[arg6] = '\0';
-    self->signature = (string) self->str_ptr;
-
-
-    self->package_name = dirname(self->class_name);
-}
-
-hotspot$target:::method-entry
-/FILTER_TYPE == ""/
-{
-    JAVA_CALLS ++;
-    @method_calls[self->class_name,
-                  self->method_name, self->signature] = count();
-    @class_calls[self->class_name] = count();
-    @package_calls[self->package_name] = count();
-}
-
-hotspot$target:::method-entry
-/FILTER_TYPE == "p"  && self->package_name == FILTER_VALUE/
-{
-    JAVA_CALLS ++;
-    @method_calls[self->class_name,
-                  self->method_name, self->signature] = count();
-    @class_calls[self->class_name] = count();
-    @package_calls[self->package_name] = count();
-}
-
-hotspot$target:::method-entry
-/FILTER_TYPE == "c"  && self->class_name == FILTER_VALUE/
-{
-    JAVA_CALLS ++;
-    @method_calls[self->class_name,
-                  self->method_name, self->signature] = count();
-    @class_calls[self->class_name] = count();
-    @package_calls[self->package_name] = count();
-}
-
-hotspot$target:::method-entry
-/FILTER_TYPE == "m"  && self->method_name == FILTER_VALUE/
-{
-    JAVA_CALLS ++;
-    @method_calls[self->class_name,
-                  self->method_name, self->signature] = count();
-    @class_calls[self->class_name] = count();
-    @package_calls[self->package_name] = count();
-}
-
-
-:::END
-{
-    RUN_TIME = (timestamp - START_TIME);
-    JAVA_TIME = RUN_TIME;
-
-    printf("Top packages calls:\n");
-    printa("%10@d %s\n", @package_calls);
-    printf("\n");
-
-    printf("Top class calls:\n");
-    printa("%10@d %s\n", @class_calls);
-    printf("\n");
-
-    printf("Top method calls:\n");
-    printa("%10@d %s:%s:%s\n", @method_calls);
-    printf("\n");
-
-    printf("=======================================\n");
-    printf("JAVA_CALLS: %10d\n", JAVA_CALLS);
-    printf("\n");
-
-    printf("Run time:       %15d\n", RUN_TIME);
-    printf("\n");
-}
-
-:::END
-{
-    printf("\nEND of %s\n", SAMPLE_NAME);
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-    exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot/method_invocation_tree.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *   1. method_invocation_tree.d -c "java ..."
- *   2. method_invocation_tree.d -p JAVA_PID
- *
- * This script prints tree of Java and JNI method invocations.
- *
- * Notes:
- *  - These probes are disabled by default since it incurs performance
- *    overhead to the application. To trace the method-entry and
- *    method-exit probes, you need to turn on the ExtendedDTraceProbes VM
- *    option.  
- *    You can either start the application with -XX:+ExtendedDTraceProbes
- *    option or use the jinfo command to enable it at runtime as follows:
- *
- *       jinfo -flag +ExtendedDTraceProbes <java_pid>
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option bufsize=16m
-#pragma D option aggrate=100ms
-
-self char *str_ptr;
-self string class_name;
-self string method_name;
-self string signature;
-
-self int indent;
-
-BEGIN
-{
-    SAMPLE_NAME = "hotspot method invocation tracing";
-
-    printf("BEGIN %s\n\n", SAMPLE_NAME);
-}
-
-hotspot$target:::*
-/!self->indent/
-{
-    self->indent = 0;
-}
-
-/*
- * hotspot:::method-entry, hotspot:::method-return probe arguments:
- *  arg0: uintptr_t,    Java thread id
- *  arg1: char*,        a pointer to mUTF-8 string containing the name of
- *                          the class of the method being entered
- *  arg2: uintptr_t,    the length of the class name (in bytes)
- *  arg3: char*,        a pointer to mUTF-8 string data which contains the
- *                          name of the method being entered
- *  arg4: uintptr_t,    the length of the method name (in bytes)
- *  arg5: char*,        a pointer to mUTF-8 string data which contains the
- *                          signature of the method being entered
- *  arg6: uintptr_t,    the length of the signature(in bytes)
- */
-
-hotspot$target:::method-return
-{
-    self->indent --;
-    METHOD_RETURN_CNT ++
-}
-
-hotspot$target:::method-entry
-{
-    self->indent ++;
-    METHOD_ENTRY_CNT ++;
-
-    self->str_ptr = (char*) copyin(arg1, arg2+1);
-    self->str_ptr[arg2] = '\0';
-    self->class_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg3, arg4+1);
-    self->str_ptr[arg4] = '\0';
-    self->method_name = (string) self->str_ptr;
-
-    self->str_ptr = (char*) copyin(arg5, arg6+1);
-    self->str_ptr[arg6] = '\0';
-    self->signature = (string) self->str_ptr;
-
-    printf("%-10u%*s%s:%s:%s\n",
-        tid, self->indent, "", self->class_name,
-        self->method_name, self->signature);
-
-}
-
-hotspot_jni$target:::*_entry
-{
-    printf("%-10u%*sJNI:%s\n", tid, self->indent+1, "", probename);
-}
-
-:::END
-{
-    printf("METHOD_ENTRY_CNT:  %10d\n", METHOD_ENTRY_CNT);
-    printf("METHOD_RETURN_CNT: %10d\n", METHOD_RETURN_CNT);
-
-    printf("\nEND of %s\n", SAMPLE_NAME);
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-   exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot/monitors.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *   1. monitors.d -c "java ..."
- *   2. monitors.d -p JAVA_PID
- *
- * The script traces monitor related probes.
- *
- * Notes:
- *  - These probes are disabled by default since it incurs performance
- *    overhead to the application. To trace the monitor-* probes, you need
- *    to turn on the ExtendedDTraceProbes VM option.
- *    You can either start the application with -XX:+ExtendedDTraceProbes
- *    option or use the jinfo command to enable it at runtime as follows:
- *
- *       jinfo -flag +ExtendedDTraceProbes <java_pid>
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option aggrate=100ms
-
-
-self string thread_name;
-self char* str_ptr;
-
-:::BEGIN
-{
-    SAMPLE_NAME = "hotspot monitors tracing";
-
-    printf("BEGIN %s\n\n", SAMPLE_NAME);
-}
-
-/*
- * hotspot:::thread-start, hotspot:::thread-stop probe arguments:
- *  arg0: char*,        thread name passed as mUTF8 string
- *  arg1: uintptr_t,    thread name length
- *  arg2: uintptr_t,    Java thread id
- *  arg3: uintptr_t,    native/OS thread id
- *  arg4: uintptr_t,    is a daemon or not
- */
-hotspot$target:::thread-start
-{
-    self->str_ptr = (char*) copyin(arg0, arg1+1);
-    self->str_ptr[arg1] = '\0';
-    self->thread_name = (string) self->str_ptr;
-
-    printf("thread-start: id=%d, is_daemon=%d, name=%s, os_id=%d\n",
-            arg2, arg4, self->thread_name, arg3);
-
-    threads[arg2] = self->thread_name;
-}
-
-
-hotspot$target:::thread-stop
-{
-    self->str_ptr = (char*) copyin(arg0, arg1+1);
-    self->str_ptr[arg1] = '\0';
-    self->thread_name = (string) self->str_ptr;
-
-
-    printf("thread-stop: id=%d, is_daemon=%d, name=%s, os_id=%d\n",
-            arg2, arg4, self->thread_name, arg3);
-}
-
-/*
- *
- * hotspot::monitor-contended-enter, hotspot::monitor-contended-entered
- *
- *  arg0: uintptr_t,    the Java thread identifier for the thread peforming
- *                          the monitor operation
- *  arg1: uintptr_t,    a unique, but opaque identifier for the specific
- *                          monitor that the action is performed upon
- *  arg2: char*,        a pointer to mUTF-8 string data which contains the
- *                          name of the class of the object being acted upon
- *  arg3: uintptr_t,    the length of the class name (in bytes)
- */
-
-hotspot$target:::monitor-contended-enter
-{
-    /* (uintptr_t thread_id, uintptr_t monitor_id,
-       char* obj_class_name, uintptr_t obj_class_name_len) */
-
-    self->str_ptr = (char*) copyin(arg2, arg3+1);
-    self->str_ptr[arg3] = '\0';
-    self->class_name = (string) self->str_ptr;
-
-    monitors[arg1] = self->class_name;
-
-    monitors_enter[arg1] = arg0;
-    printf("%s: -> enter monitor (%d) %s\n",
-        threads[arg0], arg1, monitors[arg1]);
-}
-
-hotspot$target:::monitor-contended-entered
-{
-    /* (uintptr_t thread_id, uintptr_t monitor_id, char* obj_class_name,
-        uintptr_t obj_class_name_len) */
-
-    monitors_entered[arg1] = arg0;
-    printf("%s: <- entered monitor (%d) %s\n",
-        threads[arg0], arg1, monitors[arg1]);
-}
-
-
-:::END
-{
-    printf("\nEND of %s\n", SAMPLE_NAME);
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-   exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot/object_allocation_stat.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *    1. object_allocation_stat.d -c "java ..." TOP_RESULTS_COUNT INTERVAL_SECS
- *    2. object_allocation_stat.d -p JAVA_PID TOP_RESULTS_COUNT INTERVAL_SECS
- *
- * This script collects statistics about TOP_RESULTS_COUNT (default is 25)
- * object allocations every INTERVAL_SECS (default is 60) seconds.
- *
- * The results are displayed in ascending order which means that the highest
- * allocated type is listed last. The script can be improved to sort the
- * results in reverse order when DTrace supports it.
- *
- * Notes:
- *  - The object-alloc probe is disabled by default since it incurs
- *    performance overhead to the application. To trace object-alloc probe,
- *    you need to turn on the ExtendedDTraceProbes VM option.
- *    You can either start the application with -XX:+ExtendedDTraceProbes
- *    option or use the jinfo command to enable it at runtime as follows:
- *
- *       jinfo -flag +ExtendedDTraceProbes <java_pid>
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option bufsize=16m
-#pragma D option aggrate=100ms
-
-
-self char *str_ptr;
-self string class_name;
-
-long long ALLOCATED_OBJECTS_CNT;
-
-int INTERVAL_SECS;
-
-:::BEGIN
-{
-    SAMPLE_NAME = "hotspot object allocation tracing";
-
-    TOP_RESULTS_COUNT = $1 ? $1 : 25;
-    INTERVAL_SECS = $2 ? $2 : 60;
-
-    ALLOCATED_OBJECTS_CNT = 0;
-
-    SAMPLING_TIME = timestamp + INTERVAL_SECS * 1000000000ull;
-
-    LINE_SEP =
-    "------------------------------------------------------------------------";
-
-    printf("BEGIN %s\n\n", SAMPLE_NAME);
-}
-
-/*
- * hotspot:::object-alloc probe arguments:
- *  arg0: uintptr_t,    Java thread id
- *  arg1: char*,        a pointer to mUTF-8 string containing the name of
- *                          the class of the object being allocated
- *  arg2: uintptr_t,    the length of the class name (in bytes)
- *  arg3: uintptr_t,    the size of the object being allocated
- */
-hotspot$target:::object-alloc
-{
-    ALLOCATED_OBJECTS_CNT ++;
-
-    self->str_ptr = (char*) copyin(arg1, arg2+1);
-    self->str_ptr[arg2] = '\0';
-    self->class_name = (string) self->str_ptr;
-
-
-    @allocs_count[self->class_name] = count();
-    @allocs_size[self->class_name] = sum(arg3);
-}
-
-tick-1sec
-/timestamp > SAMPLING_TIME/
-{
-    printf("\n");
-    printf("%s\n", LINE_SEP);
-    printf("%Y\n", walltimestamp);
-    printf("%s\n", LINE_SEP);
-
-    printf("\n");
-    printf("Top %d allocations by size:\n", TOP_RESULTS_COUNT);
-    trunc(@allocs_size, TOP_RESULTS_COUNT);
-    printa("%10@d %s\n", @allocs_size);
-
-    printf("\n");
-    printf("Top %d allocations by count:\n", TOP_RESULTS_COUNT);
-    trunc(@allocs_count, TOP_RESULTS_COUNT);
-    printa("%10@d %s\n", @allocs_count);
-
-    printf("\nTotal number of allocated objects: %d\n", ALLOCATED_OBJECTS_CNT);
-
-    SAMPLING_TIME = timestamp + INTERVAL_SECS * 1000000000ull;
-}
-
-:::END
-{
-    printf("\n");
-    printf("%s\n", LINE_SEP);
-    printf("%Y\n", walltimestamp);
-    printf("%s\n", LINE_SEP);
-
-    printf("\n");
-    printf("Top %d allocations by size:\n", TOP_RESULTS_COUNT);
-    trunc(@allocs_size, TOP_RESULTS_COUNT);
-    printa("%10@d %s\n", @allocs_size);
-
-    printf("\n");
-    printf("Top %d allocations by count:\n", TOP_RESULTS_COUNT);
-    trunc(@allocs_count, TOP_RESULTS_COUNT);
-    printa("%10@d %s\n", @allocs_count);
-
-    printf("\nTotal number of allocated objects: %d\n", ALLOCATED_OBJECTS_CNT);
-
-    printf("\nEND of %s\n", SAMPLE_NAME);
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-   exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot_jni/CriticalSection.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *    1. CriticalSection.d -c "java ..."
- *    2. CriticalSection.d -p JAVA_PID
- *
- * The script inspect a JNI application for Critical Section violations.
- *
- * Critical section is the space between calls to JNI methods:
- *   - GetPrimitiveArrayCritical and ReleasePrimitiveArrayCritical; or
- *   - GetStringCritical and ReleaseStringCritical.
- *
- * Inside a critical section, native code must not call other JNI functions,
- * or any system call that may cause the current thread to block and wait
- * for another Java thread. (For example, the current thread must not call
- * read on a stream being written by another Java thread.)
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option bufsize=16m
-#pragma D option aggrate=100ms
-
-
-self int in_critical_section;
-self string critical_section_name;
-
-int CRITICAL_SECTION_VIOLATION_CNT;
-
-:::BEGIN
-{
-    SAMPLE_NAME = "critical section violation checks";
-
-    printf("BEGIN %s\n", SAMPLE_NAME);
-}
-
-/*
- *   Multiple pairs of GetPrimitiveArrayCritical/ReleasePrimitiveArrayCritical,
- *   GetStringCritical/ReleaseStringCritical may be nested
- */
-hotspot_jni$target:::*_entry
-/self->in_critical_section > 0 &&
-  probename != "GetPrimitiveArrayCritical_entry" &&
-  probename != "GetStringCritical_entry" &&
-  probename != "ReleasePrimitiveArrayCritical_entry" &&
-  probename != "ReleaseStringCritical_entry" &&
-  probename != "GetPrimitiveArrayCritical_return" &&
-  probename != "GetStringCritical_return" &&
-  probename != "ReleasePrimitiveArrayCritical_return" &&
-  probename != "ReleaseStringCritical_return"/
-{
-    printf("\nJNI call %s made from JNI critical region '%s'\n",
-        probename, self->critical_section_name);
-
-    printf("Jstack:\n");
-    jstack(50, 500);
-
-    CRITICAL_SECTION_VIOLATION_CNT ++;
-}
-
-syscall:::entry
-/pid == $target && self->in_critical_section > 0/
-{
-    printf("\nSystem call %s made in JNI critical region '%s'\n",
-        probefunc, self->critical_section_name);
-
-    printf("Jstack:\n");
-    jstack(50, 500);
-
-    CRITICAL_SECTION_VIOLATION_CNT ++;
-}
-
-hotspot_jni$target:::ReleasePrimitiveArrayCritical_entry,
-hotspot_jni$target:::ReleaseStringCritical_entry
-/self->in_critical_section > 0/
-{
-    self->in_critical_section --;
-}
-
-hotspot_jni$target:::GetPrimitiveArrayCritical_return
-{
-    self->in_critical_section ++;
-    self->critical_section_name = "GetPrimitiveArrayCritical";
-}
-
-hotspot_jni$target:::GetStringCritical_return
-{
-    self->in_critical_section ++;
-    self->critical_section_name = "GetStringCritical";
-}
-
-
-:::END
-{
-    printf("%d critical section violations have been discovered\n",
-        CRITICAL_SECTION_VIOLATION_CNT);
-
-    printf("\nEND of %s\n", SAMPLE_NAME);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot_jni/CriticalSection_slow.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,178 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *    1. CriticalSection_slow.d -c "java ..."
- *    2. CriticalSection_slow.d -p JAVA_PID
- *
- * The script inspect a JNI application for Critical Section violations.
- *
- * Critical section is the space between calls to JNI methods:
- *   - GetPrimitiveArrayCritical and ReleasePrimitiveArrayCritical; or
- *   - GetStringCritical and ReleaseStringCritical.
- *
- * Inside a critical section, native code must not call other JNI functions,
- * or any system call that may cause the current thread to block and wait
- * for another Java thread. (For example, the current thread must not call
- * read on a stream being written by another Java thread.)
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option bufsize=16m
-#pragma D option aggrate=100ms
-
-
-self int in_critical_section;
-self string critical_section_name;
-
-self char *str_ptr;
-self string class_name;
-self string method_name;
-self string signature;
-
-self int indent;
-self int JAVA_STACK_DEEP;
-
-int CRITICAL_SECTION_VIOLATION_CNT;
-
-:::BEGIN
-{
-    SAMPLE_NAME = "critical section violation checks";
-
-    printf("BEGIN %s\n", SAMPLE_NAME);
-}
-
-hotspot$target:::*
-/!self->JAVA_STACK_DEEP/
-{
-    self->JAVA_STACK_DEEP = 0;
-}
-
-
-hotspot$target:::method-return
-/self->JAVA_STACK_DEEP > 0/
-{
-    self->JAVA_STACK_DEEP --;
-}
-
-hotspot$target:::method-entry
-{
-    self->JAVA_STACK_DEEP ++;
-
-    self->str_ptr = (char*) copyin(arg1, arg2+1);
-    self->str_ptr[arg2] = '\0';
-    self->method_name = strjoin( (string) self->str_ptr, ":");
-
-    self->str_ptr = (char*) copyin(arg3, arg4+1);
-    self->str_ptr[arg4] = '\0';
-    self->method_name = strjoin(self->method_name, (string) self->str_ptr);
-    self->method_name = strjoin(self->method_name, ":");
-
-    self->str_ptr = (char*) copyin(arg5, arg6+1);
-    self->str_ptr[arg6] = '\0';
-    self->method_name = strjoin(self->method_name, (string) self->str_ptr);
-
-    self->JAVA_STACK[self->JAVA_STACK_DEEP] = self->method_name;
-
-/*    printf("%-10u%*s%s\n",
- *      curcpu->cpu_id, self->indent, "", self->method_name);
- */
-}
-
-
-/*
- *   Multiple pairs of GetPrimitiveArrayCritical/ReleasePrimitiveArrayCritical,
- *   GetStringCritical/ReleaseStringCritical may be nested
- */
-hotspot_jni$target:::*_entry
-/self->in_critical_section > 0 &&
-  probename != "GetPrimitiveArrayCritical_entry" &&
-  probename != "GetStringCritical_entry" &&
-  probename != "ReleasePrimitiveArrayCritical_entry" &&
-  probename != "ReleaseStringCritical_entry" &&
-  probename != "GetPrimitiveArrayCritical_return" &&
-  probename != "GetStringCritical_return" &&
-  probename != "ReleasePrimitiveArrayCritical_return" &&
-  probename != "ReleaseStringCritical_return"/
-{
-    printf("JNI call %s made from JNI critical region '%s' from %s\n",
-        probename, self->critical_section_name,
-        self->JAVA_STACK[self->JAVA_STACK_DEEP]);
-
-    CRITICAL_SECTION_VIOLATION_CNT ++;
-}
-
-syscall:::entry
-/pid == $target && self->in_critical_section > 0/
-{
-    printf("system call %s made in JNI critical region '%s' from %s\n",
-        probefunc, self->critical_section_name,
-        self->JAVA_STACK[self->JAVA_STACK_DEEP]);
-
-    CRITICAL_SECTION_VIOLATION_CNT ++;
-}
-
-hotspot_jni$target:::ReleasePrimitiveArrayCritical_entry,
-hotspot_jni$target:::ReleaseStringCritical_entry
-/self->in_critical_section > 0/
-{
-    self->in_critical_section --;
-}
-
-hotspot_jni$target:::GetPrimitiveArrayCritical_return
-{
-    self->in_critical_section ++;
-    self->critical_section_name = "GetPrimitiveArrayCritical";
-}
-
-hotspot_jni$target:::GetStringCritical_return
-{
-    self->in_critical_section ++;
-    self->critical_section_name = "GetStringCritical";
-}
-
-
-:::END
-{
-    printf("%d critical section violations have been discovered\n",
-        CRITICAL_SECTION_VIOLATION_CNT);
-
-    printf("\nEND of %s\n", SAMPLE_NAME);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot_jni/README.txt	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-================================
-'hotspot_jni' PROBES DESCRIPTION
-================================
-
-This directory contains D scripts which demonstrate usage of 'hotspot_jni'
-provider probes. 
-
-In order to call from native code to Java code, due to embedding of the VM
-in an application or execution of native code within a Java application, the
-native code must make a call through the JNI interface. The JNI interface
-provides a number of methods for invoking Java code and examining the state
-of the VM. DTrace probes are provided at the entry point and return point
-for each of these methods. The probes are provided by the hotspot_jni
-provider. The name of the probe is the name of the JNI method, appended with
-"-entry" for entry probes, and "-return" for return probes. The arguments
-available at each entry probe are the arguments that were provided to the
-function (with the exception of the Invoke* methods, which omit the
-arguments that are passed to the Java method). The return probes have the
-return value of the method as an argument (if available).
-
-You can find more information about HotSpot probes here:
-http://java.sun.com/javase/6/docs/technotes/guides/vm/dtrace.html
-
-===========
-THE SCRIPTS
-===========
-
-The following scripts/samples which demonstrate hotspot_jni probes usage are
-available:
-
-- CriticalSection.d
-  Inspect a JNI application for Critical Section violations.
-
-- CriticalSection_slow.d
-  Do the same as CriticalSection.d but provide more debugging info.
-
-- hotspot_jni_calls_stat.d
-  This script collects statistics about how many times particular JNI method
-  has been called.
-
-- hotspot_jni_calls_tree.d
-  The script prints tree of JNI method calls.
-
-See more details in the scripts.
-
-
-==========
-HOW TO RUN
-==========
-To run any dscript from hotspot directory you can do either:
-
- # dscript.d -c "java ..."
-
- or if you don't have Solaris 10 patch which allows to specify probes that
- don't yet exist ( Hotspot DTrace probes are defined in libjvm.so and as
- result they could be not been yet loaded when you try to attach dscript to
- the Java process) do:
-
- # ../helpers/dtrace_helper.d -c "java ..." dscript.d
-
- or if your application is already running you can just simply attach
- the D script like:
-
- # dscript.d -p JAVA_PID
--- a/jdk/src/sample/solaris/dtrace/hotspot_jni/hotspot_jni_calls_stat.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *    1. hotspot_jni_calls_stat.d -c "java ..."
- *    2. hotspot_jni_calls_stat.d -p JAVA_PID
- *
- * This script collects statistics about how many times particular JNI
- * method has been called.
- *
- */
-
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option bufsize=16m
-#pragma D option aggrate=100ms
-
-
-:::BEGIN
-{
-    printf("BEGIN hotspot_jni tracing\n");
-}
-
-
-hotspot_jni$target:::*-entry
-{
-    JNI_CALLS ++;
-    @jni_calls[probename] = count();
-}
-
-:::END
-{
-    printa("%10@d %s\n", @jni_calls);
-    printf("\n");
-    printf("Total number of JNI calls: %d\n", JNI_CALLS);
-
-    printf("\nEND hotspot_jni tracing.\n");
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-   exit(0);
-}
--- a/jdk/src/sample/solaris/dtrace/hotspot_jni/hotspot_jni_calls_tree.d	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-#!/usr/sbin/dtrace -Zs
-
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
-*/
-
-/*
- * Usage:
- *   1. hotspot_jni_calls_tree.d -c "java ..."
- *   2. hotspot_jni_calls_tree.d -p JAVA_PID
- *
- * The script prints tree of JNI method calls.
- *
- */
-
-#pragma D option quiet
-#pragma D option destructive
-#pragma D option defaultargs
-#pragma D option bufsize=16m
-#pragma D option aggrate=100ms
-
-
-self int indent;
-
-:::BEGIN
-{
-    printf("BEGIN hotspot_jni tracing\n");
-}
-
-
-hotspot_jni$target:::*
-/!self->indent/
-{
-    self->indent = 11;
-}
-
-hotspot_jni$target:::*-entry
-{
-    self->indent++;
-    printf("%d %*s -> %s\n", curcpu->cpu_id, self->indent, "", probename);
-}
-
-
-hotspot_jni$target:::*-return
-{
-    printf("%d %*s <- %s\n", curcpu->cpu_id, self->indent, "", probename);
-    self->indent--;
-}
-
-:::END
-{
-   printf("\nEND hotspot_jni tracing.\n");
-
-}
-
-syscall::rexit:entry,
-syscall::exit:entry
-/pid == $target/
-{
-   exit(0);
-}
--- a/jdk/test/ProblemList.txt	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/ProblemList.txt	Fri Apr 21 03:34:11 2017 +0000
@@ -308,4 +308,7 @@
 
 org/omg/CORBA/OrbPropertiesTest.java			        8175177 generic-all
 
+sample/mergesort/MergeSortTest.java				8178912 generic-all
+sample/chatserver/ChatTest.java					8178912 generic-all
+
 ############################################################################
--- a/jdk/test/TEST.ROOT	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/TEST.ROOT	Fri Apr 21 03:34:11 2017 +0000
@@ -35,3 +35,6 @@
 
 # Use new module options
 useNewOptions=true
+
+# Use --patch-module instead of -Xmodule:
+useNewPatchModule=true
--- a/jdk/test/TEST.groups	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/TEST.groups	Fri Apr 21 03:34:11 2017 +0000
@@ -269,7 +269,6 @@
     javax/transaction \
     javax/xml \
     -javax/xml/crypto \
-    jdk/asm \
     jdk/internal/jline \
     com/sun/jndi \
     com/sun/corba \
--- a/jdk/test/java/awt/Color/LoadProfileWithSM.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/java/awt/Color/LoadProfileWithSM.java	Fri Apr 21 03:34:11 2017 +0000
@@ -25,7 +25,7 @@
 
 /*
  * @test
- * @bug 8058969
+ * @bug 8058969 8178708
  * @summary test standard profiles loads with SecurityManager installed.
  * @run main/othervm LoadProfileWithSM
  */
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/GlassPaneOverlappingTestBase.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/GlassPaneOverlappingTestBase.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -128,7 +128,7 @@
                tests fail starting after failing mixing tests but always pass alone.
              */
             Util.waitForIdle(robot);
-            ancestorLoc.translate(f.getWidth()/2-15, 2);
+            ancestorLoc.translate(isOel7() ? 5 : f.getWidth() / 2 - 15, 2);
             robot.mouseMove(ancestorLoc.x, ancestorLoc.y);
             Util.waitForIdle(robot);
             robot.mousePress(InputEvent.BUTTON1_MASK);
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/HierarchyBoundsListenerMixingTest.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/HierarchyBoundsListenerMixingTest.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,7 +85,7 @@
             components[i].addHierarchyBoundsListener(listener);
             frame.add(components[i]);
         }
-        frame.setSize(300, 300);
+        frame.setBounds(100, 100, 300, 300);
         frame.setVisible(true);
     }
 
@@ -391,8 +391,8 @@
     private int resizeCount = 0;
 
     private boolean passed = true;
-    private boolean moveTriggered = false;
-    private boolean resizeTriggered = false;
+    private volatile boolean moveTriggered = false;
+    private volatile boolean resizeTriggered = false;
     private final Object moveLock = new Object();
     private final Object resizeLock = new Object();
 
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,7 +21,6 @@
  * questions.
  */
 
-import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Point;
 import java.awt.Robot;
@@ -30,6 +29,7 @@
 import javax.swing.BoxLayout;
 import javax.swing.JComboBox;
 import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
 import test.java.awt.regtesthelpers.Util;
 
 
@@ -55,16 +55,18 @@
     private boolean lwClicked = false;
     private Point loc;
     private Point loc2;
+    private JComboBox cb;
+    private JFrame frame;
 
     {testEmbeddedFrame = true;}
 
     protected void prepareControls() {
-        final JFrame frame = new JFrame("Mixing : Dropdown Overlapping test");
+        frame = new JFrame("Mixing : Dropdown Overlapping test");
         frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
         frame.setSize(200, 200);
         frame.setVisible(true);
 
-        final JComboBox cb = new JComboBox(petStrings);
+        cb = new JComboBox(petStrings);
         cb.setPreferredSize(new Dimension(frame.getContentPane().getWidth(), 20));
         cb.addActionListener(new ActionListener() {
 
@@ -78,8 +80,6 @@
         frame.add(cb);
         propagateAWTControls(frame);
         frame.setVisible(true);
-        loc = cb.getLocationOnScreen();
-        loc2 = frame.getContentPane().getLocationOnScreen();
     }
 
     @Override
@@ -87,6 +87,16 @@
         // run robot
         Robot robot = Util.createRobot();
         robot.setAutoDelay(ROBOT_DELAY);
+        robot.waitForIdle();
+        robot.delay(200);
+        try {
+            SwingUtilities.invokeAndWait(() -> {
+                loc = cb.getLocationOnScreen();
+                loc2 = frame.getContentPane().getLocationOnScreen();
+            });
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
 
         loc2.translate(75, 75);
         pixelPreCheck(robot, loc2, currentAwtControl);
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -142,7 +142,8 @@
         JFrame ancestor = (JFrame)(testedComponent.getTopLevelAncestor());
         if( ancestor != null ) {
             Point ancestorLoc = ancestor.getLocationOnScreen();
-            ancestorLoc.translate(ancestor.getWidth()/2-15, 2);
+            ancestorLoc.translate(isOel7() ? 5 :
+                                             ancestor.getWidth() / 2 - 15, 2);
             robot.mouseMove(ancestorLoc.x, ancestorLoc.y);
             Util.waitForIdle(robot);
             robot.mousePress(InputEvent.BUTTON1_MASK);
@@ -157,5 +158,11 @@
         return wasLWClicked;
     }
 
+    public boolean isOel7() {
+        return System.getProperty("os.name").toLowerCase()
+                .contains("linux") && System.getProperty("os.version")
+                .toLowerCase().contains("el7");
+    }
+
 }
 
--- a/jdk/test/java/awt/TrayIcon/SystemTrayIconHelper.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/java/awt/TrayIcon/SystemTrayIconHelper.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,3 +1,26 @@
+/*
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.geom.Point2D;
@@ -86,10 +109,11 @@
 
 
                 Object peer = f_peer.get(icon);
-                Method m_getModel = peer.getClass().getDeclaredMethod(
-                        "getModel");
+                Class<?> superclass = peer.getClass().getSuperclass();
+                System.out.println("superclass = " + superclass);
+                Field m_getModel = superclass.getDeclaredField("ptr");
                 m_getModel.setAccessible(true);
-                long model = (Long) (m_getModel.invoke(peer, new Object[]{}));
+                long model = (Long) m_getModel.get(peer);
                 Method m_getLocation = peer.getClass().getDeclaredMethod(
                         "nativeGetIconLocation", new Class[]{Long.TYPE});
                 m_getLocation.setAccessible(true);
--- a/jdk/test/java/io/Serializable/serialFilter/SerialFilterTest.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/java/io/Serializable/serialFilter/SerialFilterTest.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,18 +26,19 @@
 import java.io.EOFException;
 import java.io.IOException;
 import java.io.InvalidClassException;
+import java.io.ObjectInputFilter;
 import java.io.ObjectInputStream;
-import java.io.ObjectInputFilter;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.lang.invoke.SerializedLambda;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Proxy;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.Set;
+import java.util.List;
 import java.util.concurrent.atomic.LongAdder;
 
 import javax.net.ssl.SSLEngineResult;
@@ -166,26 +167,33 @@
         Runnable runnable = (Runnable & Serializable) SerialFilterTest::noop;
         Object[][] objects = {
                 { null, 0, -1, 0, 0, 0,
-                        new HashSet<>()},        // no callback, no values
-                { objArray, 3, 7, 8, 2, 55,
-                        new HashSet<>(Arrays.asList(objArray.getClass()))},
-                { Object[].class, 1, -1, 1, 1, 40,
-                        new HashSet<>(Arrays.asList(Object[].class))},
-                { new SerialFilterTest(), 1, -1, 1, 1, 37,
-                        new HashSet<>(Arrays.asList(SerialFilterTest.class))},
-                { new LongAdder(), 2, -1, 1, 1, 93,
-                        new HashSet<>(Arrays.asList(LongAdder.class, serClass))},
-                { new byte[14], 2, 14, 1, 1, 27,
-                        new HashSet<>(Arrays.asList(byteArray.getClass()))},
-                { runnable, 13, 0, 10, 2, 514,
-                        new HashSet<>(Arrays.asList(java.lang.invoke.SerializedLambda.class,
+                        Arrays.asList()},        // no callback, no values
+                { objArray, 3, 7, 9, 2, 55,
+                        Arrays.asList(objArray.getClass(), objArray.getClass())},
+                { Object[].class, 1, -1, 1, 1, 38,
+                        Arrays.asList(Object[].class)},
+                { new SerialFilterTest(), 1, -1, 1, 1, 35,
+                        Arrays.asList(SerialFilterTest.class)},
+                { new LongAdder(), 2, -1, 2, 1, 93,
+                        Arrays.asList(serClass, LongAdder.class)},
+                { new byte[14], 2, 14, 2, 1, 27,
+                        Arrays.asList(byteArray.getClass(), byteArray.getClass())},
+                { runnable, 13, 0, 13, 2, 514,
+                        Arrays.asList(java.lang.invoke.SerializedLambda.class,
+                                objArray.getClass(),
+                                objArray.getClass(),
                                 SerialFilterTest.class,
-                                objArray.getClass()))},
-                { deepHashSet(10), 48, -1, 49, 11, 619,
-                        new HashSet<>(Arrays.asList(HashSet.class))},
-                { proxy.getClass(), 3, -1, 1, 1, 114,
-                        new HashSet<>(Arrays.asList(Runnable.class,
-                                java.lang.reflect.Proxy.class))},
+                                java.lang.invoke.SerializedLambda.class)},
+                { deepHashSet(10), 48, -1, 50, 11, 619,
+                        Arrays.asList(HashSet.class)},
+                { proxy.getClass(), 3, -1, 2, 2, 112,
+                        Arrays.asList(Runnable.class,
+                                java.lang.reflect.Proxy.class,
+                                java.lang.reflect.Proxy.class)},
+                { new F(), 6, -1, 6, 6, 202,
+                        Arrays.asList(F.class, E.class, D.class,
+                                C.class, B.class, A.class)},
+
         };
         return objects;
     }
@@ -224,11 +232,12 @@
     @Test(dataProvider="Objects")
     public static void t1(Object object,
                           long count, long maxArray, long maxRefs, long maxDepth, long maxBytes,
-                          Set<Class<?>> classes) throws IOException {
+                          List<Class<?>> classes) throws IOException {
         byte[] bytes = writeObjects(object);
         Validator validator = new Validator();
         validate(bytes, validator);
         System.out.printf("v: %s%n", validator);
+
         Assert.assertEquals(validator.count, count, "callback count wrong");
         Assert.assertEquals(validator.classes, classes, "classes mismatch");
         Assert.assertEquals(validator.maxArray, maxArray, "maxArray mismatch");
@@ -438,7 +447,7 @@
      */
     static class Validator implements ObjectInputFilter {
         long count;          // Count of calls to checkInput
-        HashSet<Class<?>> classes = new HashSet<>();
+        List<Class<?>> classes = new ArrayList<>();
         long maxArray = -1;
         long maxRefs;
         long maxDepth;
@@ -449,16 +458,20 @@
 
         @Override
         public ObjectInputFilter.Status checkInput(FilterInfo filter) {
+            Class<?> serialClass = filter.serialClass();
+            System.out.printf("     checkInput: class: %s, arrayLen: %d, refs: %d, depth: %d, bytes; %d%n",
+                    serialClass, filter.arrayLength(), filter.references(),
+                    filter.depth(), filter.streamBytes());
             count++;
-            if (filter.serialClass() != null) {
-                if (filter.serialClass().getName().contains("$$Lambda$")) {
+            if (serialClass != null) {
+                if (serialClass.getName().contains("$$Lambda$")) {
                     // TBD: proper identification of serialized Lambdas?
                     // Fold the serialized Lambda into the SerializedLambda type
                     classes.add(SerializedLambda.class);
-                } else if (Proxy.isProxyClass(filter.serialClass())) {
+                } else if (Proxy.isProxyClass(serialClass)) {
                     classes.add(Proxy.class);
                 } else {
-                    classes.add(filter.serialClass());
+                    classes.add(serialClass);
                 }
 
             }
@@ -626,7 +639,8 @@
             // a stream of exactly the size requested.
             return genMaxBytesObject(allowed, value);
         } else if (pattern.startsWith("maxrefs=")) {
-            Object[] array = new Object[allowed ? (int)value - 1 : (int)value];
+            // 4 references to classes in addition to the array contents
+            Object[] array = new Object[allowed ? (int)value - 4 : (int)value - 3];
             for (int i = 0; i < array.length; i++) {
                 array[i] = otherObject;
             }
@@ -775,4 +789,25 @@
             return streamBytes;
         }
     }
+
+    // Deeper superclass hierarchy
+    static class A implements Serializable {
+        private static final long serialVersionUID = 1L;
+    };
+    static class B extends A {
+        private static final long serialVersionUID = 2L;
+    }
+    static class C extends B {
+        private static final long serialVersionUID = 3L;
+    }
+    static class D extends C {
+        private static final long serialVersionUID = 4L;
+    }
+    static class E extends D {
+        private static final long serialVersionUID = 5L;
+    }
+    static class F extends E {
+        private static final long serialVersionUID = 6L;
+    }
+
 }
--- a/jdk/test/java/lang/ref/ReferenceEnqueue.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/java/lang/ref/ReferenceEnqueue.java	Fri Apr 21 03:34:11 2017 +0000
@@ -25,7 +25,7 @@
  * @bug 4268317 8132306 8175797
  * @summary Test if Reference.enqueue() works properly with GC
  * @run main ReferenceEnqueue
- * @run main/othervm -Djdk.lang.ref.disableClearAndEnqueue=true ReferenceEnqueue
+ * @run main/othervm -Djdk.lang.ref.disableClearBeforeEnqueue=true ReferenceEnqueue
  */
 
 import java.lang.ref.*;
@@ -87,13 +87,13 @@
         final ReferenceQueue<Object> queue = new ReferenceQueue<>();
         final List<Reference<Object>> refs = new ArrayList<>();
         final int iterations = 1000;
-        final boolean disableClearAndEnqueue =
-            Boolean.parseBoolean("jdk.lang.ref.disableClearAndEnqueue");
+        final boolean disableClearBeforeEnqueue =
+            Boolean.getBoolean("jdk.lang.ref.disableClearBeforeEnqueue");
 
         ExplicitEnqueue() {
             this.refs.add(new SoftReference<>(new Object(), queue));
             this.refs.add(new WeakReference<>(new Object(), queue));
-            this.refs.add(new PhantomReference<>(new Object(), queue));
+            // Can't test PhantomReference because get() always returns null.
         }
 
         void run() throws InterruptedException {
@@ -101,10 +101,10 @@
                 if (ref.enqueue() == false) {
                     throw new RuntimeException("Error: enqueue failed");
                 }
-                if (disableClearAndEnqueue && ref.get() == null) {
+                if (disableClearBeforeEnqueue && ref.get() == null) {
                     throw new RuntimeException("Error: clearing should be disabled");
                 }
-                if (!disableClearAndEnqueue && ref.get() != null) {
+                if (!disableClearBeforeEnqueue && ref.get() != null) {
                     throw new RuntimeException("Error: referent must be cleared");
                 }
             }
--- a/jdk/test/java/time/TEST.properties	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-# java.time tests use TestNG
-TestNG.dirs = .
-othervm.dirs = tck/java/time/chrono test/java/time/chrono test/java/time/format
-lib.dirs = ../../lib/testlibrary
-lib.build = jdk.testlibrary.RandomFactory
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/nontestng/java/time/chrono/Bug8178823.java	Fri Apr 21 03:34:11 2017 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package nontestng.java.time.chrono;
+
+import java.time.chrono.HijrahChronology;
+
+/* @test
+ * @bug 8178823
+ * @build Bug8178823
+ * @run main/othervm/policy=bug8178823.policy -Djava.security.manager nontestng.java.time.chrono.Bug8178823
+ * @summary Test Hijrah calendar is initialized with the security manager.
+ */
+public class Bug8178823 {
+    public static void main(String[] args) {
+        HijrahChronology.INSTANCE.isLeapYear(2017);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/nontestng/java/time/chrono/bug8178823.policy	Fri Apr 21 03:34:11 2017 +0000
@@ -0,0 +1,1 @@
+// Empty policy file for Bug8178823
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/TEST.properties	Fri Apr 21 03:34:11 2017 +0000
@@ -0,0 +1,5 @@
+# java.time tests use TestNG
+TestNG.dirs = ..
+othervm.dirs = java/time/chrono
+lib.dirs = ../../../lib/testlibrary
+lib.build = jdk.testlibrary.RandomFactory
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/test/TEST.properties	Fri Apr 21 03:34:11 2017 +0000
@@ -0,0 +1,5 @@
+# java.time tests use TestNG
+TestNG.dirs = ..
+othervm.dirs = java/time/chrono java/time/format
+lib.dirs = ../../../lib/testlibrary
+lib.build = jdk.testlibrary.RandomFactory
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/accessibility/JList/AccessibleJListChildNPETest.java	Fri Apr 21 03:34:11 2017 +0000
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* This code is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License version 2 only, as
+* published by the Free Software Foundation.
+*
+* This code is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+* version 2 for more details (a copy is included in the LICENSE file that
+* accompanied this code).
+*
+* You should have received a copy of the GNU General Public License version
+* 2 along with this work; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+*
+* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+* or visit www.oracle.com if you need additional information or have any
+* questions.
+*/
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.swing.AbstractListModel;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
+
+/* @test
+   @bug 8076249
+   @summary  NPE in AccessBridge while editing JList model
+   @author Mikhail Cherkasov
+   @run main AccessibleJListChildNPETest
+*/
+public class AccessibleJListChildNPETest {
+
+    private static String[] model = { "1", "2", "3", "4", "5", "6" };
+    private static JList<String> list;
+
+    public static void main(String[] args) throws InvocationTargetException, InterruptedException {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                JFrame frame = new JFrame();
+                frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+                final MyModel dataModel = new MyModel(Arrays.asList(model));
+                list = new JList<>(dataModel);
+                frame.getContentPane().add(list);
+                frame.pack();
+                frame.setVisible(true);
+
+            }
+        });
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                AccessibleContext ac = list.getAccessibleContext();
+                MyModel model = (MyModel)list.getModel();
+                Accessible accessibleChild = ac.getAccessibleChild(model.getSize()-1);
+                model.removeFirst();
+                accessibleChild.getAccessibleContext().getAccessibleSelection();
+                accessibleChild.getAccessibleContext().getAccessibleText();
+                accessibleChild.getAccessibleContext().getAccessibleValue();
+            }
+        });
+    }
+
+    protected static class MyModel extends AbstractListModel<String> {
+        private List<String> items = new ArrayList<>();
+
+        MyModel(final List<String> newItems) {
+            super();
+            items.addAll(newItems);
+            fireIntervalAdded(this, 0, getSize() - 1);
+        }
+
+        void removeFirst() {
+            if(getSize() > 0) {
+                items.remove(0);
+                fireIntervalRemoved(this, 0, 0);
+            }
+        }
+
+        @Override
+        public int getSize() {
+            return items.size();
+        }
+
+        @Override
+        public String getElementAt(int index) {
+            return items.get(index);
+        }
+    }
+}
--- a/jdk/test/javax/swing/JMenu/8072900/WrongSelectionOnMouseOver.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/javax/swing/JMenu/8072900/WrongSelectionOnMouseOver.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved.
  * 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,6 +52,8 @@
     private UIManager.LookAndFeelInfo laf;
     JFrame frame1;
     JFrame frame2;
+    private Point menu1location;
+    private Point menu2location;
 
     public WrongSelectionOnMouseOver(UIManager.LookAndFeelInfo laf) throws Exception {
         this.laf = laf;
@@ -136,7 +138,7 @@
             m2.add(i2);
 
             frame2.setLayout(new FlowLayout());
-            frame2.setBounds(400, 200, 200, 200);
+            frame2.setBounds(450, 200, 200, 200);
 
             frame2.setVisible(true);
         }
@@ -166,8 +168,13 @@
 
         robot.waitForIdle();
 
-        robot.mouseMove((int) m1.getLocationOnScreen().getX() + 5,
-                (int) m1.getLocationOnScreen().getY() + 5);
+        SwingUtilities.invokeAndWait(() -> {
+            menu1location = m1.getLocationOnScreen();
+            menu2location = m2.getLocationOnScreen();
+        });
+
+        robot.mouseMove((int) menu1location.getX() + 5,
+                (int) menu1location.getY() + 5);
         robot.mousePress(MouseEvent.BUTTON1_MASK);
         robot.mouseRelease(MouseEvent.BUTTON1_MASK);
 
@@ -175,8 +182,8 @@
             throw new RuntimeException("Menu has not been selected.");
         };
 
-        robot.mouseMove((int) m2.getLocationOnScreen().getX() + 5,
-                (int) m2.getLocationOnScreen().getY() + 5);
+        robot.mouseMove((int) menu2location.getX() + 5,
+                (int) menu2location.getY() + 5);
 
         if (!secondMenuMouseEntered.await(5, TimeUnit.SECONDS)) {
             throw new RuntimeException("MouseEntered event missed for the second menu");
--- a/jdk/test/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,10 +59,12 @@
             }
         });
 
-        p = Util.getCenterPoint(button);
-
         Robot robot = new Robot();
         robot.setAutoDelay(50);
+        robot.waitForIdle();
+        robot.delay(200);
+
+        p = Util.getCenterPoint(button);
 
         robot.mouseMove(p.x , p.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
--- a/jdk/test/jdk/asm/AsmSanity.java	Thu Apr 20 18:14:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-/*
- * @test
- * @bug 7197401
- * @summary Add a subset of the org.objectweb.asm packages to jdk8
- * This test doesn't test asm functionality, it just tests the presence of
- * asm in the jdk.
- * These compile/run commands do the following:
- * - Verify that asm is not in ct.sym so user code that refs it won't compile.
- * - Verify that asm really is in rt.jar and can be accessed when ct.sym is not used.
- * - Verify that if user code is compiled without ct.sym, it can't access asm classes
- *   at runtime when a security manager is in use.
- *
- * @modules java.base/jdk.internal.org.objectweb.asm
- *
- * @compile -XDignore.symbol.file=true AsmSanity.java
- * @run main/othervm AsmSanity
- *
- * @run main/othervm/fail AsmSanity secure
- *
- */
-
-
-// Verify that the expected asm pkgs are present
-import jdk.internal.org.objectweb.asm.*;
-
-// Verify that we can actually run some of the asm code.
-public class AsmSanity {
-
-    static public void main(String[] args) {
-        if (args.length == 0) {
-            System.out.println("-- Running without SecurityManager");
-            new Label();
-            System.out.println("-- Passed");
-            return;
-        }
-
-        if (args[0].equals("secure")) {
-            System.out.println("-- Running with SecurityManager");
-            java.lang.SecurityManager sm = new SecurityManager();
-            System.setSecurityManager(sm);
-            // This should cause an accessClassInPackage exception
-            new Label();
-            return;
-        }
-        throw new Error("-- Failed:  Unknown argument to main: " + args[0]);
-    }
-}
--- a/jdk/test/sun/awt/dnd/8024061/bug8024061.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/sun/awt/dnd/8024061/bug8024061.java	Fri Apr 21 03:34:11 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,9 +70,14 @@
     private static final DataFlavor DropObjectFlavor;
     private static final int DELAY = 1000;
 
-    private final DnDPanel panel1 = new DnDPanel(Color.yellow);
-    private final DnDPanel panel2 = new DnDPanel(Color.pink);
+    static final DnDPanel panel1 = new DnDPanel(Color.yellow);
+    static final DnDPanel panel2 = new DnDPanel(Color.pink);
     private final JFrame frame;
+    static Point here;
+    static Point there;
+    static Dimension d;
+
+
 
     private static final CountDownLatch lock = new CountDownLatch(1);
     private static volatile Exception dragEnterException = null;
@@ -91,7 +96,7 @@
         frame = new JFrame("DnDWithRobot");
         frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 
-        Dimension d = new Dimension(100, 100);
+        d = new Dimension(100, 100);
 
         panel1.setPreferredSize(d);
         panel2.setPreferredSize(d);
@@ -126,12 +131,15 @@
         final Robot robot = new Robot();
         robot.setAutoDelay(10);
         robot.waitForIdle();
+        robot.delay(200);
 
         JFrame frame = dnd[0].frame;
-        Point point = frame.getLocationOnScreen();
-        Point here = new Point(point.x + 35, point.y + 45);
-        Point there = new Point(point.x + 120, point.y + 45);
-        here.x += 25;
+        SwingUtilities.invokeAndWait(() -> {
+            here = panel1.getLocationOnScreen();
+            there = panel2.getLocationOnScreen();
+        });
+        here.translate(d.width / 2, d.height / 2);
+        there.translate(d.width / 2, d.height / 2);
         robot.mouseMove(here.x, here.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         while (here.x < there.x) {
@@ -159,7 +167,7 @@
                 throw new RuntimeException("Timed out waiting for dragEnter()");
             }
         } finally {
-            frame.dispose();
+            SwingUtilities.invokeLater(frame::dispose);
         }
     }
 
@@ -220,7 +228,7 @@
         }
     }
 
-    class DnDPanel extends JPanel {
+    static class DnDPanel extends JPanel {
         DropObject dropObject;
         final DragSource dragSource;
         final DropTarget dropTarget;
--- a/jdk/test/tools/jlink/bindservices/BindServices.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/tools/jlink/bindservices/BindServices.java	Fri Apr 21 03:34:11 2017 +0000
@@ -33,7 +33,6 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import static jdk.testlibrary.Asserts.assertTrue;
 import static jdk.testlibrary.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
@@ -114,7 +113,7 @@
                   "--module-path", MODULE_PATH,
                   "--add-modules", "m1",
                   "--bind-services",
-                  "--limit-modules", "m1,m2,m3,java.base");
+                  "--limit-modules", "m1,m2,m3");
 
         testImage(dir, "m1", "m2", "m3");
     }
@@ -131,16 +130,18 @@
                       "--add-modules", "m1",
                       "--bind-services",
                       "--verbose",
-                      "--limit-modules", "m1,m2,m3,java.base").output();
+                      "--limit-modules", "m1,m2,m3").output();
 
         List<String> expected = List.of(
-            "module m1 (" + MODS_DIR.resolve("m1").toUri().toString() + ")",
-            "module m2 (" + MODS_DIR.resolve("m2").toUri().toString() + ")",
-            "module m3 (" + MODS_DIR.resolve("m3").toUri().toString() + ")",
-            "module m1 provides p1.S, used by m1",
-            "module m2 provides p1.S, used by m1",
-            "module m2 provides p2.T, used by m2",
-            "module m3 provides p2.T, used by m2"
+            "m1 " + MODS_DIR.resolve("m1").toUri().toString(),
+            "m2 " + MODS_DIR.resolve("m2").toUri().toString(),
+            "m3 " + MODS_DIR.resolve("m3").toUri().toString(),
+            "java.base provides java.nio.file.spi.FileSystemProvider used by java.base",
+            "m1 provides p1.S used by m1",
+            "m2 provides p1.S used by m1",
+            "m2 provides p2.T used by m2",
+            "m3 provides p2.T used by m2",
+            "m3 provides p3.S not used by any observable module"
         );
 
         assertTrue(output.containsAll(expected));
--- a/jdk/test/tools/jlink/bindservices/SuggestProviders.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/tools/jlink/bindservices/SuggestProviders.java	Fri Apr 21 03:34:11 2017 +0000
@@ -33,8 +33,6 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import static jdk.testlibrary.Asserts.assertTrue;
-
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
@@ -85,34 +83,102 @@
         }
     }
 
+    // check a subset of services used by java.base
+    private final List<String> JAVA_BASE_USES = List.of(
+        "uses java.lang.System$LoggerFinder",
+        "uses java.net.ContentHandlerFactory",
+        "uses java.net.spi.URLStreamHandlerProvider",
+        "uses java.nio.channels.spi.AsynchronousChannelProvider",
+        "uses java.nio.channels.spi.SelectorProvider",
+        "uses java.nio.charset.spi.CharsetProvider",
+        "uses java.nio.file.spi.FileSystemProvider",
+        "uses java.nio.file.spi.FileTypeDetector",
+        "uses java.security.Provider",
+        "uses java.util.spi.ToolProvider"
+    );
+
+    private final List<String> JAVA_BASE_PROVIDERS = List.of(
+        "java.base provides java.nio.file.spi.FileSystemProvider used by java.base"
+    );
+
+    private final List<String> SYSTEM_PROVIDERS = List.of(
+        "jdk.charsets provides java.nio.charset.spi.CharsetProvider used by java.base",
+        "jdk.compiler provides java.util.spi.ToolProvider used by java.base",
+        "jdk.compiler provides javax.tools.JavaCompiler used by java.compiler",
+        "jdk.jlink provides jdk.tools.jlink.plugin.Plugin used by jdk.jlink",
+        "jdk.jlink provides java.util.spi.ToolProvider used by java.base"
+    );
+
+    private final List<String> APP_USES = List.of(
+        "uses p1.S",
+        "uses p2.T"
+    );
+
+    private final List<String> APP_PROVIDERS = List.of(
+        "m1 provides p1.S used by m1",
+        "m2 provides p1.S used by m1",
+        "m2 provides p2.T used by m2",
+        "m3 provides p2.T used by m2",
+        "m3 provides p3.S not used by any observable module"
+    );
+
     @Test
     public void suggestProviders() throws Throwable {
         if (!hasJmods()) return;
 
         List<String> output = JLink.run("--module-path", MODULE_PATH,
+                                        "--suggest-providers").output();
+
+        Stream<String> uses =
+            Stream.concat(JAVA_BASE_USES.stream(), APP_USES.stream());
+        Stream<String> providers =
+            Stream.concat(SYSTEM_PROVIDERS.stream(), APP_PROVIDERS.stream());
+
+        assertTrue(output.containsAll(Stream.concat(uses, providers)
+                                            .collect(Collectors.toList())));
+    }
+
+    /**
+     * find providers from the observable modules and --add-modules has no
+     * effect on the suggested providers
+     */
+    @Test
+    public void observableModules() throws Throwable {
+        if (!hasJmods()) return;
+
+        List<String> output = JLink.run("--module-path", MODULE_PATH,
                                         "--add-modules", "m1",
                                         "--suggest-providers").output();
-        // check a subset of services used by java.base
-        List<String> expected = List.of(
-            "uses java.lang.System$LoggerFinder",
-            "uses java.net.ContentHandlerFactory",
-            "uses java.net.spi.URLStreamHandlerProvider",
-            "uses java.nio.channels.spi.AsynchronousChannelProvider",
-            "uses java.nio.channels.spi.SelectorProvider",
-            "uses java.nio.charset.spi.CharsetProvider",
-            "uses java.nio.file.spi.FileSystemProvider",
-            "uses java.nio.file.spi.FileTypeDetector",
-            "uses java.security.Provider",
-            "uses java.util.spi.ToolProvider",
-            "uses p1.S",
-            "module jdk.charsets provides java.nio.charset.spi.CharsetProvider, used by java.base",
-            "module jdk.compiler provides java.util.spi.ToolProvider, used by java.base",
-            "module jdk.jlink provides java.util.spi.ToolProvider, used by java.base",
-            "module m1 provides p1.S, used by m1",
-            "module m2 provides p1.S, used by m1"
+
+        Stream<String> uses =
+            Stream.concat(JAVA_BASE_USES.stream(), Stream.of("uses p1.S"));
+        Stream<String> providers =
+            Stream.concat(SYSTEM_PROVIDERS.stream(), APP_PROVIDERS.stream());
+
+        assertTrue(output.containsAll(Stream.concat(uses, providers)
+                                            .collect(Collectors.toList())));
+    }
+
+    /**
+     * find providers from the observable modules with --limit-modules
+     */
+    @Test
+    public void limitModules() throws Throwable {
+        if (!hasJmods()) return;
+
+        List<String> output = JLink.run("--module-path", MODULE_PATH,
+                                        "--limit-modules", "m1",
+                                        "--suggest-providers").output();
+
+        Stream<String> uses =
+            Stream.concat(JAVA_BASE_USES.stream(), Stream.of("uses p1.S"));
+        Stream<String> providers =
+            Stream.concat(JAVA_BASE_PROVIDERS.stream(),
+                          Stream.of("m1 provides p1.S used by m1")
         );
 
-        assertTrue(output.containsAll(expected));
+        assertTrue(output.containsAll(Stream.concat(uses, providers)
+                                            .collect(Collectors.toList())));
     }
 
     @Test
@@ -121,20 +187,17 @@
 
         List<String> output =
             JLink.run("--module-path", MODULE_PATH,
-                      "--add-modules", "m1",
                       "--suggest-providers",
-                      "java.nio.charset.spi.CharsetProvider,p1.S,p2.T").output();
+                      "java.nio.charset.spi.CharsetProvider,p1.S").output();
 
         System.out.println(output);
-        List<String> expected = List.of(
-            "module jdk.charsets provides java.nio.charset.spi.CharsetProvider, used by java.base",
-            "module m1 provides p1.S, used by m1",
-            "module m2 provides p1.S, used by m1",
-            "module m2 provides p2.T, used by m2",
-            "module m3 provides p2.T, used by m2"
+        Stream<String> expected = Stream.concat(
+            Stream.of("jdk.charsets provides java.nio.charset.spi.CharsetProvider used by java.base"),
+            Stream.of("m1 provides p1.S used by m1",
+                      "m2 provides p1.S used by m1")
         );
 
-        assertTrue(output.containsAll(expected));
+        assertTrue(output.containsAll(expected.collect(Collectors.toList())));
     }
 
     @Test
@@ -143,15 +206,30 @@
 
         List<String> output =
             JLink.run("--module-path", MODULE_PATH,
-                "--add-modules", "m1",
-                "--suggest-providers",
-                "nonExistentType").output();
+                      "--suggest-providers",
+                      "p3.S").output();
+
+        List<String> expected = List.of(
+            "m3 provides p3.S not used by any observable module"
+        );
+        assertTrue(output.containsAll(expected));
+
+        // should not print other services m3 provides
+        assertFalse(output.contains("m3 provides p2.T used by m2"));
+    }
 
-        System.out.println(output);
+    @Test
+    public void nonExistentService() throws Throwable {
+        if (!hasJmods()) return;
+
+        List<String> output =
+            JLink.run("--module-path", MODULE_PATH,
+                      "--suggest-providers",
+                      "nonExistentType").output();
+
         List<String> expected = List.of(
-            "Services specified in --suggest-providers not used: nonExistentType"
+            "No provider found for service specified to --suggest-providers: nonExistentType"
         );
-
         assertTrue(output.containsAll(expected));
     }
 
@@ -161,9 +239,7 @@
 
         List<String> output =
             JLink.run("--module-path", MODULE_PATH,
-                      "--add-modules", "m1",
                       "--bind-services",
-                      "--limit-modules", "m1,m2,m3,java.base",
                       "--suggest-providers").output();
 
         String expected = "--bind-services option is specified. No additional providers suggested.";
--- a/jdk/test/tools/jlink/bindservices/src/m3/module-info.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m3/module-info.java	Fri Apr 21 03:34:11 2017 +0000
@@ -24,4 +24,5 @@
 module m3 {
     requires m2;
     provides p2.T with p3.Impl;
+    provides p3.S with p3.MyProvider;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m3/p3/MyProvider.java	Fri Apr 21 03:34:11 2017 +0000
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p3;
+
+public class MyProvider implements S {
+    public void run() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m3/p3/S.java	Fri Apr 21 03:34:11 2017 +0000
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p3;
+
+public interface S {
+    void run();
+}
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java	Thu Apr 20 18:14:05 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java	Fri Apr 21 03:34:11 2017 +0000
@@ -71,17 +71,23 @@
                     .forEach(this::checkAttributes);
     }
 
-    // JMOD files are created with osName and osArch that may be different
-    // than os.name and os.arch system property
+    // JMOD files are created with OS name and arch matching the bundle name
     private boolean checkOSName(String name) {
-        if (name.equals(OS_NAME))
-            return true;
+        if (OS_NAME.startsWith("Windows")) {
+            return name.equals("windows");
+        }
 
-        if (OS_NAME.startsWith("Windows")) {
-            return name.startsWith("Windows");
-        } else {
-            System.err.println("ERROR: " + name + " but expected: " + OS_NAME);
-            return false;
+        switch (OS_NAME) {
+            case "Linux":
+                return name.equals("linux");
+            case "SunOS":
+                return name.equals("solaris");
+            case "Mac OS X":
+                return name.equals("macos");
+            default:
+                // skip validation on unknown platform
+                System.out.println("Skip checking OS name in ModuleTarget: " + name);
+                return true;
         }
     }
 
@@ -94,10 +100,12 @@
             case "x86":
                 return name.equals("x86");
             case "amd64":
-                return name.equals("x86_64");
+            case "x86_64":
+                return name.equals("amd64");
             default:
-                System.err.println("ERROR: " + name + " but expected: " + OS_ARCH);
-                return false;
+                // skip validation on unknown platform
+                System.out.println("Skip checking OS arch in ModuleTarget: " + name);
+                return true;
         }
     }