Merge
authorprr
Fri, 04 May 2018 08:50:01 -0700
changeset 50013 a2a0c61f8b09
parent 50012 37aa8b00c604 (current diff)
parent 49986 29b840b16a96 (diff)
child 50014 09cbe16c0662
Merge
make/Images.gmk
src/hotspot/share/services/metaspaceDCmd.cpp
test/jdk/ProblemList.txt
--- a/.hgtags	Wed May 02 22:11:35 2018 -0700
+++ b/.hgtags	Fri May 04 08:50:01 2018 -0700
@@ -483,3 +483,4 @@
 6fa770f9f8ab296e1ce255ec17ccf6d4e1051886 jdk-10+46
 69d7398038c54774d9395b6810e0cca335edc02c jdk-11+10
 e1e60f75cd39312a7f59d2a4f91d624e5aecc95e jdk-11+11
+3ab6ba9f94a9045a526d645af26c933235371d6f jdk-11+12
--- a/make/Bundles.gmk	Wed May 02 22:11:35 2018 -0700
+++ b/make/Bundles.gmk	Fri May 04 08:50:01 2018 -0700
@@ -156,9 +156,6 @@
   JRE_IMAGE_HOMEDIR := $(JRE_IMAGE_DIR)
   JDK_BUNDLE_SUBDIR := jdk-$(VERSION_NUMBER)
   JRE_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)
-  JRE_COMPACT1_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact1
-  JRE_COMPACT2_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact2
-  JRE_COMPACT3_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact3
   ifneq ($(DEBUG_LEVEL), release)
     JDK_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR)/$(DEBUG_LEVEL)
     JRE_BUNDLE_SUBDIR := $(JRE_BUNDLE_SUBDIR)/$(DEBUG_LEVEL)
@@ -281,35 +278,6 @@
 
 ################################################################################
 
-ifneq ($(filter profiles-bundles, $(MAKECMDGOALS)), )
-  ifeq ($(OPENJDK_TARGET_OS), macosx)
-    $(error Creating compact profiles bundles on macosx is unsupported)
-  endif
-
-  define GenerateCompactProfilesBundles
-    ALL_JRE_COMPACT$1_FILES := $$(call CacheFind, $$(JRE_COMPACT$1_IMAGE_DIR))
-
-    JRE_COMPACT$1_BUNDLE_FILES := $$(filter-out \
-        $$(SYMBOLS_EXCLUDE_PATTERN), \
-        $$(ALL_JRE_COMPACT$1_FILES))
-
-    $$(eval $$(call SetupBundleFile, BUILD_JRE_COMPACT$1_BUNDLE, \
-        BUNDLE_NAME := $$(JRE_COMPACT$1_BUNDLE_NAME), \
-        FILES := $$(JRE_COMPACT$1_BUNDLE_FILES), \
-        BASE_DIRS := $$(JRE_COMPACT$1_IMAGE_DIR), \
-        SUBDIR := $$(JRE_COMPACT$1_BUNDLE_SUBDIR), \
-    ))
-
-    PROFILES_TARGETS += $$(BUILD_JRE_COMPACT$1_BUNDLE)
-  endef
-
-  $(eval $(call GenerateCompactProfilesBundles,1))
-  $(eval $(call GenerateCompactProfilesBundles,2))
-  $(eval $(call GenerateCompactProfilesBundles,3))
-endif
-
-################################################################################
-
 ifneq ($(filter test-bundles, $(MAKECMDGOALS)), )
   TEST_BUNDLE_FILES := $(call CacheFind, $(TEST_IMAGE_DIR))
 
@@ -345,8 +313,7 @@
 ################################################################################
 
 product-bundles: $(PRODUCT_TARGETS)
-profiles-bundles: $(PROFILES_TARGETS)
 test-bundles: $(TEST_TARGETS)
 docs-bundles: $(DOCS_TARGETS)
 
-.PHONY: all default product-bundles profiles-bundles test-bundles docs-bundles
+.PHONY: all default product-bundles test-bundles docs-bundles
--- a/make/Help.gmk	Wed May 02 22:11:35 2018 -0700
+++ b/make/Help.gmk	Fri May 04 08:50:01 2018 -0700
@@ -43,7 +43,7 @@
 	$(info $(_) make images            # Create complete jdk and jre images)
 	$(info $(_)                        # (alias for product-images))
 	$(info $(_) make <name>-image      # Build just the image for any of: )
-	$(info $(_)                        # jdk, jre, test, docs, symbols, profiles)
+	$(info $(_)                        # jdk, jre, test, docs, symbols)
 	$(info $(_) make <phase>           # Build the specified phase and everything it depends on)
 	$(info $(_)                        # (gensrc, java, copy, libs, launchers, gendata, rmic))
 	$(info $(_) make *-only            # Applies to most targets and disables building the)
@@ -51,7 +51,6 @@
 	$(info $(_)                        # result in incorrect build results!)
 	$(info $(_) make docs              # Create all docs)
 	$(info $(_) make docs-jdk-api      # Create just JDK javadocs)
-	$(info $(_) make profiles          # Create complete jre compact profile images)
 	$(info $(_) make bootcycle-images  # Build images twice, second time with newly built JDK)
 	$(info $(_) make install           # Install the generated images locally)
 	$(info $(_) make reconfigure       # Rerun configure with the same arguments as last time)
--- a/make/Images.gmk	Wed May 02 22:11:35 2018 -0700
+++ b/make/Images.gmk	Fri May 04 08:50:01 2018 -0700
@@ -47,50 +47,8 @@
     $(PLATFORM_MODULES) $(JRE_TOOL_MODULES))
 JDK_MODULES += $(ALL_MODULES)
 
-# Modules list for compact builds
-JRE_COMPACT1_MODULES := \
-    java.logging \
-    java.scripting \
-    jdk.localedata \
-    jdk.crypto.cryptoki \
-    jdk.crypto.ec \
-    jdk.unsupported \
-    #
-
-JRE_COMPACT2_MODULES := \
-    $(JRE_COMPACT1_MODULES) \
-    java.rmi \
-    java.sql \
-    java.xml \
-    jdk.xml.dom \
-    jdk.httpserver \
-    #
-
-JRE_COMPACT3_MODULES := \
-    $(JRE_COMPACT2_MODULES) \
-    java.smartcardio \
-    java.compiler \
-    java.instrument \
-    java.management \
-    java.management.rmi \
-    java.naming \
-    java.prefs \
-    java.security.jgss \
-    java.security.sasl \
-    java.sql.rowset \
-    java.xml.crypto \
-    jdk.management \
-    jdk.naming.dns \
-    jdk.naming.rmi \
-    jdk.sctp \
-    jdk.security.auth \
-    #
-
 JRE_MODULES_LIST := $(call CommaList, $(JRE_MODULES))
 JDK_MODULES_LIST := $(call CommaList, $(JDK_MODULES))
-JRE_COMPACT1_MODULES_LIST := $(call CommaList, $(JRE_COMPACT1_MODULES))
-JRE_COMPACT2_MODULES_LIST := $(call CommaList, $(JRE_COMPACT2_MODULES))
-JRE_COMPACT3_MODULES_LIST := $(call CommaList, $(JRE_COMPACT3_MODULES))
 
 ################################################################################
 
@@ -152,45 +110,8 @@
 	)
 	$(TOUCH) $@
 
-
-$(JRE_COMPACT1_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
-    $(call DependOnVariable, JRE_COMPACT1_MODULES_LIST) $(BASE_RELEASE_FILE)
-	$(ECHO) Creating jre compact1 jimage
-	$(RM) -r $(JRE_COMPACT1_IMAGE_DIR)
-	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre_compact1, \
-	    $(JLINK_TOOL) --add-modules $(JRE_COMPACT1_MODULES_LIST) \
-	        $(JLINK_JRE_EXTRA_OPTS) \
-	        --output $(JRE_COMPACT1_IMAGE_DIR) \
-	)
-	$(TOUCH) $@
-
-$(JRE_COMPACT2_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
-    $(call DependOnVariable, JRE_COMPACT2_MODULES_LIST) $(BASE_RELEASE_FILE)
-	$(ECHO) Creating jre compact2 jimage
-	$(RM) -r $(JRE_COMPACT2_IMAGE_DIR)
-	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre_compact2, \
-	    $(JLINK_TOOL) --add-modules $(JRE_COMPACT2_MODULES_LIST) \
-	        $(JLINK_JRE_EXTRA_OPTS) \
-	        --output $(JRE_COMPACT2_IMAGE_DIR) \
-	)
-	$(TOUCH) $@
-
-$(JRE_COMPACT3_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
-    $(call DependOnVariable, JRE_COMPACT3_MODULES_LIST) $(BASE_RELEASE_FILE)
-	$(ECHO) Creating jre compact3 jimage
-	$(RM) -r $(JRE_COMPACT3_IMAGE_DIR)
-	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre_compact3, \
-	    $(JLINK_TOOL) --add-modules $(JRE_COMPACT3_MODULES_LIST) \
-	        $(JLINK_JRE_EXTRA_OPTS) \
-	        --output $(JRE_COMPACT3_IMAGE_DIR) \
-	)
-	$(TOUCH) $@
-
 TOOL_JRE_TARGETS := $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
 TOOL_JDK_TARGETS := $(JDK_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
-TOOL_JRE_COMPACT1_TARGETS := $(JRE_COMPACT1_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
-TOOL_JRE_COMPACT2_TARGETS := $(JRE_COMPACT2_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
-TOOL_JRE_COMPACT3_TARGETS := $(JRE_COMPACT3_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
 
 ################################################################################
 # /man dir
@@ -441,15 +362,4 @@
 
 all: jdk jre symbols
 
-$(JRE_COMPACT1_TARGETS): $(TOOL_JRE_COMPACT1_TARGETS)
-$(JRE_COMPACT2_TARGETS): $(TOOL_JRE_COMPACT2_TARGETS)
-$(JRE_COMPACT3_TARGETS): $(TOOL_JRE_COMPACT3_TARGETS)
-
-profiles: $(TOOL_JRE_COMPACT1_TARGETS) \
-    $(TOOL_JRE_COMPACT2_TARGETS) \
-    $(TOOL_JRE_COMPACT3_TARGETS) \
-    $(JRE_COMPACT1_TARGETS) \
-    $(JRE_COMPACT2_TARGETS) \
-    $(JRE_COMPACT3_TARGETS)
-
-.PHONY: default all jdk jre symbols profiles
+.PHONY: default all jdk jre symbols
--- a/make/Main.gmk	Wed May 02 22:11:35 2018 -0700
+++ b/make/Main.gmk	Fri May 04 08:50:01 2018 -0700
@@ -344,9 +344,6 @@
 symbols-image:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk symbols)
 
-profiles-image:
-	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles)
-
 mac-bundles-jdk:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk)
 
@@ -358,7 +355,7 @@
 
 ALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \
     zip-source jrtfs-jar jdk-image jre-image \
-    symbols-image profiles-image mac-bundles-jdk \
+    symbols-image mac-bundles-jdk \
     release-file exploded-image-optimize
 
 ################################################################################
@@ -569,16 +566,13 @@
 product-bundles:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk product-bundles)
 
-profiles-bundles:
-	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk profiles-bundles)
-
 test-bundles:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk test-bundles)
 
 docs-bundles:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles)
 
-ALL_TARGETS += product-bundles profiles-bundles test-bundles docs-bundles
+ALL_TARGETS += product-bundles test-bundles docs-bundles
 
 ################################################################################
 # Install targets
@@ -804,8 +798,6 @@
   jre-image: jmods release-file
   symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS)
 
-  profiles-image: jmods release-file
-
   mac-bundles-jdk: jdk-image jre-image
 
   # The optimize target can run as soon as the modules dir has been completely
@@ -886,8 +878,6 @@
 
   product-bundles: product-images
 
-  profiles-bundles: profiles-images
-
   test-bundles: test-image
 
   docs-bundles: docs-image
@@ -992,9 +982,6 @@
 # an image until this can be cleaned up properly.
 product-images: zip-security
 
-# Declare these for backwards compatiblity and convenience.
-profiles profiles-images: profiles-image
-
 # The module summary cannot be run when:
 # * Cross compiling and building a partial BUILDJDK for the build host
 # * An external buildjdk has been supplied since it may not match the
@@ -1034,7 +1021,6 @@
     exploded-image-base exploded-image \
     create-buildjdk docs-jdk-api docs-javase-api docs-reference-api docs-jdk \
     docs-javase docs-reference docs-javadoc mac-bundles product-images \
-    profiles profiles-images \
     docs-image test-image all-images \
     all-bundles
 
--- a/make/autoconf/hotspot.m4	Wed May 02 22:11:35 2018 -0700
+++ b/make/autoconf/hotspot.m4	Fri May 04 08:50:01 2018 -0700
@@ -25,7 +25,7 @@
 
 # All valid JVM features, regardless of platform
 VALID_JVM_FEATURES="compiler1 compiler2 zero minimal dtrace jvmti jvmci \
-    graal vm-structs jni-check services management all-gcs nmt cds \
+    graal vm-structs jni-check services management cmsgc g1gc parallelgc serialgc nmt cds \
     static-build link-time-opt aot"
 
 # All valid JVM variants
@@ -305,12 +305,8 @@
     AC_MSG_ERROR([Specified JVM feature 'jvmci' requires feature 'compiler2' or 'compiler1'])
   fi
 
-  if HOTSPOT_CHECK_JVM_FEATURE(compiler2) && ! HOTSPOT_CHECK_JVM_FEATURE(all-gcs); then
-    AC_MSG_ERROR([Specified JVM feature 'compiler2' requires feature 'all-gcs'])
-  fi
-
-  if HOTSPOT_CHECK_JVM_FEATURE(vm-structs) && ! HOTSPOT_CHECK_JVM_FEATURE(all-gcs); then
-    AC_MSG_ERROR([Specified JVM feature 'vm-structs' requires feature 'all-gcs'])
+  if HOTSPOT_CHECK_JVM_FEATURE(cmsgc) && ! HOTSPOT_CHECK_JVM_FEATURE(serialgc); then
+    AC_MSG_ERROR([Specified JVM feature 'cmsgc' requires feature 'serialgc'])
   fi
 
   # Turn on additional features based on other parts of configure
@@ -395,7 +391,7 @@
   fi
 
   # All variants but minimal (and custom) get these features
-  NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti vm-structs jni-check services management all-gcs nmt"
+  NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES cmsgc g1gc parallelgc serialgc jni-check jvmti management nmt services vm-structs"
   if test "x$ENABLE_CDS" = "xtrue"; then
     NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES cds"
   fi
@@ -404,7 +400,7 @@
   JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci $JVM_FEATURES_aot $JVM_FEATURES_graal"
   JVM_FEATURES_client="compiler1 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci"
   JVM_FEATURES_core="$NON_MINIMAL_FEATURES $JVM_FEATURES"
-  JVM_FEATURES_minimal="compiler1 minimal $JVM_FEATURES $JVM_FEATURES_link_time_opt"
+  JVM_FEATURES_minimal="compiler1 minimal serialgc $JVM_FEATURES $JVM_FEATURES_link_time_opt"
   JVM_FEATURES_zero="zero $NON_MINIMAL_FEATURES $JVM_FEATURES"
   JVM_FEATURES_custom="$JVM_FEATURES"
 
@@ -442,6 +438,12 @@
     eval $features_var_name='"'$JVM_FEATURES_FOR_VARIANT'"'
     AC_MSG_RESULT(["$JVM_FEATURES_FOR_VARIANT"])
 
+    # Verify that we have at least one gc selected
+    GC_FEATURES=`$ECHO $JVM_FEATURES_FOR_VARIANT | $GREP gc`
+    if test "x$GC_FEATURES" = x; then
+      AC_MSG_WARN([Invalid JVM features: No gc selected for variant $variant.])
+    fi
+
     # Validate features (for configure script errors, not user errors)
     BASIC_GET_NON_MATCHING_VALUES(INVALID_FEATURES, $JVM_FEATURES_FOR_VARIANT, $VALID_JVM_FEATURES)
     if test "x$INVALID_FEATURES" != x; then
--- a/make/autoconf/spec.gmk.in	Wed May 02 22:11:35 2018 -0700
+++ b/make/autoconf/spec.gmk.in	Fri May 04 08:50:01 2018 -0700
@@ -817,18 +817,11 @@
 # Images directory definitions
 JDK_IMAGE_SUBDIR:=jdk
 JRE_IMAGE_SUBDIR:=jre
-JRE_COMPACT1_IMAGE_SUBDIR := jre-compact1
-JRE_COMPACT2_IMAGE_SUBDIR := jre-compact2
-JRE_COMPACT3_IMAGE_SUBDIR := jre-compact3
 
 # Colon left out to be able to override output dir for bootcycle-images
 JDK_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_IMAGE_SUBDIR)
 JRE_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_IMAGE_SUBDIR)
 
-JRE_COMPACT1_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(JRE_COMPACT1_IMAGE_SUBDIR)
-JRE_COMPACT2_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(JRE_COMPACT2_IMAGE_SUBDIR)
-JRE_COMPACT3_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(JRE_COMPACT3_IMAGE_SUBDIR)
-
 # Test image, as above
 TEST_IMAGE_SUBDIR:=test
 TEST_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(TEST_IMAGE_SUBDIR)
@@ -866,12 +859,6 @@
 endif
 JDK_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz
 JRE_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz
-JRE_COMPACT1_BUNDLE_NAME := \
-    jre-$(VERSION_SHORT)+$(VERSION_BUILD)-compact1_$(OPENJDK_TARGET_BUNDLE_PLATFORM)_bin$(DEBUG_PART).tar.gz
-JRE_COMPACT2_BUNDLE_NAME := \
-    jre-$(VERSION_SHORT)+$(VERSION_BUILD)-compact2_$(OPENJDK_TARGET_BUNDLE_PLATFORM)_bin$(DEBUG_PART).tar.gz
-JRE_COMPACT3_BUNDLE_NAME := \
-    jre-$(VERSION_SHORT)+$(VERSION_BUILD)-compact3_$(OPENJDK_TARGET_BUNDLE_PLATFORM)_bin$(DEBUG_PART).tar.gz
 JDK_SYMBOLS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz
 JRE_SYMBOLS_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz
 TEST_DEMOS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-tests-demos$(DEBUG_PART).tar.gz
--- a/make/autoconf/version-numbers	Wed May 02 22:11:35 2018 -0700
+++ b/make/autoconf/version-numbers	Fri May 04 08:50:01 2018 -0700
@@ -32,7 +32,7 @@
 DEFAULT_VERSION_DATE=2018-09-25
 DEFAULT_VERSION_CLASSFILE_MAJOR=55  # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
 DEFAULT_VERSION_CLASSFILE_MINOR=0
-DEFAULT_ACCEPTABLE_BOOT_VERSIONS="9 10 11"
+DEFAULT_ACCEPTABLE_BOOT_VERSIONS="10 11"
 
 LAUNCHER_NAME=openjdk
 PRODUCT_NAME=OpenJDK
--- a/make/conf/jib-profiles.js	Wed May 02 22:11:35 2018 -0700
+++ b/make/conf/jib-profiles.js	Fri May 04 08:50:01 2018 -0700
@@ -390,7 +390,7 @@
         };
     };
 
-    common.boot_jdk_version = "9";
+    common.boot_jdk_version = "10";
     common.boot_jdk_home = input.get("boot_jdk", "home_path") + "/jdk-"
         + common.boot_jdk_version
         + (input.build_os == "macosx" ? ".jdk/Contents/Home" : "");
@@ -848,7 +848,7 @@
             server: "jpg",
             product: "jdk",
             version: common.boot_jdk_version,
-            build_number: "181",
+            build_number: "46",
             file: "bundles/" + boot_jdk_platform + "/jdk-" + common.boot_jdk_version + "_"
                 + boot_jdk_platform + "_bin.tar.gz",
             configure_args: "--with-boot-jdk=" + common.boot_jdk_home,
--- a/make/hotspot/lib/JvmDtraceObjects.gmk	Wed May 02 22:11:35 2018 -0700
+++ b/make/hotspot/lib/JvmDtraceObjects.gmk	Fri May 04 08:50:01 2018 -0700
@@ -77,9 +77,14 @@
         vmGCOperations.o \
     )
 
-    ifeq ($(call check-jvm-feature, all-gcs), true)
+    ifeq ($(call check-jvm-feature, cmsgc), true)
       DTRACE_INSTRUMENTED_OBJS += $(addprefix $(JVM_OUTPUTDIR)/objs/, \
           vmCMSOperations.o \
+      )
+    endif
+
+    ifeq ($(call check-jvm-feature, parallelgc), true)
+      DTRACE_INSTRUMENTED_OBJS += $(addprefix $(JVM_OUTPUTDIR)/objs/, \
           vmPSOperations.o \
       )
     endif
--- a/make/hotspot/lib/JvmFeatures.gmk	Wed May 02 22:11:35 2018 -0700
+++ b/make/hotspot/lib/JvmFeatures.gmk	Fri May 04 08:50:01 2018 -0700
@@ -118,19 +118,6 @@
       #
 endif
 
-ifneq ($(call check-jvm-feature, all-gcs), true)
-  JVM_CFLAGS_FEATURES += -DINCLUDE_ALL_GCS=0
-  JVM_EXCLUDE_PATTERNS += \
-      cms/ g1/ parallel/
-  JVM_EXCLUDE_FILES += \
-      concurrentGCThread.cpp \
-      suspendibleThreadSet.cpp \
-      plab.cpp
-  JVM_EXCLUDE_FILES += \
-      g1MemoryPool.cpp \
-      psMemoryPool.cpp
-endif
-
 ifneq ($(call check-jvm-feature, nmt), true)
   JVM_CFLAGS_FEATURES += -DINCLUDE_NMT=0
   JVM_EXCLUDE_FILES += \
@@ -138,13 +125,34 @@
       memTracker.cpp nmtDCmd.cpp mallocSiteTable.cpp
 endif
 
-ifeq ($(call check-jvm-feature, aot), true)
-  JVM_CFLAGS_FEATURES += -DINCLUDE_AOT
-else
+ifneq ($(call check-jvm-feature, aot), true)
+  JVM_CFLAGS_FEATURES += -DINCLUDE_AOT=0
   JVM_EXCLUDE_FILES += \
       compiledIC_aot_x86_64.cpp compilerRuntime.cpp \
       aotCodeHeap.cpp aotCompiledMethod.cpp aotLoader.cpp compiledIC_aot.cpp
 endif
+
+ifneq ($(call check-jvm-feature, cmsgc), true)
+  JVM_CFLAGS_FEATURES += -DINCLUDE_CMSGC=0
+  JVM_EXCLUDE_PATTERNS += gc/cms
+endif
+
+ifneq ($(call check-jvm-feature, g1gc), true)
+  JVM_CFLAGS_FEATURES += -DINCLUDE_G1GC=0
+  JVM_EXCLUDE_PATTERNS += gc/g1
+endif
+
+ifneq ($(call check-jvm-feature, parallelgc), true)
+  JVM_CFLAGS_FEATURES += -DINCLUDE_PARALLELGC=0
+  JVM_EXCLUDE_PATTERNS += gc/parallel
+endif
+
+ifneq ($(call check-jvm-feature, serialgc), true)
+  JVM_CFLAGS_FEATURES += -DINCLUDE_SERIALGC=0
+  JVM_EXCLUDE_PATTERNS += gc/serial
+  # If serial is disabled, we cannot use serial as OldGC in parallel
+  JVM_EXCLUDE_FILES += psMarkSweep.cpp psMarkSweepDecorator.cpp
+endif
 ################################################################################
 
 ifeq ($(call check-jvm-feature, link-time-opt), true)
--- a/make/test/JtregNativeHotspot.gmk	Wed May 02 22:11:35 2018 -0700
+++ b/make/test/JtregNativeHotspot.gmk	Fri May 04 08:50:01 2018 -0700
@@ -59,8 +59,18 @@
     -I$(VM_TESTBASE_DIR)/nsk/share/native \
     -I$(VM_TESTBASE_DIR)/nsk/share/jni
 
+NSK_MONITORING_INCLUDES := \
+    -I$(VM_TESTBASE_DIR)/nsk/share/native \
+    -I$(VM_TESTBASE_DIR)/nsk/share/jni
+
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libProcessUtils := $(VM_SHARE_INCLUDES)
 
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libThreadController := $(NSK_MONITORING_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libDeadlock := $(NSK_MONITORING_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libRecursiveMonitoringThread := $(NSK_MONITORING_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libLockingThreads := $(NSK_MONITORING_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libStackTraceController := $(NSK_MONITORING_INCLUDES)
+
 ################################################################################
 
 # Platform specific setup
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Fri May 04 08:50:01 2018 -0700
@@ -49,11 +49,6 @@
 #include "runtime/jniHandles.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/g1CardTable.hpp"
-#include "gc/g1/heapRegion.hpp"
-#endif
 
 #ifdef PRODUCT
 #define BLOCK_COMMENT(str) /* nothing */
@@ -1951,6 +1946,11 @@
 void MacroAssembler::decrementw(Address dst, int value)
 {
   assert(!dst.uses(rscratch1), "invalid dst for address decrement");
+  if (dst.getMode() == Address::literal) {
+    assert(abs(value) < (1 << 12), "invalid value and address mode combination");
+    lea(rscratch2, dst);
+    dst = Address(rscratch2);
+  }
   ldrw(rscratch1, dst);
   decrementw(rscratch1, value);
   strw(rscratch1, dst);
@@ -1959,6 +1959,11 @@
 void MacroAssembler::decrement(Address dst, int value)
 {
   assert(!dst.uses(rscratch1), "invalid address for decrement");
+  if (dst.getMode() == Address::literal) {
+    assert(abs(value) < (1 << 12), "invalid value and address mode combination");
+    lea(rscratch2, dst);
+    dst = Address(rscratch2);
+  }
   ldr(rscratch1, dst);
   decrement(rscratch1, value);
   str(rscratch1, dst);
@@ -1991,6 +1996,11 @@
 void MacroAssembler::incrementw(Address dst, int value)
 {
   assert(!dst.uses(rscratch1), "invalid dst for address increment");
+  if (dst.getMode() == Address::literal) {
+    assert(abs(value) < (1 << 12), "invalid value and address mode combination");
+    lea(rscratch2, dst);
+    dst = Address(rscratch2);
+  }
   ldrw(rscratch1, dst);
   incrementw(rscratch1, value);
   strw(rscratch1, dst);
@@ -1999,6 +2009,11 @@
 void MacroAssembler::increment(Address dst, int value)
 {
   assert(!dst.uses(rscratch1), "invalid dst for address increment");
+  if (dst.getMode() == Address::literal) {
+    assert(abs(value) < (1 << 12), "invalid value and address mode combination");
+    lea(rscratch2, dst);
+    dst = Address(rscratch2);
+  }
   ldr(rscratch1, dst);
   increment(rscratch1, value);
   str(rscratch1, dst);
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp	Fri May 04 08:50:01 2018 -0700
@@ -781,23 +781,6 @@
 
   void resolve_jobject(Register value, Register thread, Register tmp);
 
-#if INCLUDE_ALL_GCS
-
-  void g1_write_barrier_pre(Register obj,
-                            Register pre_val,
-                            Register thread,
-                            Register tmp,
-                            bool tosca_live,
-                            bool expand_call);
-
-  void g1_write_barrier_post(Register store_addr,
-                             Register new_val,
-                             Register thread,
-                             Register tmp,
-                             Register tmp2);
-
-#endif // INCLUDE_ALL_GCS
-
   // oop manipulations
   void load_klass(Register dst, Register src);
   void store_klass(Register dst, Register src);
--- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp	Fri May 04 08:50:01 2018 -0700
@@ -2339,7 +2339,7 @@
   __ b(cont);
 
   int reexecute_offset = __ pc() - start;
-#if defined(INCLUDE_JVMCI) && !defined(COMPILER1)
+#if INCLUDE_JVMCI && !defined(COMPILER1)
   if (EnableJVMCI && UseJVMCICompiler) {
     // JVMCI does not use this kind of deoptimization
     __ should_not_reach_here();
--- a/src/hotspot/cpu/arm/assembler_arm.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/assembler_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -42,10 +42,6 @@
 #include "runtime/stubRoutines.hpp"
 #include "utilities/hashtable.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/heapRegion.hpp"
-#endif // INCLUDE_ALL_GCS
 
 int AbstractAssembler::code_fill_byte() {
   return 0xff; // illegal instruction 0xffffffff
--- a/src/hotspot/cpu/arm/assembler_arm_32.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/assembler_arm_32.cpp	Fri May 04 08:50:01 2018 -0700
@@ -42,10 +42,6 @@
 #include "runtime/stubRoutines.hpp"
 #include "utilities/hashtable.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/heapRegion.hpp"
-#endif // INCLUDE_ALL_GCS
 
 #ifdef COMPILER2
 // Convert the raw encoding form into the form expected by the
--- a/src/hotspot/cpu/arm/assembler_arm_64.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/assembler_arm_64.cpp	Fri May 04 08:50:01 2018 -0700
@@ -42,10 +42,6 @@
 #include "runtime/stubRoutines.hpp"
 #include "utilities/hashtable.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/heapRegion.hpp"
-#endif // INCLUDE_ALL_GCS
 
 // Returns whether given imm has equal bit fields <0:size-1> and <size:2*size-1>.
 inline bool Assembler::LogicalImmediate::has_equal_subpatterns(uintx imm, int size) {
--- a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -486,6 +486,9 @@
 void LIRGenerator::CardTableBarrierSet_post_barrier_helper(LIR_OprDesc* addr, LIR_Const* card_table_base) {
   assert(addr->is_register(), "must be a register at this point");
 
+  CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());
+  CardTable* ct = ctbs->card_table();
+
   LIR_Opr tmp = FrameMap::LR_ptr_opr;
 
   // TODO-AARCH64: check performance
@@ -507,7 +510,7 @@
   LIR_Address* card_addr = new LIR_Address(tmp, addr, (LIR_Address::Scale) -CardTable::card_shift, 0, T_BOOLEAN);
 #endif
   if (UseCondCardMark) {
-    if (UseConcMarkSweepGC) {
+    if (ct->scanned_concurrently()) {
       __ membar_storeload();
     }
     LIR_Opr cur_value = new_register(T_INT);
@@ -519,11 +522,9 @@
     set_card(tmp, card_addr);
     __ branch_destination(L_already_dirty->label());
   } else {
-#if INCLUDE_ALL_GCS
-    if (UseConcMarkSweepGC && CMSPrecleaningEnabled) {
+    if (ct->scanned_concurrently()) {
       __ membar_storestore();
     }
-#endif
     set_card(tmp, card_addr);
   }
 }
--- a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -28,6 +28,7 @@
 #include "gc/g1/g1BarrierSetAssembler.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/g1CardTable.hpp"
+#include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "interpreter/interp_masm.hpp"
 #include "runtime/sharedRuntime.hpp"
@@ -127,6 +128,239 @@
 #endif // !AARCH64
 }
 
+// G1 pre-barrier.
+// Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
+// If store_addr != noreg, then previous value is loaded from [store_addr];
+// in such case store_addr and new_val registers are preserved;
+// otherwise pre_val register is preserved.
+void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm,
+                                          Register store_addr,
+                                          Register new_val,
+                                          Register pre_val,
+                                          Register tmp1,
+                                          Register tmp2) {
+  Label done;
+  Label runtime;
+
+  if (store_addr != noreg) {
+    assert_different_registers(store_addr, new_val, pre_val, tmp1, tmp2, noreg);
+  } else {
+    assert (new_val == noreg, "should be");
+    assert_different_registers(pre_val, tmp1, tmp2, noreg);
+  }
+
+  Address in_progress(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()));
+  Address index(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()));
+  Address buffer(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()));
+
+  // Is marking active?
+  assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "adjust this code");
+  __ ldrb(tmp1, in_progress);
+  __ cbz(tmp1, done);
+
+  // Do we need to load the previous value?
+  if (store_addr != noreg) {
+    __ load_heap_oop(pre_val, Address(store_addr, 0));
+  }
+
+  // Is the previous value null?
+  __ cbz(pre_val, done);
+
+  // Can we store original value in the thread's buffer?
+  // Is index == 0?
+  // (The index field is typed as size_t.)
+
+  __ ldr(tmp1, index);           // tmp1 := *index_adr
+  __ ldr(tmp2, buffer);
+
+  __ subs(tmp1, tmp1, wordSize); // tmp1 := tmp1 - wordSize
+  __ b(runtime, lt);             // If negative, goto runtime
+
+  __ str(tmp1, index);           // *index_adr := tmp1
+
+  // Record the previous value
+  __ str(pre_val, Address(tmp2, tmp1));
+  __ b(done);
+
+  __ bind(runtime);
+
+  // save the live input values
+#ifdef AARCH64
+  if (store_addr != noreg) {
+    __ raw_push(store_addr, new_val);
+  } else {
+    __ raw_push(pre_val, ZR);
+  }
+#else
+  if (store_addr != noreg) {
+    // avoid raw_push to support any ordering of store_addr and new_val
+    __ push(RegisterSet(store_addr) | RegisterSet(new_val));
+  } else {
+    __ push(pre_val);
+  }
+#endif // AARCH64
+
+  if (pre_val != R0) {
+    __ mov(R0, pre_val);
+  }
+  __ mov(R1, Rthread);
+
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), R0, R1);
+
+#ifdef AARCH64
+  if (store_addr != noreg) {
+    __ raw_pop(store_addr, new_val);
+  } else {
+    __ raw_pop(pre_val, ZR);
+  }
+#else
+  if (store_addr != noreg) {
+    __ pop(RegisterSet(store_addr) | RegisterSet(new_val));
+  } else {
+    __ pop(pre_val);
+  }
+#endif // AARCH64
+
+  __ bind(done);
+}
+
+// G1 post-barrier.
+// Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
+void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm,
+                                           Register store_addr,
+                                           Register new_val,
+                                           Register tmp1,
+                                           Register tmp2,
+                                           Register tmp3) {
+
+  Address queue_index(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()));
+  Address buffer(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()));
+
+  BarrierSet* bs = BarrierSet::barrier_set();
+  CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
+  CardTable* ct = ctbs->card_table();
+  Label done;
+  Label runtime;
+
+  // Does store cross heap regions?
+
+  __ eor(tmp1, store_addr, new_val);
+#ifdef AARCH64
+  __ logical_shift_right(tmp1, tmp1, HeapRegion::LogOfHRGrainBytes);
+  __ cbz(tmp1, done);
+#else
+  __ movs(tmp1, AsmOperand(tmp1, lsr, HeapRegion::LogOfHRGrainBytes));
+  __ b(done, eq);
+#endif
+
+  // crosses regions, storing NULL?
+
+  __ cbz(new_val, done);
+
+  // storing region crossing non-NULL, is card already dirty?
+  const Register card_addr = tmp1;
+  assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
+
+  __ mov_address(tmp2, (address)ct->byte_map_base(), symbolic_Relocation::card_table_reference);
+  __ add(card_addr, tmp2, AsmOperand(store_addr, lsr, CardTable::card_shift));
+
+  __ ldrb(tmp2, Address(card_addr));
+  __ cmp(tmp2, (int)G1CardTable::g1_young_card_val());
+  __ b(done, eq);
+
+  __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), tmp2);
+
+  assert(CardTable::dirty_card_val() == 0, "adjust this code");
+  __ ldrb(tmp2, Address(card_addr));
+  __ cbz(tmp2, done);
+
+  // storing a region crossing, non-NULL oop, card is clean.
+  // dirty card and log.
+
+  __ strb(__ zero_register(tmp2), Address(card_addr));
+
+  __ ldr(tmp2, queue_index);
+  __ ldr(tmp3, buffer);
+
+  __ subs(tmp2, tmp2, wordSize);
+  __ b(runtime, lt); // go to runtime if now negative
+
+  __ str(tmp2, queue_index);
+
+  __ str(card_addr, Address(tmp3, tmp2));
+  __ b(done);
+
+  __ bind(runtime);
+
+  if (card_addr != R0) {
+    __ mov(R0, card_addr);
+  }
+  __ mov(R1, Rthread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), R0, R1);
+
+  __ bind(done);
+}
+
+void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                                    Register dst, Address src, Register tmp1, Register tmp2, Register tmp3) {
+  bool on_oop = type == T_OBJECT || type == T_ARRAY;
+  bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
+  bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0;
+  bool on_reference = on_weak || on_phantom;
+
+  ModRefBarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp2, tmp3);
+  if (on_oop && on_reference) {
+    // Generate the G1 pre-barrier code to log the value of
+    // the referent field in an SATB buffer.
+    g1_write_barrier_pre(masm, noreg, noreg, dst, tmp1, tmp2);
+  }
+}
+
+
+void G1BarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                                         Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, bool is_null) {
+  bool in_heap = (decorators & IN_HEAP) != 0;
+  bool in_concurrent_root = (decorators & IN_CONCURRENT_ROOT) != 0;
+
+  bool needs_pre_barrier = in_heap || in_concurrent_root;
+  bool needs_post_barrier = (new_val != noreg) && in_heap;
+
+  // flatten object address if needed
+  assert (obj.mode() == basic_offset, "pre- or post-indexing is not supported here");
+
+  const Register store_addr = obj.base();
+  if (obj.index() != noreg) {
+    assert (obj.disp() == 0, "index or displacement, not both");
+#ifdef AARCH64
+    __ add(store_addr, obj.base(), obj.index(), obj.extend(), obj.shift_imm());
+#else
+    assert(obj.offset_op() == add_offset, "addition is expected");
+    __ add(store_addr, obj.base(), AsmOperand(obj.index(), obj.shift(), obj.shift_imm()));
+#endif // AARCH64
+  } else if (obj.disp() != 0) {
+    __ add(store_addr, obj.base(), obj.disp());
+  }
+
+  if (needs_pre_barrier) {
+    g1_write_barrier_pre(masm, store_addr, new_val, tmp1, tmp2, tmp3);
+  }
+
+  if (is_null) {
+    BarrierSetAssembler::store_at(masm, decorators, type, Address(store_addr), new_val, tmp1, tmp2, tmp3, true);
+  } else {
+    // G1 barrier needs uncompressed oop for region cross check.
+    Register val_to_store = new_val;
+    if (UseCompressedOops) {
+      val_to_store = tmp1;
+      __ mov(val_to_store, new_val);
+    }
+    BarrierSetAssembler::store_at(masm, decorators, type, Address(store_addr), val_to_store, tmp1, tmp2, tmp3, false);
+    if (needs_post_barrier) {
+      g1_write_barrier_post(masm, store_addr, new_val, tmp1, tmp2, tmp3);
+    }
+  }
+};
+
 #ifdef COMPILER1
 
 #undef __
--- a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.hpp	Fri May 04 08:50:01 2018 -0700
@@ -41,6 +41,27 @@
   void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
                                         Register addr, Register count, Register tmp);
 
+  void g1_write_barrier_pre(MacroAssembler* masm,
+                            Register store_addr,
+                            Register new_val,
+                            Register pre_val,
+                            Register tmp1,
+                            Register tmp2);
+
+  void g1_write_barrier_post(MacroAssembler* masm,
+                             Register store_addr,
+                             Register new_val,
+                             Register tmp1,
+                             Register tmp2,
+                             Register tmp3);
+
+  virtual void oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                            Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, bool is_null);
+
+public:
+  virtual void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                       Register dst, Address src, Register tmp1, Register tmp2, Register tmp3);
+
 #ifdef COMPILER1
 public:
   void gen_pre_barrier_stub(LIR_Assembler* ce, G1PreBarrierStub* stub);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc/shared/barrierSetAssembler.hpp"
+
+#define __ masm->
+
+void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                                  Register dst, Address src, Register tmp1, Register tmp2, Register tmp3) {
+  bool on_heap = (decorators & IN_HEAP) != 0;
+  bool on_root = (decorators & IN_ROOT) != 0;
+  switch (type) {
+  case T_OBJECT:
+  case T_ARRAY: {
+    if (on_heap) {
+#ifdef AARCH64
+      if (UseCompressedOops) {
+        __ ldr_w(dst, src);
+        __ decode_heap_oop(dst);
+      } else
+#endif // AARCH64
+      {
+        __ ldr(dst, src);
+      }
+    } else {
+      assert(on_root, "why else?");
+      __ ldr(dst, src);
+    }
+    break;
+  }
+  default: Unimplemented();
+  }
+
+}
+
+void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                                   Address obj, Register val, Register tmp1, Register tmp2, Register tmp3, bool is_null) {
+  bool on_heap = (decorators & IN_HEAP) != 0;
+  bool on_root = (decorators & IN_ROOT) != 0;
+  switch (type) {
+  case T_OBJECT:
+  case T_ARRAY: {
+    if (on_heap) {
+#ifdef AARCH64
+      if (UseCompressedOops) {
+        assert(!dst.uses(src), "not enough registers");
+        if (!is_null) {
+          __ encode_heap_oop(src);
+        }
+        __ str_w(val, obj);
+      } else
+#endif // AARCH64
+      {
+        __ str(val, obj);
+      }
+    } else {
+      assert(on_root, "why else?");
+      __ str(val, obj);
+    }
+    break;
+  }
+  default: Unimplemented();
+  }
+}
+
--- a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp	Fri May 04 08:50:01 2018 -0700
@@ -36,6 +36,11 @@
   virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
                                   Register addr, Register count, Register tmp) {}
 
+  virtual void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                       Register dst, Address src, Register tmp1, Register tmp2, Register tmp3);
+  virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                        Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, bool is_null);
+
   virtual void barrier_stubs_init() {}
 };
 
--- a/src/hotspot/cpu/arm/gc/shared/cardTableBarrierSetAssembler_arm.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/gc/shared/cardTableBarrierSetAssembler_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -72,3 +72,111 @@
   __ b(L_cardtable_loop, ge);
   __ BIND(L_done);
 }
+
+void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                                             Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, bool is_null) {
+  bool on_array = (decorators & IN_HEAP_ARRAY) != 0;
+  bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;
+  bool precise = on_array || on_anonymous;
+
+  if (is_null) {
+    BarrierSetAssembler::store_at(masm, decorators, type, obj, new_val, tmp1, tmp2, tmp3, true);
+  } else {
+    assert (!precise || (obj.index() == noreg && obj.disp() == 0),
+            "store check address should be calculated beforehand");
+
+    store_check_part1(masm, tmp1);
+    BarrierSetAssembler::store_at(masm, decorators, type, obj, new_val, tmp1, tmp2, tmp3, false);
+    new_val = noreg;
+    store_check_part2(masm, obj.base(), tmp1, tmp2);
+  }
+}
+
+// The 1st part of the store check.
+// Sets card_table_base register.
+void CardTableBarrierSetAssembler::store_check_part1(MacroAssembler* masm, Register card_table_base) {
+  // Check barrier set type (should be card table) and element size
+  BarrierSet* bs = BarrierSet::barrier_set();
+  assert(bs->kind() == BarrierSet::CardTableBarrierSet,
+         "Wrong barrier set kind");
+
+  CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
+  CardTable* ct = ctbs->card_table();
+  assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "Adjust store check code");
+
+  // Load card table base address.
+
+  /* Performance note.
+
+     There is an alternative way of loading card table base address
+     from thread descriptor, which may look more efficient:
+
+     ldr(card_table_base, Address(Rthread, JavaThread::card_table_base_offset()));
+
+     However, performance measurements of micro benchmarks and specJVM98
+     showed that loading of card table base from thread descriptor is
+     7-18% slower compared to loading of literal embedded into the code.
+     Possible cause is a cache miss (card table base address resides in a
+     rarely accessed area of thread descriptor).
+  */
+  // TODO-AARCH64 Investigate if mov_slow is faster than ldr from Rthread on AArch64
+  __ mov_address(card_table_base, (address)ct->byte_map_base(), symbolic_Relocation::card_table_reference);
+}
+
+// The 2nd part of the store check.
+void CardTableBarrierSetAssembler::store_check_part2(MacroAssembler* masm, Register obj, Register card_table_base, Register tmp) {
+  assert_different_registers(obj, card_table_base, tmp);
+
+  BarrierSet* bs = BarrierSet::barrier_set();
+  assert(bs->kind() == BarrierSet::CardTableBarrierSet,
+         "Wrong barrier set kind");
+
+  CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
+  CardTable* ct = ctbs->card_table();
+  assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "Adjust store check code");
+
+  assert(CardTable::dirty_card_val() == 0, "Dirty card value must be 0 due to optimizations.");
+#ifdef AARCH64
+  add(card_table_base, card_table_base, AsmOperand(obj, lsr, CardTable::card_shift));
+  Address card_table_addr(card_table_base);
+#else
+  Address card_table_addr(card_table_base, obj, lsr, CardTable::card_shift);
+#endif
+
+  if (UseCondCardMark) {
+    if (ct->scanned_concurrently()) {
+      __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), noreg);
+    }
+    Label already_dirty;
+
+    __ ldrb(tmp, card_table_addr);
+    __ cbz(tmp, already_dirty);
+
+    set_card(masm, card_table_base, card_table_addr, tmp);
+    __ bind(already_dirty);
+
+  } else {
+    if (ct->scanned_concurrently()) {
+      __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreStore), noreg);
+    }
+    set_card(masm, card_table_base, card_table_addr, tmp);
+  }
+}
+
+void CardTableBarrierSetAssembler::set_card(MacroAssembler* masm, Register card_table_base, Address card_table_addr, Register tmp) {
+#ifdef AARCH64
+  strb(ZR, card_table_addr);
+#else
+  CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());
+  CardTable* ct = ctbs->card_table();
+  if ((((uintptr_t)ct->byte_map_base() & 0xff) == 0)) {
+    // Card table is aligned so the lowest byte of the table address base is zero.
+    // This works only if the code is not saved for later use, possibly
+    // in a context where the base would no longer be aligned.
+    __ strb(card_table_base, card_table_addr);
+  } else {
+    __ mov(tmp, 0);
+    __ strb(tmp, card_table_addr);
+  }
+#endif // AARCH64
+}
--- a/src/hotspot/cpu/arm/gc/shared/cardTableBarrierSetAssembler_arm.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/gc/shared/cardTableBarrierSetAssembler_arm.hpp	Fri May 04 08:50:01 2018 -0700
@@ -29,9 +29,18 @@
 #include "gc/shared/modRefBarrierSetAssembler.hpp"
 
 class CardTableBarrierSetAssembler: public ModRefBarrierSetAssembler {
+private:
+  void store_check(MacroAssembler* masm, Register obj, Address dst);
+  void store_check_part1(MacroAssembler* masm, Register card_table_base);
+  void store_check_part2(MacroAssembler* masm, Register obj, Register card_table_base, Register tmp);
+
+  void set_card(MacroAssembler* masm, Register card_table_base, Address card_table_addr, Register tmp);
+
 protected:
   virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
                                                 Register addr, Register count, Register tmp);
+  virtual void oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                            Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, bool is_null);
 };
 
 #endif // #ifndef CPU_ARM_GC_SHARED_CARDTABLEBARRIERSETASSEMBLER_ARM_HPP
--- a/src/hotspot/cpu/arm/gc/shared/modRefBarrierSetAssembler_arm.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/gc/shared/modRefBarrierSetAssembler_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -42,3 +42,12 @@
     gen_write_ref_array_post_barrier(masm, decorators, addr, count, tmp);
   }
 }
+
+void ModRefBarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                                         Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, bool is_null) {
+  if (type == T_OBJECT || type == T_ARRAY) {
+    oop_store_at(masm, decorators, type, obj, new_val, tmp1, tmp2, tmp3, is_null);
+  } else {
+    BarrierSetAssembler::store_at(masm, decorators, type, obj, new_val, tmp1, tmp2, tmp3, is_null);
+  }
+}
--- a/src/hotspot/cpu/arm/gc/shared/modRefBarrierSetAssembler_arm.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/gc/shared/modRefBarrierSetAssembler_arm.hpp	Fri May 04 08:50:01 2018 -0700
@@ -28,6 +28,10 @@
 #include "asm/macroAssembler.hpp"
 #include "gc/shared/barrierSetAssembler.hpp"
 
+// The ModRefBarrierSetAssembler filters away accesses on BasicTypes other
+// than T_OBJECT/T_ARRAY (oops). The oop accesses call one of the protected
+// accesses, which are overridden in the concrete BarrierSetAssembler.
+
 class ModRefBarrierSetAssembler: public BarrierSetAssembler {
 protected:
   virtual void gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
@@ -35,11 +39,16 @@
   virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
                                                 Register addr, Register count, Register tmp) {}
 
+  virtual void oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                            Address obj, Register val, Register tmp1, Register tmp2, Register tmp3, bool is_null) = 0;
+
 public:
   virtual void arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
                                   Register addr, Register count, int callee_saved_regs);
   virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
                                   Register addr, Register count, Register tmp);
+  virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
+                        Address obj, Register val, Register tmp1, Register tmp2, Register tmp3, bool is_null);
 };
 
 #endif // CPU_ARM_GC_SHARED_MODREFBARRIERSETASSEMBLER_ARM_HPP
--- a/src/hotspot/cpu/arm/interp_masm_arm.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/interp_masm_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -43,11 +43,6 @@
 #include "runtime/frame.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
 
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/heapRegion.hpp"
-#endif // INCLUDE_ALL_GCS
-
 //--------------------------------------------------------------------
 // Implementation of InterpreterMacroAssembler
 
@@ -406,91 +401,6 @@
 }
 
 
-// The 1st part of the store check.
-// Sets card_table_base register.
-void InterpreterMacroAssembler::store_check_part1(Register card_table_base) {
-  // Check barrier set type (should be card table) and element size
-  BarrierSet* bs = BarrierSet::barrier_set();
-  assert(bs->kind() == BarrierSet::CardTableBarrierSet,
-         "Wrong barrier set kind");
-
-  CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
-  CardTable* ct = ctbs->card_table();
-  assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "Adjust store check code");
-
-  // Load card table base address.
-
-  /* Performance note.
-
-     There is an alternative way of loading card table base address
-     from thread descriptor, which may look more efficient:
-
-     ldr(card_table_base, Address(Rthread, JavaThread::card_table_base_offset()));
-
-     However, performance measurements of micro benchmarks and specJVM98
-     showed that loading of card table base from thread descriptor is
-     7-18% slower compared to loading of literal embedded into the code.
-     Possible cause is a cache miss (card table base address resides in a
-     rarely accessed area of thread descriptor).
-  */
-  // TODO-AARCH64 Investigate if mov_slow is faster than ldr from Rthread on AArch64
-  mov_address(card_table_base, (address)ct->byte_map_base(), symbolic_Relocation::card_table_reference);
-}
-
-// The 2nd part of the store check.
-void InterpreterMacroAssembler::store_check_part2(Register obj, Register card_table_base, Register tmp) {
-  assert_different_registers(obj, card_table_base, tmp);
-
-  assert(CardTable::dirty_card_val() == 0, "Dirty card value must be 0 due to optimizations.");
-#ifdef AARCH64
-  add(card_table_base, card_table_base, AsmOperand(obj, lsr, CardTable::card_shift));
-  Address card_table_addr(card_table_base);
-#else
-  Address card_table_addr(card_table_base, obj, lsr, CardTable::card_shift);
-#endif
-
-  if (UseCondCardMark) {
-#if INCLUDE_ALL_GCS
-    if (UseConcMarkSweepGC) {
-      membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), noreg);
-    }
-#endif
-    Label already_dirty;
-
-    ldrb(tmp, card_table_addr);
-    cbz(tmp, already_dirty);
-
-    set_card(card_table_base, card_table_addr, tmp);
-    bind(already_dirty);
-
-  } else {
-#if INCLUDE_ALL_GCS
-    if (UseConcMarkSweepGC && CMSPrecleaningEnabled) {
-      membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreStore), noreg);
-    }
-#endif
-    set_card(card_table_base, card_table_addr, tmp);
-  }
-}
-
-void InterpreterMacroAssembler::set_card(Register card_table_base, Address card_table_addr, Register tmp) {
-#ifdef AARCH64
-  strb(ZR, card_table_addr);
-#else
-  CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());
-  CardTable* ct = ctbs->card_table();
-  if ((((uintptr_t)ct->byte_map_base() & 0xff) == 0)) {
-    // Card table is aligned so the lowest byte of the table address base is zero.
-    // This works only if the code is not saved for later use, possibly
-    // in a context where the base would no longer be aligned.
-    strb(card_table_base, card_table_addr);
-  } else {
-    mov(tmp, 0);
-    strb(tmp, card_table_addr);
-  }
-#endif // AARCH64
-}
-
 //////////////////////////////////////////////////////////////////////////////////
 
 
--- a/src/hotspot/cpu/arm/interp_masm_arm.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/interp_masm_arm.hpp	Fri May 04 08:50:01 2018 -0700
@@ -144,11 +144,6 @@
   // load cpool->resolved_klass_at(index); Rtemp is corrupted upon return
   void load_resolved_klass_at_offset(Register Rcpool, Register Rindex, Register Rklass);
 
-  void store_check_part1(Register card_table_base);                // Sets card_table_base register.
-  void store_check_part2(Register obj, Register card_table_base, Register tmp);
-
-  void set_card(Register card_table_base, Address card_table_addr, Register tmp);
-
   void pop_ptr(Register r);
   void pop_i(Register r = R0_tos);
 #ifdef AARCH64
--- a/src/hotspot/cpu/arm/macroAssembler_arm.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/macroAssembler_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -31,6 +31,7 @@
 #include "compiler/disassembler.hpp"
 #include "gc/shared/barrierSet.hpp"
 #include "gc/shared/cardTable.hpp"
+#include "gc/shared/barrierSetAssembler.hpp"
 #include "gc/shared/cardTableBarrierSet.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
 #include "interpreter/interpreter.hpp"
@@ -44,12 +45,6 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/g1CardTable.hpp"
-#include "gc/g1/g1ThreadLocalData.hpp"
-#include "gc/g1/heapRegion.hpp"
-#endif
 
 // Implementation of AddressLiteral
 
@@ -2131,22 +2126,15 @@
   cbz(value, done);             // Use NULL as-is.
   STATIC_ASSERT(JNIHandles::weak_tag_mask == 1u);
   tbz(value, 0, not_weak);      // Test for jweak tag.
+
   // Resolve jweak.
-  ldr(value, Address(value, -JNIHandles::weak_tag_value));
-  verify_oop(value);
-#if INCLUDE_ALL_GCS
-  if (UseG1GC) {
-    g1_write_barrier_pre(noreg, // store_addr
-                         noreg, // new_val
-                         value, // pre_val
-                         tmp1,  // tmp1
-                         tmp2); // tmp2
-    }
-#endif // INCLUDE_ALL_GCS
+  access_load_at(T_OBJECT, IN_ROOT | ON_PHANTOM_OOP_REF,
+                 Address(value, -JNIHandles::weak_tag_value), value, tmp1, tmp2, noreg);
   b(done);
   bind(not_weak);
   // Resolve (untagged) jobject.
-  ldr(value, Address(value));
+  access_load_at(T_OBJECT, IN_ROOT | IN_CONCURRENT_ROOT,
+                 Address(value, 0), value, tmp1, tmp2, noreg);
   verify_oop(value);
   bind(done);
 }
@@ -2154,183 +2142,6 @@
 
 //////////////////////////////////////////////////////////////////////////////////
 
-#if INCLUDE_ALL_GCS
-
-// G1 pre-barrier.
-// Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
-// If store_addr != noreg, then previous value is loaded from [store_addr];
-// in such case store_addr and new_val registers are preserved;
-// otherwise pre_val register is preserved.
-void MacroAssembler::g1_write_barrier_pre(Register store_addr,
-                                          Register new_val,
-                                          Register pre_val,
-                                          Register tmp1,
-                                          Register tmp2) {
-  Label done;
-  Label runtime;
-
-  if (store_addr != noreg) {
-    assert_different_registers(store_addr, new_val, pre_val, tmp1, tmp2, noreg);
-  } else {
-    assert (new_val == noreg, "should be");
-    assert_different_registers(pre_val, tmp1, tmp2, noreg);
-  }
-
-  Address in_progress(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()));
-  Address index(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()));
-  Address buffer(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()));
-
-  // Is marking active?
-  assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "adjust this code");
-  ldrb(tmp1, in_progress);
-  cbz(tmp1, done);
-
-  // Do we need to load the previous value?
-  if (store_addr != noreg) {
-    load_heap_oop(pre_val, Address(store_addr, 0));
-  }
-
-  // Is the previous value null?
-  cbz(pre_val, done);
-
-  // Can we store original value in the thread's buffer?
-  // Is index == 0?
-  // (The index field is typed as size_t.)
-
-  ldr(tmp1, index);           // tmp1 := *index_adr
-  ldr(tmp2, buffer);
-
-  subs(tmp1, tmp1, wordSize); // tmp1 := tmp1 - wordSize
-  b(runtime, lt);             // If negative, goto runtime
-
-  str(tmp1, index);           // *index_adr := tmp1
-
-  // Record the previous value
-  str(pre_val, Address(tmp2, tmp1));
-  b(done);
-
-  bind(runtime);
-
-  // save the live input values
-#ifdef AARCH64
-  if (store_addr != noreg) {
-    raw_push(store_addr, new_val);
-  } else {
-    raw_push(pre_val, ZR);
-  }
-#else
-  if (store_addr != noreg) {
-    // avoid raw_push to support any ordering of store_addr and new_val
-    push(RegisterSet(store_addr) | RegisterSet(new_val));
-  } else {
-    push(pre_val);
-  }
-#endif // AARCH64
-
-  if (pre_val != R0) {
-    mov(R0, pre_val);
-  }
-  mov(R1, Rthread);
-
-  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), R0, R1);
-
-#ifdef AARCH64
-  if (store_addr != noreg) {
-    raw_pop(store_addr, new_val);
-  } else {
-    raw_pop(pre_val, ZR);
-  }
-#else
-  if (store_addr != noreg) {
-    pop(RegisterSet(store_addr) | RegisterSet(new_val));
-  } else {
-    pop(pre_val);
-  }
-#endif // AARCH64
-
-  bind(done);
-}
-
-// G1 post-barrier.
-// Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
-void MacroAssembler::g1_write_barrier_post(Register store_addr,
-                                           Register new_val,
-                                           Register tmp1,
-                                           Register tmp2,
-                                           Register tmp3) {
-
-  Address queue_index(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()));
-  Address buffer(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()));
-
-  BarrierSet* bs = BarrierSet::barrier_set();
-  CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
-  CardTable* ct = ctbs->card_table();
-  Label done;
-  Label runtime;
-
-  // Does store cross heap regions?
-
-  eor(tmp1, store_addr, new_val);
-#ifdef AARCH64
-  logical_shift_right(tmp1, tmp1, HeapRegion::LogOfHRGrainBytes);
-  cbz(tmp1, done);
-#else
-  movs(tmp1, AsmOperand(tmp1, lsr, HeapRegion::LogOfHRGrainBytes));
-  b(done, eq);
-#endif
-
-  // crosses regions, storing NULL?
-
-  cbz(new_val, done);
-
-  // storing region crossing non-NULL, is card already dirty?
-  const Register card_addr = tmp1;
-  assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
-
-  mov_address(tmp2, (address)ct->byte_map_base(), symbolic_Relocation::card_table_reference);
-  add(card_addr, tmp2, AsmOperand(store_addr, lsr, CardTable::card_shift));
-
-  ldrb(tmp2, Address(card_addr));
-  cmp(tmp2, (int)G1CardTable::g1_young_card_val());
-  b(done, eq);
-
-  membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), tmp2);
-
-  assert(CardTable::dirty_card_val() == 0, "adjust this code");
-  ldrb(tmp2, Address(card_addr));
-  cbz(tmp2, done);
-
-  // storing a region crossing, non-NULL oop, card is clean.
-  // dirty card and log.
-
-  strb(zero_register(tmp2), Address(card_addr));
-
-  ldr(tmp2, queue_index);
-  ldr(tmp3, buffer);
-
-  subs(tmp2, tmp2, wordSize);
-  b(runtime, lt); // go to runtime if now negative
-
-  str(tmp2, queue_index);
-
-  str(card_addr, Address(tmp3, tmp2));
-  b(done);
-
-  bind(runtime);
-
-  if (card_addr != R0) {
-    mov(R0, card_addr);
-  }
-  mov(R1, Rthread);
-  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), R0, R1);
-
-  bind(done);
-}
-
-#endif // INCLUDE_ALL_GCS
-
-//////////////////////////////////////////////////////////////////////////////////
-
 #ifdef AARCH64
 
 void MacroAssembler::load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed) {
@@ -2873,38 +2684,39 @@
 #endif // AARCH64
 
 
-void MacroAssembler::load_heap_oop(Register dst, Address src) {
-#ifdef AARCH64
-  if (UseCompressedOops) {
-    ldr_w(dst, src);
-    decode_heap_oop(dst);
-    return;
-  }
-#endif // AARCH64
-  ldr(dst, src);
+void MacroAssembler::load_heap_oop(Register dst, Address src, Register tmp1, Register tmp2, Register tmp3, DecoratorSet decorators) {
+  access_load_at(T_OBJECT, IN_HEAP | decorators, src, dst, tmp1, tmp2, tmp3);
 }
 
 // Blows src and flags.
-void MacroAssembler::store_heap_oop(Register src, Address dst) {
-#ifdef AARCH64
-  if (UseCompressedOops) {
-    assert(!dst.uses(src), "not enough registers");
-    encode_heap_oop(src);
-    str_w(src, dst);
-    return;
+void MacroAssembler::store_heap_oop(Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, DecoratorSet decorators) {
+  access_store_at(T_OBJECT, IN_HEAP | decorators, obj, new_val, tmp1, tmp2, tmp3, false);
+}
+
+void MacroAssembler::store_heap_oop_null(Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, DecoratorSet decorators) {
+  access_store_at(T_OBJECT, IN_HEAP, obj, new_val, tmp1, tmp2, tmp3, true);
+}
+
+void MacroAssembler::access_load_at(BasicType type, DecoratorSet decorators,
+                                    Address src, Register dst, Register tmp1, Register tmp2, Register tmp3) {
+  BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+  bool as_raw = (decorators & AS_RAW) != 0;
+  if (as_raw) {
+    bs->BarrierSetAssembler::load_at(this, decorators, type, dst, src, tmp1, tmp2, tmp3);
+  } else {
+    bs->load_at(this, decorators, type, dst, src, tmp1, tmp2, tmp3);
   }
-#endif // AARCH64
-  str(src, dst);
 }
 
-void MacroAssembler::store_heap_oop_null(Register src, Address dst) {
-#ifdef AARCH64
-  if (UseCompressedOops) {
-    str_w(src, dst);
-    return;
+void MacroAssembler::access_store_at(BasicType type, DecoratorSet decorators,
+                                     Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, bool is_null) {
+  BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+  bool as_raw = (decorators & AS_RAW) != 0;
+  if (as_raw) {
+    bs->BarrierSetAssembler::store_at(this, decorators, type, obj, new_val, tmp1, tmp2, tmp3, is_null);
+  } else {
+    bs->store_at(this, decorators, type, obj, new_val, tmp1, tmp2, tmp3, is_null);
   }
-#endif // AARCH64
-  str(src, dst);
 }
 
 
--- a/src/hotspot/cpu/arm/macroAssembler_arm.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/macroAssembler_arm.hpp	Fri May 04 08:50:01 2018 -0700
@@ -401,27 +401,6 @@
 
   void resolve_jobject(Register value, Register tmp1, Register tmp2);
 
-#if INCLUDE_ALL_GCS
-  // G1 pre-barrier.
-  // Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
-  // If store_addr != noreg, then previous value is loaded from [store_addr];
-  // in such case store_addr and new_val registers are preserved;
-  // otherwise pre_val register is preserved.
-  void g1_write_barrier_pre(Register store_addr,
-                            Register new_val,
-                            Register pre_val,
-                            Register tmp1,
-                            Register tmp2);
-
-  // G1 post-barrier.
-  // Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
-  void g1_write_barrier_post(Register store_addr,
-                             Register new_val,
-                             Register tmp1,
-                             Register tmp2,
-                             Register tmp3);
-#endif // INCLUDE_ALL_GCS
-
 #ifndef AARCH64
   void nop() {
     mov(R0, R0);
@@ -1072,12 +1051,12 @@
 
     // oop manipulations
 
-  void load_heap_oop(Register dst, Address src);
-  void store_heap_oop(Register src, Address dst);
-  void store_heap_oop(Address dst, Register src) {
-    store_heap_oop(src, dst);
-  }
-  void store_heap_oop_null(Register src, Address dst);
+  void load_heap_oop(Register dst, Address src, Register tmp1 = noreg, Register tmp2 = noreg, Register tmp3 = noreg, DecoratorSet decorators = 0);
+  void store_heap_oop(Address obj, Register new_val, Register tmp1 = noreg, Register tmp2 = noreg, Register tmp3 = noreg, DecoratorSet decorators = 0);
+  void store_heap_oop_null(Address obj, Register new_val, Register tmp1 = noreg, Register tmp2 = noreg, Register tmp3 = noreg, DecoratorSet decorators = 0);
+
+  void access_load_at(BasicType type, DecoratorSet decorators, Address src, Register dst, Register tmp1, Register tmp2, Register tmp3);
+  void access_store_at(BasicType type, DecoratorSet decorators, Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, bool is_null);
 
 #ifdef AARCH64
   void encode_heap_oop(Register dst, Register src);
--- a/src/hotspot/cpu/arm/stubGenerator_arm.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/stubGenerator_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -3260,7 +3260,7 @@
     __ align(OptoLoopAlignment);
     __ BIND(store_element);
     if (UseCompressedOops) {
-      __ store_heap_oop(R5, Address(to, BytesPerHeapOop, post_indexed));  // store the oop, changes flags
+      __ store_heap_oop(Address(to, BytesPerHeapOop, post_indexed), R5);  // store the oop, changes flags
       __ subs_32(count,count,1);
     } else {
       __ subs_32(count,count,1);
--- a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -852,80 +852,53 @@
 //
 
 address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {
-#if INCLUDE_ALL_GCS
-  if (UseG1GC) {
-    // Code: _aload_0, _getfield, _areturn
-    // parameter size = 1
-    //
-    // The code that gets generated by this routine is split into 2 parts:
-    //    1. The "intrinsified" code for G1 (or any SATB based GC),
-    //    2. The slow path - which is an expansion of the regular method entry.
-    //
-    // Notes:-
-    // * In the G1 code we do not check whether we need to block for
-    //   a safepoint. If G1 is enabled then we must execute the specialized
-    //   code for Reference.get (except when the Reference object is null)
-    //   so that we can log the value in the referent field with an SATB
-    //   update buffer.
-    //   If the code for the getfield template is modified so that the
-    //   G1 pre-barrier code is executed when the current method is
-    //   Reference.get() then going through the normal method entry
-    //   will be fine.
-    // * The G1 code can, however, check the receiver object (the instance
-    //   of java.lang.Reference) and jump to the slow path if null. If the
-    //   Reference object is null then we obviously cannot fetch the referent
-    //   and so we don't need to call the G1 pre-barrier. Thus we can use the
-    //   regular method entry code to generate the NPE.
-    //
-    // This code is based on generate_accessor_enty.
-    //
-    // Rmethod: Method*
-    // Rthread: thread
-    // Rsender_sp: sender sp, must be preserved for slow path, set SP to it on fast path
-    // Rparams: parameters
+  // Code: _aload_0, _getfield, _areturn
+  // parameter size = 1
+  //
+  // The code that gets generated by this routine is split into 2 parts:
+  //    1. The "intrinsified" code performing an ON_WEAK_OOP_REF load,
+  //    2. The slow path - which is an expansion of the regular method entry.
+  //
+  // Notes:-
+  // * An intrinsic is always executed, where an ON_WEAK_OOP_REF load is performed.
+  // * We may jump to the slow path iff the receiver is null. If the
+  //   Reference object is null then we no longer perform an ON_WEAK_OOP_REF load
+  //   Thus we can use the regular method entry code to generate the NPE.
+  //
+  // Rmethod: Method*
+  // Rthread: thread
+  // Rsender_sp: sender sp, must be preserved for slow path, set SP to it on fast path
+  // Rparams: parameters
+
+  address entry = __ pc();
+  Label slow_path;
+  const Register Rthis = R0;
+  const Register Rret_addr = Rtmp_save1;
+  assert_different_registers(Rthis, Rret_addr, Rsender_sp);
 
-    address entry = __ pc();
-    Label slow_path;
-    const Register Rthis = R0;
-    const Register Rret_addr = Rtmp_save1;
-    assert_different_registers(Rthis, Rret_addr, Rsender_sp);
-
-    const int referent_offset = java_lang_ref_Reference::referent_offset;
-    guarantee(referent_offset > 0, "referent offset not initialized");
+  const int referent_offset = java_lang_ref_Reference::referent_offset;
+  guarantee(referent_offset > 0, "referent offset not initialized");
 
-    // Check if local 0 != NULL
-    // If the receiver is null then it is OK to jump to the slow path.
-    __ ldr(Rthis, Address(Rparams));
-    __ cbz(Rthis, slow_path);
+  // Check if local 0 != NULL
+  // If the receiver is null then it is OK to jump to the slow path.
+  __ ldr(Rthis, Address(Rparams));
+  __ cbz(Rthis, slow_path);
 
-    // Generate the G1 pre-barrier code to log the value of
-    // the referent field in an SATB buffer.
-
-    // Load the value of the referent field.
-    __ load_heap_oop(R0, Address(Rthis, referent_offset));
+  // Preserve LR
+  __ mov(Rret_addr, LR);
 
-    // Preserve LR
-    __ mov(Rret_addr, LR);
-
-    __ g1_write_barrier_pre(noreg,   // store_addr
-                            noreg,   // new_val
-                            R0,      // pre_val
-                            Rtemp,   // tmp1
-                            R1_tmp); // tmp2
+  // Load the value of the referent field.
+  const Address field_address(Rthis, referent_offset);
+  __ load_heap_oop(R0, field_address, Rtemp, R1_tmp, R2_tmp, ON_WEAK_OOP_REF);
 
-    // _areturn
-    __ mov(SP, Rsender_sp);
-    __ ret(Rret_addr);
+  // _areturn
+  __ mov(SP, Rsender_sp);
+  __ ret(Rret_addr);
 
-    // generate a vanilla interpreter entry as the slow path
-    __ bind(slow_path);
-    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals));
-    return entry;
-  }
-#endif // INCLUDE_ALL_GCS
-
-  // If G1 is not enabled then attempt to go through the normal entry point
-  return NULL;
+  // generate a vanilla interpreter entry as the slow path
+  __ bind(slow_path);
+  __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals));
+  return entry;
 }
 
 // Not supported
--- a/src/hotspot/cpu/arm/templateTable_arm.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/arm/templateTable_arm.cpp	Fri May 04 08:50:01 2018 -0700
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "asm/macroAssembler.hpp"
+#include "gc/shared/barrierSetAssembler.hpp"
 #include "interpreter/interp_masm.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
@@ -187,72 +188,24 @@
                          Register tmp1,
                          Register tmp2,
                          Register tmp3,
-                         BarrierSet::Name barrier,
-                         bool precise,
-                         bool is_null) {
+                         bool is_null,
+                         DecoratorSet decorators = 0) {
 
   assert_different_registers(obj.base(), new_val, tmp1, tmp2, tmp3, noreg);
-  switch (barrier) {
-#if INCLUDE_ALL_GCS
-    case BarrierSet::G1BarrierSet:
-      {
-        // flatten object address if needed
-        assert (obj.mode() == basic_offset, "pre- or post-indexing is not supported here");
-
-        const Register store_addr = obj.base();
-        if (obj.index() != noreg) {
-          assert (obj.disp() == 0, "index or displacement, not both");
-#ifdef AARCH64
-          __ add(store_addr, obj.base(), obj.index(), obj.extend(), obj.shift_imm());
-#else
-          assert(obj.offset_op() == add_offset, "addition is expected");
-          __ add(store_addr, obj.base(), AsmOperand(obj.index(), obj.shift(), obj.shift_imm()));
-#endif // AARCH64
-        } else if (obj.disp() != 0) {
-          __ add(store_addr, obj.base(), obj.disp());
-        }
-
-        __ g1_write_barrier_pre(store_addr, new_val, tmp1, tmp2, tmp3);
-        if (is_null) {
-          __ store_heap_oop_null(new_val, Address(store_addr));
-        } else {
-          // G1 barrier needs uncompressed oop for region cross check.
-          Register val_to_store = new_val;
-          if (UseCompressedOops) {
-            val_to_store = tmp1;
-            __ mov(val_to_store, new_val);
-          }
-          __ store_heap_oop(val_to_store, Address(store_addr)); // blows val_to_store:
-          val_to_store = noreg;
-          __ g1_write_barrier_post(store_addr, new_val, tmp1, tmp2, tmp3);
-        }
-      }
-      break;
-#endif // INCLUDE_ALL_GCS
-    case BarrierSet::CardTableBarrierSet:
-      {
-        if (is_null) {
-          __ store_heap_oop_null(new_val, obj);
-        } else {
-          assert (!precise || (obj.index() == noreg && obj.disp() == 0),
-                  "store check address should be calculated beforehand");
-
-          __ store_check_part1(tmp1);
-          __ store_heap_oop(new_val, obj); // blows new_val:
-          new_val = noreg;
-          __ store_check_part2(obj.base(), tmp1, tmp2);
-        }
-      }
-      break;
-    case BarrierSet::ModRef:
-      ShouldNotReachHere();
-      break;
-    default:
-      ShouldNotReachHere();
-      break;
+  if (is_null) {
+    __ store_heap_oop_null(obj, new_val, tmp1, tmp2, tmp3, decorators);
+  } else {
+    __ store_heap_oop(obj, new_val, tmp1, tmp2, tmp3, decorators);
   }
 }
 
+static void do_oop_load(InterpreterMacroAssembler* _masm,
+                        Register dst,
+                        Address obj,
+                        DecoratorSet decorators = 0) {
+  __ load_heap_oop(dst, obj, noreg, noreg, noreg, decorators);
+}
+
 Address TemplateTable::at_bcp(int offset) {
   assert(_desc->uses_bcp(), "inconsistent uses_bcp information");
   return Address(Rbcp, offset);
@@ -863,7 +816,7 @@
   const Register Rindex = R0_tos;
 
   index_check(Rarray, Rindex);
-  __ load_heap_oop(R0_tos, get_array_elem_addr(T_OBJECT, Rarray, Rindex, Rtemp));
+  do_oop_load(_masm, R0_tos, get_array_elem_addr(T_OBJECT, Rarray, Rindex, Rtemp), IN_HEAP_ARRAY);
 }
 
 
@@ -1248,7 +1201,7 @@
   __ add(Raddr_1, Raddr_1, AsmOperand(Rindex_4, lsl, LogBytesPerHeapOop));
 
   // Now store using the appropriate barrier
-  do_oop_store(_masm, Raddr_1, Rvalue_2, Rtemp, R0_tmp, R3_tmp, _bs->kind(), true, false);
+  do_oop_store(_masm, Raddr_1, Rvalue_2, Rtemp, R0_tmp, R3_tmp, false, IN_HEAP_ARRAY);
   __ b(done);
 
   __ bind(throw_array_store);
@@ -1264,7 +1217,7 @@
   __ profile_null_seen(R0_tmp);
 
   // Store a NULL
-  do_oop_store(_masm, Address::indexed_oop(Raddr_1, Rindex_4), Rvalue_2, Rtemp, R0_tmp, R3_tmp, _bs->kind(), true, true);
+  do_oop_store(_masm, Address::indexed_oop(Raddr_1, Rindex_4), Rvalue_2, Rtemp, R0_tmp, R3_tmp, true, IN_HEAP_ARRAY);
 
   // Pop stack arguments
   __ bind(done);
@@ -3286,7 +3239,7 @@
     // atos case for AArch64 and slow version on 32-bit ARM
     if(!atos_merged_with_itos) {
       __ bind(Latos);
-      __ load_heap_oop(R0_tos, Address(Robj, Roffset));
+      do_oop_load(_masm, R0_tos, Address(Robj, Roffset));
       __ push(atos);
       // Rewrite bytecode to be faster
       if (!is_static && rc == may_rewrite) {
@@ -3638,7 +3591,7 @@
     __ pop(atos);
     if (!is_static) pop_and_check_object(Robj);
     // Store into the field
-    do_oop_store(_masm, Address(Robj, Roffset), R0_tos, Rtemp, R1_tmp, R5_tmp, _bs->kind(), false, false);
+    do_oop_store(_masm, Address(Robj, Roffset), R0_tos, Rtemp, R1_tmp, R5_tmp, false);
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_aputfield, R0_tmp, Rtemp, true, byte_no);
     }
@@ -3816,7 +3769,7 @@
 #endif // AARCH64
 
     case Bytecodes::_fast_aputfield:
-      do_oop_store(_masm, Address(Robj, Roffset), R0_tos, Rtemp, R1_tmp, R2_tmp, _bs->kind(), false, false);
+      do_oop_store(_masm, Address(Robj, Roffset), R0_tos, Rtemp, R1_tmp, R2_tmp, false);
       break;
 
     default:
@@ -3912,7 +3865,7 @@
     case Bytecodes::_fast_dgetfield: __ add(Roffset, Robj, Roffset); __ fldd(D0_tos, Address(Roffset)); break;
 #endif // __SOFTFP__
 #endif // AARCH64
-    case Bytecodes::_fast_agetfield: __ load_heap_oop(R0_tos, Address(Robj, Roffset)); __ verify_oop(R0_tos); break;
+    case Bytecodes::_fast_agetfield: do_oop_load(_masm, R0_tos, Address(Robj, Roffset)); __ verify_oop(R0_tos); break;
     default:
       ShouldNotReachHere();
   }
@@ -3992,7 +3945,7 @@
   if (state == itos) {
     __ ldr_s32(R0_tos, Address(Robj, Roffset));
   } else if (state == atos) {
-    __ load_heap_oop(R0_tos, Address(Robj, Roffset));
+    do_oop_load(_masm, R0_tos, Address(Robj, Roffset));
     __ verify_oop(R0_tos);
   } else if (state == ftos) {
 #ifdef AARCH64
--- a/src/hotspot/cpu/ppc/assembler_ppc.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/ppc/assembler_ppc.cpp	Fri May 04 08:50:01 2018 -0700
@@ -37,10 +37,6 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/heapRegion.hpp"
-#endif // INCLUDE_ALL_GCS
 
 #ifdef PRODUCT
 #define BLOCK_COMMENT(str) // nothing
--- a/src/hotspot/cpu/s390/assembler_s390.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/s390/assembler_s390.cpp	Fri May 04 08:50:01 2018 -0700
@@ -38,10 +38,6 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/heapRegion.hpp"
-#endif
 
 // Convention: Use Z_R0 and Z_R1 instead of Z_scratch_* in all
 // assembler_s390.* files.
--- a/src/hotspot/cpu/x86/assembler_x86.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/x86/assembler_x86.cpp	Fri May 04 08:50:01 2018 -0700
@@ -36,10 +36,6 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/heapRegion.hpp"
-#endif // INCLUDE_ALL_GCS
 
 #ifdef PRODUCT
 #define BLOCK_COMMENT(str) /* nothing */
--- a/src/hotspot/cpu/zero/assembler_zero.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/zero/assembler_zero.cpp	Fri May 04 08:50:01 2018 -0700
@@ -37,10 +37,6 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/heapRegion.hpp"
-#endif // INCLUDE_ALL_GCS
 
 int AbstractAssembler::code_fill_byte() {
   return 0;
--- a/src/hotspot/cpu/zero/cppInterpreterGenerator_zero.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/cpu/zero/cppInterpreterGenerator_zero.cpp	Fri May 04 08:50:01 2018 -0700
@@ -65,7 +65,7 @@
 }
 
 address CppInterpreterGenerator::generate_Reference_get_entry(void) {
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   if (UseG1GC) {
     // We need to generate have a routine that generates code to:
     //   * load the value in the referent field
@@ -77,7 +77,7 @@
     // field as live.
     Unimplemented();
   }
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
   // If G1 is not enabled then attempt to go through the normal entry point
   // Reference.get could be instrumented by jvmti
--- a/src/hotspot/os/linux/os_linux.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/os/linux/os_linux.cpp	Fri May 04 08:50:01 2018 -0700
@@ -3111,6 +3111,68 @@
   return nbot;
 }
 
+bool os::committed_in_range(address start, size_t size, address& committed_start, size_t& committed_size) {
+  int mincore_return_value;
+  const size_t stripe = 1024;  // query this many pages each time
+  unsigned char vec[stripe];
+  const size_t page_sz = os::vm_page_size();
+  size_t pages = size / page_sz;
+
+  assert(is_aligned(start, page_sz), "Start address must be page aligned");
+  assert(is_aligned(size, page_sz), "Size must be page aligned");
+
+  committed_start = NULL;
+
+  int loops = (pages + stripe - 1) / stripe;
+  int committed_pages = 0;
+  address loop_base = start;
+  for (int index = 0; index < loops; index ++) {
+    assert(pages > 0, "Nothing to do");
+    int pages_to_query = (pages >= stripe) ? stripe : pages;
+    pages -= pages_to_query;
+
+    // Get stable read
+    while ((mincore_return_value = mincore(loop_base, pages_to_query * page_sz, vec)) == -1 && errno == EAGAIN);
+
+    // During shutdown, some memory goes away without properly notifying NMT,
+    // E.g. ConcurrentGCThread/WatcherThread can exit without deleting thread object.
+    // Bailout and return as not committed for now.
+    if (mincore_return_value == -1 && errno == ENOMEM) {
+      return false;
+    }
+
+    assert(mincore_return_value == 0, "Range must be valid");
+    // Process this stripe
+    for (int vecIdx = 0; vecIdx < pages_to_query; vecIdx ++) {
+      if ((vec[vecIdx] & 0x01) == 0) { // not committed
+        // End of current contiguous region
+        if (committed_start != NULL) {
+          break;
+        }
+      } else { // committed
+        // Start of region
+        if (committed_start == NULL) {
+          committed_start = loop_base + page_sz * vecIdx;
+        }
+        committed_pages ++;
+      }
+    }
+
+    loop_base += pages_to_query * page_sz;
+  }
+
+  if (committed_start != NULL) {
+    assert(committed_pages > 0, "Must have committed region");
+    assert(committed_pages <= int(size / page_sz), "Can not commit more than it has");
+    assert(committed_start >= start && committed_start < start + size, "Out of range");
+    committed_size = page_sz * committed_pages;
+    return true;
+  } else {
+    assert(committed_pages == 0, "Should not have committed region");
+    return false;
+  }
+}
+
 
 // Linux uses a growable mapping for the stack, and if the mapping for
 // the stack guard pages is not removed when we detach a thread the
--- a/src/hotspot/os/linux/os_linux.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/os/linux/os_linux.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -98,26 +98,8 @@
 
 inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
 {
-// readdir_r has been deprecated since glibc 2.24.
-// See https://sourceware.org/bugzilla/show_bug.cgi?id=19056 for more details.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
-  dirent* p;
-  int status;
   assert(dirp != NULL, "just checking");
-
-  // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
-  // version. Here is the doc for this function:
-  // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
-
-  if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
-    errno = status;
-    return NULL;
-  } else
-    return p;
-
-#pragma GCC diagnostic pop
+  return ::readdir(dirp);
 }
 
 inline int os::closedir(DIR *dirp) {
--- a/src/hotspot/os/windows/attachListener_windows.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/os/windows/attachListener_windows.cpp	Fri May 04 08:50:01 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "logging/log.hpp"
 #include "runtime/interfaceSupport.inline.hpp"
 #include "runtime/os.hpp"
 #include "services/attachListener.hpp"
--- a/src/hotspot/os/windows/os_windows.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/os/windows/os_windows.cpp	Fri May 04 08:50:01 2018 -0700
@@ -365,6 +365,39 @@
   return sz;
 }
 
+bool os::committed_in_range(address start, size_t size, address& committed_start, size_t& committed_size) {
+  MEMORY_BASIC_INFORMATION minfo;
+  committed_start = NULL;
+  committed_size = 0;
+  address top = start + size;
+  const address start_addr = start;
+  while (start < top) {
+    VirtualQuery(start, &minfo, sizeof(minfo));
+    if ((minfo.State & MEM_COMMIT) == 0) {  // not committed
+      if (committed_start != NULL) {
+        break;
+      }
+    } else {  // committed
+      if (committed_start == NULL) {
+        committed_start = start;
+      }
+      size_t offset = start - (address)minfo.BaseAddress;
+      committed_size += minfo.RegionSize - offset;
+    }
+    start = (address)minfo.BaseAddress + minfo.RegionSize;
+  }
+
+  if (committed_start == NULL) {
+    assert(committed_size == 0, "Sanity");
+    return false;
+  } else {
+    assert(committed_start >= start_addr && committed_start < top, "Out of range");
+    // current region may go beyond the limit, trim to the limit
+    committed_size = MIN2(committed_size, size_t(top - committed_start));
+    return true;
+  }
+}
+
 struct tm* os::localtime_pd(const time_t* clock, struct tm* res) {
   const struct tm* time_struct_ptr = localtime(clock);
   if (time_struct_ptr != NULL) {
--- a/src/hotspot/share/aot/aotCodeHeap.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/aot/aotCodeHeap.cpp	Fri May 04 08:50:01 2018 -0700
@@ -421,9 +421,11 @@
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_new_multi_array", address, JVMCIRuntime::new_multi_array);
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_dynamic_new_array", address, JVMCIRuntime::dynamic_new_array);
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_validate_object", address, JVMCIRuntime::validate_object);
+#if INCLUDE_G1GC
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_write_barrier_pre", address, JVMCIRuntime::write_barrier_pre);
+    SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_write_barrier_post", address, JVMCIRuntime::write_barrier_post);
+#endif
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_identity_hash_code", address, JVMCIRuntime::identity_hash_code);
-    SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_write_barrier_post", address, JVMCIRuntime::write_barrier_post);
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_dynamic_new_instance", address, JVMCIRuntime::dynamic_new_instance);
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_thread_is_interrupted", address, JVMCIRuntime::thread_is_interrupted);
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_exception_handler_for_pc", address, JVMCIRuntime::exception_handler_for_pc);
@@ -552,7 +554,9 @@
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_polling_page", address, os::get_polling_page());
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_narrow_klass_base_address", address, Universe::narrow_klass_base());
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_narrow_oop_base_address", address, Universe::narrow_oop_base());
+#if INCLUDE_G1GC
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_log_of_heap_region_grain_bytes", int, HeapRegion::LogOfHRGrainBytes);
+#endif
     SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_inline_contiguous_allocation_supported", bool, heap->supports_inline_contig_alloc());
     link_shared_runtime_symbols();
     link_stub_routines_symbols();
--- a/src/hotspot/share/classfile/classFileParser.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Fri May 04 08:50:01 2018 -0700
@@ -3592,8 +3592,13 @@
   this_klass->set_methods(_methods);
   this_klass->set_inner_classes(_inner_classes);
   this_klass->set_local_interfaces(_local_interfaces);
-  this_klass->set_transitive_interfaces(_transitive_interfaces);
   this_klass->set_annotations(_combined_annotations);
+  // Delay the setting of _transitive_interfaces until after initialize_supers() in
+  // fill_instance_klass(). It is because the _transitive_interfaces may be shared with
+  // its _super. If an OOM occurs while loading the current klass, its _super field
+  // may not have been set. When GC tries to free the klass, the _transitive_interfaces
+  // may be deallocated mistakenly in InstanceKlass::deallocate_interfaces(). Subsequent
+  // dereferences to the deallocated _transitive_interfaces will result in a crash.
 
   // Clear out these fields so they don't get deallocated by the destructor
   clear_class_metadata();
@@ -5462,7 +5467,6 @@
   assert(NULL == _methods, "invariant");
   assert(NULL == _inner_classes, "invariant");
   assert(NULL == _local_interfaces, "invariant");
-  assert(NULL == _transitive_interfaces, "invariant");
   assert(NULL == _combined_annotations, "invariant");
 
   if (_has_final_method) {
@@ -5529,7 +5533,9 @@
   }
 
   // Fill in information needed to compute superclasses.
-  ik->initialize_supers(const_cast<InstanceKlass*>(_super_klass), CHECK);
+  ik->initialize_supers(const_cast<InstanceKlass*>(_super_klass), _transitive_interfaces, CHECK);
+  ik->set_transitive_interfaces(_transitive_interfaces);
+  _transitive_interfaces = NULL;
 
   // Initialize itable offset tables
   klassItable::setup_itable_offset_table(ik);
@@ -5834,7 +5840,6 @@
   _methods = NULL;
   _inner_classes = NULL;
   _local_interfaces = NULL;
-  _transitive_interfaces = NULL;
   _combined_annotations = NULL;
   _annotations = _type_annotations = NULL;
   _fields_annotations = _fields_type_annotations = NULL;
@@ -5886,6 +5891,7 @@
   }
 
   clear_class_metadata();
+  _transitive_interfaces = NULL;
 
   // deallocate the klass if already created.  Don't directly deallocate, but add
   // to the deallocate list so that the klass is removed from the CLD::_klasses list
--- a/src/hotspot/share/classfile/classLoader.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/classfile/classLoader.cpp	Fri May 04 08:50:01 2018 -0700
@@ -37,8 +37,6 @@
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "compiler/compileBroker.hpp"
-#include "gc/shared/collectedHeap.inline.hpp"
-#include "gc/shared/generation.hpp"
 #include "interpreter/bytecodeStream.hpp"
 #include "interpreter/oopMapCache.hpp"
 #include "logging/log.hpp"
--- a/src/hotspot/share/classfile/stringTable.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/classfile/stringTable.cpp	Fri May 04 08:50:01 2018 -0700
@@ -44,7 +44,7 @@
 #include "services/diagnosticCommand.hpp"
 #include "utilities/hashtable.inline.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1StringDedup.hpp"
 #endif
 
@@ -260,7 +260,7 @@
     string = java_lang_String::create_from_unicode(name, len, CHECK_NULL);
   }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   if (G1StringDedup::is_enabled()) {
     // Deduplicate the string before it is interned. Note that we should never
     // deduplicate a string after it has been interned. Doing so will counteract
--- a/src/hotspot/share/classfile/symbolTable.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/classfile/symbolTable.cpp	Fri May 04 08:50:01 2018 -0700
@@ -29,7 +29,6 @@
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
-#include "gc/shared/gcLocker.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/filemap.hpp"
 #include "memory/metaspaceClosure.hpp"
--- a/src/hotspot/share/code/compiledMethod.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/code/compiledMethod.cpp	Fri May 04 08:50:01 2018 -0700
@@ -389,22 +389,24 @@
 
 void CompiledMethod::clean_ic_if_metadata_is_dead(CompiledIC *ic) {
   if (ic->is_icholder_call()) {
-    // The only exception is compiledICHolder oops which may
+    // The only exception is compiledICHolder metdata which may
     // yet be marked below. (We check this further below).
-    CompiledICHolder* cichk_oop = ic->cached_icholder();
+    CompiledICHolder* cichk_metdata = ic->cached_icholder();
 
-    if (cichk_oop->is_loader_alive()) {
+    if (cichk_metdata->is_loader_alive()) {
       return;
     }
   } else {
-    Metadata* ic_oop = ic->cached_metadata();
-    if (ic_oop != NULL) {
-      if (ic_oop->is_klass()) {
-        if (((Klass*)ic_oop)->is_loader_alive()) {
+    Metadata* ic_metdata = ic->cached_metadata();
+    if (ic_metdata != NULL) {
+      if (ic_metdata->is_klass()) {
+        if (((Klass*)ic_metdata)->is_loader_alive()) {
           return;
         }
-      } else if (ic_oop->is_method()) {
-        if (((Method*)ic_oop)->method_holder()->is_loader_alive()) {
+      } else if (ic_metdata->is_method()) {
+        Method* method = (Method*)ic_metdata;
+        assert(!method->is_old(), "old method should have been cleaned");
+        if (method->method_holder()->is_loader_alive()) {
           return;
         }
       } else {
@@ -493,16 +495,6 @@
     // (See comment above.)
   }
 
-  // The RedefineClasses() API can cause the class unloading invariant
-  // to no longer be true. See jvmtiExport.hpp for details.
-  // Also, leave a debugging breadcrumb in local flag.
-  if (JvmtiExport::has_redefined_a_class()) {
-    // This set of the unloading_occurred flag is done before the
-    // call to post_compiled_method_unload() so that the unloading
-    // of this nmethod is reported.
-    unloading_occurred = true;
-  }
-
   // Exception cache
   clean_exception_cache();
 
@@ -581,16 +573,6 @@
     // (See comment above.)
   }
 
-  // The RedefineClasses() API can cause the class unloading invariant
-  // to no longer be true. See jvmtiExport.hpp for details.
-  // Also, leave a debugging breadcrumb in local flag.
-  if (JvmtiExport::has_redefined_a_class()) {
-    // This set of the unloading_occurred flag is done before the
-    // call to post_compiled_method_unload() so that the unloading
-    // of this nmethod is reported.
-    unloading_occurred = true;
-  }
-
   // Exception cache
   clean_exception_cache();
 
--- a/src/hotspot/share/compiler/abstractCompiler.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/compiler/abstractCompiler.cpp	Fri May 04 08:50:01 2018 -0700
@@ -21,7 +21,6 @@
 // questions.
 //
 
-
 #include "precompiled.hpp"
 #include "compiler/abstractCompiler.hpp"
 #include "compiler/compileBroker.hpp"
--- a/src/hotspot/share/compiler/oopMap.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/compiler/oopMap.cpp	Fri May 04 08:50:01 2018 -0700
@@ -266,9 +266,9 @@
 }
 
 static void add_derived_oop(oop* base, oop* derived) {
-#if !defined(TIERED) && !defined(INCLUDE_JVMCI)
+#if !defined(TIERED) && !INCLUDE_JVMCI
   COMPILER1_PRESENT(ShouldNotReachHere();)
-#endif // !defined(TIERED) && !defined(INCLUDE_JVMCI)
+#endif // !defined(TIERED) && !INCLUDE_JVMCI
 #if COMPILER2_OR_JVMCI
   DerivedPointerTable::add(derived, base);
 #endif // COMPILER2_OR_JVMCI
@@ -459,7 +459,7 @@
 #ifndef PRODUCT
 
 bool ImmutableOopMap::has_derived_pointer() const {
-#if !defined(TIERED) && !defined(INCLUDE_JVMCI)
+#if !defined(TIERED) && !INCLUDE_JVMCI
   COMPILER1_PRESENT(return false);
 #endif // !TIERED
 #if COMPILER2_OR_JVMCI
--- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Fri May 04 08:50:01 2018 -0700
@@ -290,13 +290,13 @@
   if (_ref_processor == NULL) {
     // Allocate and initialize a reference processor
     _ref_processor =
-      new ReferenceProcessor(_span,                               // span
+      new ReferenceProcessor(&_span_based_discoverer,
                              (ParallelGCThreads > 1) && ParallelRefProcEnabled, // mt processing
-                             ParallelGCThreads,                   // mt processing degree
-                             _cmsGen->refs_discovery_is_mt(),     // mt discovery
+                             ParallelGCThreads,                      // mt processing degree
+                             _cmsGen->refs_discovery_is_mt(),        // mt discovery
                              MAX2(ConcGCThreads, ParallelGCThreads), // mt discovery degree
-                             _cmsGen->refs_discovery_is_atomic(), // discovery is not atomic
-                             &_is_alive_closure);                 // closure for liveness info
+                             _cmsGen->refs_discovery_is_atomic(),    // discovery is not atomic
+                             &_is_alive_closure);                    // closure for liveness info
     // Initialize the _ref_processor field of CMSGen
     _cmsGen->set_ref_processor(_ref_processor);
 
@@ -445,7 +445,10 @@
                            CardTableRS*                   ct,
                            ConcurrentMarkSweepPolicy*     cp):
   _cmsGen(cmsGen),
+  // Adjust span to cover old (cms) gen
+  _span(cmsGen->reserved()),
   _ct(ct),
+  _span_based_discoverer(_span),
   _ref_processor(NULL),    // will be set later
   _conc_workers(NULL),     // may be set later
   _abort_preclean(false),
@@ -455,8 +458,6 @@
   _modUnionTable((CardTable::card_shift - LogHeapWordSize),
                  -1 /* lock-free */, "No_lock" /* dummy */),
   _modUnionClosurePar(&_modUnionTable),
-  // Adjust my span to cover old (cms) gen
-  _span(cmsGen->reserved()),
   // Construct the is_alive_closure with _span & markBitMap
   _is_alive_closure(_span, &_markBitMap),
   _restart_addr(NULL),
@@ -3744,7 +3745,6 @@
   }
 }
 
-
 size_t CMSCollector::preclean_work(bool clean_refs, bool clean_survivor) {
   assert(_collectorState == Precleaning ||
          _collectorState == AbortablePreclean, "incorrect state");
@@ -3761,7 +3761,7 @@
   // referents.
   if (clean_refs) {
     CMSPrecleanRefsYieldClosure yield_cl(this);
-    assert(rp->span().equals(_span), "Spans should be equal");
+    assert(_span_based_discoverer.span().equals(_span), "Spans should be equal");
     CMSKeepAliveClosure keep_alive(this, _span, &_markBitMap,
                                    &_markStack, true /* preclean */);
     CMSDrainMarkingStackClosure complete_trace(this,
@@ -5153,7 +5153,7 @@
   WorkGang* workers = heap->workers();
   assert(workers != NULL, "Need parallel worker threads.");
   CMSRefProcTaskProxy rp_task(task, &_collector,
-                              _collector.ref_processor()->span(),
+                              _collector.ref_processor_span(),
                               _collector.markBitMap(),
                               workers, _collector.task_queues());
   workers->run_task(&rp_task);
@@ -5174,13 +5174,13 @@
   HandleMark   hm;
 
   ReferenceProcessor* rp = ref_processor();
-  assert(rp->span().equals(_span), "Spans should be equal");
+  assert(_span_based_discoverer.span().equals(_span), "Spans should be equal");
   assert(!rp->enqueuing_is_done(), "Enqueuing should not be complete");
   // Process weak references.
   rp->setup_policy(false);
   verify_work_stacks_empty();
 
-  ReferenceProcessorPhaseTimes pt(_gc_timer_cm, rp->num_q());
+  ReferenceProcessorPhaseTimes pt(_gc_timer_cm, rp->num_queues());
   {
     GCTraceTime(Debug, gc, phases) t("Reference Processing", _gc_timer_cm);
 
@@ -5245,7 +5245,7 @@
       CodeCache::do_unloading(&_is_alive_closure, purged_class);
 
       // Prune dead klasses from subklass/sibling/implementor lists.
-      Klass::clean_weak_klass_links();
+      Klass::clean_weak_klass_links(purged_class);
     }
 
     {
--- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.hpp	Fri May 04 08:50:01 2018 -0700
@@ -69,7 +69,6 @@
 class ParNewGeneration;
 class PromotionInfo;
 class ScanMarkedObjectsAgainCarefullyClosure;
-class TenuredGeneration;
 class SerialOldTracer;
 
 // A generic CMS bit map. It's the basis for both the CMS marking bit map
@@ -617,7 +616,7 @@
 
  protected:
   ConcurrentMarkSweepGeneration* _cmsGen;  // Old gen (CMS)
-  MemRegion                      _span;    // Span covering above two
+  MemRegion                      _span;    // Span covering above
   CardTableRS*                   _ct;      // Card table
 
   // CMS marking support structures
@@ -641,8 +640,9 @@
   NOT_PRODUCT(ssize_t _num_par_pushes;)
 
   // ("Weak") Reference processing support.
-  ReferenceProcessor*            _ref_processor;
-  CMSIsAliveClosure              _is_alive_closure;
+  SpanSubjectToDiscoveryClosure _span_based_discoverer;
+  ReferenceProcessor*           _ref_processor;
+  CMSIsAliveClosure             _is_alive_closure;
   // Keep this textually after _markBitMap and _span; c'tor dependency.
 
   ConcurrentMarkSweepThread*     _cmsThread;   // The thread doing the work
@@ -841,6 +841,7 @@
                ConcurrentMarkSweepPolicy*     cp);
   ConcurrentMarkSweepThread* cmsThread() { return _cmsThread; }
 
+  MemRegion ref_processor_span() const { return _span_based_discoverer.span(); }
   ReferenceProcessor* ref_processor() { return _ref_processor; }
   void ref_processor_init();
 
--- a/src/hotspot/share/gc/cms/parNewGeneration.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/cms/parNewGeneration.cpp	Fri May 04 08:50:01 2018 -0700
@@ -983,7 +983,7 @@
   // Can  the mt_degree be set later (at run_task() time would be best)?
   rp->set_active_mt_degree(active_workers);
   ReferenceProcessorStats stats;
-  ReferenceProcessorPhaseTimes pt(_gc_timer, rp->num_q());
+  ReferenceProcessorPhaseTimes pt(_gc_timer, rp->num_queues());
   if (rp->processing_is_mt()) {
     ParNewRefProcTaskExecutor task_executor(*this, *_old_gen, thread_state_set);
     stats = rp->process_discovered_references(&is_alive, &keep_alive,
@@ -1471,8 +1471,9 @@
 void ParNewGeneration::ref_processor_init() {
   if (_ref_processor == NULL) {
     // Allocate and initialize a reference processor
+    _span_based_discoverer.set_span(_reserved);
     _ref_processor =
-      new ReferenceProcessor(_reserved,                  // span
+      new ReferenceProcessor(&_span_based_discoverer,    // span
                              ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
                              ParallelGCThreads,          // mt processing degree
                              refs_discovery_is_mt(),     // mt discovery
--- a/src/hotspot/share/gc/g1/g1Arguments.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1Arguments.cpp	Fri May 04 08:50:01 2018 -0700
@@ -81,11 +81,9 @@
     vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL);
   }
 
-#if INCLUDE_ALL_GCS
   if (FLAG_IS_DEFAULT(G1ConcRefinementThreads)) {
     FLAG_SET_ERGO(uint, G1ConcRefinementThreads, ParallelGCThreads);
   }
-#endif
 
   // MarkStackSize will be set (if it hasn't been set by the user)
   // when concurrent marking is initialized.
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Fri May 04 08:50:01 2018 -0700
@@ -988,9 +988,9 @@
 
   // Disable discovery and empty the discovered lists
   // for the CM ref processor.
-  ref_processor_cm()->disable_discovery();
-  ref_processor_cm()->abandon_partial_discovery();
-  ref_processor_cm()->verify_no_references_recorded();
+  _ref_processor_cm->disable_discovery();
+  _ref_processor_cm->abandon_partial_discovery();
+  _ref_processor_cm->verify_no_references_recorded();
 
   // Abandon current iterations of concurrent marking and concurrent
   // refinement, if any are in progress.
@@ -1080,10 +1080,10 @@
   // That will be done at the start of the next marking cycle.
   // We also know that the STW processor should no longer
   // discover any new references.
-  assert(!ref_processor_stw()->discovery_enabled(), "Postcondition");
-  assert(!ref_processor_cm()->discovery_enabled(), "Postcondition");
-  ref_processor_stw()->verify_no_references_recorded();
-  ref_processor_cm()->verify_no_references_recorded();
+  assert(!_ref_processor_stw->discovery_enabled(), "Postcondition");
+  assert(!_ref_processor_cm->discovery_enabled(), "Postcondition");
+  _ref_processor_stw->verify_no_references_recorded();
+  _ref_processor_cm->verify_no_references_recorded();
 }
 
 void G1CollectedHeap::print_heap_after_full_collection(G1HeapTransition* heap_transition) {
@@ -1410,10 +1410,12 @@
   _g1_policy(new G1Policy(_gc_timer_stw)),
   _collection_set(this, _g1_policy),
   _dirty_card_queue_set(false),
-  _is_alive_closure_cm(this),
+  _ref_processor_stw(NULL),
   _is_alive_closure_stw(this),
+  _is_subject_to_discovery_stw(this),
   _ref_processor_cm(NULL),
-  _ref_processor_stw(NULL),
+  _is_alive_closure_cm(this),
+  _is_subject_to_discovery_cm(this),
   _bot(NULL),
   _hot_card_cache(NULL),
   _g1_rem_set(NULL),
@@ -1786,43 +1788,27 @@
   //     * Discovery is atomic - i.e. not concurrent.
   //     * Reference discovery will not need a barrier.
 
-  MemRegion mr = reserved_region();
-
   bool mt_processing = ParallelRefProcEnabled && (ParallelGCThreads > 1);
 
   // Concurrent Mark ref processor
   _ref_processor_cm =
-    new ReferenceProcessor(mr,    // span
-                           mt_processing,
-                                // mt processing
-                           ParallelGCThreads,
-                                // degree of mt processing
-                           (ParallelGCThreads > 1) || (ConcGCThreads > 1),
-                                // mt discovery
-                           MAX2(ParallelGCThreads, ConcGCThreads),
-                                // degree of mt discovery
-                           false,
-                                // Reference discovery is not atomic
-                           &_is_alive_closure_cm);
-                                // is alive closure
-                                // (for efficiency/performance)
+    new ReferenceProcessor(&_is_subject_to_discovery_cm,
+                           mt_processing,                                  // mt processing
+                           ParallelGCThreads,                              // degree of mt processing
+                           (ParallelGCThreads > 1) || (ConcGCThreads > 1), // mt discovery
+                           MAX2(ParallelGCThreads, ConcGCThreads),         // degree of mt discovery
+                           false,                                          // Reference discovery is not atomic
+                           &_is_alive_closure_cm);                         // is alive closure
 
   // STW ref processor
   _ref_processor_stw =
-    new ReferenceProcessor(mr,    // span
-                           mt_processing,
-                                // mt processing
-                           ParallelGCThreads,
-                                // degree of mt processing
-                           (ParallelGCThreads > 1),
-                                // mt discovery
-                           ParallelGCThreads,
-                                // degree of mt discovery
-                           true,
-                                // Reference discovery is atomic
-                           &_is_alive_closure_stw);
-                                // is alive closure
-                                // (for efficiency/performance)
+    new ReferenceProcessor(&_is_subject_to_discovery_stw,
+                           mt_processing,                        // mt processing
+                           ParallelGCThreads,                    // degree of mt processing
+                           (ParallelGCThreads > 1),              // mt discovery
+                           ParallelGCThreads,                    // degree of mt discovery
+                           true,                                 // Reference discovery is atomic
+                           &_is_alive_closure_stw);              // is alive closure
 }
 
 CollectorPolicy* G1CollectedHeap::collector_policy() const {
@@ -2853,14 +2839,14 @@
       // reference processing currently works in G1.
 
       // Enable discovery in the STW reference processor
-      ref_processor_stw()->enable_discovery();
+      _ref_processor_stw->enable_discovery();
 
       {
         // We want to temporarily turn off discovery by the
         // CM ref processor, if necessary, and turn it back on
         // on again later if we do. Using a scoped
         // NoRefDiscovery object will do this.
-        NoRefDiscovery no_cm_discovery(ref_processor_cm());
+        NoRefDiscovery no_cm_discovery(_ref_processor_cm);
 
         // Forget the current alloc region (we might even choose it to be part
         // of the collection set!).
@@ -2998,8 +2984,8 @@
         _verifier->verify_after_gc(verify_type);
         _verifier->check_bitmaps("GC End");
 
-        assert(!ref_processor_stw()->discovery_enabled(), "Postcondition");
-        ref_processor_stw()->verify_no_references_recorded();
+        assert(!_ref_processor_stw->discovery_enabled(), "Postcondition");
+        _ref_processor_stw->verify_no_references_recorded();
 
         // CM reference discovery will be re-enabled if necessary.
       }
@@ -3543,6 +3529,7 @@
 // To minimize the remark pause times, the tasks below are done in parallel.
 class G1ParallelCleaningTask : public AbstractGangTask {
 private:
+  bool                          _unloading_occurred;
   G1StringAndSymbolCleaningTask _string_symbol_task;
   G1CodeCacheUnloadingTask      _code_cache_task;
   G1KlassCleaningTask           _klass_cleaning_task;
@@ -3555,6 +3542,7 @@
       _string_symbol_task(is_alive, true, true, G1StringDedup::is_enabled()),
       _code_cache_task(num_workers, is_alive, unloading_occurred),
       _klass_cleaning_task(),
+      _unloading_occurred(unloading_occurred),
       _resolved_method_cleaning_task() {
   }
 
@@ -3580,7 +3568,11 @@
     _code_cache_task.work_second_pass(worker_id);
 
     // Clean all klasses that were not unloaded.
-    _klass_cleaning_task.work();
+    // The weak metadata in klass doesn't need to be
+    // processed if there was no unloading.
+    if (_unloading_occurred) {
+      _klass_cleaning_task.work();
+    }
   }
 };
 
@@ -3642,26 +3634,21 @@
 
 // Weak Reference Processing support
 
-// An always "is_alive" closure that is used to preserve referents.
-// If the object is non-null then it's alive.  Used in the preservation
-// of referent objects that are pointed to by reference objects
-// discovered by the CM ref processor.
-class G1AlwaysAliveClosure: public BoolObjectClosure {
-public:
-  bool do_object_b(oop p) {
-    if (p != NULL) {
-      return true;
-    }
-    return false;
-  }
-};
-
 bool G1STWIsAliveClosure::do_object_b(oop p) {
   // An object is reachable if it is outside the collection set,
   // or is inside and copied.
   return !_g1h->is_in_cset(p) || p->is_forwarded();
 }
 
+bool G1STWSubjectToDiscoveryClosure::do_object_b(oop obj) {
+  assert(obj != NULL, "must not be NULL");
+  assert(_g1h->is_in_reserved(obj), "Trying to discover obj " PTR_FORMAT " not in heap", p2i(obj));
+  // The areas the CM and STW ref processor manage must be disjoint. The is_in_cset() below
+  // may falsely indicate that this is not the case here: however the collection set only
+  // contains old regions when concurrent mark is not running.
+  return _g1h->is_in_cset(obj) || _g1h->heap_region_containing(obj)->is_survivor();
+}
+
 // Non Copying Keep Alive closure
 class G1KeepAliveClosure: public OopClosure {
   G1CollectedHeap*_g1h;
@@ -3892,126 +3879,6 @@
 
 // End of weak reference support closures
 
-// Abstract task used to preserve (i.e. copy) any referent objects
-// that are in the collection set and are pointed to by reference
-// objects discovered by the CM ref processor.
-
-class G1ParPreserveCMReferentsTask: public AbstractGangTask {
-protected:
-  G1CollectedHeap*         _g1h;
-  G1ParScanThreadStateSet* _pss;
-  RefToScanQueueSet*       _queues;
-  ParallelTaskTerminator   _terminator;
-  uint                     _n_workers;
-
-public:
-  G1ParPreserveCMReferentsTask(G1CollectedHeap* g1h, G1ParScanThreadStateSet* per_thread_states, int workers, RefToScanQueueSet *task_queues) :
-    AbstractGangTask("ParPreserveCMReferents"),
-    _g1h(g1h),
-    _pss(per_thread_states),
-    _queues(task_queues),
-    _terminator(workers, _queues),
-    _n_workers(workers)
-  {
-    g1h->ref_processor_cm()->set_active_mt_degree(workers);
-  }
-
-  void work(uint worker_id) {
-    G1GCParPhaseTimesTracker x(_g1h->g1_policy()->phase_times(), G1GCPhaseTimes::PreserveCMReferents, worker_id);
-
-    ResourceMark rm;
-    HandleMark   hm;
-
-    G1ParScanThreadState*          pss = _pss->state_for_worker(worker_id);
-    pss->set_ref_discoverer(NULL);
-    assert(pss->queue_is_empty(), "both queue and overflow should be empty");
-
-    // Is alive closure
-    G1AlwaysAliveClosure always_alive;
-
-    // Copying keep alive closure. Applied to referent objects that need
-    // to be copied.
-    G1CopyingKeepAliveClosure keep_alive(_g1h, pss->closures()->raw_strong_oops(), pss);
-
-    ReferenceProcessor* rp = _g1h->ref_processor_cm();
-
-    uint limit = ReferenceProcessor::number_of_subclasses_of_ref() * rp->max_num_q();
-    uint stride = MIN2(MAX2(_n_workers, 1U), limit);
-
-    // limit is set using max_num_q() - which was set using ParallelGCThreads.
-    // So this must be true - but assert just in case someone decides to
-    // change the worker ids.
-    assert(worker_id < limit, "sanity");
-    assert(!rp->discovery_is_atomic(), "check this code");
-
-    // Select discovered lists [i, i+stride, i+2*stride,...,limit)
-    for (uint idx = worker_id; idx < limit; idx += stride) {
-      DiscoveredList& ref_list = rp->discovered_refs()[idx];
-
-      DiscoveredListIterator iter(ref_list, &keep_alive, &always_alive);
-      while (iter.has_next()) {
-        // Since discovery is not atomic for the CM ref processor, we
-        // can see some null referent objects.
-        iter.load_ptrs(DEBUG_ONLY(true));
-        oop ref = iter.obj();
-
-        // This will filter nulls.
-        if (iter.is_referent_alive()) {
-          iter.make_referent_alive();
-        }
-        iter.move_to_next();
-      }
-    }
-
-    // Drain the queue - which may cause stealing
-    G1ParEvacuateFollowersClosure drain_queue(_g1h, pss, _queues, &_terminator);
-    drain_queue.do_void();
-    // Allocation buffers were retired at the end of G1ParEvacuateFollowersClosure
-    assert(pss->queue_is_empty(), "should be");
-  }
-};
-
-void G1CollectedHeap::preserve_cm_referents(G1ParScanThreadStateSet* per_thread_states) {
-  // Any reference objects, in the collection set, that were 'discovered'
-  // by the CM ref processor should have already been copied (either by
-  // applying the external root copy closure to the discovered lists, or
-  // by following an RSet entry).
-  //
-  // But some of the referents, that are in the collection set, that these
-  // reference objects point to may not have been copied: the STW ref
-  // processor would have seen that the reference object had already
-  // been 'discovered' and would have skipped discovering the reference,
-  // but would not have treated the reference object as a regular oop.
-  // As a result the copy closure would not have been applied to the
-  // referent object.
-  //
-  // We need to explicitly copy these referent objects - the references
-  // will be processed at the end of remarking.
-  //
-  // We also need to do this copying before we process the reference
-  // objects discovered by the STW ref processor in case one of these
-  // referents points to another object which is also referenced by an
-  // object discovered by the STW ref processor.
-  double preserve_cm_referents_time = 0.0;
-
-  // To avoid spawning task when there is no work to do, check that
-  // a concurrent cycle is active and that some references have been
-  // discovered.
-  if (concurrent_mark()->cm_thread()->during_cycle() &&
-      ref_processor_cm()->has_discovered_references()) {
-    double preserve_cm_referents_start = os::elapsedTime();
-    uint no_of_gc_workers = workers()->active_workers();
-    G1ParPreserveCMReferentsTask keep_cm_referents(this,
-                                                   per_thread_states,
-                                                   no_of_gc_workers,
-                                                   _task_queues);
-    workers()->run_task(&keep_cm_referents);
-    preserve_cm_referents_time = os::elapsedTime() - preserve_cm_referents_start;
-  }
-
-  g1_policy()->phase_times()->record_preserve_cm_referents_time_ms(preserve_cm_referents_time * 1000.0);
-}
-
 // Weak Reference processing during an evacuation pause (part 1).
 void G1CollectedHeap::process_discovered_references(G1ParScanThreadStateSet* per_thread_states) {
   double ref_proc_start = os::elapsedTime();
@@ -4055,9 +3922,9 @@
     uint no_of_gc_workers = workers()->active_workers();
 
     // Parallel reference processing
-    assert(no_of_gc_workers <= rp->max_num_q(),
+    assert(no_of_gc_workers <= rp->max_num_queues(),
            "Mismatch between the number of GC workers %u and the maximum number of Reference process queues %u",
-           no_of_gc_workers,  rp->max_num_q());
+           no_of_gc_workers,  rp->max_num_queues());
 
     G1STWRefProcTaskExecutor par_task_executor(this, per_thread_states, workers(), _task_queues, no_of_gc_workers);
     stats = rp->process_discovered_references(&is_alive,
@@ -4095,9 +3962,9 @@
 
     uint n_workers = workers()->active_workers();
 
-    assert(n_workers <= rp->max_num_q(),
+    assert(n_workers <= rp->max_num_queues(),
            "Mismatch between the number of GC workers %u and the maximum number of Reference process queues %u",
-           n_workers,  rp->max_num_q());
+           n_workers,  rp->max_num_queues());
 
     G1STWRefProcTaskExecutor par_task_executor(this, per_thread_states, workers(), _task_queues, n_workers);
     rp->enqueue_discovered_references(&par_task_executor, pt);
@@ -4192,13 +4059,17 @@
 }
 
 void G1CollectedHeap::post_evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
+  // Also cleans the card table from temporary duplicate detection information used
+  // during UpdateRS/ScanRS.
+  g1_rem_set()->cleanup_after_oops_into_collection_set_do();
+
   // Process any discovered reference objects - we have
   // to do this _before_ we retire the GC alloc regions
   // as we may have to copy some 'reachable' referent
   // objects (and their reachable sub-graphs) that were
   // not copied during the pause.
-  preserve_cm_referents(per_thread_states);
   process_discovered_references(per_thread_states);
+  enqueue_discovered_references(per_thread_states);
 
   G1STWIsAliveClosure is_alive(this);
   G1KeepAliveClosure keep_alive(this);
@@ -4221,8 +4092,6 @@
     g1_policy()->phase_times()->record_string_dedup_fixup_time(fixup_time_ms);
   }
 
-  g1_rem_set()->cleanup_after_oops_into_collection_set_do();
-
   if (evacuation_failed()) {
     restore_after_evac_failure();
 
@@ -4234,15 +4103,6 @@
 
   _preserved_marks_set.assert_empty();
 
-  // Enqueue any remaining references remaining on the STW
-  // reference processor's discovered lists. We need to do
-  // this after the card table is cleaned (and verified) as
-  // the act of enqueueing entries on to the pending list
-  // will log these updates (and dirty their associated
-  // cards). We need these updates logged to update any
-  // RSets.
-  enqueue_discovered_references(per_thread_states);
-
   _allocator->release_gc_alloc_regions(evacuation_info);
 
   merge_per_thread_state_info(per_thread_states);
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Fri May 04 08:50:01 2018 -0700
@@ -107,13 +107,20 @@
 // (optional) _is_alive_non_header closure in the STW
 // reference processor. It is also extensively used during
 // reference processing during STW evacuation pauses.
-class G1STWIsAliveClosure: public BoolObjectClosure {
+class G1STWIsAliveClosure : public BoolObjectClosure {
   G1CollectedHeap* _g1h;
 public:
   G1STWIsAliveClosure(G1CollectedHeap* g1h) : _g1h(g1h) {}
   bool do_object_b(oop p);
 };
 
+class G1STWSubjectToDiscoveryClosure : public BoolObjectClosure {
+  G1CollectedHeap* _g1h;
+public:
+  G1STWSubjectToDiscoveryClosure(G1CollectedHeap* g1h) : _g1h(g1h) {}
+  bool do_object_b(oop p);
+};
+
 class G1RegionMappingChangedListener : public G1MappingChangedListener {
  private:
   void reset_from_card_cache(uint start_idx, size_t num_regions);
@@ -506,9 +513,6 @@
   // allocated block, or else "NULL".
   HeapWord* expand_and_allocate(size_t word_size);
 
-  // Preserve any referents discovered by concurrent marking that have not yet been
-  // copied by the STW pause.
-  void preserve_cm_referents(G1ParScanThreadStateSet* per_thread_states);
   // Process any reference objects discovered during
   // an incremental evacuation pause.
   void process_discovered_references(G1ParScanThreadStateSet* per_thread_states);
@@ -897,6 +901,8 @@
   // the discovered lists during reference discovery.
   G1STWIsAliveClosure _is_alive_closure_stw;
 
+  G1STWSubjectToDiscoveryClosure _is_subject_to_discovery_stw;
+
   // The (concurrent marking) reference processor...
   ReferenceProcessor* _ref_processor_cm;
 
@@ -908,6 +914,7 @@
   // discovery.
   G1CMIsAliveClosure _is_alive_closure_cm;
 
+  G1CMSubjectToDiscoveryClosure _is_subject_to_discovery_cm;
 public:
 
   RefToScanQueue *task_queue(uint i) const;
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp	Fri May 04 08:50:01 2018 -0700
@@ -1389,15 +1389,6 @@
   }
 }
 
-// Supporting Object and Oop closures for reference discovery
-// and processing in during marking
-
-bool G1CMIsAliveClosure::do_object_b(oop obj) {
-  HeapWord* addr = (HeapWord*)obj;
-  return addr != NULL &&
-         (!_g1h->is_in_g1_reserved(addr) || !_g1h->is_obj_ill(obj));
-}
-
 // 'Keep Alive' oop closure used by both serial parallel reference processing.
 // Uses the G1CMTask associated with a worker thread (for serial reference
 // processing the G1CMTask for worker 0 is used) to preserve (mark) and
@@ -1665,7 +1656,7 @@
     // Reference lists are balanced (see balance_all_queues() and balance_queues()).
     rp->set_active_mt_degree(active_workers);
 
-    ReferenceProcessorPhaseTimes pt(_gc_timer_cm, rp->num_q());
+    ReferenceProcessorPhaseTimes pt(_gc_timer_cm, rp->num_queues());
 
     // Process the weak references.
     const ReferenceProcessorStats& stats =
@@ -1684,7 +1675,7 @@
     assert(has_overflown() || _global_mark_stack.is_empty(),
            "Mark stack should be empty (unless it has overflown)");
 
-    assert(rp->num_q() == active_workers, "why not");
+    assert(rp->num_queues() == active_workers, "why not");
 
     rp->enqueue_discovered_references(executor, &pt);
 
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp	Fri May 04 08:50:01 2018 -0700
@@ -36,6 +36,7 @@
 class ConcurrentGCTimer;
 class G1ConcurrentMarkThread;
 class G1CollectedHeap;
+class G1CMOopClosure;
 class G1CMTask;
 class G1ConcurrentMark;
 class G1OldTracer;
@@ -109,7 +110,13 @@
   G1CollectedHeap* _g1h;
 public:
   G1CMIsAliveClosure(G1CollectedHeap* g1h) : _g1h(g1h) { }
+  bool do_object_b(oop obj);
+};
 
+class G1CMSubjectToDiscoveryClosure : public BoolObjectClosure {
+  G1CollectedHeap* _g1h;
+public:
+  G1CMSubjectToDiscoveryClosure(G1CollectedHeap* g1h) : _g1h(g1h) { }
   bool do_object_b(oop obj);
 };
 
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -38,6 +38,22 @@
 #include "gc/shared/taskqueue.inline.hpp"
 #include "utilities/bitMap.inline.hpp"
 
+inline bool G1CMIsAliveClosure::do_object_b(oop obj) {
+  return !_g1h->is_obj_ill(obj);
+}
+
+inline bool G1CMSubjectToDiscoveryClosure::do_object_b(oop obj) {
+  // Re-check whether the passed object is null. With ReferentBasedDiscovery the
+  // mutator may have changed the referent's value (i.e. cleared it) between the
+  // time the referent was determined to be potentially alive and calling this
+  // method.
+  if (obj == NULL) {
+    return false;
+  }
+  assert(_g1h->is_in_reserved(obj), "Trying to discover obj " PTR_FORMAT " not in heap", p2i(obj));
+  return _g1h->heap_region_containing(obj)->is_old_or_humongous();
+}
+
 inline bool G1ConcurrentMark::mark_in_next_bitmap(uint const worker_id, oop const obj, size_t const obj_size) {
   HeapRegion* const hr = _g1h->heap_region_containing(obj);
   return mark_in_next_bitmap(worker_id, hr, obj, obj_size);
--- a/src/hotspot/share/gc/g1/g1FullCollector.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp	Fri May 04 08:50:01 2018 -0700
@@ -112,7 +112,9 @@
     _preserved_marks_set(true),
     _serial_compaction_point(),
     _is_alive(heap->concurrent_mark()->next_mark_bitmap()),
-    _is_alive_mutator(heap->ref_processor_stw(), &_is_alive) {
+    _is_alive_mutator(heap->ref_processor_stw(), &_is_alive),
+    _always_subject_to_discovery(),
+    _is_subject_mutator(heap->ref_processor_stw(), &_always_subject_to_discovery) {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
 
   _preserved_marks_set.init(_num_workers);
--- a/src/hotspot/share/gc/g1/g1FullCollector.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1FullCollector.hpp	Fri May 04 08:50:01 2018 -0700
@@ -42,6 +42,16 @@
 class GCMemoryManager;
 class ReferenceProcessor;
 
+// Subject-to-discovery closure for reference processing during Full GC. During
+// Full GC the whole heap is subject to discovery.
+class G1FullGCSubjectToDiscoveryClosure: public BoolObjectClosure {
+public:
+  bool do_object_b(oop p) {
+    assert(p != NULL, "must be");
+    return true;
+  }
+};
+
 // The G1FullCollector holds data associated with the current Full GC.
 class G1FullCollector : StackObj {
   G1CollectedHeap*          _heap;
@@ -58,6 +68,9 @@
 
   static uint calc_active_workers();
 
+  G1FullGCSubjectToDiscoveryClosure _always_subject_to_discovery;
+  ReferenceProcessorSubjectToDiscoveryMutator _is_subject_mutator;
+
 public:
   G1FullCollector(G1CollectedHeap* heap, GCMemoryManager* memory_manager, bool explicit_gc, bool clear_soft_refs);
   ~G1FullCollector();
--- a/src/hotspot/share/gc/g1/g1FullGCMarker.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1FullGCMarker.cpp	Fri May 04 08:50:01 2018 -0700
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/g1FullGCMarker.inline.hpp"
+#include "gc/shared/referenceProcessor.hpp"
 
 G1FullGCMarker::G1FullGCMarker(uint worker_id, PreservedMarks* preserved_stack, G1CMBitMap* bitmap) :
     _worker_id(worker_id),
--- a/src/hotspot/share/gc/g1/g1FullGCReferenceProcessorExecutor.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1FullGCReferenceProcessorExecutor.cpp	Fri May 04 08:50:01 2018 -0700
@@ -34,7 +34,7 @@
 G1FullGCReferenceProcessingExecutor::G1FullGCReferenceProcessingExecutor(G1FullCollector* collector) :
     _collector(collector),
     _reference_processor(collector->reference_processor()),
-    _old_mt_degree(_reference_processor->num_q()) {
+    _old_mt_degree(_reference_processor->num_queues()) {
   if (_reference_processor->processing_is_mt()) {
     _reference_processor->set_active_mt_degree(_collector->workers());
   }
@@ -92,7 +92,7 @@
   G1FullGCMarker* marker = _collector->marker(0);
   G1IsAliveClosure is_alive(_collector->mark_bitmap());
   G1FullKeepAliveClosure keep_alive(marker);
-  ReferenceProcessorPhaseTimes pt(timer, _reference_processor->num_q());
+  ReferenceProcessorPhaseTimes pt(timer, _reference_processor->num_queues());
   AbstractRefProcTaskExecutor* executor = _reference_processor->processing_is_mt() ? this : NULL;
 
   // Process discovered references, use this executor if multi-threaded
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp	Fri May 04 08:50:01 2018 -0700
@@ -113,8 +113,6 @@
   _gc_par_phases[YoungFreeCSet] = new WorkerDataArray<double>(max_gc_threads, "Young Free Collection Set (ms):");
   _gc_par_phases[NonYoungFreeCSet] = new WorkerDataArray<double>(max_gc_threads, "Non-Young Free Collection Set (ms):");
 
-  _gc_par_phases[PreserveCMReferents] = new WorkerDataArray<double>(max_gc_threads, "Parallel Preserve CM Refs (ms):");
-
   reset();
 }
 
@@ -399,8 +397,7 @@
 
   debug_time("Code Roots Fixup", _cur_collection_code_root_fixup_time_ms);
 
-  debug_time("Preserve CM Refs", _recorded_preserve_cm_referents_time_ms);
-  trace_phase(_gc_par_phases[PreserveCMReferents]);
+  debug_time("Clear Card Table", _cur_clear_ct_time_ms);
 
   debug_time_for_reference("Reference Processing", _cur_ref_proc_time_ms);
   _ref_phase_times.print_all_references(2, false);
@@ -413,8 +410,6 @@
     debug_phase(_gc_par_phases[StringDedupTableFixup]);
   }
 
-  debug_time("Clear Card Table", _cur_clear_ct_time_ms);
-
   if (G1CollectedHeap::heap()->evacuation_failed()) {
     debug_time("Evacuation Failure", evac_fail_handling);
     trace_time("Recalculate Used", _cur_evac_fail_recalc_used);
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp	Fri May 04 08:50:01 2018 -0700
@@ -73,7 +73,6 @@
     StringDedupQueueFixup,
     StringDedupTableFixup,
     RedirtyCards,
-    PreserveCMReferents,
     YoungFreeCSet,
     NonYoungFreeCSet,
     GCParPhasesSentinel
--- a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp	Fri May 04 08:50:01 2018 -0700
@@ -26,6 +26,7 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1MonitoringSupport.hpp"
 #include "gc/g1/g1Policy.hpp"
+#include "gc/shared/collectorCounters.hpp"
 #include "gc/shared/hSpaceCounters.hpp"
 #include "memory/metaspaceCounters.hpp"
 
--- a/src/hotspot/share/gc/g1/g1RootProcessor.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1RootProcessor.cpp	Fri May 04 08:50:01 2018 -0700
@@ -38,6 +38,7 @@
 #include "gc/g1/g1RootClosures.hpp"
 #include "gc/g1/g1RootProcessor.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
+#include "gc/shared/referenceProcessor.hpp"
 #include "gc/shared/weakProcessor.hpp"
 #include "memory/allocation.inline.hpp"
 #include "runtime/mutex.hpp"
--- a/src/hotspot/share/gc/parallel/asPSYoungGen.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/asPSYoungGen.cpp	Fri May 04 08:50:01 2018 -0700
@@ -496,7 +496,7 @@
 
   _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
                         (HeapWord*)virtual_space()->high_boundary());
-  PSScavenge::reference_processor()->set_span(_reserved);
+  PSScavenge::set_subject_to_discovery_span(_reserved);
 
   HeapWord* new_eden_bottom = (HeapWord*)virtual_space()->low();
   HeapWord* eden_bottom = eden_space()->bottom();
--- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp	Fri May 04 08:50:01 2018 -0700
@@ -31,7 +31,7 @@
 #include "gc/parallel/objectStartArray.inline.hpp"
 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
-#include "gc/parallel/psMarkSweep.hpp"
+#include "gc/parallel/psMarkSweepProxy.hpp"
 #include "gc/parallel/psMemoryPool.hpp"
 #include "gc/parallel/psParallelCompact.inline.hpp"
 #include "gc/parallel/psPromotionManager.hpp"
@@ -48,6 +48,7 @@
 #include "runtime/vmThread.hpp"
 #include "services/memoryManager.hpp"
 #include "services/memTracker.hpp"
+#include "utilities/macros.hpp"
 #include "utilities/vmError.hpp"
 
 PSYoungGen*  ParallelScavengeHeap::_young_gen = NULL;
@@ -155,7 +156,7 @@
   if (UseParallelOldGC) {
     PSParallelCompact::post_initialize();
   } else {
-    PSMarkSweep::initialize();
+    PSMarkSweepProxy::initialize();
   }
   PSPromotionManager::initialize();
 }
@@ -406,7 +407,7 @@
     bool maximum_compaction = clear_all_soft_refs;
     PSParallelCompact::invoke(maximum_compaction);
   } else {
-    PSMarkSweep::invoke(clear_all_soft_refs);
+    PSMarkSweepProxy::invoke(clear_all_soft_refs);
   }
 }
 
@@ -545,7 +546,7 @@
 jlong ParallelScavengeHeap::millis_since_last_gc() {
   return UseParallelOldGC ?
     PSParallelCompact::millis_since_last_gc() :
-    PSMarkSweep::millis_since_last_gc();
+    PSMarkSweepProxy::millis_since_last_gc();
 }
 
 void ParallelScavengeHeap::prepare_for_verify() {
@@ -602,7 +603,7 @@
   AdaptiveSizePolicyOutput::print();
   log_debug(gc, heap, exit)("Accumulated young generation GC time %3.7f secs", PSScavenge::accumulated_time()->seconds());
   log_debug(gc, heap, exit)("Accumulated old generation GC time %3.7f secs",
-      UseParallelOldGC ? PSParallelCompact::accumulated_time()->seconds() : PSMarkSweep::accumulated_time()->seconds());
+      UseParallelOldGC ? PSParallelCompact::accumulated_time()->seconds() : PSMarkSweepProxy::accumulated_time()->seconds());
 }
 
 
--- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -26,13 +26,13 @@
 #define SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_INLINE_HPP
 
 #include "gc/parallel/parallelScavengeHeap.hpp"
-#include "gc/parallel/psMarkSweep.hpp"
+#include "gc/parallel/psMarkSweepProxy.hpp"
 #include "gc/parallel/psParallelCompact.inline.hpp"
 #include "gc/parallel/psScavenge.hpp"
 
 inline size_t ParallelScavengeHeap::total_invocations() {
   return UseParallelOldGC ? PSParallelCompact::total_invocations() :
-    PSMarkSweep::total_invocations();
+    PSMarkSweepProxy::total_invocations();
 }
 
 inline bool ParallelScavengeHeap::should_alloc_in_eden(const size_t size) const {
--- a/src/hotspot/share/gc/parallel/psMarkSweep.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psMarkSweep.cpp	Fri May 04 08:50:01 2018 -0700
@@ -65,9 +65,11 @@
 jlong               PSMarkSweep::_time_of_last_gc   = 0;
 CollectorCounters*  PSMarkSweep::_counters = NULL;
 
+SpanSubjectToDiscoveryClosure PSMarkSweep::_span_based_discoverer;
+
 void PSMarkSweep::initialize() {
-  MemRegion mr = ParallelScavengeHeap::heap()->reserved_region();
-  set_ref_processor(new ReferenceProcessor(mr));     // a vanilla ref proc
+  _span_based_discoverer.set_span(ParallelScavengeHeap::heap()->reserved_region());
+  set_ref_processor(new ReferenceProcessor(&_span_based_discoverer));     // a vanilla ref proc
   _counters = new CollectorCounters("PSMarkSweep", 1);
 }
 
@@ -258,7 +260,7 @@
     DerivedPointerTable::update_pointers();
 #endif
 
-    ReferenceProcessorPhaseTimes pt(_gc_timer, ref_processor()->num_q());
+    ReferenceProcessorPhaseTimes pt(_gc_timer, ref_processor()->num_queues());
 
     ref_processor()->enqueue_discovered_references(NULL, &pt);
 
@@ -537,7 +539,7 @@
     GCTraceTime(Debug, gc, phases) t("Reference Processing", _gc_timer);
 
     ref_processor()->setup_policy(clear_all_softrefs);
-    ReferenceProcessorPhaseTimes pt(_gc_timer, ref_processor()->num_q());
+    ReferenceProcessorPhaseTimes pt(_gc_timer, ref_processor()->num_queues());
     const ReferenceProcessorStats& stats =
       ref_processor()->process_discovered_references(
         is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL, &pt);
@@ -563,7 +565,7 @@
     CodeCache::do_unloading(is_alive_closure(), purged_class);
 
     // Prune dead klasses from subklass/sibling/implementor lists.
-    Klass::clean_weak_klass_links();
+    Klass::clean_weak_klass_links(purged_class);
   }
 
   {
--- a/src/hotspot/share/gc/parallel/psMarkSweep.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psMarkSweep.hpp	Fri May 04 08:50:01 2018 -0700
@@ -27,6 +27,7 @@
 
 #include "gc/serial/markSweep.hpp"
 #include "gc/shared/collectorCounters.hpp"
+#include "gc/shared/referenceProcessor.hpp"
 #include "utilities/stack.hpp"
 
 class PSAdaptiveSizePolicy;
@@ -39,6 +40,8 @@
   static jlong               _time_of_last_gc;   // ms
   static CollectorCounters*  _counters;
 
+  static SpanSubjectToDiscoveryClosure _span_based_discoverer;
+
   // Closure accessors
   static OopClosure* mark_and_push_closure()   { return &MarkSweep::mark_and_push_closure; }
   static VoidClosure* follow_stack_closure()   { return &MarkSweep::follow_stack_closure; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/parallel/psMarkSweepProxy.hpp	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_GC_PARALLEL_PSMARKSWEEPPROXY_HPP
+#define SHARE_GC_PARALLEL_PSMARKSWEEPPROXY_HPP
+
+#include "utilities/macros.hpp"
+#if INCLUDE_SERIALGC
+#include "gc/parallel/psMarkSweep.hpp"
+#endif
+
+#if INCLUDE_SERIALGC
+namespace PSMarkSweepProxy {
+  inline void initialize()                              { PSMarkSweep::initialize(); }
+  inline void invoke(bool maximum_heap_compaction)      { PSMarkSweep::invoke(maximum_heap_compaction); }
+  inline bool invoke_no_policy(bool clear_all_softrefs) { return PSMarkSweep::invoke_no_policy(clear_all_softrefs); }
+  inline jlong millis_since_last_gc()                   { return PSMarkSweep::millis_since_last_gc(); }
+  inline elapsedTimer* accumulated_time()               { return PSMarkSweep::accumulated_time(); }
+  inline uint total_invocations()                       { return PSMarkSweep::total_invocations(); }
+};
+#else
+namespace PSMarkSweepProxy {
+  inline void initialize()                { fatal("Serial GC excluded from build"); }
+  inline void invoke(bool)                { fatal("Serial GC excluded from build"); }
+  inline bool invoke_no_policy(bool)      { fatal("Serial GC excluded from build"); return false;}
+  inline jlong millis_since_last_gc()     { fatal("Serial GC excluded from build"); return 0L; }
+  inline elapsedTimer* accumulated_time() { fatal("Serial GC excluded from build"); return NULL; }
+  inline uint total_invocations()         { fatal("Serial GC excluded from build"); return 0u; }
+};
+#endif
+
+#endif // SHARE_GC_PARALLEL_PSMARKSWEEPPROXY_HPP
--- a/src/hotspot/share/gc/parallel/psOldGen.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psOldGen.cpp	Fri May 04 08:50:01 2018 -0700
@@ -139,10 +139,13 @@
                              SpaceDecorator::Clear,
                              SpaceDecorator::Mangle);
 
+#if INCLUDE_SERIALGC
   _object_mark_sweep = new PSMarkSweepDecorator(_object_space, start_array(), MarkSweepDeadRatio);
 
-  if (_object_mark_sweep == NULL)
+  if (_object_mark_sweep == NULL) {
     vm_exit_during_initialization("Could not complete allocation of old generation");
+  }
+#endif // INCLUDE_SERIALGC
 
   // Update the start_array
   start_array()->set_covered_region(cmr);
@@ -163,6 +166,8 @@
   return virtual_space()->reserved_size() != 0;
 }
 
+#if INCLUDE_SERIALGC
+
 void PSOldGen::precompact() {
   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
 
@@ -183,6 +188,8 @@
   object_mark_sweep()->compact(ZapUnusedHeapArea);
 }
 
+#endif // INCLUDE_SERIALGC
+
 size_t PSOldGen::contiguous_available() const {
   return object_space()->free_in_bytes() + virtual_space()->uncommitted_size();
 }
--- a/src/hotspot/share/gc/parallel/psOldGen.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psOldGen.hpp	Fri May 04 08:50:01 2018 -0700
@@ -45,7 +45,9 @@
   PSVirtualSpace*          _virtual_space;     // Controls mapping and unmapping of virtual mem
   ObjectStartArray         _start_array;       // Keeps track of where objects start in a 512b block
   MutableSpace*            _object_space;      // Where all the objects live
+#if INCLUDE_SERIALGC
   PSMarkSweepDecorator*    _object_mark_sweep; // The mark sweep view of _object_space
+#endif
   const char* const        _name;              // Name of this generation.
 
   // Performance Counters
@@ -150,17 +152,21 @@
   }
 
   MutableSpace*         object_space() const      { return _object_space; }
+#if INCLUDE_SERIALGC
   PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; }
+#endif
   ObjectStartArray*     start_array()             { return &_start_array; }
   PSVirtualSpace*       virtual_space() const     { return _virtual_space;}
 
   // Has the generation been successfully allocated?
   bool is_allocated();
 
+#if INCLUDE_SERIALGC
   // MarkSweep methods
   virtual void precompact();
   void adjust_pointers();
   void compact();
+#endif
 
   // Size info
   size_t capacity_in_bytes() const        { return object_space()->capacity_in_bytes(); }
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp	Fri May 04 08:50:01 2018 -0700
@@ -34,8 +34,6 @@
 #include "gc/parallel/pcTasks.hpp"
 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
 #include "gc/parallel/psCompactionManager.inline.hpp"
-#include "gc/parallel/psMarkSweep.hpp"
-#include "gc/parallel/psMarkSweepDecorator.hpp"
 #include "gc/parallel/psOldGen.hpp"
 #include "gc/parallel/psParallelCompact.inline.hpp"
 #include "gc/parallel/psPromotionManager.inline.hpp"
@@ -72,6 +70,7 @@
 #include "utilities/debug.hpp"
 #include "utilities/events.hpp"
 #include "utilities/formatBuffer.hpp"
+#include "utilities/macros.hpp"
 #include "utilities/stack.inline.hpp"
 
 #include <math.h>
@@ -117,6 +116,7 @@
 
 SpaceInfo PSParallelCompact::_space_info[PSParallelCompact::last_space_id];
 
+SpanSubjectToDiscoveryClosure PSParallelCompact::_span_based_discoverer;
 ReferenceProcessor* PSParallelCompact::_ref_processor = NULL;
 
 double PSParallelCompact::_dwl_mean;
@@ -843,14 +843,14 @@
 
 void PSParallelCompact::post_initialize() {
   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
-  MemRegion mr = heap->reserved_region();
+  _span_based_discoverer.set_span(heap->reserved_region());
   _ref_processor =
-    new ReferenceProcessor(mr,            // span
+    new ReferenceProcessor(&_span_based_discoverer,
                            ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
-                           ParallelGCThreads, // mt processing degree
-                           true,              // mt discovery
-                           ParallelGCThreads, // mt discovery degree
-                           true,              // atomic_discovery
+                           ParallelGCThreads,   // mt processing degree
+                           true,                // mt discovery
+                           ParallelGCThreads,   // mt discovery degree
+                           true,                // atomic_discovery
                            &_is_alive_closure); // non-header is alive closure
   _counters = new CollectorCounters("PSParallelCompact", 1);
 
@@ -1038,7 +1038,7 @@
   DerivedPointerTable::update_pointers();
 #endif
 
-  ReferenceProcessorPhaseTimes pt(&_gc_timer, ref_processor()->num_q());
+  ReferenceProcessorPhaseTimes pt(&_gc_timer, ref_processor()->num_queues());
 
   ref_processor()->enqueue_discovered_references(NULL, &pt);
 
@@ -2105,7 +2105,7 @@
     GCTraceTime(Debug, gc, phases) tm("Reference Processing", &_gc_timer);
 
     ReferenceProcessorStats stats;
-    ReferenceProcessorPhaseTimes pt(&_gc_timer, ref_processor()->num_q());
+    ReferenceProcessorPhaseTimes pt(&_gc_timer, ref_processor()->num_queues());
     if (ref_processor()->processing_is_mt()) {
       RefProcTaskExecutor task_executor;
       stats = ref_processor()->process_discovered_references(
@@ -2139,7 +2139,7 @@
     CodeCache::do_unloading(is_alive_closure(), purged_class);
 
     // Prune dead klasses from subklass/sibling/implementor lists.
-    Klass::clean_weak_klass_links();
+    Klass::clean_weak_klass_links(purged_class);
   }
 
   {
--- a/src/hotspot/share/gc/parallel/psParallelCompact.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.hpp	Fri May 04 08:50:01 2018 -0700
@@ -968,6 +968,7 @@
   static SpaceInfo            _space_info[last_space_id];
 
   // Reference processing (used in ...follow_contents)
+  static SpanSubjectToDiscoveryClosure  _span_based_discoverer;
   static ReferenceProcessor*  _ref_processor;
 
   // Values computed at initialization and used by dead_wood_limiter().
--- a/src/hotspot/share/gc/parallel/psScavenge.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psScavenge.cpp	Fri May 04 08:50:01 2018 -0700
@@ -28,7 +28,7 @@
 #include "gc/parallel/gcTaskManager.hpp"
 #include "gc/parallel/parallelScavengeHeap.hpp"
 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
-#include "gc/parallel/psMarkSweep.hpp"
+#include "gc/parallel/psMarkSweepProxy.hpp"
 #include "gc/parallel/psParallelCompact.inline.hpp"
 #include "gc/parallel/psScavenge.inline.hpp"
 #include "gc/parallel/psTasks.hpp"
@@ -58,18 +58,19 @@
 #include "services/memoryService.hpp"
 #include "utilities/stack.inline.hpp"
 
-HeapWord*                  PSScavenge::_to_space_top_before_gc = NULL;
-int                        PSScavenge::_consecutive_skipped_scavenges = 0;
-ReferenceProcessor*        PSScavenge::_ref_processor = NULL;
-PSCardTable*               PSScavenge::_card_table = NULL;
-bool                       PSScavenge::_survivor_overflow = false;
-uint                       PSScavenge::_tenuring_threshold = 0;
-HeapWord*                  PSScavenge::_young_generation_boundary = NULL;
-uintptr_t                  PSScavenge::_young_generation_boundary_compressed = 0;
-elapsedTimer               PSScavenge::_accumulated_time;
-STWGCTimer                 PSScavenge::_gc_timer;
-ParallelScavengeTracer     PSScavenge::_gc_tracer;
-CollectorCounters*         PSScavenge::_counters = NULL;
+HeapWord*                     PSScavenge::_to_space_top_before_gc = NULL;
+int                           PSScavenge::_consecutive_skipped_scavenges = 0;
+SpanSubjectToDiscoveryClosure PSScavenge::_span_based_discoverer;
+ReferenceProcessor*           PSScavenge::_ref_processor = NULL;
+PSCardTable*                  PSScavenge::_card_table = NULL;
+bool                          PSScavenge::_survivor_overflow = false;
+uint                          PSScavenge::_tenuring_threshold = 0;
+HeapWord*                     PSScavenge::_young_generation_boundary = NULL;
+uintptr_t                     PSScavenge::_young_generation_boundary_compressed = 0;
+elapsedTimer                  PSScavenge::_accumulated_time;
+STWGCTimer                    PSScavenge::_gc_timer;
+ParallelScavengeTracer        PSScavenge::_gc_tracer;
+CollectorCounters*            PSScavenge::_counters = NULL;
 
 // Define before use
 class PSIsAliveClosure: public BoolObjectClosure {
@@ -234,7 +235,7 @@
     if (UseParallelOldGC) {
       full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs);
     } else {
-      full_gc_done = PSMarkSweep::invoke_no_policy(clear_all_softrefs);
+      full_gc_done = PSMarkSweepProxy::invoke_no_policy(clear_all_softrefs);
     }
   }
 
@@ -416,7 +417,7 @@
       PSKeepAliveClosure keep_alive(promotion_manager);
       PSEvacuateFollowersClosure evac_followers(promotion_manager);
       ReferenceProcessorStats stats;
-      ReferenceProcessorPhaseTimes pt(&_gc_timer, reference_processor()->num_q());
+      ReferenceProcessorPhaseTimes pt(&_gc_timer, reference_processor()->num_queues());
       if (reference_processor()->processing_is_mt()) {
         PSRefProcTaskExecutor task_executor;
         stats = reference_processor()->process_discovered_references(
@@ -766,10 +767,9 @@
   set_young_generation_boundary(young_gen->eden_space()->bottom());
 
   // Initialize ref handling object for scavenging.
-  MemRegion mr = young_gen->reserved();
-
+  _span_based_discoverer.set_span(young_gen->reserved());
   _ref_processor =
-    new ReferenceProcessor(mr,                         // span
+    new ReferenceProcessor(&_span_based_discoverer,
                            ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
                            ParallelGCThreads,          // mt processing degree
                            true,                       // mt discovery
--- a/src/hotspot/share/gc/parallel/psScavenge.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psScavenge.hpp	Fri May 04 08:50:01 2018 -0700
@@ -65,14 +65,15 @@
 
  protected:
   // Flags/counters
-  static ReferenceProcessor*  _ref_processor;        // Reference processor for scavenging.
-  static PSIsAliveClosure     _is_alive_closure;     // Closure used for reference processing
-  static PSCardTable*         _card_table;           // We cache the card table for fast access.
-  static bool                 _survivor_overflow;    // Overflow this collection
-  static uint                 _tenuring_threshold;   // tenuring threshold for next scavenge
-  static elapsedTimer         _accumulated_time;     // total time spent on scavenge
-  static STWGCTimer           _gc_timer;             // GC time book keeper
-  static ParallelScavengeTracer _gc_tracer;          // GC tracing
+  static SpanSubjectToDiscoveryClosure _span_based_discoverer;
+  static ReferenceProcessor*           _ref_processor;        // Reference processor for scavenging.
+  static PSIsAliveClosure              _is_alive_closure;     // Closure used for reference processing
+  static PSCardTable*                  _card_table;           // We cache the card table for fast access.
+  static bool                          _survivor_overflow;    // Overflow this collection
+  static uint                          _tenuring_threshold;   // tenuring threshold for next scavenge
+  static elapsedTimer                  _accumulated_time;     // total time spent on scavenge
+  static STWGCTimer                    _gc_timer;             // GC time book keeper
+  static ParallelScavengeTracer        _gc_tracer;          // GC tracing
   // The lowest address possible for the young_gen.
   // This is used to decide if an oop should be scavenged,
   // cards should be marked, etc.
@@ -102,6 +103,9 @@
   // Performance Counters
   static CollectorCounters* counters()           { return _counters; }
 
+  static void set_subject_to_discovery_span(MemRegion mr) {
+    _span_based_discoverer.set_span(mr);
+  }
   // Used by scavenge_contents && psMarkSweep
   static ReferenceProcessor* const reference_processor() {
     assert(_ref_processor != NULL, "Sanity");
--- a/src/hotspot/share/gc/parallel/psTasks.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psTasks.cpp	Fri May 04 08:50:01 2018 -0700
@@ -27,7 +27,6 @@
 #include "classfile/systemDictionary.hpp"
 #include "code/codeCache.hpp"
 #include "gc/parallel/gcTaskManager.hpp"
-#include "gc/parallel/psMarkSweep.hpp"
 #include "gc/parallel/psCardTable.hpp"
 #include "gc/parallel/psPromotionManager.hpp"
 #include "gc/parallel/psPromotionManager.inline.hpp"
--- a/src/hotspot/share/gc/parallel/psYoungGen.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psYoungGen.cpp	Fri May 04 08:50:01 2018 -0700
@@ -730,6 +730,8 @@
   to_space()->object_iterate(blk);
 }
 
+#if INCLUDE_SERIALGC
+
 void PSYoungGen::precompact() {
   eden_mark_sweep()->precompact();
   from_mark_sweep()->precompact();
@@ -749,6 +751,8 @@
   to_mark_sweep()->compact(false);
 }
 
+#endif // INCLUDE_SERIALGC
+
 void PSYoungGen::print() const { print_on(tty); }
 void PSYoungGen::print_on(outputStream* st) const {
   st->print(" %-15s", "PSYoungGen");
@@ -839,7 +843,7 @@
 void PSYoungGen::reset_survivors_after_shrink() {
   _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
                         (HeapWord*)virtual_space()->high_boundary());
-  PSScavenge::reference_processor()->set_span(_reserved);
+  PSScavenge::set_subject_to_discovery_span(_reserved);
 
   MutableSpace* space_shrinking = NULL;
   if (from_space()->end() > to_space()->end()) {
--- a/src/hotspot/share/gc/parallel/psYoungGen.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psYoungGen.hpp	Fri May 04 08:50:01 2018 -0700
@@ -123,9 +123,11 @@
   PSMarkSweepDecorator* from_mark_sweep() const    { return _from_mark_sweep; }
   PSMarkSweepDecorator* to_mark_sweep() const      { return _to_mark_sweep;   }
 
+#if INCLUDE_SERIALGC
   void precompact();
   void adjust_pointers();
   void compact();
+#endif
 
   // Called during/after GC
   void swap_spaces();
--- a/src/hotspot/share/gc/parallel/vmPSOperations.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/parallel/vmPSOperations.cpp	Fri May 04 08:50:01 2018 -0700
@@ -24,7 +24,6 @@
 
 #include "precompiled.hpp"
 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
-#include "gc/parallel/psMarkSweep.hpp"
 #include "gc/parallel/psScavenge.hpp"
 #include "gc/parallel/vmPSOperations.hpp"
 #include "gc/shared/gcLocker.hpp"
--- a/src/hotspot/share/gc/serial/defNewGeneration.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp	Fri May 04 08:50:01 2018 -0700
@@ -56,7 +56,7 @@
 #include "utilities/copy.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/stack.inline.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
 #include "gc/cms/parOopClosures.hpp"
 #endif
 
@@ -646,7 +646,7 @@
   FastKeepAliveClosure keep_alive(this, &scan_weak_ref);
   ReferenceProcessor* rp = ref_processor();
   rp->setup_policy(clear_all_soft_refs);
-  ReferenceProcessorPhaseTimes pt(_gc_timer, rp->num_q());
+  ReferenceProcessorPhaseTimes pt(_gc_timer, rp->num_queues());
   const ReferenceProcessorStats& stats =
   rp->process_discovered_references(&is_alive, &keep_alive, &evacuate_followers,
                                     NULL, &pt);
@@ -1006,7 +1006,7 @@
   // have to use it here, as well.
   HeapWord* result = eden()->par_allocate(word_size);
   if (result != NULL) {
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
     if (CMSEdenChunksRecordAlways && _old_gen != NULL) {
       _old_gen->sample_eden_chunk();
     }
@@ -1024,7 +1024,7 @@
 HeapWord* DefNewGeneration::par_allocate(size_t word_size,
                                          bool is_tlab) {
   HeapWord* res = eden()->par_allocate(word_size);
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
   if (CMSEdenChunksRecordAlways && _old_gen != NULL) {
     _old_gen->sample_eden_chunk();
   }
--- a/src/hotspot/share/gc/serial/genMarkSweep.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/serial/genMarkSweep.cpp	Fri May 04 08:50:01 2018 -0700
@@ -208,7 +208,7 @@
     GCTraceTime(Debug, gc, phases) tm_m("Reference Processing", gc_timer());
 
     ref_processor()->setup_policy(clear_all_softrefs);
-    ReferenceProcessorPhaseTimes pt(_gc_timer, ref_processor()->num_q());
+    ReferenceProcessorPhaseTimes pt(_gc_timer, ref_processor()->num_queues());
     const ReferenceProcessorStats& stats =
       ref_processor()->process_discovered_references(
         &is_alive, &keep_alive, &follow_stack_closure, NULL, &pt);
@@ -234,7 +234,7 @@
     CodeCache::do_unloading(&is_alive, purged_class);
 
     // Prune dead klasses from subklass/sibling/implementor lists.
-    Klass::clean_weak_klass_links();
+    Klass::clean_weak_klass_links(purged_class);
   }
 
   {
--- a/src/hotspot/share/gc/serial/tenuredGeneration.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/serial/tenuredGeneration.cpp	Fri May 04 08:50:01 2018 -0700
@@ -39,7 +39,7 @@
 #include "oops/oop.inline.hpp"
 #include "runtime/java.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
 #include "gc/cms/parOopClosures.hpp"
 #endif
 
--- a/src/hotspot/share/gc/serial/vmStructs_serial.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/serial/vmStructs_serial.hpp	Fri May 04 08:50:01 2018 -0700
@@ -32,7 +32,14 @@
                             volatile_nonstatic_field,                         \
                             static_field)                                     \
   nonstatic_field(TenuredGeneration, _min_heap_delta_bytes, size_t)           \
-  nonstatic_field(TenuredGeneration, _the_space,            ContiguousSpace*)
+  nonstatic_field(TenuredGeneration, _the_space,            ContiguousSpace*) \
+                                                                              \
+  nonstatic_field(DefNewGeneration,  _old_gen,              Generation*)      \
+  nonstatic_field(DefNewGeneration,  _tenuring_threshold,   uint)             \
+  nonstatic_field(DefNewGeneration,  _age_table,            AgeTable)         \
+  nonstatic_field(DefNewGeneration,  _eden_space,           ContiguousSpace*) \
+  nonstatic_field(DefNewGeneration,  _from_space,           ContiguousSpace*) \
+  nonstatic_field(DefNewGeneration,  _to_space,             ContiguousSpace*)
 
 #define VM_TYPES_SERIALGC(declare_type,                                       \
                           declare_toplevel_type,                              \
@@ -41,6 +48,8 @@
   declare_type(TenuredGeneration,            CardGeneration)                  \
   declare_type(TenuredSpace,                 OffsetTableContigSpace)          \
                                                                               \
+  declare_type(DefNewGeneration,             Generation)                      \
+                                                                              \
   declare_toplevel_type(TenuredGeneration*)
 
 #define VM_INT_CONSTANTS_SERIALGC(declare_constant,                           \
--- a/src/hotspot/share/gc/shared/barrierSetConfig.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/barrierSetConfig.hpp	Fri May 04 08:50:01 2018 -0700
@@ -27,17 +27,10 @@
 
 #include "utilities/macros.hpp"
 
-#if INCLUDE_ALL_GCS
-#define FOR_EACH_CONCRETE_INCLUDE_ALL_GC_BARRIER_SET_DO(f) \
-  f(G1BarrierSet)
-#else
-#define FOR_EACH_CONCRETE_INCLUDE_ALL_GC_BARRIER_SET_DO(f)
-#endif
-
 // Do something for each concrete barrier set part of the build.
 #define FOR_EACH_CONCRETE_BARRIER_SET_DO(f)          \
   f(CardTableBarrierSet)                             \
-  FOR_EACH_CONCRETE_INCLUDE_ALL_GC_BARRIER_SET_DO(f)
+  G1GC_ONLY(f(G1BarrierSet))
 
 #define FOR_EACH_ABSTRACT_BARRIER_SET_DO(f)          \
   f(ModRef)
--- a/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -30,7 +30,7 @@
 #include "gc/shared/modRefBarrierSet.inline.hpp"
 #include "gc/shared/cardTableBarrierSet.inline.hpp"
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1BarrierSet.inline.hpp" // G1 support
 #endif
 
--- a/src/hotspot/share/gc/shared/blockOffsetTable.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/blockOffsetTable.hpp	Fri May 04 08:50:01 2018 -0700
@@ -153,14 +153,14 @@
 
   void fill_range(size_t start, size_t num_cards, u_char offset) {
     void* start_ptr = &_offset_array[start];
-#if INCLUDE_ALL_GCS
     // If collector is concurrent, special handling may be needed.
-    assert(!UseG1GC, "Shouldn't be here when using G1");
+    G1GC_ONLY(assert(!UseG1GC, "Shouldn't be here when using G1");)
+#if INCLUDE_CMSGC
     if (UseConcMarkSweepGC) {
       memset_with_concurrent_readers(start_ptr, offset, num_cards);
       return;
     }
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_CMSGC
     memset(start_ptr, offset, num_cards);
   }
 
--- a/src/hotspot/share/gc/shared/cardGeneration.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/cardGeneration.cpp	Fri May 04 08:50:01 2018 -0700
@@ -208,7 +208,7 @@
 
     const size_t free_after_gc = free();
     const double free_percentage = ((double)free_after_gc) / capacity_after_gc;
-    log_trace(gc, heap)("TenuredGeneration::compute_new_size:");
+    log_trace(gc, heap)("CardGeneration::compute_new_size:");
     log_trace(gc, heap)("    minimum_free_percentage: %6.2f  maximum_used_percentage: %6.2f",
                   minimum_free_percentage,
                   maximum_used_percentage);
--- a/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp	Fri May 04 08:50:01 2018 -0700
@@ -126,7 +126,7 @@
 // that specific collector in mind, and the documentation above suitably
 // extended and updated.
 void CardTableBarrierSet::on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) {
-#if defined(COMPILER2) || INCLUDE_JVMCI
+#if COMPILER2_OR_JVMCI
   if (!ReduceInitialCardMarks) {
     return;
   }
@@ -148,13 +148,13 @@
       invalidate(mr);
     }
   }
-#endif // COMPILER2 || JVMCI
+#endif // COMPILER2_OR_JVMCI
 }
 
 void CardTableBarrierSet::initialize_deferred_card_mark_barriers() {
   // Used for ReduceInitialCardMarks (when COMPILER2 or JVMCI is used);
   // otherwise remains unused.
-#if defined(COMPILER2) || INCLUDE_JVMCI
+#if COMPILER2_OR_JVMCI
   _defer_initial_card_mark = is_server_compilation_mode_vm() && ReduceInitialCardMarks && can_elide_tlab_store_barriers()
                              && (DeferInitialCardMark || card_mark_must_follow_store());
 #else
@@ -163,7 +163,7 @@
 }
 
 void CardTableBarrierSet::flush_deferred_card_mark_barrier(JavaThread* thread) {
-#if defined(COMPILER2) || INCLUDE_JVMCI
+#if COMPILER2_OR_JVMCI
   MemRegion deferred = thread->deferred_card_mark();
   if (!deferred.is_empty()) {
     assert(_defer_initial_card_mark, "Otherwise should be empty");
--- a/src/hotspot/share/gc/shared/cardTableRS.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/cardTableRS.cpp	Fri May 04 08:50:01 2018 -0700
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "gc/shared/cardTableRS.hpp"
 #include "gc/shared/genCollectedHeap.hpp"
+#include "gc/shared/genOopClosures.hpp"
 #include "gc/shared/generation.hpp"
 #include "gc/shared/space.inline.hpp"
 #include "memory/allocation.inline.hpp"
--- a/src/hotspot/share/gc/shared/collectedHeap.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/collectedHeap.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -45,13 +45,13 @@
                                                  HeapWord* obj_ptr) {
   post_allocation_setup_no_klass_install(klass, obj_ptr);
   oop obj = (oop)obj_ptr;
-#if ! INCLUDE_ALL_GCS
-  obj->set_klass(klass);
-#else
+#if (INCLUDE_G1GC || INCLUDE_CMSGC)
   // Need a release store to ensure array/class length, mark word, and
   // object zeroing are visible before setting the klass non-NULL, for
   // concurrent collectors.
   obj->release_set_klass(klass);
+#else
+  obj->set_klass(klass);
 #endif
 }
 
--- a/src/hotspot/share/gc/shared/collectorPolicy.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/collectorPolicy.hpp	Fri May 04 08:50:01 2018 -0700
@@ -48,11 +48,8 @@
 // Forward declarations.
 class GenCollectorPolicy;
 class AdaptiveSizePolicy;
-#if INCLUDE_ALL_GCS
 class ConcurrentMarkSweepPolicy;
 class G1CollectorPolicy;
-#endif // INCLUDE_ALL_GCS
-
 class MarkSweepPolicy;
 
 class CollectorPolicy : public CHeapObj<mtGC> {
--- a/src/hotspot/share/gc/shared/gcConfig.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/gcConfig.cpp	Fri May 04 08:50:01 2018 -0700
@@ -23,16 +23,23 @@
  */
 
 #include "precompiled.hpp"
-#include "gc/serial/serialArguments.hpp"
 #include "gc/shared/gcConfig.hpp"
+#include "runtime/globals_extension.hpp"
 #include "runtime/java.hpp"
 #include "runtime/os.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/parallel/parallelArguments.hpp"
+#if INCLUDE_CMSGC
 #include "gc/cms/cmsArguments.hpp"
+#endif
+#if INCLUDE_G1GC
 #include "gc/g1/g1Arguments.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif
+#if INCLUDE_PARALLELGC
+#include "gc/parallel/parallelArguments.hpp"
+#endif
+#if INCLUDE_SERIALGC
+#include "gc/serial/serialArguments.hpp"
+#endif
 
 struct SupportedGC {
   bool&               _flag;
@@ -44,23 +51,19 @@
       _flag(flag), _name(name), _arguments(arguments), _hs_err_name(hs_err_name) {}
 };
 
-static SerialArguments   serialArguments;
-#if INCLUDE_ALL_GCS
-static ParallelArguments parallelArguments;
-static CMSArguments      cmsArguments;
-static G1Arguments       g1Arguments;
-#endif // INCLUDE_ALL_GCS
+     CMSGC_ONLY(static CMSArguments      cmsArguments;)
+      G1GC_ONLY(static G1Arguments       g1Arguments;)
+PARALLELGC_ONLY(static ParallelArguments parallelArguments;)
+  SERIALGC_ONLY(static SerialArguments   serialArguments;)
 
 // Table of supported GCs, for translating between command
 // line flag, CollectedHeap::Name and GCArguments instance.
 static const SupportedGC SupportedGCs[] = {
-  SupportedGC(UseSerialGC,        CollectedHeap::Serial,   serialArguments,   "serial gc"),
-#if INCLUDE_ALL_GCS
-  SupportedGC(UseParallelGC,      CollectedHeap::Parallel, parallelArguments, "parallel gc"),
-  SupportedGC(UseParallelOldGC,   CollectedHeap::Parallel, parallelArguments, "parallel gc"),
-  SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS,      cmsArguments,      "concurrent mark sweep gc"),
-  SupportedGC(UseG1GC,            CollectedHeap::G1,       g1Arguments,       "g1 gc"),
-#endif // INCLUDE_ALL_GCS
+       CMSGC_ONLY_ARG(SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS,      cmsArguments,      "concurrent mark sweep gc"))
+        G1GC_ONLY_ARG(SupportedGC(UseG1GC,            CollectedHeap::G1,       g1Arguments,       "g1 gc"))
+  PARALLELGC_ONLY_ARG(SupportedGC(UseParallelGC,      CollectedHeap::Parallel, parallelArguments, "parallel gc"))
+  PARALLELGC_ONLY_ARG(SupportedGC(UseParallelOldGC,   CollectedHeap::Parallel, parallelArguments, "parallel gc"))
+    SERIALGC_ONLY_ARG(SupportedGC(UseSerialGC,        CollectedHeap::Serial,   serialArguments,   "serial gc"))
 };
 
 #define FOR_EACH_SUPPORTED_GC(var) \
@@ -70,19 +73,25 @@
 bool GCConfig::_gc_selected_ergonomically = false;
 
 void GCConfig::select_gc_ergonomically() {
-#if INCLUDE_ALL_GCS
   if (os::is_server_class_machine()) {
+#if INCLUDE_G1GC
     FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
+#elif INCLUDE_PARALLELGC
+    FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true);
+#elif INCLUDE_SERIALGC
+    FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
+#endif
   } else {
+#if INCLUDE_SERIALGC
     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
+#endif
   }
-#else
-  UNSUPPORTED_OPTION(UseG1GC);
-  UNSUPPORTED_OPTION(UseParallelGC);
-  UNSUPPORTED_OPTION(UseParallelOldGC);
-  UNSUPPORTED_OPTION(UseConcMarkSweepGC);
-  FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
-#endif // INCLUDE_ALL_GCS
+
+  NOT_CMSGC(     UNSUPPORTED_OPTION(UseConcMarkSweepGC));
+  NOT_G1GC(      UNSUPPORTED_OPTION(UseG1GC);)
+  NOT_PARALLELGC(UNSUPPORTED_OPTION(UseParallelGC);)
+  NOT_PARALLELGC(UNSUPPORTED_OPTION(UseParallelOldGC));
+  NOT_SERIALGC(  UNSUPPORTED_OPTION(UseSerialGC);)
 }
 
 bool GCConfig::is_no_gc_selected() {
@@ -128,17 +137,25 @@
     _gc_selected_ergonomically = true;
   }
 
-  if (is_exactly_one_gc_selected()) {
-    // Exacly one GC selected
-    FOR_EACH_SUPPORTED_GC(gc) {
-      if (gc->_flag) {
-        return &gc->_arguments;
-      }
+  if (!is_exactly_one_gc_selected()) {
+    // More than one GC selected
+    vm_exit_during_initialization("Multiple garbage collectors selected", NULL);
+  }
+
+#if INCLUDE_PARALLELGC && !INCLUDE_SERIALGC
+  if (FLAG_IS_CMDLINE(UseParallelOldGC) && !UseParallelOldGC) {
+    vm_exit_during_initialization("This JVM build only supports UseParallelOldGC as the full GC");
+  }
+#endif
+
+  // Exactly one GC selected
+  FOR_EACH_SUPPORTED_GC(gc) {
+    if (gc->_flag) {
+      return &gc->_arguments;
     }
   }
 
-  // More than one GC selected
-  vm_exit_during_initialization("Multiple garbage collectors selected", NULL);
+  fatal("Should have found the selected GC");
 
   return NULL;
 }
--- a/src/hotspot/share/gc/shared/gcTrace.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/gcTrace.cpp	Fri May 04 08:50:01 2018 -0700
@@ -36,7 +36,7 @@
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/ticks.inline.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/evacuationInfo.hpp"
 #endif
 
@@ -184,7 +184,7 @@
   send_concurrent_mode_failure_event();
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 void G1MMUTracer::report_mmu(double time_slice_sec, double gc_time_sec, double max_time_sec) {
   send_g1_mmu_event(time_slice_sec * MILLIUNITS,
                     gc_time_sec * MILLIUNITS,
@@ -252,4 +252,4 @@
   _shared_gc_info.set_cause(cause);
 }
 
-#endif
+#endif // INCLUDE_G1GC
--- a/src/hotspot/share/gc/shared/gcTrace.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/gcTrace.hpp	Fri May 04 08:50:01 2018 -0700
@@ -34,7 +34,7 @@
 #include "memory/referenceType.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/ticks.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1YCTypes.hpp"
 #endif
 
@@ -97,7 +97,7 @@
   void* dense_prefix() const { return _dense_prefix; }
 };
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 
 class G1YoungGCInfo {
   G1YCType _type;
@@ -109,7 +109,7 @@
   G1YCType type() const { return _type; }
 };
 
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
 class GCTracer : public ResourceObj {
  protected:
@@ -232,7 +232,7 @@
   ParNewTracer() : YoungGCTracer(ParNew) {}
 };
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 class G1MMUTracer : public AllStatic {
   static void send_g1_mmu_event(double time_slice_ms, double gc_time_ms, double max_time_ms);
 
@@ -294,7 +294,7 @@
   G1FullGCTracer() : OldGCTracer(G1Full) {}
 };
 
-#endif
+#endif // INCLUDE_G1GC
 
 class CMSTracer : public OldGCTracer {
  public:
--- a/src/hotspot/share/gc/shared/gcTraceSend.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/gcTraceSend.cpp	Fri May 04 08:50:01 2018 -0700
@@ -31,11 +31,11 @@
 #include "runtime/os.hpp"
 #include "trace/traceBackend.hpp"
 #include "trace/tracing.hpp"
+#include "tracefiles/traceEventClasses.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/evacuationInfo.hpp"
 #include "gc/g1/g1YCTypes.hpp"
-#include "tracefiles/traceEventClasses.hpp"
 #endif
 
 // All GC dependencies against the trace framework is contained within this file.
@@ -188,7 +188,7 @@
   }
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 void G1NewTracer::send_g1_young_gc_event() {
   EventG1GarbageCollection e(UNTIMED);
   if (e.should_commit()) {
@@ -311,7 +311,7 @@
   }
 }
 
-#endif
+#endif // INCLUDE_G1GC
 
 static TraceStructVirtualSpace to_trace_struct(const VirtualSpaceSummary& summary) {
   TraceStructVirtualSpace space;
--- a/src/hotspot/share/gc/shared/gc_globals.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/gc_globals.hpp	Fri May 04 08:50:01 2018 -0700
@@ -25,12 +25,18 @@
 #ifndef SHARE_GC_SHARED_GC_GLOBALS_HPP
 #define SHARE_GC_SHARED_GC_GLOBALS_HPP
 
+#include "utilities/macros.hpp"
+#if INCLUDE_CMSGC
+#include "gc/cms/cms_globals.hpp"
+#endif
+#if INCLUDE_G1GC
+#include "gc/g1/g1_globals.hpp"
+#endif
+#if INCLUDE_PARALLELGC
+#include "gc/parallel/parallel_globals.hpp"
+#endif
+#if INCLUDE_SERIALGC
 #include "gc/serial/serial_globals.hpp"
-#include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/cms/cms_globals.hpp"
-#include "gc/g1/g1_globals.hpp"
-#include "gc/parallel/parallel_globals.hpp"
 #endif
 
 #define GC_FLAGS(develop,                                                   \
@@ -48,7 +54,7 @@
                  constraint,                                                \
                  writeable)                                                 \
                                                                             \
-  ALL_GCS_ONLY(GC_CMS_FLAGS(                                                \
+  CMSGC_ONLY(GC_CMS_FLAGS(                                                  \
     develop,                                                                \
     develop_pd,                                                             \
     product,                                                                \
@@ -64,7 +70,7 @@
     constraint,                                                             \
     writeable))                                                             \
                                                                             \
-  ALL_GCS_ONLY(GC_G1_FLAGS(                                                 \
+  G1GC_ONLY(GC_G1_FLAGS(                                                    \
     develop,                                                                \
     develop_pd,                                                             \
     product,                                                                \
@@ -80,7 +86,7 @@
     constraint,                                                             \
     writeable))                                                             \
                                                                             \
-  ALL_GCS_ONLY(GC_PARALLEL_FLAGS(                                           \
+  PARALLELGC_ONLY(GC_PARALLEL_FLAGS(                                        \
     develop,                                                                \
     develop_pd,                                                             \
     product,                                                                \
@@ -96,7 +102,7 @@
     constraint,                                                             \
     writeable))                                                             \
                                                                             \
-  GC_SERIAL_FLAGS(                                                          \
+  SERIALGC_ONLY(GC_SERIAL_FLAGS(                                            \
     develop,                                                                \
     develop_pd,                                                             \
     product,                                                                \
@@ -110,7 +116,7 @@
     lp64_product,                                                           \
     range,                                                                  \
     constraint,                                                             \
-    writeable)                                                              \
+    writeable))                                                             \
                                                                             \
   /* gc */                                                                  \
                                                                             \
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Fri May 04 08:50:01 2018 -0700
@@ -30,6 +30,7 @@
 #include "classfile/vmSymbols.hpp"
 #include "code/codeCache.hpp"
 #include "code/icBuffer.hpp"
+#include "gc/serial/defNewGeneration.hpp"
 #include "gc/shared/adaptiveSizePolicy.hpp"
 #include "gc/shared/cardTableBarrierSet.hpp"
 #include "gc/shared/cardTableRS.hpp"
@@ -516,7 +517,7 @@
     }
     gen->collect(full, clear_soft_refs, size, is_tlab);
     if (!rp->enqueuing_is_done()) {
-      ReferenceProcessorPhaseTimes pt(NULL, rp->num_q());
+      ReferenceProcessorPhaseTimes pt(NULL, rp->num_queues());
       rp->enqueue_discovered_references(NULL, &pt);
       pt.print_enqueue_phase();
     } else {
@@ -1250,12 +1251,14 @@
   return (GenCollectedHeap*) heap;
 }
 
+#if INCLUDE_SERIALGC
 void GenCollectedHeap::prepare_for_compaction() {
   // Start by compacting into same gen.
   CompactPoint cp(_old_gen);
   _old_gen->prepare_for_compaction(&cp);
   _young_gen->prepare_for_compaction(&cp);
 }
+#endif // INCLUDE_SERIALGC
 
 void GenCollectedHeap::verify(VerifyOption option /* ignored */) {
   log_debug(gc, verify)("%s", _old_gen->name());
--- a/src/hotspot/share/gc/shared/genCollectedHeap.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.hpp	Fri May 04 08:50:01 2018 -0700
@@ -502,10 +502,12 @@
   void check_for_non_bad_heap_word_value(HeapWord* addr,
     size_t size) PRODUCT_RETURN;
 
+#if INCLUDE_SERIALGC
   // For use by mark-sweep.  As implemented, mark-sweep-compact is global
   // in an essential way: compaction is performed across generations, by
   // iterating over spaces.
   void prepare_for_compaction();
+#endif
 
   // Perform a full collection of the generations up to and including max_generation.
   // This is the low level interface used by the public versions of
--- a/src/hotspot/share/gc/shared/genMemoryPools.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/genMemoryPools.cpp	Fri May 04 08:50:01 2018 -0700
@@ -23,10 +23,12 @@
  */
 
 #include "precompiled.hpp"
-#include "gc/serial/defNewGeneration.hpp"
 #include "gc/shared/generation.hpp"
 #include "gc/shared/genMemoryPools.hpp"
 #include "gc/shared/space.hpp"
+#if INCLUDE_SERIALGC
+#include "gc/serial/defNewGeneration.hpp"
+#endif
 
 ContiguousSpacePool::ContiguousSpacePool(ContiguousSpace* space,
                                          const char* name,
@@ -48,6 +50,8 @@
   return MemoryUsage(initial_size(), used, committed, maxSize);
 }
 
+#if INCLUDE_SERIALGC
+
 SurvivorContiguousSpacePool::SurvivorContiguousSpacePool(DefNewGeneration* young_gen,
                                                          const char* name,
                                                          size_t max_size,
@@ -72,6 +76,8 @@
   return MemoryUsage(initial_size(), used, committed, maxSize);
 }
 
+#endif // INCLUDE_SERIALGC
+
 GenerationPool::GenerationPool(Generation* gen,
                                const char* name,
                                bool support_usage_threshold) :
--- a/src/hotspot/share/gc/shared/genOopClosures.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/genOopClosures.cpp	Fri May 04 08:50:01 2018 -0700
@@ -22,12 +22,16 @@
  */
 
 #include "precompiled.hpp"
-#include "gc/serial/serial_specialized_oop_closures.hpp"
 #include "gc/shared/genOopClosures.inline.hpp"
 #include "memory/iterator.inline.hpp"
+#if INCLUDE_SERIALGC
+#include "gc/serial/serial_specialized_oop_closures.hpp"
+#endif
 
 void FilteringClosure::do_oop(oop* p)       { do_oop_nv(p); }
 void FilteringClosure::do_oop(narrowOop* p) { do_oop_nv(p); }
 
+#if INCLUDE_SERIALGC
 // Generate Serial GC specialized oop_oop_iterate functions.
 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(ALL_KLASS_OOP_OOP_ITERATE_DEFN)
+#endif
--- a/src/hotspot/share/gc/shared/genOopClosures.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/genOopClosures.hpp	Fri May 04 08:50:01 2018 -0700
@@ -94,6 +94,7 @@
   void do_cld_barrier();
 };
 
+#if INCLUDE_SERIALGC
 
 // Closure for scanning DefNewGeneration.
 //
@@ -132,6 +133,8 @@
   inline void do_oop_nv(narrowOop* p);
 };
 
+#endif // INCLUDE_SERIALGC
+
 class CLDScanClosure: public CLDClosure {
   OopsInClassLoaderDataOrGenClosure*   _scavenge_closure;
   // true if the the modified oops state should be saved.
@@ -161,6 +164,8 @@
   inline bool do_metadata_nv()        { assert(!_cl->do_metadata(), "assumption broken, must change to 'return _cl->do_metadata()'"); return false; }
 };
 
+#if INCLUDE_SERIALGC
+
 // Closure for scanning DefNewGeneration's weak references.
 // NOTE: very much like ScanClosure but not derived from
 //  OopsInGenClosure -- weak references are processed all
@@ -178,4 +183,6 @@
   inline void do_oop_nv(narrowOop* p);
 };
 
+#endif // INCLUDE_SERIALGC
+
 #endif // SHARE_VM_GC_SHARED_GENOOPCLOSURES_HPP
--- a/src/hotspot/share/gc/shared/genOopClosures.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/genOopClosures.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -25,7 +25,6 @@
 #ifndef SHARE_VM_GC_SHARED_GENOOPCLOSURES_INLINE_HPP
 #define SHARE_VM_GC_SHARED_GENOOPCLOSURES_INLINE_HPP
 
-#include "gc/serial/defNewGeneration.hpp"
 #include "gc/shared/cardTableRS.hpp"
 #include "gc/shared/genCollectedHeap.hpp"
 #include "gc/shared/genOopClosures.hpp"
@@ -34,6 +33,9 @@
 #include "oops/access.inline.hpp"
 #include "oops/compressedOops.inline.hpp"
 #include "oops/oop.inline.hpp"
+#if INCLUDE_SERIALGC
+#include "gc/serial/defNewGeneration.inline.hpp"
+#endif
 
 inline OopsInGenClosure::OopsInGenClosure(Generation* gen) :
   ExtendedOopClosure(gen->ref_processor()), _orig_gen(gen), _rs(NULL) {
@@ -78,6 +80,8 @@
   }
 }
 
+#if INCLUDE_SERIALGC
+
 // NOTE! Any changes made here should also be made
 // in FastScanClosure::do_oop_work()
 template <class T> inline void ScanClosure::do_oop_work(T* p) {
@@ -129,6 +133,8 @@
 inline void FastScanClosure::do_oop_nv(oop* p)       { FastScanClosure::do_oop_work(p); }
 inline void FastScanClosure::do_oop_nv(narrowOop* p) { FastScanClosure::do_oop_work(p); }
 
+#endif // INCLUDE_SERIALGC
+
 template <class T> void FilteringClosure::do_oop_work(T* p) {
   T heap_oop = RawAccess<>::oop_load(p);
   if (!CompressedOops::is_null(heap_oop)) {
@@ -142,6 +148,8 @@
 void FilteringClosure::do_oop_nv(oop* p)       { FilteringClosure::do_oop_work(p); }
 void FilteringClosure::do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); }
 
+#if INCLUDE_SERIALGC
+
 // Note similarity to ScanClosure; the difference is that
 // the barrier set is taken care of outside this closure.
 template <class T> inline void ScanWeakRefClosure::do_oop_work(T* p) {
@@ -158,4 +166,6 @@
 inline void ScanWeakRefClosure::do_oop_nv(oop* p)       { ScanWeakRefClosure::do_oop_work(p); }
 inline void ScanWeakRefClosure::do_oop_nv(narrowOop* p) { ScanWeakRefClosure::do_oop_work(p); }
 
+#endif // INCLUDE_SERIALGC
+
 #endif // SHARE_VM_GC_SHARED_GENOOPCLOSURES_INLINE_HPP
--- a/src/hotspot/share/gc/shared/generation.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/generation.cpp	Fri May 04 08:50:01 2018 -0700
@@ -23,7 +23,6 @@
  */
 
 #include "precompiled.hpp"
-#include "gc/serial/genMarkSweep.hpp"
 #include "gc/shared/blockOffsetTable.inline.hpp"
 #include "gc/shared/cardTableRS.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
@@ -77,7 +76,8 @@
 void Generation::ref_processor_init() {
   assert(_ref_processor == NULL, "a reference processor already exists");
   assert(!_reserved.is_empty(), "empty generation?");
-  _ref_processor = new ReferenceProcessor(_reserved);    // a vanilla reference processor
+  _span_based_discoverer.set_span(_reserved);
+  _ref_processor = new ReferenceProcessor(&_span_based_discoverer);    // a vanilla reference processor
   if (_ref_processor == NULL) {
     vm_exit_during_initialization("Could not allocate ReferenceProcessor object");
   }
@@ -303,6 +303,8 @@
   space_iterate(&blk);
 }
 
+#if INCLUDE_SERIALGC
+
 void Generation::prepare_for_compaction(CompactPoint* cp) {
   // Generic implementation, can be specialized
   CompactibleSpace* space = first_compaction_space();
@@ -333,3 +335,5 @@
     sp = sp->next_compaction_space();
   }
 }
+
+#endif // INCLUDE_SERIALGC
--- a/src/hotspot/share/gc/shared/generation.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/generation.hpp	Fri May 04 08:50:01 2018 -0700
@@ -100,6 +100,7 @@
   VirtualSpace _virtual_space;
 
   // ("Weak") Reference processing support
+  SpanSubjectToDiscoveryClosure _span_based_discoverer;
   ReferenceProcessor* _ref_processor;
 
   // Performance Counters
@@ -400,6 +401,7 @@
   GCStats* gc_stats() const { return _gc_stats; }
   virtual void update_gc_stats(Generation* current_generation, bool full) {}
 
+#if INCLUDE_SERIALGC
   // Mark sweep support phase2
   virtual void prepare_for_compaction(CompactPoint* cp);
   // Mark sweep support phase3
@@ -407,6 +409,7 @@
   // Mark sweep support phase4
   virtual void compact();
   virtual void post_compact() { ShouldNotReachHere(); }
+#endif
 
   // Support for CMS's rescan. In this general form we return a pointer
   // to an abstract object that can be used, based on specific previously
--- a/src/hotspot/share/gc/shared/generationSpec.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/generationSpec.cpp	Fri May 04 08:50:01 2018 -0700
@@ -23,28 +23,32 @@
  */
 
 #include "precompiled.hpp"
-#include "gc/serial/defNewGeneration.hpp"
-#include "gc/serial/tenuredGeneration.hpp"
 #include "gc/shared/cardTableRS.hpp"
 #include "gc/shared/generationSpec.hpp"
 #include "memory/binaryTreeDictionary.hpp"
 #include "memory/filemap.hpp"
 #include "runtime/java.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
 #include "gc/cms/concurrentMarkSweepGeneration.hpp"
 #include "gc/cms/parNewGeneration.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif
+#if INCLUDE_SERIALGC
+#include "gc/serial/defNewGeneration.hpp"
+#include "gc/serial/tenuredGeneration.hpp"
+#endif
 
 Generation* GenerationSpec::init(ReservedSpace rs, CardTableRS* remset) {
   switch (name()) {
+#if INCLUDE_SERIALGC
     case Generation::DefNew:
       return new DefNewGeneration(rs, init_size());
 
     case Generation::MarkSweepCompact:
       return new TenuredGeneration(rs, init_size(), remset);
+#endif
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
     case Generation::ParNew:
       return new ParNewGeneration(rs, init_size());
 
@@ -64,7 +68,7 @@
 
       return g;
     }
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_CMSGC
 
     default:
       guarantee(false, "unrecognized GenerationName");
--- a/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp	Fri May 04 08:50:01 2018 -0700
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "gc/shared/collectedHeap.hpp"
 #include "gc/shared/collectorPolicy.hpp"
+#include "gc/shared/gcConfig.hpp"
 #include "gc/shared/jvmFlagConstraintsGC.hpp"
 #include "gc/shared/plab.hpp"
 #include "gc/shared/threadLocalAllocBuffer.hpp"
@@ -36,9 +37,13 @@
 #include "utilities/align.hpp"
 #include "utilities/defaultStream.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
 #include "gc/cms/jvmFlagConstraintsCMS.hpp"
+#endif
+#if INCLUDE_G1GC
 #include "gc/g1/jvmFlagConstraintsG1.hpp"
+#endif
+#if INCLUDE_PARALLELGC
 #include "gc/parallel/jvmFlagConstraintsParallel.hpp"
 #endif
 #ifdef COMPILER1
@@ -60,12 +65,14 @@
 JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) {
   JVMFlag::Error status = JVMFlag::SUCCESS;
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   status = ParallelGCThreadsConstraintFuncParallel(value, verbose);
   if (status != JVMFlag::SUCCESS) {
     return status;
   }
+#endif
 
+#if INCLUDE_CMSGC
   status = ParallelGCThreadsConstraintFuncCMS(value, verbose);
   if (status != JVMFlag::SUCCESS) {
     return status;
@@ -78,42 +85,44 @@
 // As ConcGCThreads should be smaller than ParallelGCThreads,
 // we need constraint function.
 JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) {
-#if INCLUDE_ALL_GCS
   // CMS and G1 GCs use ConcGCThreads.
-  if ((UseConcMarkSweepGC || UseG1GC) && (value > ParallelGCThreads)) {
+  if ((GCConfig::is_gc_selected(CollectedHeap::CMS) ||
+       GCConfig::is_gc_selected(CollectedHeap::G1)) && (value > ParallelGCThreads)) {
     CommandLineError::print(verbose,
                             "ConcGCThreads (" UINT32_FORMAT ") must be "
                             "less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n",
                             value, ParallelGCThreads);
     return JVMFlag::VIOLATES_CONSTRAINT;
   }
-#endif
+
   return JVMFlag::SUCCESS;
 }
 
 static JVMFlag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) {
-#if INCLUDE_ALL_GCS
-  if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value < PLAB::min_size())) {
+  if ((GCConfig::is_gc_selected(CollectedHeap::CMS) ||
+       GCConfig::is_gc_selected(CollectedHeap::G1)  ||
+       GCConfig::is_gc_selected(CollectedHeap::Parallel)) && (value < PLAB::min_size())) {
     CommandLineError::print(verbose,
                             "%s (" SIZE_FORMAT ") must be "
                             "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n",
                             name, value, PLAB::min_size());
     return JVMFlag::VIOLATES_CONSTRAINT;
   }
-#endif // INCLUDE_ALL_GCS
+
   return JVMFlag::SUCCESS;
 }
 
 JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
-#if INCLUDE_ALL_GCS
-  if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value > PLAB::max_size())) {
+  if ((GCConfig::is_gc_selected(CollectedHeap::CMS) ||
+       GCConfig::is_gc_selected(CollectedHeap::G1)  ||
+       GCConfig::is_gc_selected(CollectedHeap::Parallel)) && (value > PLAB::max_size())) {
     CommandLineError::print(verbose,
                             "%s (" SIZE_FORMAT ") must be "
                             "less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
                             name, value, PLAB::max_size());
     return JVMFlag::VIOLATES_CONSTRAINT;
   }
-#endif // INCLUDE_ALL_GCS
+
   return JVMFlag::SUCCESS;
 }
 
@@ -133,13 +142,15 @@
 JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) {
   JVMFlag::Error status = JVMFlag::SUCCESS;
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
   if (UseConcMarkSweepGC) {
     return OldPLABSizeConstraintFuncCMS(value, verbose);
-  } else {
+  } else
+#endif
+  {
     status = MinMaxPLABSizeBounds("OldPLABSize", value, verbose);
   }
-#endif
+
   return status;
 }
 
@@ -221,7 +232,7 @@
 }
 
 JVMFlag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) {
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   JVMFlag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose);
   if (status != JVMFlag::SUCCESS) {
     return status;
@@ -232,7 +243,7 @@
 }
 
 JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) {
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   JVMFlag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose);
   if (status != JVMFlag::SUCCESS) {
     return status;
@@ -253,7 +264,7 @@
 }
 
 JVMFlag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) {
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   JVMFlag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose);
   if (status != JVMFlag::SUCCESS) {
     return status;
@@ -264,7 +275,7 @@
 }
 
 JVMFlag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) {
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   JVMFlag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose);
   if (status != JVMFlag::SUCCESS) {
     return status;
@@ -302,7 +313,7 @@
 static JVMFlag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
   size_t heap_alignment;
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   if (UseG1GC) {
     // For G1 GC, we don't know until G1CollectorPolicy is created.
     heap_alignment = MaxSizeForHeapAlignmentG1();
@@ -343,7 +354,7 @@
 }
 
 JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose);
   if (status != JVMFlag::SUCCESS) {
     return status;
--- a/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.hpp	Fri May 04 08:50:01 2018 -0700
@@ -27,9 +27,13 @@
 
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
 #include "gc/cms/jvmFlagConstraintsCMS.hpp"
+#endif
+#if INCLUDE_G1GC
 #include "gc/g1/jvmFlagConstraintsG1.hpp"
+#endif
+#if INCLUDE_PARALLELGC
 #include "gc/parallel/jvmFlagConstraintsParallel.hpp"
 #endif
 
--- a/src/hotspot/share/gc/shared/oopStorage.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/oopStorage.cpp	Fri May 04 08:50:01 2018 -0700
@@ -28,20 +28,22 @@
 #include "logging/log.hpp"
 #include "logging/logStream.hpp"
 #include "memory/allocation.inline.hpp"
-#include "memory/resourceArea.hpp"
 #include "runtime/atomic.hpp"
+#include "runtime/globals.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/mutex.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "runtime/orderAccess.inline.hpp"
 #include "runtime/safepoint.hpp"
 #include "runtime/stubRoutines.hpp"
+#include "runtime/thread.hpp"
 #include "utilities/align.hpp"
 #include "utilities/count_trailing_zeros.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/ostream.hpp"
+#include "utilities/spinYield.hpp"
 
 OopStorage::BlockEntry::BlockEntry() : _prev(NULL), _next(NULL) {}
 
@@ -108,6 +110,90 @@
   }
 }
 
+OopStorage::BlockArray::BlockArray(size_t size) :
+  _size(size),
+  _block_count(0),
+  _refcount(0)
+{}
+
+OopStorage::BlockArray::~BlockArray() {
+  assert(_refcount == 0, "precondition");
+}
+
+OopStorage::BlockArray* OopStorage::BlockArray::create(size_t size, AllocFailType alloc_fail) {
+  size_t size_in_bytes = blocks_offset() + sizeof(Block*) * size;
+  void* mem = NEW_C_HEAP_ARRAY3(char, size_in_bytes, mtGC, CURRENT_PC, alloc_fail);
+  if (mem == NULL) return NULL;
+  return new (mem) BlockArray(size);
+}
+
+void OopStorage::BlockArray::destroy(BlockArray* ba) {
+  ba->~BlockArray();
+  FREE_C_HEAP_ARRAY(char, ba);
+}
+
+size_t OopStorage::BlockArray::size() const {
+  return _size;
+}
+
+size_t OopStorage::BlockArray::block_count() const {
+  return _block_count;
+}
+
+size_t OopStorage::BlockArray::block_count_acquire() const {
+  return OrderAccess::load_acquire(&_block_count);
+}
+
+void OopStorage::BlockArray::increment_refcount() const {
+  int new_value = Atomic::add(1, &_refcount);
+  assert(new_value >= 1, "negative refcount %d", new_value - 1);
+}
+
+bool OopStorage::BlockArray::decrement_refcount() const {
+  int new_value = Atomic::sub(1, &_refcount);
+  assert(new_value >= 0, "negative refcount %d", new_value);
+  return new_value == 0;
+}
+
+bool OopStorage::BlockArray::push(Block* block) {
+  size_t index = _block_count;
+  if (index < _size) {
+    block->set_active_index(index);
+    *block_ptr(index) = block;
+    // Use a release_store to ensure all the setup is complete before
+    // making the block visible.
+    OrderAccess::release_store(&_block_count, index + 1);
+    return true;
+  } else {
+    return false;
+  }
+}
+
+void OopStorage::BlockArray::remove(Block* block) {
+  assert(_block_count > 0, "array is empty");
+  size_t index = block->active_index();
+  assert(*block_ptr(index) == block, "block not present");
+  size_t last_index = _block_count - 1;
+  Block* last_block = *block_ptr(last_index);
+  last_block->set_active_index(index);
+  *block_ptr(index) = last_block;
+  _block_count = last_index;
+}
+
+void OopStorage::BlockArray::copy_from(const BlockArray* from) {
+  assert(_block_count == 0, "array must be empty");
+  size_t count = from->_block_count;
+  assert(count <= _size, "precondition");
+  Block* const* from_ptr = from->block_ptr(0);
+  Block** to_ptr = block_ptr(0);
+  for (size_t i = 0; i < count; ++i) {
+    Block* block = *from_ptr++;
+    assert(block->active_index() == i, "invariant");
+    *to_ptr++ = block;
+  }
+  _block_count = count;
+}
+
 // Blocks start with an array of BitsPerWord oop entries.  That array
 // is divided into conceptual BytesPerWord sections of BitsPerByte
 // entries.  Blocks are allocated aligned on section boundaries, for
@@ -125,7 +211,7 @@
   _allocated_bitmask(0),
   _owner(owner),
   _memory(memory),
-  _active_entry(),
+  _active_index(0),
   _allocate_entry(),
   _deferred_updates_next(NULL),
   _release_refcount(0)
@@ -146,10 +232,6 @@
   const_cast<OopStorage* volatile&>(_owner) = NULL;
 }
 
-const OopStorage::BlockEntry& OopStorage::Block::get_active_entry(const Block& block) {
-  return block._active_entry;
-}
-
 const OopStorage::BlockEntry& OopStorage::Block::get_allocate_entry(const Block& block) {
   return block._allocate_entry;
 }
@@ -204,6 +286,20 @@
   return (base <= ptr) && (ptr < (base + ARRAY_SIZE(_data)));
 }
 
+size_t OopStorage::Block::active_index() const {
+  return _active_index;
+}
+
+void OopStorage::Block::set_active_index(size_t index) {
+  _active_index = index;
+}
+
+size_t OopStorage::Block::active_index_safe(const Block* block) {
+  STATIC_ASSERT(sizeof(intptr_t) == sizeof(block->_active_index));
+  assert(CanUseSafeFetchN(), "precondition");
+  return SafeFetchN((intptr_t*)&block->_active_index, 0);
+}
+
 unsigned OopStorage::Block::get_index(const oop* ptr) const {
   assert(contains(ptr), PTR_FORMAT " not in block " PTR_FORMAT, p2i(ptr), p2i(this));
   return static_cast<unsigned>(ptr - get_pointer(0));
@@ -246,7 +342,7 @@
 
 // This can return a false positive if ptr is not contained by some
 // block.  For some uses, it is a precondition that ptr is valid,
-// e.g. contained in some block in owner's _active_list.  Other uses
+// e.g. contained in some block in owner's _active_array.  Other uses
 // require additional validation of the result.
 OopStorage::Block*
 OopStorage::Block::block_for_ptr(const OopStorage* owner, const oop* ptr) {
@@ -280,12 +376,12 @@
 // Allocation involves the _allocate_list, which contains a subset of the
 // blocks owned by a storage object.  This is a doubly-linked list, linked
 // through dedicated fields in the blocks.  Full blocks are removed from this
-// list, though they are still present in the _active_list.  Empty blocks are
+// list, though they are still present in the _active_array.  Empty blocks are
 // kept at the end of the _allocate_list, to make it easy for empty block
 // deletion to find them.
 //
 // allocate(), and delete_empty_blocks_concurrent() lock the
-// _allocate_mutex while performing any list modifications.
+// _allocate_mutex while performing any list and array modifications.
 //
 // allocate() and release() update a block's _allocated_bitmask using CAS
 // loops.  This prevents loss of updates even though release() performs
@@ -299,7 +395,7 @@
 //
 // release() is performed lock-free. release() first looks up the block for
 // the entry, using address alignment to find the enclosing block (thereby
-// avoiding iteration over the _active_list).  Once the block has been
+// avoiding iteration over the _active_array).  Once the block has been
 // determined, its _allocated_bitmask needs to be updated, and its position in
 // the _allocate_list may need to be updated.  There are two cases:
 //
@@ -340,7 +436,7 @@
           // Failed to make new block, no other thread made a block
           // available while the mutex was released, and didn't get
           // one from a deferred update either, so return failure.
-          log_info(oopstorage, ref)("%s: failed allocation", name());
+          log_info(oopstorage, ref)("%s: failed block allocation", name());
           return NULL;
         }
       }
@@ -348,17 +444,21 @@
       // Add new block to storage.
       log_info(oopstorage, blocks)("%s: new block " PTR_FORMAT, name(), p2i(block));
 
+      // Add new block to the _active_array, growing if needed.
+      if (!_active_array->push(block)) {
+        if (expand_active_array()) {
+          guarantee(_active_array->push(block), "push failed after expansion");
+        } else {
+          log_info(oopstorage, blocks)("%s: failed active array expand", name());
+          Block::delete_block(*block);
+          return NULL;
+        }
+      }
       // Add to end of _allocate_list.  The mutex release allowed
       // other threads to add blocks to the _allocate_list.  We prefer
       // to allocate from non-empty blocks, to allow empty blocks to
       // be deleted.
       _allocate_list.push_back(*block);
-      // Add to front of _active_list, and then record as the head
-      // block, for concurrent iteration protocol.
-      _active_list.push_front(*block);
-      ++_block_count;
-      // Ensure all setup of block is complete before making it visible.
-      OrderAccess::release_store(&_active_head, block);
     }
     block = _allocate_list.head();
   }
@@ -383,6 +483,123 @@
   return result;
 }
 
+// Create a new, larger, active array with the same content as the
+// current array, and then replace, relinquishing the old array.
+// Return true if the array was successfully expanded, false to
+// indicate allocation failure.
+bool OopStorage::expand_active_array() {
+  assert_lock_strong(_allocate_mutex);
+  BlockArray* old_array = _active_array;
+  size_t new_size = 2 * old_array->size();
+  log_info(oopstorage, blocks)("%s: expand active array " SIZE_FORMAT,
+                               name(), new_size);
+  BlockArray* new_array = BlockArray::create(new_size, AllocFailStrategy::RETURN_NULL);
+  if (new_array == NULL) return false;
+  new_array->copy_from(old_array);
+  replace_active_array(new_array);
+  relinquish_block_array(old_array);
+  return true;
+}
+
+OopStorage::ProtectActive::ProtectActive() : _enter(0), _exit() {}
+
+// Begin read-side critical section.
+uint OopStorage::ProtectActive::read_enter() {
+  return Atomic::add(2u, &_enter);
+}
+
+// End read-side critical section.
+void OopStorage::ProtectActive::read_exit(uint enter_value) {
+  Atomic::add(2u, &_exit[enter_value & 1]);
+}
+
+// Wait until all readers that entered the critical section before
+// synchronization have exited that critical section.
+void OopStorage::ProtectActive::write_synchronize() {
+  SpinYield spinner;
+  // Determine old and new exit counters, based on bit0 of the
+  // on-entry _enter counter.
+  uint value = OrderAccess::load_acquire(&_enter);
+  volatile uint* new_ptr = &_exit[(value + 1) & 1];
+  // Atomically change the in-use exit counter to the new counter, by
+  // adding 1 to the _enter counter (flipping bit0 between 0 and 1)
+  // and initializing the new exit counter to that enter value.  Note:
+  // The new exit counter is not being used by read operations until
+  // this change succeeds.
+  uint old;
+  do {
+    old = value;
+    *new_ptr = ++value;
+    value = Atomic::cmpxchg(value, &_enter, old);
+  } while (old != value);
+  // Readers that entered the critical section before we changed the
+  // selected exit counter will use the old exit counter.  Readers
+  // entering after the change will use the new exit counter.  Wait
+  // for all the critical sections started before the change to
+  // complete, e.g. for the value of old_ptr to catch up with old.
+  volatile uint* old_ptr = &_exit[old & 1];
+  while (old != OrderAccess::load_acquire(old_ptr)) {
+    spinner.wait();
+  }
+}
+
+// Make new_array the _active_array.  Increments new_array's refcount
+// to account for the new reference.  The assignment is atomic wrto
+// obtain_active_array; once this function returns, it is safe for the
+// caller to relinquish the old array.
+void OopStorage::replace_active_array(BlockArray* new_array) {
+  // Caller has the old array that is the current value of _active_array.
+  // Update new_array refcount to account for the new reference.
+  new_array->increment_refcount();
+  // Install new_array, ensuring its initialization is complete first.
+  OrderAccess::release_store(&_active_array, new_array);
+  // Wait for any readers that could read the old array from _active_array.
+  _protect_active.write_synchronize();
+  // All obtain critical sections that could see the old array have
+  // completed, having incremented the refcount of the old array.  The
+  // caller can now safely relinquish the old array.
+}
+
+// Atomically (wrto replace_active_array) get the active array and
+// increment its refcount.  This provides safe access to the array,
+// even if an allocate operation expands and replaces the value of
+// _active_array.  The caller must relinquish the array when done
+// using it.
+OopStorage::BlockArray* OopStorage::obtain_active_array() const {
+  uint enter_value = _protect_active.read_enter();
+  BlockArray* result = OrderAccess::load_acquire(&_active_array);
+  result->increment_refcount();
+  _protect_active.read_exit(enter_value);
+  return result;
+}
+
+// Decrement refcount of array and destroy if refcount is zero.
+void OopStorage::relinquish_block_array(BlockArray* array) const {
+  if (array->decrement_refcount()) {
+    assert(array != _active_array, "invariant");
+    BlockArray::destroy(array);
+  }
+}
+
+class OopStorage::WithActiveArray : public StackObj {
+  const OopStorage* _storage;
+  BlockArray* _active_array;
+
+public:
+  WithActiveArray(const OopStorage* storage) :
+    _storage(storage),
+    _active_array(storage->obtain_active_array())
+  {}
+
+  ~WithActiveArray() {
+    _storage->relinquish_block_array(_active_array);
+  }
+
+  BlockArray& active_array() const {
+    return *_active_array;
+  }
+};
+
 OopStorage::Block* OopStorage::find_block_or_null(const oop* ptr) const {
   assert(ptr != NULL, "precondition");
   return Block::block_for_ptr(this, ptr);
@@ -392,7 +609,6 @@
                                     uintx old_allocated,
                                     const OopStorage* owner,
                                     const void* block) {
-  ResourceMark rm;
   Log(oopstorage, blocks) log;
   LogStream ls(log.debug());
   if (is_full_bitmask(old_allocated)) {
@@ -546,20 +762,21 @@
   return dup;
 }
 
+const size_t initial_active_array_size = 8;
+
 OopStorage::OopStorage(const char* name,
                        Mutex* allocate_mutex,
                        Mutex* active_mutex) :
   _name(dup_name(name)),
-  _active_list(&Block::get_active_entry),
+  _active_array(BlockArray::create(initial_active_array_size)),
   _allocate_list(&Block::get_allocate_entry),
-  _active_head(NULL),
   _deferred_updates(NULL),
   _allocate_mutex(allocate_mutex),
   _active_mutex(active_mutex),
   _allocation_count(0),
-  _block_count(0),
   _concurrent_iteration_active(false)
 {
+  _active_array->increment_refcount();
   assert(_active_mutex->rank() < _allocate_mutex->rank(),
          "%s: active_mutex must have lower rank than allocate_mutex", _name);
   assert(_active_mutex->_safepoint_check_required != Mutex::_safepoint_check_always,
@@ -583,10 +800,13 @@
   while ((block = _allocate_list.head()) != NULL) {
     _allocate_list.unlink(*block);
   }
-  while ((block = _active_list.head()) != NULL) {
-    _active_list.unlink(*block);
+  bool unreferenced = _active_array->decrement_refcount();
+  assert(unreferenced, "deleting storage while _active_array is referenced");
+  for (size_t i = _active_array->block_count(); 0 < i; ) {
+    block = _active_array->at(--i);
     Block::delete_block(*block);
   }
+  BlockArray::destroy(_active_array);
   FREE_C_HEAP_ARRAY(char, _name);
 }
 
@@ -598,16 +818,13 @@
   // Don't interfere with a concurrent iteration.
   if (_concurrent_iteration_active) return;
   // Delete empty (and otherwise deletable) blocks from end of _allocate_list.
-  for (const Block* block = _allocate_list.ctail();
+  for (Block* block = _allocate_list.tail();
        (block != NULL) && block->is_deletable();
-       block = _allocate_list.ctail()) {
-    _active_list.unlink(*block);
+       block = _allocate_list.tail()) {
+    _active_array->remove(block);
     _allocate_list.unlink(*block);
     delete_empty_block(*block);
-    --_block_count;
   }
-  // Update _active_head, in case current value was in deleted set.
-  _active_head = _active_list.head();
 }
 
 void OopStorage::delete_empty_blocks_concurrent() {
@@ -616,14 +833,14 @@
   // release the mutex across the block deletions.  Set an upper bound
   // on how many blocks we'll try to release, so other threads can't
   // cause an unbounded stay in this function.
-  size_t limit = _block_count;
+  size_t limit = block_count();
 
   for (size_t i = 0; i < limit; ++i) {
     // Additional updates might become available while we dropped the
     // lock.  But limit number processed to limit lock duration.
     reduce_deferred_updates();
 
-    const Block* block = _allocate_list.ctail();
+    Block* block = _allocate_list.tail();
     if ((block == NULL) || !block->is_deletable()) {
       // No block to delete, so done.  There could be more pending
       // deferred updates that could give us more work to do; deal with
@@ -635,12 +852,7 @@
       MutexLockerEx aml(_active_mutex, Mutex::_no_safepoint_check_flag);
       // Don't interfere with a concurrent iteration.
       if (_concurrent_iteration_active) return;
-      // Remove block from _active_list, updating head if needed.
-      _active_list.unlink(*block);
-      --_block_count;
-      if (block == _active_head) {
-        _active_head = _active_list.head();
-      }
+      _active_array->remove(block);
     }
     // Remove block from _allocate_list and delete it.
     _allocate_list.unlink(*block);
@@ -653,18 +865,17 @@
 OopStorage::EntryStatus OopStorage::allocation_status(const oop* ptr) const {
   const Block* block = find_block_or_null(ptr);
   if (block != NULL) {
-    // Verify block is a real block.  For now, simple linear search.
-    // Do something more clever if this is a performance bottleneck.
+    // Prevent block deletion and _active_array modification.
     MutexLockerEx ml(_allocate_mutex, Mutex::_no_safepoint_check_flag);
-    for (const Block* check_block = _active_list.chead();
-         check_block != NULL;
-         check_block = _active_list.next(*check_block)) {
-      if (check_block == block) {
-        if ((block->allocated_bitmask() & block->bitmask_for_entry(ptr)) != 0) {
-          return ALLOCATED_ENTRY;
-        } else {
-          return UNALLOCATED_ENTRY;
-        }
+    // Block could be a false positive, so get index carefully.
+    size_t index = Block::active_index_safe(block);
+    if ((index < _active_array->block_count()) &&
+        (block == _active_array->at(index)) &&
+        block->contains(ptr)) {
+      if ((block->allocated_bitmask() & block->bitmask_for_entry(ptr)) != 0) {
+        return ALLOCATED_ENTRY;
+      } else {
+        return UNALLOCATED_ENTRY;
       }
     }
   }
@@ -676,30 +887,50 @@
 }
 
 size_t OopStorage::block_count() const {
-  return _block_count;
+  WithActiveArray wab(this);
+  // Count access is racy, but don't care.
+  return wab.active_array().block_count();
 }
 
 size_t OopStorage::total_memory_usage() const {
   size_t total_size = sizeof(OopStorage);
   total_size += strlen(name()) + 1;
-  total_size += block_count() * Block::allocation_size();
+  total_size += sizeof(BlockArray);
+  WithActiveArray wab(this);
+  const BlockArray& blocks = wab.active_array();
+  // Count access is racy, but don't care.
+  total_size += blocks.block_count() * Block::allocation_size();
+  total_size += blocks.size() * sizeof(Block*);
   return total_size;
 }
 
 // Parallel iteration support
 
-static char* not_started_marker_dummy = NULL;
-static void* const not_started_marker = &not_started_marker_dummy;
+uint OopStorage::BasicParState::default_estimated_thread_count(bool concurrent) {
+  return concurrent ? ConcGCThreads : ParallelGCThreads;
+}
 
-OopStorage::BasicParState::BasicParState(OopStorage* storage, bool concurrent) :
+OopStorage::BasicParState::BasicParState(const OopStorage* storage,
+                                         uint estimated_thread_count,
+                                         bool concurrent) :
   _storage(storage),
-  _next_block(not_started_marker),
+  _active_array(_storage->obtain_active_array()),
+  _block_count(0),              // initialized properly below
+  _next_block(0),
+  _estimated_thread_count(estimated_thread_count),
   _concurrent(concurrent)
 {
+  assert(estimated_thread_count > 0, "estimated thread count must be positive");
   update_iteration_state(true);
+  // Get the block count *after* iteration state updated, so concurrent
+  // empty block deletion is suppressed and can't reduce the count.  But
+  // ensure the count we use was written after the block with that count
+  // was fully initialized; see BlockArray::push.
+  _block_count = _active_array->block_count_acquire();
 }
 
 OopStorage::BasicParState::~BasicParState() {
+  _storage->relinquish_block_array(_active_array);
   update_iteration_state(false);
 }
 
@@ -711,29 +942,49 @@
   }
 }
 
-void OopStorage::BasicParState::ensure_iteration_started() {
-  if (!_concurrent) {
-    assert_at_safepoint();
+bool OopStorage::BasicParState::claim_next_segment(IterationData* data) {
+  data->_processed += data->_segment_end - data->_segment_start;
+  size_t start = OrderAccess::load_acquire(&_next_block);
+  if (start >= _block_count) {
+    return finish_iteration(data); // No more blocks available.
   }
-  assert(!_concurrent || _storage->_concurrent_iteration_active, "invariant");
-  // Ensure _next_block is not the not_started_marker, setting it to
-  // the _active_head to start the iteration if necessary.
-  if (OrderAccess::load_acquire(&_next_block) == not_started_marker) {
-    Atomic::cmpxchg(_storage->_active_head, &_next_block, not_started_marker);
+  // Try to claim several at a time, but not *too* many.  We want to
+  // avoid deciding there are many available and selecting a large
+  // quantity, get delayed, and then end up claiming most or all of
+  // the remaining largish amount of work, leaving nothing for other
+  // threads to do.  But too small a step can lead to contention
+  // over _next_block, esp. when the work per block is small.
+  size_t max_step = 10;
+  size_t remaining = _block_count - start;
+  size_t step = MIN2(max_step, 1 + (remaining / _estimated_thread_count));
+  // Atomic::add with possible overshoot.  This can perform better
+  // than a CAS loop on some platforms when there is contention.
+  // We can cope with the uncertainty by recomputing start/end from
+  // the result of the add, and dealing with potential overshoot.
+  size_t end = Atomic::add(step, &_next_block);
+  // _next_block may have changed, so recompute start from result of add.
+  start = end - step;
+  // _next_block may have changed so much that end has overshot.
+  end = MIN2(end, _block_count);
+  // _next_block may have changed so much that even start has overshot.
+  if (start < _block_count) {
+    // Record claimed segment for iteration.
+    data->_segment_start = start;
+    data->_segment_end = end;
+    return true;                // Success.
+  } else {
+    // No more blocks to claim.
+    return finish_iteration(data);
   }
-  assert(_next_block != not_started_marker, "postcondition");
 }
 
-OopStorage::Block* OopStorage::BasicParState::claim_next_block() {
-  assert(_next_block != not_started_marker, "Iteration not started");
-  void* next = _next_block;
-  while (next != NULL) {
-    void* new_next = _storage->_active_list.next(*static_cast<Block*>(next));
-    void* fetched = Atomic::cmpxchg(new_next, &_next_block, next);
-    if (fetched == next) break; // Claimed.
-    next = fetched;
-  }
-  return static_cast<Block*>(next);
+bool OopStorage::BasicParState::finish_iteration(const IterationData* data) const {
+  log_debug(oopstorage, blocks, stats)
+           ("Parallel iteration on %s: blocks = " SIZE_FORMAT
+            ", processed = " SIZE_FORMAT " (%2.f%%)",
+            _storage->name(), _block_count, data->_processed,
+            percent_of(data->_processed, _block_count));
+  return false;
 }
 
 const char* OopStorage::name() const { return _name; }
@@ -742,7 +993,7 @@
 
 void OopStorage::print_on(outputStream* st) const {
   size_t allocations = _allocation_count;
-  size_t blocks = _block_count;
+  size_t blocks = _active_array->block_count();
 
   double data_size = section_size * section_count;
   double alloc_percentage = percent_of((double)allocations, blocks * data_size);
--- a/src/hotspot/share/gc/shared/oopStorage.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/oopStorage.hpp	Fri May 04 08:50:01 2018 -0700
@@ -170,27 +170,11 @@
   // classes. C++03 introduced access for nested classes with DR45, but xlC
   // version 12 rejects it.
 NOT_AIX( private: )
-  class Block;                  // Forward decl; defined in .inline.hpp file.
-  class BlockList;              // Forward decl for BlockEntry friend decl.
-
-  class BlockEntry {
-    friend class BlockList;
+  class Block;                  // Fixed-size array of oops, plus bookkeeping.
+  class BlockArray;             // Array of Blocks, plus bookkeeping.
+  class BlockEntry;             // Provides BlockList links in a Block.
 
-    // Members are mutable, and we deal exclusively with pointers to
-    // const, to make const blocks easier to use; a block being const
-    // doesn't prevent modifying its list state.
-    mutable const Block* _prev;
-    mutable const Block* _next;
-
-    // Noncopyable.
-    BlockEntry(const BlockEntry&);
-    BlockEntry& operator=(const BlockEntry&);
-
-  public:
-    BlockEntry();
-    ~BlockEntry();
-  };
-
+  // Doubly-linked list of Blocks.
   class BlockList {
     const Block* _head;
     const Block* _tail;
@@ -205,6 +189,7 @@
     ~BlockList();
 
     Block* head();
+    Block* tail();
     const Block* chead() const;
     const Block* ctail() const;
 
@@ -219,19 +204,34 @@
     void unlink(const Block& block);
   };
 
+  // RCU-inspired protection of access to _active_array.
+  class ProtectActive {
+    volatile uint _enter;
+    volatile uint _exit[2];
+
+  public:
+    ProtectActive();
+
+    uint read_enter();
+    void read_exit(uint enter_value);
+    void write_synchronize();
+  };
+
 private:
   const char* _name;
-  BlockList _active_list;
+  BlockArray* _active_array;
   BlockList _allocate_list;
-  Block* volatile _active_head;
   Block* volatile _deferred_updates;
 
   Mutex* _allocate_mutex;
   Mutex* _active_mutex;
 
-  // Counts are volatile for racy unlocked accesses.
+  // Volatile for racy unlocked accesses.
   volatile size_t _allocation_count;
-  volatile size_t _block_count;
+
+  // Protection for _active_array.
+  mutable ProtectActive _protect_active;
+
   // mutable because this gets set even for const iteration.
   mutable bool _concurrent_iteration_active;
 
@@ -239,6 +239,13 @@
   void delete_empty_block(const Block& block);
   bool reduce_deferred_updates();
 
+  // Managing _active_array.
+  bool expand_active_array();
+  void replace_active_array(BlockArray* new_array);
+  BlockArray* obtain_active_array() const;
+  void relinquish_block_array(BlockArray* array) const;
+  class WithActiveArray;        // RAII helper for active array access.
+
   template<typename F, typename Storage>
   static bool iterate_impl(F f, Storage* storage);
 
--- a/src/hotspot/share/gc/shared/oopStorage.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/oopStorage.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -30,10 +30,107 @@
 #include "metaprogramming/isConst.hpp"
 #include "oops/oop.hpp"
 #include "runtime/safepoint.hpp"
+#include "utilities/align.hpp"
 #include "utilities/count_trailing_zeros.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/globalDefinitions.hpp"
 
+// Array of all active blocks.  Refcounted for lock-free reclaim of
+// old array when a new array is allocated for expansion.
+class OopStorage::BlockArray {
+  friend class OopStorage::TestAccess;
+
+  size_t _size;
+  volatile size_t _block_count;
+  mutable volatile int _refcount;
+  // Block* _blocks[1];            // Pseudo flexible array member.
+
+  BlockArray(size_t size);
+  ~BlockArray();
+
+  // Noncopyable
+  BlockArray(const BlockArray&);
+  BlockArray& operator=(const BlockArray&);
+
+  static size_t blocks_offset();
+  Block* const* base_ptr() const;
+
+  Block* const* block_ptr(size_t index) const;
+  Block** block_ptr(size_t index);
+
+public:
+  static BlockArray* create(size_t size, AllocFailType alloc_fail = AllocFailStrategy::EXIT_OOM);
+  static void destroy(BlockArray* ba);
+
+  inline Block* at(size_t i) const;
+
+  size_t size() const;
+  size_t block_count() const;
+  size_t block_count_acquire() const;
+  void increment_refcount() const;
+  bool decrement_refcount() const; // Return true if zero, otherwise false
+
+  // Support for OopStorage::allocate.
+  // Add block to the end of the array.  Updates block count at the
+  // end of the operation, with a release_store. Returns true if the
+  // block was added, false if there was no room available.
+  // precondition: owner's _allocation_mutex is locked, or at safepoint.
+  bool push(Block* block);
+
+  // Support OopStorage::delete_empty_blocks_xxx operations.
+  // Remove block from the array.
+  // precondition: block must be present at its active_index element.
+  void remove(Block* block);
+
+  void copy_from(const BlockArray* from);
+};
+
+inline size_t OopStorage::BlockArray::blocks_offset() {
+  return align_up(sizeof(BlockArray), sizeof(Block*));
+}
+
+inline OopStorage::Block* const* OopStorage::BlockArray::base_ptr() const {
+  const void* ptr = reinterpret_cast<const char*>(this) + blocks_offset();
+  return reinterpret_cast<Block* const*>(ptr);
+}
+
+inline OopStorage::Block* const* OopStorage::BlockArray::block_ptr(size_t index) const {
+  return base_ptr() + index;
+}
+
+inline OopStorage::Block** OopStorage::BlockArray::block_ptr(size_t index) {
+  return const_cast<Block**>(base_ptr() + index);
+}
+
+inline OopStorage::Block* OopStorage::BlockArray::at(size_t index) const {
+  assert(index < _block_count, "precondition");
+  return *block_ptr(index);
+}
+
+// A Block has an embedded BlockEntry to provide the links between
+// Blocks in a BlockList.
+class OopStorage::BlockEntry {
+  friend class OopStorage::BlockList;
+
+  // Members are mutable, and we deal exclusively with pointers to
+  // const, to make const blocks easier to use; a block being const
+  // doesn't prevent modifying its list state.
+  mutable const Block* _prev;
+  mutable const Block* _next;
+
+  // Noncopyable.
+  BlockEntry(const BlockEntry&);
+  BlockEntry& operator=(const BlockEntry&);
+
+public:
+  BlockEntry();
+  ~BlockEntry();
+};
+
+// Fixed-sized array of oops, plus bookkeeping data.
+// All blocks are in the storage's _active_array, at the block's _active_index.
+// Non-full blocks are in the storage's _allocate_list, linked through the
+// block's _allocate_entry.  Empty blocks are at the end of that list.
 class OopStorage::Block /* No base class, to avoid messing up alignment. */ {
   // _data must be the first non-static data member, for alignment.
   oop _data[BitsPerWord];
@@ -42,7 +139,7 @@
   volatile uintx _allocated_bitmask; // One bit per _data element.
   const OopStorage* _owner;
   void* _memory;              // Unaligned storage containing block.
-  BlockEntry _active_entry;
+  size_t _active_index;
   BlockEntry _allocate_entry;
   Block* volatile _deferred_updates_next;
   volatile uintx _release_refcount;
@@ -61,7 +158,6 @@
   Block& operator=(const Block&);
 
 public:
-  static const BlockEntry& get_active_entry(const Block& block);
   static const BlockEntry& get_allocate_entry(const Block& block);
 
   static size_t allocation_size();
@@ -84,6 +180,10 @@
 
   bool contains(const oop* ptr) const;
 
+  size_t active_index() const;
+  void set_active_index(size_t index);
+  static size_t active_index_safe(const Block* block); // Returns 0 if access fails.
+
   // Returns NULL if ptr is not in a block or not allocated in that block.
   static Block* block_for_ptr(const OopStorage* owner, const oop* ptr);
 
@@ -101,6 +201,10 @@
   return const_cast<Block*>(_head);
 }
 
+inline OopStorage::Block* OopStorage::BlockList::tail() {
+  return const_cast<Block*>(_tail);
+}
+
 inline const OopStorage::Block* OopStorage::BlockList::chead() const {
   return _head;
 }
@@ -253,9 +357,10 @@
   // Propagate const/non-const iteration to the block layer, by using
   // const or non-const blocks as corresponding to Storage.
   typedef typename Conditional<IsConst<Storage>::value, const Block*, Block*>::type BlockPtr;
-  for (BlockPtr block = storage->_active_head;
-       block != NULL;
-       block = storage->_active_list.next(*block)) {
+  BlockArray* blocks = storage->_active_array;
+  size_t limit = blocks->block_count();
+  for (size_t i = 0; i < limit; ++i) {
+    BlockPtr block = blocks->at(i);
     if (!block->iterate(f)) {
       return false;
     }
--- a/src/hotspot/share/gc/shared/oopStorageParState.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/oopStorageParState.hpp	Fri May 04 08:50:01 2018 -0700
@@ -36,9 +36,8 @@
 //
 // Concurrent Iteration
 //
-// Iteration involves the _active_list, which contains all of the blocks owned
-// by a storage object.  This is a doubly-linked list, linked through
-// dedicated fields in the blocks.
+// Iteration involves the _active_array (a BlockArray), which contains all of
+// the blocks owned by a storage object.
 //
 // At most one concurrent ParState can exist at a time for a given storage
 // object.
@@ -48,27 +47,29 @@
 // sets it false when the state is destroyed.  These assignments are made with
 // _active_mutex locked.  Meanwhile, empty block deletion is not done while
 // _concurrent_iteration_active is true.  The flag check and the dependent
-// removal of a block from the _active_list is performed with _active_mutex
+// removal of a block from the _active_array is performed with _active_mutex
 // locked.  This prevents concurrent iteration and empty block deletion from
 // interfering with with each other.
 //
 // Both allocate() and delete_empty_blocks_concurrent() lock the
-// _allocate_mutex while performing their respective list manipulations,
-// preventing them from interfering with each other.
+// _allocate_mutex while performing their respective list and array
+// manipulations, preventing them from interfering with each other.
 //
-// When allocate() creates a new block, it is added to the front of the
-// _active_list.  Then _active_head is set to the new block.  When concurrent
-// iteration is started (by a parallel worker thread calling the state's
-// iterate() function), the current _active_head is used as the initial block
-// for the iteration, with iteration proceeding down the list headed by that
-// block.
+// When allocate() creates a new block, it is added to the end of the
+// _active_array.  Then _active_array's _block_count is incremented to account
+// for the new block.  When concurrent iteration is started (by a parallel
+// worker thread calling the state's iterate() function), the current
+// _active_array and its _block_count are captured for use by the iteration,
+// with iteration processing all blocks in that array up to that block count.
 //
-// As a result, the list over which concurrent iteration operates is stable.
-// However, once the iteration is started, later allocations may add blocks to
-// the front of the list that won't be examined by the iteration.  And while
-// the list is stable, concurrent allocate() and release() operations may
-// change the set of allocated entries in a block at any time during the
-// iteration.
+// As a result, the sequence over which concurrent iteration operates is
+// stable.  However, once the iteration is started, later allocations may add
+// blocks to the end of the array that won't be examined by the iteration.
+// An allocation may even require expansion of the array, so the iteration is
+// no longer processing the current array, but rather the previous one.
+// And while the sequence is stable, concurrent allocate() and release()
+// operations may change the set of allocated entries in a block at any time
+// during the iteration.
 //
 // As a result, a concurrent iteration handler must accept that some
 // allocations and releases that occur after the iteration started will not be
@@ -138,36 +139,49 @@
 //   invoked on p.
 
 class OopStorage::BasicParState {
-  OopStorage* _storage;
-  void* volatile _next_block;
+  const OopStorage* _storage;
+  BlockArray* _active_array;
+  size_t _block_count;
+  volatile size_t _next_block;
+  uint _estimated_thread_count;
   bool _concurrent;
 
   // Noncopyable.
   BasicParState(const BasicParState&);
   BasicParState& operator=(const BasicParState&);
 
+  struct IterationData;
+
   void update_iteration_state(bool value);
-  void ensure_iteration_started();
-  Block* claim_next_block();
+  bool claim_next_segment(IterationData* data);
+  bool finish_iteration(const IterationData* data) const;
 
   // Wrapper for iteration handler; ignore handler result and return true.
   template<typename F> class AlwaysTrueFn;
 
 public:
-  BasicParState(OopStorage* storage, bool concurrent);
+  BasicParState(const OopStorage* storage,
+                uint estimated_thread_count,
+                bool concurrent);
   ~BasicParState();
 
   template<bool is_const, typename F> void iterate(F f);
+
+  static uint default_estimated_thread_count(bool concurrent);
 };
 
 template<bool concurrent, bool is_const>
 class OopStorage::ParState {
   BasicParState _basic_state;
 
+  typedef typename Conditional<is_const,
+                               const OopStorage*,
+                               OopStorage*>::type StoragePtr;
+
 public:
-  ParState(const OopStorage* storage) :
-    // For simplicity, always recorded as non-const.
-    _basic_state(const_cast<OopStorage*>(storage), concurrent)
+  ParState(StoragePtr storage,
+           uint estimated_thread_count = BasicParState::default_estimated_thread_count(concurrent)) :
+    _basic_state(storage, estimated_thread_count, concurrent)
   {}
 
   template<typename F> void iterate(F f);
@@ -179,8 +193,9 @@
   BasicParState _basic_state;
 
 public:
-  ParState(OopStorage* storage) :
-    _basic_state(storage, false)
+  ParState(OopStorage* storage,
+           uint estimated_thread_count = BasicParState::default_estimated_thread_count(false)) :
+    _basic_state(storage, estimated_thread_count, false)
   {}
 
   template<typename F> void iterate(F f);
--- a/src/hotspot/share/gc/shared/oopStorageParState.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/oopStorageParState.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -41,14 +41,26 @@
   bool operator()(OopPtr ptr) const { _f(ptr); return true; }
 };
 
+struct OopStorage::BasicParState::IterationData {
+  size_t _segment_start;
+  size_t _segment_end;
+  size_t _processed;
+};
+
 template<bool is_const, typename F>
 inline void OopStorage::BasicParState::iterate(F f) {
   // Wrap f in ATF so we can use Block::iterate.
   AlwaysTrueFn<F> atf_f(f);
-  ensure_iteration_started();
-  typename Conditional<is_const, const Block*, Block*>::type block;
-  while ((block = claim_next_block()) != NULL) {
-    block->iterate(atf_f);
+  IterationData data = {};      // zero initialize.
+  while (claim_next_segment(&data)) {
+    assert(data._segment_start < data._segment_end, "invariant");
+    assert(data._segment_end <= _block_count, "invariant");
+    typedef typename Conditional<is_const, const Block*, Block*>::type BlockPtr;
+    size_t i = data._segment_start;
+    do {
+      BlockPtr block = _active_array->at(i);
+      block->iterate(atf_f);
+    } while (++i < data._segment_end);
   }
 }
 
--- a/src/hotspot/share/gc/shared/preservedMarks.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/preservedMarks.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -26,6 +26,7 @@
 #define SHARE_VM_GC_SHARED_PRESERVEDMARKS_INLINE_HPP
 
 #include "gc/shared/preservedMarks.hpp"
+#include "logging/log.hpp"
 #include "oops/oop.inline.hpp"
 #include "utilities/stack.inline.hpp"
 
--- a/src/hotspot/share/gc/shared/referenceProcessor.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp	Fri May 04 08:50:01 2018 -0700
@@ -92,37 +92,39 @@
   _discovering_refs = true;
 }
 
-ReferenceProcessor::ReferenceProcessor(MemRegion span,
+ReferenceProcessor::ReferenceProcessor(BoolObjectClosure* is_subject_to_discovery,
                                        bool      mt_processing,
                                        uint      mt_processing_degree,
                                        bool      mt_discovery,
                                        uint      mt_discovery_degree,
                                        bool      atomic_discovery,
                                        BoolObjectClosure* is_alive_non_header)  :
+  _is_subject_to_discovery(is_subject_to_discovery),
   _discovering_refs(false),
   _enqueuing_is_done(false),
   _is_alive_non_header(is_alive_non_header),
   _processing_is_mt(mt_processing),
   _next_id(0)
 {
-  _span = span;
+  assert(is_subject_to_discovery != NULL, "must be set");
+
   _discovery_is_atomic = atomic_discovery;
   _discovery_is_mt     = mt_discovery;
-  _num_q               = MAX2(1U, mt_processing_degree);
-  _max_num_q           = MAX2(_num_q, mt_discovery_degree);
+  _num_queues          = MAX2(1U, mt_processing_degree);
+  _max_num_queues      = MAX2(_num_queues, mt_discovery_degree);
   _discovered_refs     = NEW_C_HEAP_ARRAY(DiscoveredList,
-            _max_num_q * number_of_subclasses_of_ref(), mtGC);
+            _max_num_queues * number_of_subclasses_of_ref(), mtGC);
 
   if (_discovered_refs == NULL) {
     vm_exit_during_initialization("Could not allocated RefProc Array");
   }
   _discoveredSoftRefs    = &_discovered_refs[0];
-  _discoveredWeakRefs    = &_discoveredSoftRefs[_max_num_q];
-  _discoveredFinalRefs   = &_discoveredWeakRefs[_max_num_q];
-  _discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_q];
+  _discoveredWeakRefs    = &_discoveredSoftRefs[_max_num_queues];
+  _discoveredFinalRefs   = &_discoveredWeakRefs[_max_num_queues];
+  _discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_queues];
 
   // Initialize all entries to NULL
-  for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
+  for (uint i = 0; i < _max_num_queues * number_of_subclasses_of_ref(); i++) {
     _discovered_refs[i].set_head(NULL);
     _discovered_refs[i].set_length(0);
   }
@@ -133,7 +135,7 @@
 #ifndef PRODUCT
 void ReferenceProcessor::verify_no_references_recorded() {
   guarantee(!_discovering_refs, "Discovering refs?");
-  for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
+  for (uint i = 0; i < _max_num_queues * number_of_subclasses_of_ref(); i++) {
     guarantee(_discovered_refs[i].is_empty(),
               "Found non-empty discovered list at %u", i);
   }
@@ -141,7 +143,7 @@
 #endif
 
 void ReferenceProcessor::weak_oops_do(OopClosure* f) {
-  for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
+  for (uint i = 0; i < _max_num_queues * number_of_subclasses_of_ref(); i++) {
     if (UseCompressedOops) {
       f->do_oop((narrowOop*)_discovered_refs[i].adr_head());
     } else {
@@ -181,7 +183,7 @@
 
 size_t ReferenceProcessor::total_count(DiscoveredList lists[]) const {
   size_t total = 0;
-  for (uint i = 0; i < _max_num_q; ++i) {
+  for (uint i = 0; i < _max_num_queues; ++i) {
     total += lists[i].length();
   }
   return total;
@@ -281,21 +283,21 @@
   log_develop_trace(gc, ref)("ReferenceProcessor::enqueue_discovered_reflist list " INTPTR_FORMAT, p2i(&refs_list));
 
   oop obj = NULL;
-  oop next_d = refs_list.head();
+  oop next_discovered = refs_list.head();
   // Walk down the list, self-looping the next field
   // so that the References are not considered active.
-  while (obj != next_d) {
-    obj = next_d;
+  while (obj != next_discovered) {
+    obj = next_discovered;
     assert(obj->is_instance(), "should be an instance object");
     assert(InstanceKlass::cast(obj->klass())->is_reference_instance_klass(), "should be reference object");
-    next_d = java_lang_ref_Reference::discovered(obj);
-    log_develop_trace(gc, ref)("        obj " INTPTR_FORMAT "/next_d " INTPTR_FORMAT, p2i(obj), p2i(next_d));
+    next_discovered = java_lang_ref_Reference::discovered(obj);
+    log_develop_trace(gc, ref)("        obj " INTPTR_FORMAT "/next_discovered " INTPTR_FORMAT, p2i(obj), p2i(next_discovered));
     assert(java_lang_ref_Reference::next(obj) == NULL,
            "Reference not active; should not be discovered");
     // Self-loop next, so as to make Ref not active.
     java_lang_ref_Reference::set_next_raw(obj, obj);
-    if (next_d != obj) {
-      HeapAccess<AS_NO_KEEPALIVE>::oop_store_at(obj, java_lang_ref_Reference::discovered_offset, next_d);
+    if (next_discovered != obj) {
+      HeapAccess<AS_NO_KEEPALIVE>::oop_store_at(obj, java_lang_ref_Reference::discovered_offset, next_discovered);
     } else {
       // This is the last object.
       // Swap refs_list into pending list and set obj's
@@ -319,14 +321,14 @@
   virtual void work(unsigned int work_id) {
     RefProcWorkerTimeTracker tt(ReferenceProcessorPhaseTimes::RefEnqueue, _phase_times, work_id);
 
-    assert(work_id < (unsigned int)_ref_processor.max_num_q(), "Index out-of-bounds");
+    assert(work_id < (unsigned int)_ref_processor.max_num_queues(), "Index out-of-bounds");
     // Simplest first cut: static partitioning.
     int index = work_id;
     // The increment on "index" must correspond to the maximum number of queues
     // (n_queues) with which that ReferenceProcessor was created.  That
     // is because of the "clever" way the discovered references lists were
     // allocated and are indexed into.
-    assert(_n_queues == (int) _ref_processor.max_num_q(), "Different number not expected");
+    assert(_n_queues == (int) _ref_processor.max_num_queues(), "Different number not expected");
     for (int j = 0;
          j < ReferenceProcessor::number_of_subclasses_of_ref();
          j++, index += _n_queues) {
@@ -350,11 +352,11 @@
 
   if (_processing_is_mt && task_executor != NULL) {
     // Parallel code
-    RefProcEnqueueTask tsk(*this, _discovered_refs, _max_num_q, phase_times);
+    RefProcEnqueueTask tsk(*this, _discovered_refs, _max_num_queues, phase_times);
     task_executor->execute(tsk);
   } else {
     // Serial code: call the parent class's implementation
-    for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
+    for (uint i = 0; i < _max_num_queues * number_of_subclasses_of_ref(); i++) {
       enqueue_discovered_reflist(_discovered_refs[i]);
       _discovered_refs[i].set_head(NULL);
       _discovered_refs[i].set_length(0);
@@ -363,13 +365,14 @@
 }
 
 void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) {
-  _discovered_addr = java_lang_ref_Reference::discovered_addr_raw(_ref);
-  oop discovered = java_lang_ref_Reference::discovered(_ref);
-  assert(_discovered_addr && oopDesc::is_oop_or_null(discovered),
+  _current_discovered_addr = java_lang_ref_Reference::discovered_addr_raw(_current_discovered);
+  oop discovered = java_lang_ref_Reference::discovered(_current_discovered);
+  assert(_current_discovered_addr && oopDesc::is_oop_or_null(discovered),
          "Expected an oop or NULL for discovered field at " PTR_FORMAT, p2i(discovered));
-  _next = discovered;
-  _referent_addr = java_lang_ref_Reference::referent_addr_raw(_ref);
-  _referent = java_lang_ref_Reference::referent(_ref);
+  _next_discovered = discovered;
+
+  _referent_addr = java_lang_ref_Reference::referent_addr_raw(_current_discovered);
+  _referent = java_lang_ref_Reference::referent(_current_discovered);
   assert(Universe::heap()->is_in_reserved_or_null(_referent),
          "Wrong oop found in java.lang.Reference object");
   assert(allow_null_referent ?
@@ -381,23 +384,23 @@
 }
 
 void DiscoveredListIterator::remove() {
-  assert(oopDesc::is_oop(_ref), "Dropping a bad reference");
-  RawAccess<>::oop_store(_discovered_addr, oop(NULL));
+  assert(oopDesc::is_oop(_current_discovered), "Dropping a bad reference");
+  RawAccess<>::oop_store(_current_discovered_addr, oop(NULL));
 
   // First _prev_next ref actually points into DiscoveredList (gross).
   oop new_next;
-  if (_next == _ref) {
+  if (_next_discovered == _current_discovered) {
     // At the end of the list, we should make _prev point to itself.
     // If _ref is the first ref, then _prev_next will be in the DiscoveredList,
     // and _prev will be NULL.
-    new_next = _prev;
+    new_next = _prev_discovered;
   } else {
-    new_next = _next;
+    new_next = _next_discovered;
   }
   // Remove Reference object from discovered list. Note that G1 does not need a
   // pre-barrier here because we know the Reference has already been found/marked,
   // that's how it ended up in the discovered list in the first place.
-  RawAccess<>::oop_store(_prev_next, new_next);
+  RawAccess<>::oop_store(_prev_discovered_addr, new_next);
   NOT_PRODUCT(_removed++);
   _refs_list.dec_length(1);
 }
@@ -449,6 +452,19 @@
                              iter.removed(), iter.processed(), p2i(&refs_list));
 }
 
+void ReferenceProcessor::process_phase2(DiscoveredList&    refs_list,
+                                        BoolObjectClosure* is_alive,
+                                        OopClosure*        keep_alive,
+                                        VoidClosure*       complete_gc) {
+  if (discovery_is_atomic()) {
+    // complete_gc is ignored in this case for this phase
+    pp2_work(refs_list, is_alive, keep_alive);
+  } else {
+    assert(complete_gc != NULL, "Error");
+    pp2_work_concurrent_discovery(refs_list, is_alive,
+                                  keep_alive, complete_gc);
+  }
+}
 // Traverse the list and remove any Refs that are not active, or
 // whose referents are either alive or NULL.
 void
@@ -524,15 +540,11 @@
   )
 }
 
-// Traverse the list and process the referents, by either
-// clearing them or keeping them (and their reachable
-// closure) alive.
-void
-ReferenceProcessor::process_phase3(DiscoveredList&    refs_list,
-                                   bool               clear_referent,
-                                   BoolObjectClosure* is_alive,
-                                   OopClosure*        keep_alive,
-                                   VoidClosure*       complete_gc) {
+void ReferenceProcessor::process_phase3(DiscoveredList&    refs_list,
+                                        bool               clear_referent,
+                                        BoolObjectClosure* is_alive,
+                                        OopClosure*        keep_alive,
+                                        VoidClosure*       complete_gc) {
   ResourceMark rm;
   DiscoveredListIterator iter(refs_list, keep_alive, is_alive);
   while (iter.has_next()) {
@@ -568,8 +580,8 @@
 
 void ReferenceProcessor::abandon_partial_discovery() {
   // loop over the lists
-  for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
-    if ((i % _max_num_q) == 0) {
+  for (uint i = 0; i < _max_num_queues * number_of_subclasses_of_ref(); i++) {
+    if ((i % _max_num_queues) == 0) {
       log_develop_trace(gc, ref)("Abandoning %s discovered list", list_name(i));
     }
     clear_discovered_references(_discovered_refs[i]);
@@ -677,7 +689,7 @@
   }
   log_develop_trace(gc, ref)("%s= " SIZE_FORMAT, st.as_string(), total_refs);
 #ifdef ASSERT
-  for (uint i = active_length; i < _max_num_q; i++) {
+  for (uint i = active_length; i < _max_num_queues; i++) {
     assert(ref_lists[i].length() == 0, SIZE_FORMAT " unexpected References in %u",
            ref_lists[i].length(), i);
   }
@@ -686,7 +698,7 @@
 #endif
 
 void ReferenceProcessor::set_active_mt_degree(uint v) {
-  _num_q = v;
+  _num_queues = v;
   _next_id = 0;
 }
 
@@ -700,20 +712,20 @@
   size_t total_refs = 0;
   log_develop_trace(gc, ref)("Balance ref_lists ");
 
-  for (uint i = 0; i < _max_num_q; ++i) {
+  for (uint i = 0; i < _max_num_queues; ++i) {
     total_refs += ref_lists[i].length();
   }
-  log_reflist_counts(ref_lists, _max_num_q, total_refs);
-  size_t avg_refs = total_refs / _num_q + 1;
+  log_reflist_counts(ref_lists, _max_num_queues, total_refs);
+  size_t avg_refs = total_refs / _num_queues + 1;
   uint to_idx = 0;
-  for (uint from_idx = 0; from_idx < _max_num_q; from_idx++) {
+  for (uint from_idx = 0; from_idx < _max_num_queues; from_idx++) {
     bool move_all = false;
-    if (from_idx >= _num_q) {
+    if (from_idx >= _num_queues) {
       move_all = ref_lists[from_idx].length() > 0;
     }
     while ((ref_lists[from_idx].length() > avg_refs) ||
            move_all) {
-      assert(to_idx < _num_q, "Sanity Check!");
+      assert(to_idx < _num_queues, "Sanity Check!");
       if (ref_lists[to_idx].length() < avg_refs) {
         // move superfluous refs
         size_t refs_to_move;
@@ -759,16 +771,16 @@
           break;
         }
       } else {
-        to_idx = (to_idx + 1) % _num_q;
+        to_idx = (to_idx + 1) % _num_queues;
       }
     }
   }
 #ifdef ASSERT
   size_t balanced_total_refs = 0;
-  for (uint i = 0; i < _num_q; ++i) {
+  for (uint i = 0; i < _num_queues; ++i) {
     balanced_total_refs += ref_lists[i].length();
   }
-  log_reflist_counts(ref_lists, _num_q, balanced_total_refs);
+  log_reflist_counts(ref_lists, _num_queues, balanced_total_refs);
   assert(total_refs == balanced_total_refs, "Balancing was incomplete");
 #endif
 }
@@ -811,7 +823,7 @@
       RefProcPhase1Task phase1(*this, refs_lists, policy, true /*marks_oops_alive*/, phase_times);
       task_executor->execute(phase1);
     } else {
-      for (uint i = 0; i < _max_num_q; i++) {
+      for (uint i = 0; i < _max_num_queues; i++) {
         process_phase1(refs_lists[i], policy,
                        is_alive, keep_alive, complete_gc);
       }
@@ -830,7 +842,7 @@
       RefProcPhase2Task phase2(*this, refs_lists, !discovery_is_atomic() /*marks_oops_alive*/, phase_times);
       task_executor->execute(phase2);
     } else {
-      for (uint i = 0; i < _max_num_q; i++) {
+      for (uint i = 0; i < _max_num_queues; i++) {
         process_phase2(refs_lists[i], is_alive, keep_alive, complete_gc);
       }
     }
@@ -845,7 +857,7 @@
       RefProcPhase3Task phase3(*this, refs_lists, clear_referent, true /*marks_oops_alive*/, phase_times);
       task_executor->execute(phase3);
     } else {
-      for (uint i = 0; i < _max_num_q; i++) {
+      for (uint i = 0; i < _max_num_queues; i++) {
         process_phase3(refs_lists[i], clear_referent,
                        is_alive, keep_alive, complete_gc);
       }
@@ -868,7 +880,7 @@
       id = next_id();
     }
   }
-  assert(id < _max_num_q, "Id is out-of-bounds id %u and max id %u)", id, _max_num_q);
+  assert(id < _max_num_queues, "Id is out-of-bounds id %u and max id %u)", id, _max_num_queues);
 
   // Get the discovered queue to which we will add
   DiscoveredList* list = NULL;
@@ -941,6 +953,10 @@
 }
 #endif
 
+bool ReferenceProcessor::is_subject_to_discovery(oop const obj) const {
+  return _is_subject_to_discovery->do_object_b(obj);
+}
+
 // We mention two of several possible choices here:
 // #0: if the reference object is not in the "originating generation"
 //     (or part of the heap being collected, indicated by our "span"
@@ -978,9 +994,8 @@
     return false;
   }
 
-  HeapWord* obj_addr = (HeapWord*)obj;
   if (RefDiscoveryPolicy == ReferenceBasedDiscovery &&
-      !_span.contains(obj_addr)) {
+      !is_subject_to_discovery(obj)) {
     // Reference is not in the originating generation;
     // don't treat it specially (i.e. we want to scan it as a normal
     // object with strong references).
@@ -1039,16 +1054,15 @@
     // Discover if and only if EITHER:
     // .. reference is in our span, OR
     // .. we are an atomic collector and referent is in our span
-    if (_span.contains(obj_addr) ||
+    if (is_subject_to_discovery(obj) ||
         (discovery_is_atomic() &&
-         _span.contains(java_lang_ref_Reference::referent(obj)))) {
-      // should_enqueue = true;
+         is_subject_to_discovery(java_lang_ref_Reference::referent(obj)))) {
     } else {
       return false;
     }
   } else {
     assert(RefDiscoveryPolicy == ReferenceBasedDiscovery &&
-           _span.contains(obj_addr), "code inconsistency");
+           is_subject_to_discovery(obj), "code inconsistency");
   }
 
   // Get the right type of discovered queue head.
@@ -1079,7 +1093,7 @@
 }
 
 bool ReferenceProcessor::has_discovered_references() {
-  for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
+  for (uint i = 0; i < _max_num_queues * number_of_subclasses_of_ref(); i++) {
     if (!_discovered_refs[i].is_empty()) {
       return true;
     }
@@ -1101,7 +1115,7 @@
   // Soft references
   {
     GCTraceTime(Debug, gc, ref) tm("Preclean SoftReferences", gc_timer);
-    for (uint i = 0; i < _max_num_q; i++) {
+    for (uint i = 0; i < _max_num_queues; i++) {
       if (yield->should_return()) {
         return;
       }
@@ -1113,7 +1127,7 @@
   // Weak references
   {
     GCTraceTime(Debug, gc, ref) tm("Preclean WeakReferences", gc_timer);
-    for (uint i = 0; i < _max_num_q; i++) {
+    for (uint i = 0; i < _max_num_queues; i++) {
       if (yield->should_return()) {
         return;
       }
@@ -1125,7 +1139,7 @@
   // Final references
   {
     GCTraceTime(Debug, gc, ref) tm("Preclean FinalReferences", gc_timer);
-    for (uint i = 0; i < _max_num_q; i++) {
+    for (uint i = 0; i < _max_num_queues; i++) {
       if (yield->should_return()) {
         return;
       }
@@ -1137,7 +1151,7 @@
   // Phantom references
   {
     GCTraceTime(Debug, gc, ref) tm("Preclean PhantomReferences", gc_timer);
-    for (uint i = 0; i < _max_num_q; i++) {
+    for (uint i = 0; i < _max_num_queues; i++) {
       if (yield->should_return()) {
         return;
       }
@@ -1200,10 +1214,10 @@
 }
 
 const char* ReferenceProcessor::list_name(uint i) {
-   assert(i <= _max_num_q * number_of_subclasses_of_ref(),
+   assert(i <= _max_num_queues * number_of_subclasses_of_ref(),
           "Out of bounds index");
 
-   int j = i / _max_num_q;
+   int j = i / _max_num_queues;
    switch (j) {
      case 0: return "SoftRef";
      case 1: return "WeakRef";
--- a/src/hotspot/share/gc/shared/referenceProcessor.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/referenceProcessor.hpp	Fri May 04 08:50:01 2018 -0700
@@ -38,18 +38,13 @@
 // of java.lang.Reference objects for GC. The interface is useful for supporting
 // a generational abstraction, in particular when there are multiple
 // generations that are being independently collected -- possibly
-// concurrently and/or incrementally.  Note, however, that the
+// concurrently and/or incrementally.
 // ReferenceProcessor class abstracts away from a generational setting
-// by using only a heap interval (called "span" below), thus allowing
-// its use in a straightforward manner in a general, non-generational
-// setting.
+// by using a closure that determines whether a given reference or referent are
+// subject to this ReferenceProcessor's discovery, thus allowing its use in a
+// straightforward manner in a general, non-generational, non-contiguous generation
+// (or heap) setting.
 //
-// The basic idea is that each ReferenceProcessor object concerns
-// itself with ("weak") reference processing in a specific "span"
-// of the heap of interest to a specific collector. Currently,
-// the span is a convex interval of the heap, but, efficiency
-// apart, there seems to be no reason it couldn't be extended
-// (with appropriate modifications) to any "non-convex interval".
 
 // forward references
 class ReferencePolicy;
@@ -82,13 +77,15 @@
 class DiscoveredListIterator {
 private:
   DiscoveredList&    _refs_list;
-  HeapWord*          _prev_next;
-  oop                _prev;
-  oop                _ref;
-  HeapWord*          _discovered_addr;
-  oop                _next;
+  HeapWord*          _prev_discovered_addr;
+  oop                _prev_discovered;
+  oop                _current_discovered;
+  HeapWord*          _current_discovered_addr;
+  oop                _next_discovered;
+
   HeapWord*          _referent_addr;
   oop                _referent;
+
   OopClosure*        _keep_alive;
   BoolObjectClosure* _is_alive;
 
@@ -107,10 +104,10 @@
                                 BoolObjectClosure* is_alive);
 
   // End Of List.
-  inline bool has_next() const { return _ref != NULL; }
+  inline bool has_next() const { return _current_discovered != NULL; }
 
   // Get oop to the Reference object.
-  inline oop obj() const { return _ref; }
+  inline oop obj() const { return _current_discovered; }
 
   // Get oop to the referent object.
   inline oop referent() const { return _referent; }
@@ -129,8 +126,8 @@
 
   // Move to the next discovered reference.
   inline void next() {
-    _prev_next = _discovered_addr;
-    _prev = _ref;
+    _prev_discovered_addr = _current_discovered_addr;
+    _prev_discovered = _current_discovered;
     move_to_next();
   }
 
@@ -156,28 +153,26 @@
   )
 
   inline void move_to_next() {
-    if (_ref == _next) {
+    if (_current_discovered == _next_discovered) {
       // End of the list.
-      _ref = NULL;
+      _current_discovered = NULL;
     } else {
-      _ref = _next;
+      _current_discovered = _next_discovered;
     }
-    assert(_ref != _first_seen, "cyclic ref_list found");
+    assert(_current_discovered != _first_seen, "cyclic ref_list found");
     NOT_PRODUCT(_processed++);
   }
 };
 
 class ReferenceProcessor : public ReferenceDiscoverer {
-
- private:
   size_t total_count(DiscoveredList lists[]) const;
 
- protected:
   // The SoftReference master timestamp clock
   static jlong _soft_ref_timestamp_clock;
 
-  MemRegion   _span;                    // (right-open) interval of heap
-                                        // subject to wkref discovery
+  BoolObjectClosure* _is_subject_to_discovery; // determines whether a given oop is subject
+                                               // to this ReferenceProcessor's discovery
+                                               // (and further processing).
 
   bool        _discovering_refs;        // true when discovery enabled
   bool        _discovery_is_atomic;     // if discovery is atomic wrt
@@ -187,7 +182,7 @@
   bool        _enqueuing_is_done;       // true if all weak references enqueued
   bool        _processing_is_mt;        // true during phases when
                                         // reference processing is MT.
-  uint        _next_id;                 // round-robin mod _num_q counter in
+  uint        _next_id;                 // round-robin mod _num_queues counter in
                                         // support of work distribution
 
   // For collectors that do not keep GC liveness information
@@ -208,9 +203,9 @@
   // The discovered ref lists themselves
 
   // The active MT'ness degree of the queues below
-  uint             _num_q;
+  uint            _num_queues;
   // The maximum MT'ness degree of the queues below
-  uint             _max_num_q;
+  uint            _max_num_queues;
 
   // Master array of discovered oops
   DiscoveredList* _discovered_refs;
@@ -224,8 +219,8 @@
  public:
   static int number_of_subclasses_of_ref() { return (REF_PHANTOM - REF_OTHER); }
 
-  uint num_q()                             { return _num_q; }
-  uint max_num_q()                         { return _max_num_q; }
+  uint num_queues() const                  { return _num_queues; }
+  uint max_num_queues() const              { return _max_num_queues; }
   void set_active_mt_degree(uint v);
 
   DiscoveredList* discovered_refs()        { return _discovered_refs; }
@@ -257,19 +252,10 @@
                       VoidClosure*        complete_gc);
   // Phase2: remove all those references whose referents are
   // reachable.
-  inline void process_phase2(DiscoveredList&    refs_list,
-                             BoolObjectClosure* is_alive,
-                             OopClosure*        keep_alive,
-                             VoidClosure*       complete_gc) {
-    if (discovery_is_atomic()) {
-      // complete_gc is ignored in this case for this phase
-      pp2_work(refs_list, is_alive, keep_alive);
-    } else {
-      assert(complete_gc != NULL, "Error");
-      pp2_work_concurrent_discovery(refs_list, is_alive,
-                                    keep_alive, complete_gc);
-    }
-  }
+  void process_phase2(DiscoveredList&    refs_list,
+                      BoolObjectClosure* is_alive,
+                      OopClosure*        keep_alive,
+                      VoidClosure*       complete_gc);
   // Work methods in support of process_phase2
   void pp2_work(DiscoveredList&    refs_list,
                 BoolObjectClosure* is_alive,
@@ -280,7 +266,7 @@
                 OopClosure*        keep_alive,
                 VoidClosure*       complete_gc);
   // Phase3: process the referents by either clearing them
-  // or keeping them alive (and their closure)
+  // or keeping them alive (and their closure), and enqueuing them.
   void process_phase3(DiscoveredList&    refs_list,
                       bool               clear_referent,
                       BoolObjectClosure* is_alive,
@@ -306,13 +292,12 @@
                                       GCTimer*           gc_timer);
 
   // Returns the name of the discovered reference list
-  // occupying the i / _num_q slot.
+  // occupying the i / _num_queues slot.
   const char* list_name(uint i);
 
   void enqueue_discovered_reflists(AbstractRefProcTaskExecutor* task_executor,
                                    ReferenceProcessorPhaseTimes* phase_times);
 
- protected:
   // "Preclean" the given discovered reference list
   // by removing references with strongly reachable referents.
   // Currently used in support of CMS only.
@@ -321,15 +306,15 @@
                                    OopClosure*        keep_alive,
                                    VoidClosure*       complete_gc,
                                    YieldClosure*      yield);
-
-  // round-robin mod _num_q (not: _not_ mode _max_num_q)
+private:
+  // round-robin mod _num_queues (not: _not_ mod _max_num_queues)
   uint next_id() {
     uint id = _next_id;
     assert(!_discovery_is_mt, "Round robin should only be used in serial discovery");
-    if (++_next_id == _num_q) {
+    if (++_next_id == _num_queues) {
       _next_id = 0;
     }
-    assert(_next_id < _num_q, "_next_id %u _num_q %u _max_num_q %u", _next_id, _num_q, _max_num_q);
+    assert(_next_id < _num_queues, "_next_id %u _num_queues %u _max_num_queues %u", _next_id, _num_queues, _max_num_queues);
     return id;
   }
   DiscoveredList* get_discovered_list(ReferenceType rt);
@@ -346,9 +331,11 @@
   // Update (advance) the soft ref master clock field.
   void update_soft_ref_master_clock();
 
- public:
+  bool is_subject_to_discovery(oop const obj) const;
+
+public:
   // Default parameters give you a vanilla reference processor.
-  ReferenceProcessor(MemRegion span,
+  ReferenceProcessor(BoolObjectClosure* is_subject_to_discovery,
                      bool mt_processing = false, uint mt_processing_degree = 1,
                      bool mt_discovery  = false, uint mt_discovery_degree  = 1,
                      bool atomic_discovery = true,
@@ -373,9 +360,8 @@
     _is_alive_non_header = is_alive_non_header;
   }
 
-  // get and set span
-  MemRegion span()                   { return _span; }
-  void      set_span(MemRegion span) { _span = span; }
+  BoolObjectClosure* is_subject_to_discovery_closure() const { return _is_subject_to_discovery; }
+  void set_is_subject_to_discovery_closure(BoolObjectClosure* cl) { _is_subject_to_discovery = cl; }
 
   // start and stop weak ref discovery
   void enable_discovery(bool check_no_refs = true);
@@ -435,6 +421,26 @@
   void verify_referent(oop obj)        PRODUCT_RETURN;
 };
 
+// A subject-to-discovery closure that uses a single memory span to determine the area that
+// is subject to discovery. Useful for collectors which have contiguous generations.
+class SpanSubjectToDiscoveryClosure : public BoolObjectClosure {
+  MemRegion _span;
+
+public:
+  SpanSubjectToDiscoveryClosure() : BoolObjectClosure(), _span() { }
+  SpanSubjectToDiscoveryClosure(MemRegion span) : BoolObjectClosure(), _span(span) { }
+
+  MemRegion span() const { return _span; }
+
+  void set_span(MemRegion mr) {
+    _span = mr;
+  }
+
+  virtual bool do_object_b(oop obj) {
+    return _span.contains(obj);
+  }
+};
+
 // A utility class to disable reference discovery in
 // the scope which contains it, for given ReferenceProcessor.
 class NoRefDiscovery: StackObj {
@@ -456,24 +462,43 @@
   }
 };
 
+// A utility class to temporarily mutate the subject discovery closure of the
+// given ReferenceProcessor in the scope that contains it.
+class ReferenceProcessorSubjectToDiscoveryMutator : StackObj {
+  ReferenceProcessor* _rp;
+  BoolObjectClosure* _saved_cl;
+
+public:
+  ReferenceProcessorSubjectToDiscoveryMutator(ReferenceProcessor* rp, BoolObjectClosure* cl):
+    _rp(rp) {
+    _saved_cl = _rp->is_subject_to_discovery_closure();
+    _rp->set_is_subject_to_discovery_closure(cl);
+  }
+
+  ~ReferenceProcessorSubjectToDiscoveryMutator() {
+    _rp->set_is_subject_to_discovery_closure(_saved_cl);
+  }
+};
 
 // A utility class to temporarily mutate the span of the
 // given ReferenceProcessor in the scope that contains it.
-class ReferenceProcessorSpanMutator: StackObj {
- private:
+class ReferenceProcessorSpanMutator : StackObj {
   ReferenceProcessor* _rp;
-  MemRegion           _saved_span;
+  SpanSubjectToDiscoveryClosure _discoverer;
+  BoolObjectClosure* _old_discoverer;
 
- public:
+public:
   ReferenceProcessorSpanMutator(ReferenceProcessor* rp,
                                 MemRegion span):
-    _rp(rp) {
-    _saved_span = _rp->span();
-    _rp->set_span(span);
+    _rp(rp),
+    _discoverer(span),
+    _old_discoverer(rp->is_subject_to_discovery_closure()) {
+
+    rp->set_is_subject_to_discovery_closure(&_discoverer);
   }
 
   ~ReferenceProcessorSpanMutator() {
-    _rp->set_span(_saved_span);
+    _rp->set_is_subject_to_discovery_closure(_old_discoverer);
   }
 };
 
@@ -498,7 +523,6 @@
   }
 };
 
-
 // A utility class to temporarily change the disposition
 // of the "is_alive_non_header" closure field of the
 // given ReferenceProcessor in the scope that contains it.
--- a/src/hotspot/share/gc/shared/referenceProcessor.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/referenceProcessor.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,9 +51,9 @@
                                                OopClosure*        keep_alive,
                                                BoolObjectClosure* is_alive):
   _refs_list(refs_list),
-  _prev_next(refs_list.adr_head()),
-  _prev(NULL),
-  _ref(refs_list.head()),
+  _prev_discovered_addr(refs_list.adr_head()),
+  _prev_discovered(NULL),
+  _current_discovered(refs_list.head()),
 #ifdef ASSERT
   _first_seen(refs_list.head()),
 #endif
@@ -61,7 +61,7 @@
   _processed(0),
   _removed(0),
 #endif
-  _next(NULL),
+  _next_discovered(NULL),
   _keep_alive(keep_alive),
   _is_alive(is_alive) {
 }
--- a/src/hotspot/share/gc/shared/space.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/space.cpp	Fri May 04 08:50:01 2018 -0700
@@ -25,7 +25,6 @@
 #include "precompiled.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
-#include "gc/serial/defNewGeneration.hpp"
 #include "gc/shared/blockOffsetTable.inline.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
 #include "gc/shared/genCollectedHeap.hpp"
@@ -44,6 +43,9 @@
 #include "utilities/copy.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/macros.hpp"
+#if INCLUDE_SERIALGC
+#include "gc/serial/defNewGeneration.hpp"
+#endif
 
 HeapWord* DirtyCardToOopClosure::get_actual_top(HeapWord* top,
                                                 HeapWord* top_obj) {
@@ -412,6 +414,8 @@
   return compact_top;
 }
 
+#if INCLUDE_SERIALGC
+
 void ContiguousSpace::prepare_for_compaction(CompactPoint* cp) {
   scan_and_forward(this, cp);
 }
@@ -429,6 +433,8 @@
   scan_and_compact(this);
 }
 
+#endif // INCLUDE_SERIALGC
+
 void Space::print_short() const { print_short_on(tty); }
 
 void Space::print_short_on(outputStream* st) const {
@@ -484,7 +490,7 @@
   return true;
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
 #define ContigSpace_PAR_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)         \
                                                                             \
   void ContiguousSpace::par_oop_iterate(MemRegion mr, OopClosureType* blk) {\
@@ -499,7 +505,7 @@
   ALL_PAR_OOP_ITERATE_CLOSURES(ContigSpace_PAR_OOP_ITERATE_DEFN)
 
 #undef ContigSpace_PAR_OOP_ITERATE_DEFN
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_CMSGC
 
 void ContiguousSpace::oop_iterate(ExtendedOopClosure* blk) {
   if (is_empty()) return;
--- a/src/hotspot/share/gc/shared/space.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/space.hpp	Fri May 04 08:50:01 2018 -0700
@@ -220,9 +220,11 @@
   // Allocation (return NULL if full).  Enforces mutual exclusion internally.
   virtual HeapWord* par_allocate(size_t word_size) = 0;
 
+#if INCLUDE_SERIALGC
   // Mark-sweep-compact support: all spaces can update pointers to objects
   // moving as a part of compaction.
   virtual void adjust_pointers() = 0;
+#endif
 
   virtual void print() const;
   virtual void print_on(outputStream* st) const;
@@ -405,6 +407,7 @@
     _next_compaction_space = csp;
   }
 
+#if INCLUDE_SERIALGC
   // MarkSweep support phase2
 
   // Start the process of compaction of the current space: compute
@@ -420,6 +423,7 @@
   virtual void adjust_pointers();
   // MarkSweep support phase4
   virtual void compact();
+#endif // INCLUDE_SERIALGC
 
   // The maximum percentage of objects that can be dead in the compacted
   // live part of a compacted space ("deadwood" support.)
@@ -474,9 +478,11 @@
   // and possibly also overriding obj_size(), and adjust_obj_size().
   // These functions should avoid virtual calls whenever possible.
 
+#if INCLUDE_SERIALGC
   // Frequently calls adjust_obj_size().
   template <class SpaceType>
   static inline void scan_and_adjust_pointers(SpaceType* space);
+#endif
 
   // Frequently calls obj_size().
   template <class SpaceType>
@@ -603,14 +609,14 @@
   }
 
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
   // In support of parallel oop_iterate.
   #define ContigSpace_PAR_OOP_ITERATE_DECL(OopClosureType, nv_suffix)  \
     void par_oop_iterate(MemRegion mr, OopClosureType* blk);
 
     ALL_PAR_OOP_ITERATE_CLOSURES(ContigSpace_PAR_OOP_ITERATE_DECL)
   #undef ContigSpace_PAR_OOP_ITERATE_DECL
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_CMSGC
 
   // Compaction support
   virtual void reset_after_compaction() {
@@ -654,8 +660,10 @@
   HeapWord** top_addr() { return &_top; }
   HeapWord** end_addr() { return &_end; }
 
+#if INCLUDE_SERIALGC
   // Overrides for more efficient compaction support.
   void prepare_for_compaction(CompactPoint* cp);
+#endif
 
   virtual void print_on(outputStream* st) const;
 
--- a/src/hotspot/share/gc/shared/space.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/space.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -25,7 +25,6 @@
 #ifndef SHARE_VM_GC_SHARED_SPACE_INLINE_HPP
 #define SHARE_VM_GC_SHARED_SPACE_INLINE_HPP
 
-#include "gc/serial/markSweep.inline.hpp"
 #include "gc/shared/collectedHeap.hpp"
 #include "gc/shared/generation.hpp"
 #include "gc/shared/space.hpp"
@@ -35,6 +34,9 @@
 #include "oops/oop.inline.hpp"
 #include "runtime/prefetch.inline.hpp"
 #include "runtime/safepoint.hpp"
+#if INCLUDE_SERIALGC
+#include "gc/serial/markSweep.inline.hpp"
+#endif
 
 inline HeapWord* Space::block_start(const void* p) {
   return block_start_const(p);
@@ -77,6 +79,8 @@
   return oop(addr)->size();
 }
 
+#if INCLUDE_SERIALGC
+
 class DeadSpacer : StackObj {
   size_t _allowed_deadspace_words;
   bool _active;
@@ -347,6 +351,8 @@
   clear_empty_region(space);
 }
 
+#endif // INCLUDE_SERIALGC
+
 size_t ContiguousSpace::scanned_block_size(const HeapWord* addr) const {
   return oop(addr)->size();
 }
--- a/src/hotspot/share/gc/shared/specialized_oop_closures.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/specialized_oop_closures.hpp	Fri May 04 08:50:01 2018 -0700
@@ -25,12 +25,16 @@
 #ifndef SHARE_VM_GC_SHARED_SPECIALIZED_OOP_CLOSURES_HPP
 #define SHARE_VM_GC_SHARED_SPECIALIZED_OOP_CLOSURES_HPP
 
+#include "utilities/macros.hpp"
+#if INCLUDE_CMSGC
+#include "gc/cms/cms_specialized_oop_closures.hpp"
+#endif
+#if INCLUDE_G1GC
+#include "gc/g1/g1_specialized_oop_closures.hpp"
+#endif
+#if INCLUDE_SERIALGC
 #include "gc/serial/serial_specialized_oop_closures.hpp"
-#include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/cms/cms_specialized_oop_closures.hpp"
-#include "gc/g1/g1_specialized_oop_closures.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif
 
 // The following OopClosure types get specialized versions of
 // "oop_oop_iterate" that invoke the closures' do_oop methods
@@ -56,14 +60,14 @@
 
 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f)                 \
   f(NoHeaderExtendedOopClosure,_nv)                               \
-               SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f)          \
-  ALL_GCS_ONLY(SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f))
+  SERIALGC_ONLY(SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f))        \
+     CMSGC_ONLY(SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f))
 
 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f)                 \
-               SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_MS(f)         \
-  ALL_GCS_ONLY(SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_CMS(f))       \
-  ALL_GCS_ONLY(SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_G1(f))        \
-  ALL_GCS_ONLY(SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_G1FULL(f))
+  SERIALGC_ONLY(SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_MS(f))       \
+     CMSGC_ONLY(SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_CMS(f))      \
+      G1GC_ONLY(SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_G1(f))       \
+      G1GC_ONLY(SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_G1FULL(f))
 
 // We separate these out, because sometime the general one has
 // a different definition from the specialized ones, and sometimes it
@@ -85,7 +89,7 @@
 
 #define ALL_PAR_OOP_ITERATE_CLOSURES(f)                           \
   f(ExtendedOopClosure,_v)                                        \
-  ALL_GCS_ONLY(SPECIALIZED_PAR_OOP_ITERATE_CLOSURES(f))
+  CMSGC_ONLY(SPECIALIZED_PAR_OOP_ITERATE_CLOSURES(f))
 
 // This macro applies an argument macro to all OopClosures for which we
 // want specialized bodies of a family of methods related to
@@ -94,8 +98,8 @@
 // "OopClosure" in some applications and "OopsInGenClosure" in others.
 
 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(f)  \
-               SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f)   \
-  ALL_GCS_ONLY(SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f))
+  SERIALGC_ONLY(SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f))   \
+     CMSGC_ONLY(SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f))
 
 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f)                  \
   SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(f)
--- a/src/hotspot/share/gc/shared/vmGCOperations.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/vmGCOperations.cpp	Fri May 04 08:50:01 2018 -0700
@@ -38,10 +38,10 @@
 #include "utilities/dtrace.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/preserveException.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1Policy.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
 VM_GC_Operation::~VM_GC_Operation() {
   CollectedHeap* ch = Universe::heap();
@@ -193,12 +193,14 @@
 
 // Returns true iff concurrent GCs unloads metadata.
 bool VM_CollectForMetadataAllocation::initiate_concurrent_GC() {
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
   if (UseConcMarkSweepGC && CMSClassUnloadingEnabled) {
     MetaspaceGC::set_should_concurrent_collect(true);
     return true;
   }
+#endif
 
+#if INCLUDE_G1GC
   if (UseG1GC && ClassUnloadingWithConcurrentMark) {
     G1CollectedHeap* g1h = G1CollectedHeap::heap();
     g1h->g1_policy()->collector_state()->set_initiate_conc_mark_if_possible(true);
--- a/src/hotspot/share/gc/shared/vmStructs_gc.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/gc/shared/vmStructs_gc.hpp	Fri May 04 08:50:01 2018 -0700
@@ -25,6 +25,7 @@
 #ifndef SHARE_GC_SHARED_VMSTRUCTS_GC_HPP
 #define SHARE_GC_SHARED_VMSTRUCTS_GC_HPP
 
+#include "gc/shared/ageTable.hpp"
 #include "gc/shared/cardGeneration.hpp"
 #include "gc/shared/cardTableRS.hpp"
 #include "gc/shared/collectedHeap.hpp"
@@ -33,30 +34,36 @@
 #include "gc/shared/generationSpec.hpp"
 #include "gc/shared/oopStorage.hpp"
 #include "gc/shared/space.hpp"
+#if INCLUDE_CMSGC
+#include "gc/cms/vmStructs_cms.hpp"
+#endif
+#if INCLUDE_G1GC
+#include "gc/g1/vmStructs_g1.hpp"
+#endif
+#if INCLUDE_PARALLELGC
+#include "gc/parallel/vmStructs_parallelgc.hpp"
+#endif
+#if INCLUDE_SERIALGC
 #include "gc/serial/defNewGeneration.hpp"
 #include "gc/serial/vmStructs_serial.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/cms/vmStructs_cms.hpp"
-#include "gc/g1/vmStructs_g1.hpp"
-#include "gc/parallel/vmStructs_parallelgc.hpp"
 #endif
 
 #define VM_STRUCTS_GC(nonstatic_field,                                                                                               \
                       volatile_nonstatic_field,                                                                                      \
                       static_field,                                                                                                  \
                       unchecked_nonstatic_field)                                                                                     \
-  ALL_GCS_ONLY(VM_STRUCTS_CMSGC(nonstatic_field,                                                                                     \
-                                volatile_nonstatic_field,                                                                            \
-                                static_field))                                                                                       \
-  ALL_GCS_ONLY(VM_STRUCTS_G1GC(nonstatic_field,                                                                                      \
-                               volatile_nonstatic_field,                                                                             \
-                               static_field))                                                                                        \
-  ALL_GCS_ONLY(VM_STRUCTS_PARALLELGC(nonstatic_field,                                                                                \
-                                     volatile_nonstatic_field,                                                                       \
-                                     static_field))                                                                                  \
-  VM_STRUCTS_SERIALGC(nonstatic_field,                                                                                               \
-                      volatile_nonstatic_field,                                                                                      \
-                      static_field)                                                                                                  \
+  CMSGC_ONLY(VM_STRUCTS_CMSGC(nonstatic_field,                                                                                       \
+                              volatile_nonstatic_field,                                                                              \
+                              static_field))                                                                                         \
+  G1GC_ONLY(VM_STRUCTS_G1GC(nonstatic_field,                                                                                         \
+                            volatile_nonstatic_field,                                                                                \
+                            static_field))                                                                                           \
+  PARALLELGC_ONLY(VM_STRUCTS_PARALLELGC(nonstatic_field,                                                                             \
+                                        volatile_nonstatic_field,                                                                    \
+                                        static_field))                                                                               \
+  SERIALGC_ONLY(VM_STRUCTS_SERIALGC(nonstatic_field,                                                                                 \
+                                    volatile_nonstatic_field,                                                                        \
+                                    static_field))                                                                                   \
   /**********************************************************************************/                                               \
   /* Generation and Space hierarchies                                               */                                               \
   /**********************************************************************************/                                               \
@@ -114,13 +121,6 @@
   nonstatic_field(ContiguousSpace,             _concurrent_iteration_safe_limit,              HeapWord*)                             \
   nonstatic_field(ContiguousSpace,             _saved_mark_word,                              HeapWord*)                             \
                                                                                                                                      \
-  nonstatic_field(DefNewGeneration,            _old_gen,                                      Generation*)                           \
-  nonstatic_field(DefNewGeneration,            _tenuring_threshold,                           uint)                                  \
-  nonstatic_field(DefNewGeneration,            _age_table,                                    AgeTable)                              \
-  nonstatic_field(DefNewGeneration,            _eden_space,                                   ContiguousSpace*)                      \
-  nonstatic_field(DefNewGeneration,            _from_space,                                   ContiguousSpace*)                      \
-  nonstatic_field(DefNewGeneration,            _to_space,                                     ContiguousSpace*)                      \
-                                                                                                                                     \
   nonstatic_field(Generation,                  _reserved,                                     MemRegion)                             \
   nonstatic_field(Generation,                  _virtual_space,                                VirtualSpace)                          \
   nonstatic_field(Generation,                  _stat_record,                                  Generation::StatRecord)                \
@@ -150,18 +150,18 @@
 #define VM_TYPES_GC(declare_type,                                         \
                     declare_toplevel_type,                                \
                     declare_integer_type)                                 \
-  ALL_GCS_ONLY(VM_TYPES_CMSGC(declare_type,                               \
-                             declare_toplevel_type,                       \
-                             declare_integer_type))                       \
-  ALL_GCS_ONLY(VM_TYPES_G1GC(declare_type,                                \
-                             declare_toplevel_type,                       \
-                             declare_integer_type))                       \
-  ALL_GCS_ONLY(VM_TYPES_PARALLELGC(declare_type,                          \
-                                   declare_toplevel_type,                 \
-                                   declare_integer_type))                 \
-  VM_TYPES_SERIALGC(declare_type,                                         \
-                    declare_toplevel_type,                                \
-                    declare_integer_type)                                 \
+  CMSGC_ONLY(VM_TYPES_CMSGC(declare_type,                                 \
+                            declare_toplevel_type,                        \
+                            declare_integer_type))                        \
+  G1GC_ONLY(VM_TYPES_G1GC(declare_type,                                   \
+                          declare_toplevel_type,                          \
+                          declare_integer_type))                          \
+  PARALLELGC_ONLY(VM_TYPES_PARALLELGC(declare_type,                       \
+                                      declare_toplevel_type,              \
+                                      declare_integer_type))              \
+  SERIALGC_ONLY(VM_TYPES_SERIALGC(declare_type,                           \
+                                  declare_toplevel_type,                  \
+                                  declare_integer_type))                  \
   /******************************************/                            \
   /* Generation and space hierarchies       */                            \
   /* (needed for run-time type information) */                            \
@@ -170,7 +170,6 @@
   declare_toplevel_type(CollectedHeap)                                    \
            declare_type(GenCollectedHeap,             CollectedHeap)      \
   declare_toplevel_type(Generation)                                       \
-           declare_type(DefNewGeneration,             Generation)         \
            declare_type(CardGeneration,               Generation)         \
   declare_toplevel_type(Space)                                            \
            declare_type(CompactibleSpace,             Space)              \
@@ -224,14 +223,14 @@
 
 #define VM_INT_CONSTANTS_GC(declare_constant,                               \
                             declare_constant_with_value)                    \
-  ALL_GCS_ONLY(VM_INT_CONSTANTS_CMSGC(declare_constant,                     \
-                                      declare_constant_with_value))         \
-  ALL_GCS_ONLY(VM_INT_CONSTANTS_G1GC(declare_constant,                      \
-                                     declare_constant_with_value))          \
-  ALL_GCS_ONLY(VM_INT_CONSTANTS_PARALLELGC(declare_constant,                \
-                                           declare_constant_with_value))    \
-  VM_INT_CONSTANTS_SERIALGC(declare_constant,                               \
-                            declare_constant_with_value)                    \
+  CMSGC_ONLY(VM_INT_CONSTANTS_CMSGC(declare_constant,                       \
+                                    declare_constant_with_value))           \
+  G1GC_ONLY(VM_INT_CONSTANTS_G1GC(declare_constant,                         \
+                                  declare_constant_with_value))             \
+  PARALLELGC_ONLY(VM_INT_CONSTANTS_PARALLELGC(declare_constant,             \
+                                              declare_constant_with_value)) \
+  SERIALGC_ONLY(VM_INT_CONSTANTS_SERIALGC(declare_constant,                 \
+                                          declare_constant_with_value))     \
                                                                             \
   /********************************************/                            \
   /* Generation and Space Hierarchy Constants */                            \
--- a/src/hotspot/share/jvmci/jvmciRuntime.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp	Fri May 04 08:50:01 2018 -0700
@@ -50,9 +50,9 @@
 #include "utilities/debug.hpp"
 #include "utilities/defaultStream.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1ThreadLocalData.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
 #if defined(_MSC_VER)
 #define strtoll _strtoi64
@@ -484,18 +484,18 @@
   }
 JRT_END
 
+#if INCLUDE_G1GC
+
 JRT_LEAF(void, JVMCIRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj))
-#if INCLUDE_ALL_GCS
   G1ThreadLocalData::satb_mark_queue(thread).enqueue(obj);
-#endif // INCLUDE_ALL_GCS
 JRT_END
 
 JRT_LEAF(void, JVMCIRuntime::write_barrier_post(JavaThread* thread, void* card_addr))
-#if INCLUDE_ALL_GCS
   G1ThreadLocalData::dirty_card_queue(thread).enqueue(card_addr);
-#endif // INCLUDE_ALL_GCS
 JRT_END
 
+#endif // INCLUDE_G1GC
+
 JRT_LEAF(jboolean, JVMCIRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child))
   bool ret = true;
   if(!Universe::heap()->is_in_closed_subset(parent)) {
--- a/src/hotspot/share/jvmci/jvmciRuntime.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/jvmci/jvmciRuntime.hpp	Fri May 04 08:50:01 2018 -0700
@@ -150,8 +150,10 @@
   // printed as a string, otherwise the type of the object is printed
   // followed by its address.
   static void log_object(JavaThread* thread, oopDesc* object, bool as_string, bool newline);
+#if INCLUDE_G1GC
   static void write_barrier_pre(JavaThread* thread, oopDesc* obj);
   static void write_barrier_post(JavaThread* thread, void* card);
+#endif
   static jboolean validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child);
 
   // used to throw exceptions from compiled JVMCI code
--- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp	Fri May 04 08:50:01 2018 -0700
@@ -40,8 +40,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.hpp"
 #include "runtime/vm_version.hpp"
-
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1BarrierSet.hpp"
 #include "gc/g1/g1CardTable.hpp"
 #include "gc/g1/heapRegion.hpp"
@@ -636,14 +635,14 @@
   declare_function(JVMCIRuntime::log_printf) \
   declare_function(JVMCIRuntime::vm_error) \
   declare_function(JVMCIRuntime::load_and_clear_exception) \
-  ALL_GCS_ONLY(declare_function(JVMCIRuntime::write_barrier_pre)) \
-  ALL_GCS_ONLY(declare_function(JVMCIRuntime::write_barrier_post)) \
+  G1GC_ONLY(declare_function(JVMCIRuntime::write_barrier_pre)) \
+  G1GC_ONLY(declare_function(JVMCIRuntime::write_barrier_post)) \
   declare_function(JVMCIRuntime::validate_object) \
   \
   declare_function(JVMCIRuntime::test_deoptimize_call_int)
 
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 
 #define VM_STRUCTS_JVMCI_G1GC(nonstatic_field, static_field) \
   static_field(HeapRegion, LogOfHRGrainBytes, int)
@@ -656,7 +655,7 @@
   declare_constant_with_value("G1ThreadLocalData::dirty_card_queue_index_offset", in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset())) \
   declare_constant_with_value("G1ThreadLocalData::dirty_card_queue_buffer_offset", in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()))
 
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
 
 #ifdef LINUX
@@ -872,7 +871,7 @@
                  GENERATE_C1_UNCHECKED_STATIC_VM_STRUCT_ENTRY,
                  GENERATE_C2_UNCHECKED_STATIC_VM_STRUCT_ENTRY)
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   VM_STRUCTS_JVMCI_G1GC(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
                         GENERATE_STATIC_VM_STRUCT_ENTRY)
 #endif
@@ -924,7 +923,7 @@
                        GENERATE_C2_VM_INT_CONSTANT_ENTRY,
                        GENERATE_C2_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   VM_INT_CONSTANTS_JVMCI_G1GC(GENERATE_VM_INT_CONSTANT_ENTRY,
                               GENERATE_VM_INT_CONSTANT_WITH_VALUE_ENTRY,
                               GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)
--- a/src/hotspot/share/logging/logFileOutput.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/logging/logFileOutput.cpp	Fri May 04 08:50:01 2018 -0700
@@ -245,7 +245,7 @@
     increment_file_count();
   }
 
-  _stream = fopen(_file_name, FileOpenMode);
+  _stream = os::fopen(_file_name, FileOpenMode);
   if (_stream == NULL) {
     errstream->print_cr("Error opening log file '%s': %s",
                         _file_name, strerror(errno));
@@ -334,7 +334,7 @@
   archive();
 
   // Open the active log file using the same stream as before
-  _stream = fopen(_file_name, FileOpenMode);
+  _stream = os::fopen(_file_name, FileOpenMode);
   if (_stream == NULL) {
     jio_fprintf(defaultStream::error_stream(), "Could not reopen file '%s' during log rotation (%s).\n",
                 _file_name, os::strerror(errno));
--- a/src/hotspot/share/logging/logStream.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/logging/logStream.cpp	Fri May 04 08:50:01 2018 -0700
@@ -112,3 +112,12 @@
   update_position(s, len);
 }
 
+// Destructor writes any unfinished output left in the line buffer.
+LogStream::~LogStream() {
+  if (_current_line.is_empty() == false) {
+    _log_handle.print("%s", _current_line.buffer());
+    _current_line.reset();
+  }
+}
+
+
--- a/src/hotspot/share/logging/logStream.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/logging/logStream.hpp	Fri May 04 08:50:01 2018 -0700
@@ -48,6 +48,7 @@
   public:
     LineBuffer();
     ~LineBuffer();
+    bool is_empty() const { return _pos == 0; }
     const char* buffer() const { return _buf; }
     void append(const char* s, size_t len);
     void reset();
@@ -77,6 +78,9 @@
   LogStream(const LogTargetImpl<level, T0, T1, T2, T3, T4, GuardTag>* type_carrier) :
       _log_handle(level, &LogTagSetMapping<T0, T1, T2, T3, T4>::tagset()) {}
 
+  // Destructor writes any unfinished output left in the line buffer.
+  ~LogStream();
+
   // Constructor to support creation from a LogTargetHandle.
   //
   // LogTarget(Debug, gc) log;
--- a/src/hotspot/share/memory/filemap.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/memory/filemap.cpp	Fri May 04 08:50:01 2018 -0700
@@ -49,7 +49,7 @@
 #include "services/memTracker.hpp"
 #include "utilities/align.hpp"
 #include "utilities/defaultStream.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1CollectedHeap.hpp"
 #endif
 
--- a/src/hotspot/share/memory/metachunk.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/memory/metachunk.hpp	Fri May 04 08:50:01 2018 -0700
@@ -110,6 +110,9 @@
 size_t get_size_for_nonhumongous_chunktype(ChunkIndex chunk_type, bool is_class);
 ChunkIndex get_chunk_type_by_size(size_t size, bool is_class);
 
+ChunkIndex next_chunk_index(ChunkIndex i);
+ChunkIndex prev_chunk_index(ChunkIndex i);
+
 // Returns a descriptive name for a chunk type.
 const char* chunk_size_name(ChunkIndex index);
 
@@ -184,7 +187,7 @@
   // Alignment of each allocation in the chunks.
   static size_t object_alignment();
 
-  // Size of the Metachunk header, including alignment.
+  // Size of the Metachunk header, in words, including alignment.
   static size_t overhead();
 
   Metachunk(ChunkIndex chunktype, bool is_class, size_t word_size, VirtualSpaceNode* container);
--- a/src/hotspot/share/memory/metaspace.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/memory/metaspace.cpp	Fri May 04 08:50:01 2018 -0700
@@ -33,6 +33,8 @@
 #include "memory/freeList.inline.hpp"
 #include "memory/metachunk.hpp"
 #include "memory/metaspace.hpp"
+#include "memory/metaspace/metaspaceCommon.hpp"
+#include "memory/metaspace/metaspaceStatistics.hpp"
 #include "memory/metaspaceGCThresholdUpdater.hpp"
 #include "memory/metaspaceShared.hpp"
 #include "memory/metaspaceTracer.hpp"
@@ -43,14 +45,18 @@
 #include "runtime/init.hpp"
 #include "runtime/java.hpp"
 #include "runtime/mutex.hpp"
+#include "runtime/mutexLocker.hpp"
 #include "runtime/orderAccess.inline.hpp"
 #include "services/memTracker.hpp"
 #include "services/memoryService.hpp"
 #include "utilities/align.hpp"
 #include "utilities/copy.hpp"
 #include "utilities/debug.hpp"
+#include "utilities/globalDefinitions.hpp"
 #include "utilities/macros.hpp"
 
+using namespace metaspace::internals;
+
 typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > BlockTreeDictionary;
 typedef BinaryTreeDictionary<Metachunk, FreeList<Metachunk> > ChunkTreeDictionary;
 
@@ -70,6 +76,30 @@
 
 DEBUG_ONLY(bool Metaspace::_frozen = false;)
 
+// Internal statistics.
+#ifdef ASSERT
+static struct {
+  // Number of allocations.
+  uintx num_allocs;
+  // Number of times a ClassLoaderMetaspace was born...
+  uintx num_metaspace_births;
+  // ... and died.
+  uintx num_metaspace_deaths;
+  // Number of times VirtualSpaceListNodes were created...
+  uintx num_vsnodes_created;
+  // ... and purged.
+  uintx num_vsnodes_purged;
+  // Number of times we expanded the committed section of the space.
+  uintx num_committed_space_expanded;
+  // Number of deallocations
+  uintx num_deallocs;
+  // Number of deallocations triggered from outside ("real" deallocations).
+  uintx num_external_deallocs;
+  // Number of times an allocation was satisfied from deallocated blocks.
+  uintx num_allocs_from_deallocated_blocks;
+} g_internal_statistics;
+#endif
+
 enum ChunkSizes {    // in words.
   ClassSpecializedChunk = 128,
   SpecializedChunk = 128,
@@ -133,33 +163,33 @@
   return (ChunkIndex)-1;
 }
 
-
-static ChunkIndex next_chunk_index(ChunkIndex i) {
+ChunkIndex next_chunk_index(ChunkIndex i) {
   assert(i < NumberOfInUseLists, "Out of bound");
   return (ChunkIndex) (i+1);
 }
 
-static ChunkIndex prev_chunk_index(ChunkIndex i) {
+ChunkIndex prev_chunk_index(ChunkIndex i) {
   assert(i > ZeroIndex, "Out of bound");
   return (ChunkIndex) (i-1);
 }
 
-static const char* scale_unit(size_t scale) {
-  switch(scale) {
-    case 1: return "BYTES";
-    case K: return "KB";
-    case M: return "MB";
-    case G: return "GB";
-    default:
-      ShouldNotReachHere();
-      return NULL;
-  }
+static const char* space_type_name(Metaspace::MetaspaceType t) {
+  const char* s = NULL;
+  switch (t) {
+    case Metaspace::StandardMetaspaceType: s = "Standard"; break;
+    case Metaspace::BootMetaspaceType: s = "Boot"; break;
+    case Metaspace::AnonymousMetaspaceType: s = "Anonymous"; break;
+    case Metaspace::ReflectionMetaspaceType: s = "Reflection"; break;
+    default: ShouldNotReachHere();
+  }
+  return s;
 }
 
 volatile intptr_t MetaspaceGC::_capacity_until_GC = 0;
 uint MetaspaceGC::_shrink_factor = 0;
 bool MetaspaceGC::_should_concurrent_collect = false;
 
+
 typedef class FreeList<Metachunk> ChunkList;
 
 // Manages the global free lists of chunks.
@@ -240,19 +270,6 @@
 
  public:
 
-  struct ChunkManagerStatistics {
-    size_t num_by_type[NumberOfFreeLists];
-    size_t single_size_by_type[NumberOfFreeLists];
-    size_t total_size_by_type[NumberOfFreeLists];
-    size_t num_humongous_chunks;
-    size_t total_size_humongous_chunks;
-  };
-
-  void locked_get_statistics(ChunkManagerStatistics* stat) const;
-  void get_statistics(ChunkManagerStatistics* stat) const;
-  static void print_statistics(const ChunkManagerStatistics* stat, outputStream* out, size_t scale);
-
-
   ChunkManager(bool is_class)
       : _is_class(is_class), _free_chunks_total(0), _free_chunks_count(0) {
     _free_chunks[SpecializedIndex].set_size(get_size_for_nonhumongous_chunktype(SpecializedIndex, is_class));
@@ -358,13 +375,14 @@
 
   void print_on(outputStream* st) const;
 
-  // Prints composition for both non-class and (if available)
-  // class chunk manager.
-  static void print_all_chunkmanagers(outputStream* out, size_t scale = 1);
+  // Fill in current statistic values to the given statistics object.
+  void collect_statistics(ChunkManagerStatistics* out) const;
+
 };
 
 class SmallBlocks : public CHeapObj<mtClass> {
   const static uint _small_block_max_size = sizeof(TreeChunk<Metablock,  FreeList<Metablock> >)/HeapWordSize;
+  // Note: this corresponds to the imposed miminum allocation size, see SpaceManager::get_allocation_word_size()
   const static uint _small_block_min_size = sizeof(Metablock)/HeapWordSize;
 
  private:
@@ -383,6 +401,7 @@
     }
   }
 
+  // Returns the total size, in words, of all blocks, across all block sizes.
   size_t total_size() const {
     size_t result = 0;
     for (uint i = _small_block_min_size; i < _small_block_max_size; i++) {
@@ -392,6 +411,16 @@
     return result;
   }
 
+  // Returns the total number of all blocks across all block sizes.
+  uintx total_num_blocks() const {
+    uintx result = 0;
+    for (uint i = _small_block_min_size; i < _small_block_max_size; i++) {
+      uint k = i - _small_block_min_size;
+      result = result + _small_lists[k].count();
+    }
+    return result;
+  }
+
   static uint small_block_max_size() { return _small_block_max_size; }
   static uint small_block_min_size() { return _small_block_min_size; }
 
@@ -444,6 +473,7 @@
   MetaWord* get_block(size_t word_size);
   void return_block(MetaWord* p, size_t word_size);
 
+  // Returns the total size, in words, of all blocks kept in this structure.
   size_t total_size() const  {
     size_t result = dictionary()->total_size();
     if (_small_blocks != NULL) {
@@ -452,6 +482,15 @@
     return result;
   }
 
+  // Returns the number of all blocks kept in this structure.
+  uintx num_blocks() const {
+    uintx result = dictionary()->total_free_blocks();
+    if (_small_blocks != NULL) {
+      result = result + _small_blocks->total_num_blocks();
+    }
+    return result;
+  }
+
   static size_t min_dictionary_size()   { return TreeChunk<Metablock, FreeList<Metablock> >::min_size(); }
   void print_on(outputStream* st) const;
 };
@@ -857,7 +896,8 @@
   void retire(ChunkManager* chunk_manager);
 
 
-  void print_on(outputStream* st) const;
+  void print_on(outputStream* st) const                 { print_on(st, K); }
+  void print_on(outputStream* st, size_t scale) const;
   void print_map(outputStream* st, bool is_class) const;
 
   // Debug support
@@ -875,6 +915,12 @@
          SIZE_FORMAT_HEX " is not aligned to "               \
          SIZE_FORMAT, (size_t)(uintptr_t)value, (alignment))
 
+#define assert_counter(expected_value, real_value, msg) \
+  assert( (expected_value) == (real_value),             \
+         "Counter mismatch (%s): expected " SIZE_FORMAT \
+         ", but got: " SIZE_FORMAT ".", msg, expected_value, \
+         real_value);
+
 // Decide if large pages should be committed when the memory is reserved.
 static bool should_commit_large_pages_when_reserving(size_t bytes) {
   if (UseLargePages && UseLargePagesInMetaspace && !os::can_commit_large_page_memory()) {
@@ -1181,7 +1227,8 @@
   // Unlink empty VirtualSpaceNodes and free it.
   void purge(ChunkManager* chunk_manager);
 
-  void print_on(outputStream* st) const;
+  void print_on(outputStream* st) const                 { print_on(st, K); }
+  void print_on(outputStream* st, size_t scale) const;
   void print_map(outputStream* st) const;
 
   class VirtualSpaceListIterator : public StackObj {
@@ -1218,6 +1265,7 @@
 
 int Metadebug::_allocation_fail_alot_count = 0;
 
+
 //  SpaceManager - used by Metaspace to handle allocations
 class SpaceManager : public CHeapObj<mtClass> {
   friend class ClassLoaderMetaspace;
@@ -1247,12 +1295,13 @@
   // metadata space to a SpaceManager
   static uint const _anon_and_delegating_metadata_specialize_chunk_limit;
 
-  // Sum of all space in allocated chunks
-  size_t _allocated_blocks_words;
-
-  // Sum of all allocated chunks
-  size_t _allocated_chunks_words;
-  size_t _allocated_chunks_count;
+  // Some running counters, but lets keep their number small to not add to much to
+  // the per-classloader footprint.
+  // Note: capacity = used + free + waste + overhead. We do not keep running counters for
+  // free and waste. Their sum can be deduced from the three other values.
+  size_t _overhead_words;
+  size_t _capacity_words;
+  size_t _used_words;
 
   // Free lists of blocks are per SpaceManager since they
   // are assumed to be in chunks in use by the SpaceManager
@@ -1287,6 +1336,12 @@
 
   Mutex* lock() const { return _lock; }
 
+  // Adds to the given statistic object. Expects to be locked with lock().
+  void add_to_statistics_locked(SpaceManagerStatistics* out) const;
+
+  // Verify internal counters against the current state. Expects to be locked with lock().
+  DEBUG_ONLY(void verify_metrics_locked() const;)
+
  protected:
   void initialize();
 
@@ -1317,25 +1372,21 @@
 
   size_t medium_chunk_bunch()     const { return medium_chunk_size() * MediumChunkMultiple; }
 
-  size_t allocated_blocks_words() const { return _allocated_blocks_words; }
-  size_t allocated_blocks_bytes() const { return _allocated_blocks_words * BytesPerWord; }
-  size_t allocated_chunks_words() const { return _allocated_chunks_words; }
-  size_t allocated_chunks_bytes() const { return _allocated_chunks_words * BytesPerWord; }
-  size_t allocated_chunks_count() const { return _allocated_chunks_count; }
-
   bool is_humongous(size_t word_size) { return word_size > medium_chunk_size(); }
 
-  // Increment the per Metaspace and global running sums for Metachunks
-  // by the given size.  This is used when a Metachunk to added to
-  // the in-use list.
-  void inc_size_metrics(size_t words);
-  // Increment the per Metaspace and global running sums Metablocks by the given
-  // size.  This is used when a Metablock is allocated.
-  void inc_used_metrics(size_t words);
-  // Delete the portion of the running sums for this SpaceManager. That is,
-  // the globals running sums for the Metachunks and Metablocks are
-  // decremented for all the Metachunks in-use by this SpaceManager.
-  void dec_total_from_size_metrics();
+  size_t capacity_words() const     { return _capacity_words; }
+  size_t used_words() const         { return _used_words; }
+  size_t overhead_words() const     { return _overhead_words; }
+
+  // Adjust local, global counters after a new chunk has been added.
+  void account_for_new_chunk(const Metachunk* new_chunk);
+
+  // Adjust local, global counters after space has been allocated from the current chunk.
+  void account_for_allocation(size_t words);
+
+  // Adjust global counters just before the SpaceManager dies, after all its chunks
+  // have been returned to the freelist.
+  void account_for_spacemanager_death();
 
   // Adjust the initial chunk size to match one of the fixed chunk list sizes,
   // or return the unadjusted size if the requested size is humongous.
@@ -1345,13 +1396,7 @@
   // Get the initial chunks size for this metaspace type.
   size_t get_initial_chunk_size(Metaspace::MetaspaceType type) const;
 
-  size_t sum_capacity_in_chunks_in_use() const;
-  size_t sum_used_in_chunks_in_use() const;
-  size_t sum_free_in_chunks_in_use() const;
-  size_t sum_waste_in_chunks_in_use() const;
-  size_t sum_waste_in_chunks_in_use(ChunkIndex index ) const;
-
-  size_t sum_count_in_chunks_in_use();
+  // Todo: remove this once we have counters by chunk type.
   size_t sum_count_in_chunks_in_use(ChunkIndex i);
 
   Metachunk* get_new_chunk(size_t chunk_word_size);
@@ -1380,15 +1425,11 @@
 
   // debugging support.
 
-  void dump(outputStream* const out) const;
   void print_on(outputStream* st) const;
   void locked_print_chunks_in_use_on(outputStream* st) const;
 
   void verify();
   void verify_chunk_size(Metachunk* chunk);
-#ifdef ASSERT
-  void verify_allocated_blocks_words();
-#endif
 
   // This adjusts the size given to be greater than the minimum allocation size in
   // words for data in metaspace.  Esentially the minimum size is currently 3 words.
@@ -1403,6 +1444,13 @@
 
     return raw_word_size;
   }
+
+  // Adds to the given statistic object.
+  void add_to_statistics(SpaceManagerStatistics* out) const;
+
+  // Verify internal counters against the current state.
+  DEBUG_ONLY(void verify_metrics() const;)
+
 };
 
 uint const SpaceManager::_small_chunk_limit = 4;
@@ -1657,6 +1705,7 @@
       ls.print("VirtualSpaceNode::take_from_committed() not available " SIZE_FORMAT " words ", chunk_word_size);
       // Dump some information about the virtual space that is nearly full
       print_on(&ls);
+      ls.cr(); // ~LogStream does not autoflush.
     }
     return NULL;
   }
@@ -1703,6 +1752,7 @@
   if (result) {
     log_trace(gc, metaspace, freelist)("Expanded %s virtual space list node by " SIZE_FORMAT " words.",
               (is_class() ? "class" : "non-class"), commit);
+    DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_committed_space_expanded));
   } else {
     log_trace(gc, metaspace, freelist)("Failed to expand %s virtual space list node by " SIZE_FORMAT " words.",
               (is_class() ? "class" : "non-class"), commit);
@@ -1762,15 +1812,22 @@
   return result;
 }
 
-void VirtualSpaceNode::print_on(outputStream* st) const {
-  size_t used = used_words_in_vs();
-  size_t capacity = capacity_words_in_vs();
+void VirtualSpaceNode::print_on(outputStream* st, size_t scale) const {
+  size_t used_words = used_words_in_vs();
+  size_t commit_words = committed_words();
+  size_t res_words = reserved_words();
   VirtualSpace* vs = virtual_space();
-  st->print_cr("   space @ " PTR_FORMAT " " SIZE_FORMAT "K, " SIZE_FORMAT_W(3) "%% used "
-           "[" PTR_FORMAT ", " PTR_FORMAT ", "
+
+  st->print("node @" PTR_FORMAT ": ", p2i(this));
+  st->print("reserved=");
+  print_scaled_words(st, res_words, scale);
+  st->print(", committed=");
+  print_scaled_words_and_percentage(st, commit_words, res_words, scale);
+  st->print(", used=");
+  print_scaled_words_and_percentage(st, used_words, res_words, scale);
+  st->cr();
+  st->print("   [" PTR_FORMAT ", " PTR_FORMAT ", "
            PTR_FORMAT ", " PTR_FORMAT ")",
-           p2i(vs), capacity / K,
-           capacity == 0 ? 0 : used * 100 / capacity,
            p2i(bottom()), p2i(top()), p2i(end()),
            p2i(vs->high_boundary()));
 }
@@ -1992,6 +2049,7 @@
     if (vsl->container_count() == 0 && vsl != current_virtual_space()) {
       log_trace(gc, metaspace, freelist)("Purging VirtualSpaceNode " PTR_FORMAT " (capacity: " SIZE_FORMAT
                                          ", used: " SIZE_FORMAT ").", p2i(vsl), vsl->capacity_words_in_vs(), vsl->used_words_in_vs());
+      DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_vsnodes_purged));
       // Unlink it from the list
       if (prev_vsl == vsl) {
         // This is the case of the current node being the first node.
@@ -2139,6 +2197,7 @@
     // ensure lock-free iteration sees fully initialized node
     OrderAccess::storestore();
     link_vs(new_entry);
+    DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_vsnodes_created));
     return true;
   }
 }
@@ -2162,6 +2221,7 @@
     VirtualSpaceNode* vsl = current_virtual_space();
     ResourceMark rm;
     vsl->print_on(&ls);
+    ls.cr(); // ~LogStream does not autoflush.
   }
 }
 
@@ -2287,11 +2347,14 @@
    return next;
 }
 
-void VirtualSpaceList::print_on(outputStream* st) const {
+void VirtualSpaceList::print_on(outputStream* st, size_t scale) const {
+  st->print_cr(SIZE_FORMAT " nodes, current node: " PTR_FORMAT,
+      _virtual_space_count, p2i(_current_virtual_space));
   VirtualSpaceListIterator iter(virtual_space_list());
   while (iter.repeat()) {
+    st->cr();
     VirtualSpaceNode* node = iter.get_next();
-    node->print_on(st);
+    node->print_on(st, scale);
   }
 }
 
@@ -2978,6 +3041,7 @@
              p2i(this), p2i(chunk), chunk->word_size(), list_count);
     ResourceMark rm;
     locked_print_free_chunks(&ls);
+    ls.cr(); // ~LogStream does not autoflush.
   }
 
   return chunk;
@@ -3072,80 +3136,10 @@
   _humongous_dictionary.report_statistics(out);
 }
 
-void ChunkManager::locked_get_statistics(ChunkManagerStatistics* stat) const {
-  assert_lock_strong(MetaspaceExpand_lock);
-  for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) {
-    stat->num_by_type[i] = num_free_chunks(i);
-    stat->single_size_by_type[i] = size_by_index(i);
-    stat->total_size_by_type[i] = size_free_chunks_in_bytes(i);
-  }
-  stat->num_humongous_chunks = num_free_chunks(HumongousIndex);
-  stat->total_size_humongous_chunks = size_free_chunks_in_bytes(HumongousIndex);
-}
-
-void ChunkManager::get_statistics(ChunkManagerStatistics* stat) const {
-  MutexLockerEx cl(MetaspaceExpand_lock,
-                   Mutex::_no_safepoint_check_flag);
-  locked_get_statistics(stat);
-}
-
-void ChunkManager::print_statistics(const ChunkManagerStatistics* stat, outputStream* out, size_t scale) {
-  size_t total = 0;
-  assert(scale == 1 || scale == K || scale == M || scale == G, "Invalid scale");
-
-  const char* unit = scale_unit(scale);
-  for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) {
-    out->print("  " SIZE_FORMAT " %s (" SIZE_FORMAT " bytes) chunks, total ",
-                   stat->num_by_type[i], chunk_size_name(i),
-                   stat->single_size_by_type[i]);
-    if (scale == 1) {
-      out->print_cr(SIZE_FORMAT " bytes", stat->total_size_by_type[i]);
-    } else {
-      out->print_cr("%.2f%s", (float)stat->total_size_by_type[i] / scale, unit);
-    }
-
-    total += stat->total_size_by_type[i];
-  }
-
-
-  total += stat->total_size_humongous_chunks;
-
-  if (scale == 1) {
-    out->print_cr("  " SIZE_FORMAT " humongous chunks, total " SIZE_FORMAT " bytes",
-    stat->num_humongous_chunks, stat->total_size_humongous_chunks);
-
-    out->print_cr("  total size: " SIZE_FORMAT " bytes.", total);
-  } else {
-    out->print_cr("  " SIZE_FORMAT " humongous chunks, total %.2f%s",
-    stat->num_humongous_chunks,
-    (float)stat->total_size_humongous_chunks / scale, unit);
-
-    out->print_cr("  total size: %.2f%s.", (float)total / scale, unit);
-  }
-
-}
-
-void ChunkManager::print_all_chunkmanagers(outputStream* out, size_t scale) {
-  assert(scale == 1 || scale == K || scale == M || scale == G, "Invalid scale");
-
-  // Note: keep lock protection only to retrieving statistics; keep printing
-  // out of lock protection
-  ChunkManagerStatistics stat;
-  out->print_cr("Chunkmanager (non-class):");
-  const ChunkManager* const non_class_cm = Metaspace::chunk_manager_metadata();
-  if (non_class_cm != NULL) {
-    non_class_cm->get_statistics(&stat);
-    ChunkManager::print_statistics(&stat, out, scale);
-  } else {
-    out->print_cr("unavailable.");
-  }
-  out->print_cr("Chunkmanager (class):");
-  const ChunkManager* const class_cm = Metaspace::chunk_manager_class();
-  if (class_cm != NULL) {
-    class_cm->get_statistics(&stat);
-    ChunkManager::print_statistics(&stat, out, scale);
-  } else {
-    out->print_cr("unavailable.");
+void ChunkManager::collect_statistics(ChunkManagerStatistics* out) const {
+  MutexLockerEx cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
+  for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
+    out->chunk_stats(i).add(num_free_chunks(i), size_free_chunks_in_bytes(i) / sizeof(MetaWord));
   }
 }
 
@@ -3201,77 +3195,6 @@
   return adjusted;
 }
 
-size_t SpaceManager::sum_free_in_chunks_in_use() const {
-  MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
-  size_t free = 0;
-  for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
-    Metachunk* chunk = chunks_in_use(i);
-    while (chunk != NULL) {
-      free += chunk->free_word_size();
-      chunk = chunk->next();
-    }
-  }
-  return free;
-}
-
-size_t SpaceManager::sum_waste_in_chunks_in_use() const {
-  MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
-  size_t result = 0;
-  for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
-   result += sum_waste_in_chunks_in_use(i);
-  }
-
-  return result;
-}
-
-size_t SpaceManager::sum_waste_in_chunks_in_use(ChunkIndex index) const {
-  size_t result = 0;
-  Metachunk* chunk = chunks_in_use(index);
-  // Count the free space in all the chunk but not the
-  // current chunk from which allocations are still being done.
-  while (chunk != NULL) {
-    if (chunk != current_chunk()) {
-      result += chunk->free_word_size();
-    }
-    chunk = chunk->next();
-  }
-  return result;
-}
-
-size_t SpaceManager::sum_capacity_in_chunks_in_use() const {
-  // For CMS use "allocated_chunks_words()" which does not need the
-  // Metaspace lock.  For the other collectors sum over the
-  // lists.  Use both methods as a check that "allocated_chunks_words()"
-  // is correct.  That is, sum_capacity_in_chunks() is too expensive
-  // to use in the product and allocated_chunks_words() should be used
-  // but allow for  checking that allocated_chunks_words() returns the same
-  // value as sum_capacity_in_chunks_in_use() which is the definitive
-  // answer.
-  if (UseConcMarkSweepGC) {
-    return allocated_chunks_words();
-  } else {
-    MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
-    size_t sum = 0;
-    for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
-      Metachunk* chunk = chunks_in_use(i);
-      while (chunk != NULL) {
-        sum += chunk->word_size();
-        chunk = chunk->next();
-      }
-    }
-  return sum;
-  }
-}
-
-size_t SpaceManager::sum_count_in_chunks_in_use() {
-  size_t count = 0;
-  for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
-    count = count + sum_count_in_chunks_in_use(i);
-  }
-
-  return count;
-}
-
 size_t SpaceManager::sum_count_in_chunks_in_use(ChunkIndex i) {
   size_t count = 0;
   Metachunk* chunk = chunks_in_use(i);
@@ -3282,20 +3205,6 @@
   return count;
 }
 
-
-size_t SpaceManager::sum_used_in_chunks_in_use() const {
-  MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
-  size_t used = 0;
-  for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
-    Metachunk* chunk = chunks_in_use(i);
-    while (chunk != NULL) {
-      used += chunk->used_word_size();
-      chunk = chunk->next();
-    }
-  }
-  return used;
-}
-
 void SpaceManager::locked_print_chunks_in_use_on(outputStream* st) const {
 
   for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
@@ -3427,24 +3336,9 @@
 }
 
 void SpaceManager::print_on(outputStream* st) const {
-
-  for (ChunkIndex i = ZeroIndex;
-       i < NumberOfInUseLists ;
-       i = next_chunk_index(i) ) {
-    st->print_cr("  chunks_in_use " PTR_FORMAT " chunk size " SIZE_FORMAT,
-                 p2i(chunks_in_use(i)),
-                 chunks_in_use(i) == NULL ? 0 : chunks_in_use(i)->word_size());
-  }
-  st->print_cr("    waste:  Small " SIZE_FORMAT " Medium " SIZE_FORMAT
-               " Humongous " SIZE_FORMAT,
-               sum_waste_in_chunks_in_use(SmallIndex),
-               sum_waste_in_chunks_in_use(MediumIndex),
-               sum_waste_in_chunks_in_use(HumongousIndex));
-  // block free lists
-  if (block_freelists() != NULL) {
-    st->print_cr("total in block free lists " SIZE_FORMAT,
-      block_freelists()->total_size());
-  }
+  SpaceManagerStatistics stat;
+  add_to_statistics(&stat); // will lock _lock.
+  stat.print_on(st, 1*K, false);
 }
 
 SpaceManager::SpaceManager(Metaspace::MetadataType mdtype,
@@ -3452,43 +3346,46 @@
                            Mutex* lock) :
   _mdtype(mdtype),
   _space_type(space_type),
-  _allocated_blocks_words(0),
-  _allocated_chunks_words(0),
-  _allocated_chunks_count(0),
+  _capacity_words(0),
+  _used_words(0),
+  _overhead_words(0),
   _block_freelists(NULL),
   _lock(lock)
 {
   initialize();
 }
 
-void SpaceManager::inc_size_metrics(size_t words) {
+void SpaceManager::account_for_new_chunk(const Metachunk* new_chunk) {
+
   assert_lock_strong(MetaspaceExpand_lock);
-  // Total of allocated Metachunks and allocated Metachunks count
-  // for each SpaceManager
-  _allocated_chunks_words = _allocated_chunks_words + words;
-  _allocated_chunks_count++;
-  // Global total of capacity in allocated Metachunks
-  MetaspaceUtils::inc_capacity(mdtype(), words);
-  // Global total of allocated Metablocks.
-  // used_words_slow() includes the overhead in each
-  // Metachunk so include it in the used when the
-  // Metachunk is first added (so only added once per
-  // Metachunk).
-  MetaspaceUtils::inc_used(mdtype(), Metachunk::overhead());
+
+  _capacity_words += new_chunk->word_size();
+  _overhead_words += Metachunk::overhead();
+
+  // Adjust global counters:
+  MetaspaceUtils::inc_capacity(mdtype(), new_chunk->word_size());
+  MetaspaceUtils::inc_overhead(mdtype(), Metachunk::overhead());
 }
 
-void SpaceManager::inc_used_metrics(size_t words) {
-  // Add to the per SpaceManager total
-  Atomic::add(words, &_allocated_blocks_words);
-  // Add to the global total
+void SpaceManager::account_for_allocation(size_t words) {
+  // Note: we should be locked with the ClassloaderData-specific metaspace lock.
+  // We may or may not be locked with the global metaspace expansion lock.
+  assert_lock_strong(lock());
+
+  // Add to the per SpaceManager totals. This can be done non-atomically.
+  _used_words += words;
+
+  // Adjust global counters. This will be done atomically.
   MetaspaceUtils::inc_used(mdtype(), words);
 }
 
-void SpaceManager::dec_total_from_size_metrics() {
-  MetaspaceUtils::dec_capacity(mdtype(), allocated_chunks_words());
-  MetaspaceUtils::dec_used(mdtype(), allocated_blocks_words());
-  // Also deduct the overhead per Metachunk
-  MetaspaceUtils::dec_used(mdtype(), allocated_chunks_count() * Metachunk::overhead());
+void SpaceManager::account_for_spacemanager_death() {
+
+  assert_lock_strong(MetaspaceExpand_lock);
+
+  MetaspaceUtils::dec_capacity(mdtype(), _capacity_words);
+  MetaspaceUtils::dec_overhead(mdtype(), _overhead_words);
+  MetaspaceUtils::dec_used(mdtype(), _used_words);
 }
 
 void SpaceManager::initialize() {
@@ -3501,23 +3398,16 @@
 }
 
 SpaceManager::~SpaceManager() {
+
   // This call this->_lock which can't be done while holding MetaspaceExpand_lock
-  assert(sum_capacity_in_chunks_in_use() == allocated_chunks_words(),
-         "sum_capacity_in_chunks_in_use() " SIZE_FORMAT
-         " allocated_chunks_words() " SIZE_FORMAT,
-         sum_capacity_in_chunks_in_use(), allocated_chunks_words());
+  DEBUG_ONLY(verify_metrics());
 
   MutexLockerEx fcl(MetaspaceExpand_lock,
                     Mutex::_no_safepoint_check_flag);
 
-  assert(sum_count_in_chunks_in_use() == allocated_chunks_count(),
-         "sum_count_in_chunks_in_use() " SIZE_FORMAT
-         " allocated_chunks_count() " SIZE_FORMAT,
-         sum_count_in_chunks_in_use(), allocated_chunks_count());
-
   chunk_manager()->slow_locked_verify();
 
-  dec_total_from_size_metrics();
+  account_for_spacemanager_death();
 
   Log(gc, metaspace, freelist) log;
   if (log.is_trace()) {
@@ -3528,6 +3418,7 @@
     if (block_freelists() != NULL) {
       block_freelists()->print_on(&ls);
     }
+    ls.cr(); // ~LogStream does not autoflush.
   }
 
   // Add all the chunks in use by this space manager
@@ -3550,7 +3441,7 @@
 }
 
 void SpaceManager::deallocate(MetaWord* p, size_t word_size) {
-  assert_lock_strong(_lock);
+  assert_lock_strong(lock());
   // Allocations and deallocations are in raw_word_size
   size_t raw_word_size = get_allocation_word_size(word_size);
   // Lazily create a block_freelist
@@ -3558,6 +3449,7 @@
     _block_freelists = new BlockFreelist();
   }
   block_freelists()->return_block(p, raw_word_size);
+  DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_deallocs));
 }
 
 // Adds a chunk to the list of chunks in use.
@@ -3584,27 +3476,28 @@
   new_chunk->set_next(chunks_in_use(index));
   set_chunks_in_use(index, new_chunk);
 
-  // Add to the running sum of capacity
-  inc_size_metrics(new_chunk->word_size());
+  // Adjust counters.
+  account_for_new_chunk(new_chunk);
 
   assert(new_chunk->is_empty(), "Not ready for reuse");
   Log(gc, metaspace, freelist) log;
   if (log.is_trace()) {
-    log.trace("SpaceManager::add_chunk: " SIZE_FORMAT ") ", sum_count_in_chunks_in_use());
+    log.trace("SpaceManager::added chunk: ");
     ResourceMark rm;
     LogStream ls(log.trace());
     new_chunk->print_on(&ls);
     chunk_manager()->locked_print_free_chunks(&ls);
+    ls.cr(); // ~LogStream does not autoflush.
   }
 }
 
 void SpaceManager::retire_current_chunk() {
   if (current_chunk() != NULL) {
     size_t remaining_words = current_chunk()->free_word_size();
-    if (remaining_words >= BlockFreelist::min_dictionary_size()) {
+    if (remaining_words >= SmallBlocks::small_block_min_size()) {
       MetaWord* ptr = current_chunk()->allocate(remaining_words);
       deallocate(ptr, remaining_words);
-      inc_used_metrics(remaining_words);
+      account_for_allocation(remaining_words);
     }
   }
 }
@@ -3632,6 +3525,9 @@
   size_t raw_word_size = get_allocation_word_size(word_size);
   BlockFreelist* fl =  block_freelists();
   MetaWord* p = NULL;
+
+  DEBUG_ONLY(if (VerifyMetaspace) verify_metrics_locked());
+
   // Allocation from the dictionary is expensive in the sense that
   // the dictionary has to be searched for a size.  Don't allocate
   // from the dictionary until it starts to get fat.  Is this
@@ -3639,6 +3535,9 @@
   // for allocations.  Do some profiling.  JJJ
   if (fl != NULL && fl->total_size() > allocation_from_dictionary_limit) {
     p = fl->get_block(raw_word_size);
+    if (p != NULL) {
+      DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_allocs_from_deallocated_blocks));
+    }
   }
   if (p == NULL) {
     p = allocate_work(raw_word_size);
@@ -3650,7 +3549,7 @@
 // Returns the address of spaced allocated for "word_size".
 // This methods does not know about blocks (Metablocks)
 MetaWord* SpaceManager::allocate_work(size_t word_size) {
-  assert_lock_strong(_lock);
+  assert_lock_strong(lock());
 #ifdef ASSERT
   if (Metadebug::test_metadata_failure()) {
     return NULL;
@@ -3668,7 +3567,7 @@
   }
 
   if (result != NULL) {
-    inc_used_metrics(word_size);
+    account_for_allocation(word_size);
     assert(result != (MetaWord*) chunks_in_use(MediumIndex),
            "Head of the list is being allocated");
   }
@@ -3696,162 +3595,129 @@
   return;
 }
 
-#ifdef ASSERT
-void SpaceManager::verify_allocated_blocks_words() {
-  // Verification is only guaranteed at a safepoint.
-  assert(SafepointSynchronize::is_at_safepoint() || !Universe::is_fully_initialized(),
-    "Verification can fail if the applications is running");
-  assert(allocated_blocks_words() == sum_used_in_chunks_in_use(),
-         "allocation total is not consistent " SIZE_FORMAT
-         " vs " SIZE_FORMAT,
-         allocated_blocks_words(), sum_used_in_chunks_in_use());
+void SpaceManager::add_to_statistics_locked(SpaceManagerStatistics* out) const {
+  assert_lock_strong(lock());
+  for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
+    UsedChunksStatistics& chunk_stat = out->chunk_stats(i);
+    Metachunk* chunk = chunks_in_use(i);
+    while (chunk != NULL) {
+      chunk_stat.add_num(1);
+      chunk_stat.add_cap(chunk->word_size());
+      chunk_stat.add_overhead(Metachunk::overhead());
+      chunk_stat.add_used(chunk->used_word_size() - Metachunk::overhead());
+      if (chunk != current_chunk()) {
+        chunk_stat.add_waste(chunk->free_word_size());
+      } else {
+        chunk_stat.add_free(chunk->free_word_size());
+      }
+      chunk = chunk->next();
+    }
+  }
+  if (block_freelists() != NULL) {
+    out->add_free_blocks_info(block_freelists()->num_blocks(), block_freelists()->total_size());
+  }
 }
 
-#endif
-
-void SpaceManager::dump(outputStream* const out) const {
-  size_t curr_total = 0;
-  size_t waste = 0;
-  uint i = 0;
-  size_t used = 0;
-  size_t capacity = 0;
-
-  // Add up statistics for all chunks in this SpaceManager.
-  for (ChunkIndex index = ZeroIndex;
-       index < NumberOfInUseLists;
-       index = next_chunk_index(index)) {
-    for (Metachunk* curr = chunks_in_use(index);
-         curr != NULL;
-         curr = curr->next()) {
-      out->print("%d) ", i++);
-      curr->print_on(out);
-      curr_total += curr->word_size();
-      used += curr->used_word_size();
-      capacity += curr->word_size();
-      waste += curr->free_word_size() + curr->overhead();;
-    }
-  }
-
-  if (log_is_enabled(Trace, gc, metaspace, freelist)) {
-    if (block_freelists() != NULL) block_freelists()->print_on(out);
-  }
-
-  size_t free = current_chunk() == NULL ? 0 : current_chunk()->free_word_size();
-  // Free space isn't wasted.
-  waste -= free;
-
-  out->print_cr("total of all chunks "  SIZE_FORMAT " used " SIZE_FORMAT
-                " free " SIZE_FORMAT " capacity " SIZE_FORMAT
-                " waste " SIZE_FORMAT, curr_total, used, free, capacity, waste);
+void SpaceManager::add_to_statistics(SpaceManagerStatistics* out) const {
+  MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
+  add_to_statistics_locked(out);
 }
 
+#ifdef ASSERT
+void SpaceManager::verify_metrics_locked() const {
+  assert_lock_strong(lock());
+
+  SpaceManagerStatistics stat;
+  add_to_statistics_locked(&stat);
+
+  UsedChunksStatistics chunk_stats = stat.totals();
+
+  DEBUG_ONLY(chunk_stats.check_sanity());
+
+  assert_counter(_capacity_words, chunk_stats.cap(), "SpaceManager::_capacity_words");
+  assert_counter(_used_words, chunk_stats.used(), "SpaceManager::_used_words");
+  assert_counter(_overhead_words, chunk_stats.overhead(), "SpaceManager::_overhead_words");
+}
+
+void SpaceManager::verify_metrics() const {
+  MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
+  verify_metrics_locked();
+}
+#endif // ASSERT
+
+
+
 // MetaspaceUtils
-
-
-size_t MetaspaceUtils::_capacity_words[] = {0, 0};
-volatile size_t MetaspaceUtils::_used_words[] = {0, 0};
-
-size_t MetaspaceUtils::free_bytes(Metaspace::MetadataType mdtype) {
+size_t MetaspaceUtils::_capacity_words [Metaspace:: MetadataTypeCount] = {0, 0};
+size_t MetaspaceUtils::_overhead_words [Metaspace:: MetadataTypeCount] = {0, 0};
+volatile size_t MetaspaceUtils::_used_words [Metaspace:: MetadataTypeCount] = {0, 0};
+
+// Collect used metaspace statistics. This involves walking the CLDG. The resulting
+// output will be the accumulated values for all live metaspaces.
+// Note: method does not do any locking.
+void MetaspaceUtils::collect_statistics(ClassLoaderMetaspaceStatistics* out) {
+  out->reset();
+  ClassLoaderDataGraphMetaspaceIterator iter;
+   while (iter.repeat()) {
+     ClassLoaderMetaspace* msp = iter.get_next();
+     if (msp != NULL) {
+       msp->add_to_statistics(out);
+     }
+   }
+}
+
+size_t MetaspaceUtils::free_in_vs_bytes(Metaspace::MetadataType mdtype) {
   VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
   return list == NULL ? 0 : list->free_bytes();
 }
 
-size_t MetaspaceUtils::free_bytes() {
-  return free_bytes(Metaspace::ClassType) + free_bytes(Metaspace::NonClassType);
+size_t MetaspaceUtils::free_in_vs_bytes() {
+  return free_in_vs_bytes(Metaspace::ClassType) + free_in_vs_bytes(Metaspace::NonClassType);
+}
+
+static void inc_stat_nonatomically(size_t* pstat, size_t words) {
+  assert_lock_strong(MetaspaceExpand_lock);
+  (*pstat) += words;
+}
+
+static void dec_stat_nonatomically(size_t* pstat, size_t words) {
+  assert_lock_strong(MetaspaceExpand_lock);
+  const size_t size_now = *pstat;
+  assert(size_now >= words, "About to decrement counter below zero "
+         "(current value: " SIZE_FORMAT ", decrement value: " SIZE_FORMAT ".",
+         size_now, words);
+  *pstat = size_now - words;
+}
+
+static void inc_stat_atomically(volatile size_t* pstat, size_t words) {
+  Atomic::add(words, pstat);
+}
+
+static void dec_stat_atomically(volatile size_t* pstat, size_t words) {
+  const size_t size_now = *pstat;
+  assert(size_now >= words, "About to decrement counter below zero "
+         "(current value: " SIZE_FORMAT ", decrement value: " SIZE_FORMAT ".",
+         size_now, words);
+  Atomic::sub(words, pstat);
 }
 
 void MetaspaceUtils::dec_capacity(Metaspace::MetadataType mdtype, size_t words) {
-  assert_lock_strong(MetaspaceExpand_lock);
-  assert(words <= capacity_words(mdtype),
-         "About to decrement below 0: words " SIZE_FORMAT
-         " is greater than _capacity_words[%u] " SIZE_FORMAT,
-         words, mdtype, capacity_words(mdtype));
-  _capacity_words[mdtype] -= words;
+  dec_stat_nonatomically(&_capacity_words[mdtype], words);
 }
-
 void MetaspaceUtils::inc_capacity(Metaspace::MetadataType mdtype, size_t words) {
-  assert_lock_strong(MetaspaceExpand_lock);
-  // Needs to be atomic
-  _capacity_words[mdtype] += words;
+  inc_stat_nonatomically(&_capacity_words[mdtype], words);
 }
-
 void MetaspaceUtils::dec_used(Metaspace::MetadataType mdtype, size_t words) {
-  assert(words <= used_words(mdtype),
-         "About to decrement below 0: words " SIZE_FORMAT
-         " is greater than _used_words[%u] " SIZE_FORMAT,
-         words, mdtype, used_words(mdtype));
-  // For CMS deallocation of the Metaspaces occurs during the
-  // sweep which is a concurrent phase.  Protection by the MetaspaceExpand_lock
-  // is not enough since allocation is on a per Metaspace basis
-  // and protected by the Metaspace lock.
-  Atomic::sub(words, &_used_words[mdtype]);
-}
-
-void MetaspaceUtils::inc_used(Metaspace::MetadataType mdtype, size_t words) {
-  // _used_words tracks allocations for
-  // each piece of metadata.  Those allocations are
-  // generally done concurrently by different application
-  // threads so must be done atomically.
-  Atomic::add(words, &_used_words[mdtype]);
-}
-
-size_t MetaspaceUtils::used_bytes_slow(Metaspace::MetadataType mdtype) {
-  size_t used = 0;
-  ClassLoaderDataGraphMetaspaceIterator iter;
-  while (iter.repeat()) {
-    ClassLoaderMetaspace* msp = iter.get_next();
-    // Sum allocated_blocks_words for each metaspace
-    if (msp != NULL) {
-      used += msp->used_words_slow(mdtype);
-    }
-  }
-  return used * BytesPerWord;
+  dec_stat_atomically(&_used_words[mdtype], words);
 }
-
-size_t MetaspaceUtils::free_bytes_slow(Metaspace::MetadataType mdtype) {
-  size_t free = 0;
-  ClassLoaderDataGraphMetaspaceIterator iter;
-  while (iter.repeat()) {
-    ClassLoaderMetaspace* msp = iter.get_next();
-    if (msp != NULL) {
-      free += msp->free_words_slow(mdtype);
-    }
-  }
-  return free * BytesPerWord;
+void MetaspaceUtils::inc_used(Metaspace::MetadataType mdtype, size_t words) {
+  inc_stat_atomically(&_used_words[mdtype], words);
 }
-
-size_t MetaspaceUtils::capacity_bytes_slow(Metaspace::MetadataType mdtype) {
-  if ((mdtype == Metaspace::ClassType) && !Metaspace::using_class_space()) {
-    return 0;
-  }
-  // Don't count the space in the freelists.  That space will be
-  // added to the capacity calculation as needed.
-  size_t capacity = 0;
-  ClassLoaderDataGraphMetaspaceIterator iter;
-  while (iter.repeat()) {
-    ClassLoaderMetaspace* msp = iter.get_next();
-    if (msp != NULL) {
-      capacity += msp->capacity_words_slow(mdtype);
-    }
-  }
-  return capacity * BytesPerWord;
+void MetaspaceUtils::dec_overhead(Metaspace::MetadataType mdtype, size_t words) {
+  dec_stat_nonatomically(&_overhead_words[mdtype], words);
 }
-
-size_t MetaspaceUtils::capacity_bytes_slow() {
-#ifdef PRODUCT
-  // Use capacity_bytes() in PRODUCT instead of this function.
-  guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT");
-#endif
-  size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType);
-  size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType);
-  assert(capacity_bytes() == class_capacity + non_class_capacity,
-         "bad accounting: capacity_bytes() " SIZE_FORMAT
-         " class_capacity + non_class_capacity " SIZE_FORMAT
-         " class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT,
-         capacity_bytes(), class_capacity + non_class_capacity,
-         class_capacity, non_class_capacity);
-
-  return class_capacity + non_class_capacity;
+void MetaspaceUtils::inc_overhead(Metaspace::MetadataType mdtype, size_t words) {
+  inc_stat_nonatomically(&_overhead_words[mdtype], words);
 }
 
 size_t MetaspaceUtils::reserved_bytes(Metaspace::MetadataType mdtype) {
@@ -3933,280 +3799,386 @@
   }
 }
 
-// Print information for class space and data space separately.
-// This is almost the same as above.
-void MetaspaceUtils::print_on(outputStream* out, Metaspace::MetadataType mdtype) {
-  size_t free_chunks_capacity_bytes = free_chunks_total_bytes(mdtype);
-  size_t capacity_bytes = capacity_bytes_slow(mdtype);
-  size_t used_bytes = used_bytes_slow(mdtype);
-  size_t free_bytes = free_bytes_slow(mdtype);
-  size_t used_and_free = used_bytes + free_bytes +
-                           free_chunks_capacity_bytes;
-  out->print_cr("  Chunk accounting: (used in chunks " SIZE_FORMAT
-             "K + unused in chunks " SIZE_FORMAT "K  + "
-             " capacity in free chunks " SIZE_FORMAT "K) = " SIZE_FORMAT
-             "K  capacity in allocated chunks " SIZE_FORMAT "K",
-             used_bytes / K,
-             free_bytes / K,
-             free_chunks_capacity_bytes / K,
-             used_and_free / K,
-             capacity_bytes / K);
-  // Accounting can only be correct if we got the values during a safepoint
-  assert(!SafepointSynchronize::is_at_safepoint() || used_and_free == capacity_bytes, "Accounting is wrong");
-}
-
-// Print total fragmentation for class metaspaces
-void MetaspaceUtils::print_class_waste(outputStream* out) {
-  assert(Metaspace::using_class_space(), "class metaspace not used");
-  size_t cls_specialized_waste = 0, cls_small_waste = 0, cls_medium_waste = 0;
-  size_t cls_specialized_count = 0, cls_small_count = 0, cls_medium_count = 0, cls_humongous_count = 0;
-  ClassLoaderDataGraphMetaspaceIterator iter;
-  while (iter.repeat()) {
-    ClassLoaderMetaspace* msp = iter.get_next();
-    if (msp != NULL) {
-      cls_specialized_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(SpecializedIndex);
-      cls_specialized_count += msp->class_vsm()->sum_count_in_chunks_in_use(SpecializedIndex);
-      cls_small_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(SmallIndex);
-      cls_small_count += msp->class_vsm()->sum_count_in_chunks_in_use(SmallIndex);
-      cls_medium_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(MediumIndex);
-      cls_medium_count += msp->class_vsm()->sum_count_in_chunks_in_use(MediumIndex);
-      cls_humongous_count += msp->class_vsm()->sum_count_in_chunks_in_use(HumongousIndex);
-    }
-  }
-  out->print_cr(" class: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", "
-                SIZE_FORMAT " small(s) " SIZE_FORMAT ", "
-                SIZE_FORMAT " medium(s) " SIZE_FORMAT ", "
-                "large count " SIZE_FORMAT,
-                cls_specialized_count, cls_specialized_waste,
-                cls_small_count, cls_small_waste,
-                cls_medium_count, cls_medium_waste, cls_humongous_count);
-}
-
-// Print total fragmentation for data and class metaspaces separately
-void MetaspaceUtils::print_waste(outputStream* out) {
-  size_t specialized_waste = 0, small_waste = 0, medium_waste = 0;
-  size_t specialized_count = 0, small_count = 0, medium_count = 0, humongous_count = 0;
-
-  ClassLoaderDataGraphMetaspaceIterator iter;
-  while (iter.repeat()) {
-    ClassLoaderMetaspace* msp = iter.get_next();
-    if (msp != NULL) {
-      specialized_waste += msp->vsm()->sum_waste_in_chunks_in_use(SpecializedIndex);
-      specialized_count += msp->vsm()->sum_count_in_chunks_in_use(SpecializedIndex);
-      small_waste += msp->vsm()->sum_waste_in_chunks_in_use(SmallIndex);
-      small_count += msp->vsm()->sum_count_in_chunks_in_use(SmallIndex);
-      medium_waste += msp->vsm()->sum_waste_in_chunks_in_use(MediumIndex);
-      medium_count += msp->vsm()->sum_count_in_chunks_in_use(MediumIndex);
-      humongous_count += msp->vsm()->sum_count_in_chunks_in_use(HumongousIndex);
-    }
-  }
-  out->print_cr("Total fragmentation waste (words) doesn't count free space");
-  out->print_cr("  data: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", "
-                        SIZE_FORMAT " small(s) " SIZE_FORMAT ", "
-                        SIZE_FORMAT " medium(s) " SIZE_FORMAT ", "
-                        "large count " SIZE_FORMAT,
-             specialized_count, specialized_waste, small_count,
-             small_waste, medium_count, medium_waste, humongous_count);
-  if (Metaspace::using_class_space()) {
-    print_class_waste(out);
-  }
-}
-
-class MetadataStats {
+class PrintCLDMetaspaceInfoClosure : public CLDClosure {
 private:
-  size_t _capacity;
-  size_t _used;
-  size_t _free;
-  size_t _waste;
+  outputStream* const _out;
+  const size_t        _scale;
+  const bool          _do_print;
+  const bool          _break_down_by_chunktype;
 
 public:
-  MetadataStats() : _capacity(0), _used(0), _free(0), _waste(0) { }
-  MetadataStats(size_t capacity, size_t used, size_t free, size_t waste)
-  : _capacity(capacity), _used(used), _free(free), _waste(waste) { }
-
-  void add(const MetadataStats& stats) {
-    _capacity += stats.capacity();
-    _used += stats.used();
-    _free += stats.free();
-    _waste += stats.waste();
-  }
-
-  size_t capacity() const { return _capacity; }
-  size_t used() const     { return _used; }
-  size_t free() const     { return _free; }
-  size_t waste() const    { return _waste; }
-
-  void print_on(outputStream* out, size_t scale) const;
-};
-
-
-void MetadataStats::print_on(outputStream* out, size_t scale) const {
-  const char* unit = scale_unit(scale);
-  out->print_cr("capacity=%10.2f%s used=%10.2f%s free=%10.2f%s waste=%10.2f%s",
-    (float)capacity() / scale, unit,
-    (float)used() / scale, unit,
-    (float)free() / scale, unit,
-    (float)waste() / scale, unit);
-}
-
-class PrintCLDMetaspaceInfoClosure : public CLDClosure {
-private:
-  outputStream*  _out;
-  size_t         _scale;
-
-  size_t         _total_count;
-  MetadataStats  _total_metadata;
-  MetadataStats  _total_class;
-
-  size_t         _total_anon_count;
-  MetadataStats  _total_anon_metadata;
-  MetadataStats  _total_anon_class;
+
+  uintx                           _num_loaders;
+  ClassLoaderMetaspaceStatistics  _stats_total;
+
+  uintx                           _num_loaders_by_spacetype [Metaspace::MetaspaceTypeCount];
+  ClassLoaderMetaspaceStatistics  _stats_by_spacetype [Metaspace::MetaspaceTypeCount];
 
 public:
-  PrintCLDMetaspaceInfoClosure(outputStream* out, size_t scale = K)
-  : _out(out), _scale(scale), _total_count(0), _total_anon_count(0) { }
-
-  ~PrintCLDMetaspaceInfoClosure() {
-    print_summary();
+  PrintCLDMetaspaceInfoClosure(outputStream* out, size_t scale, bool do_print, bool break_down_by_chunktype)
+    : _out(out), _scale(scale), _do_print(do_print), _break_down_by_chunktype(break_down_by_chunktype)
+    , _num_loaders(0)
+  {
+    memset(_num_loaders_by_spacetype, 0, sizeof(_num_loaders_by_spacetype));
   }
 
   void do_cld(ClassLoaderData* cld) {
+
     assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
 
-    if (cld->is_unloading()) return;
     ClassLoaderMetaspace* msp = cld->metaspace_or_null();
     if (msp == NULL) {
       return;
     }
 
-    bool anonymous = false;
-    if (cld->is_anonymous()) {
-      _out->print_cr("ClassLoader: for anonymous class");
-      anonymous = true;
-    } else {
-      ResourceMark rm;
-      _out->print_cr("ClassLoader: %s", cld->loader_name());
+    // Collect statistics for this class loader metaspace
+    ClassLoaderMetaspaceStatistics this_cld_stat;
+    msp->add_to_statistics(&this_cld_stat);
+
+    // And add it to the running totals
+    _stats_total.add(this_cld_stat);
+    _num_loaders ++;
+    _stats_by_spacetype[msp->space_type()].add(this_cld_stat);
+    _num_loaders_by_spacetype[msp->space_type()] ++;
+
+    // Optionally, print.
+    if (_do_print) {
+
+      _out->print(UINTX_FORMAT_W(4) ": ", _num_loaders);
+
+      if (cld->is_anonymous()) {
+        _out->print("ClassLoaderData " PTR_FORMAT " for anonymous class", p2i(cld));
+      } else {
+        ResourceMark rm;
+        _out->print("ClassLoaderData " PTR_FORMAT " for %s", p2i(cld), cld->loader_name());
+      }
+
+      if (cld->is_unloading()) {
+        _out->print(" (unloading)");
+      }
+
+      this_cld_stat.print_on(_out, _scale, _break_down_by_chunktype);
+      _out->cr();
+
     }
 
-    print_metaspace(msp, anonymous);
-    _out->cr();
-  }
-
-private:
-  void print_metaspace(ClassLoaderMetaspace* msp, bool anonymous);
-  void print_summary() const;
+  } // do_cld
+
 };
 
-void PrintCLDMetaspaceInfoClosure::print_metaspace(ClassLoaderMetaspace* msp, bool anonymous){
-  assert(msp != NULL, "Sanity");
-  SpaceManager* vsm = msp->vsm();
-  const char* unit = scale_unit(_scale);
-
-  size_t capacity = vsm->sum_capacity_in_chunks_in_use() * BytesPerWord;
-  size_t used = vsm->sum_used_in_chunks_in_use() * BytesPerWord;
-  size_t free = vsm->sum_free_in_chunks_in_use() * BytesPerWord;
-  size_t waste = vsm->sum_waste_in_chunks_in_use() * BytesPerWord;
-
-  _total_count ++;
-  MetadataStats metadata_stats(capacity, used, free, waste);
-  _total_metadata.add(metadata_stats);
-
-  if (anonymous) {
-    _total_anon_count ++;
-    _total_anon_metadata.add(metadata_stats);
-  }
-
-  _out->print("  Metadata   ");
-  metadata_stats.print_on(_out, _scale);
+void MetaspaceUtils::print_vs(outputStream* out, size_t scale) {
+  const size_t reserved_nonclass_words = reserved_bytes(Metaspace::NonClassType) / sizeof(MetaWord);
+  const size_t committed_nonclass_words = committed_bytes(Metaspace::NonClassType) / sizeof(MetaWord);
+  {
+    if (Metaspace::using_class_space()) {
+      out->print("  Non-class space:  ");
+    }
+    print_scaled_words(out, reserved_nonclass_words, scale, 7);
+    out->print(" reserved, ");
+    print_scaled_words_and_percentage(out, committed_nonclass_words, reserved_nonclass_words, scale, 7);
+    out->print_cr(" committed ");
+
+    if (Metaspace::using_class_space()) {
+      const size_t reserved_class_words = reserved_bytes(Metaspace::ClassType) / sizeof(MetaWord);
+      const size_t committed_class_words = committed_bytes(Metaspace::ClassType) / sizeof(MetaWord);
+      out->print("      Class space:  ");
+      print_scaled_words(out, reserved_class_words, scale, 7);
+      out->print(" reserved, ");
+      print_scaled_words_and_percentage(out, committed_class_words, reserved_class_words, scale, 7);
+      out->print_cr(" committed ");
+
+      const size_t reserved_words = reserved_nonclass_words + reserved_class_words;
+      const size_t committed_words = committed_nonclass_words + committed_class_words;
+      out->print("             Both:  ");
+      print_scaled_words(out, reserved_words, scale, 7);
+      out->print(" reserved, ");
+      print_scaled_words_and_percentage(out, committed_words, reserved_words, scale, 7);
+      out->print_cr(" committed ");
+    }
+  }
+}
+
+// This will print out a basic metaspace usage report but
+// unlike print_report() is guaranteed not to lock or to walk the CLDG.
+void MetaspaceUtils::print_basic_report(outputStream* out, size_t scale) {
+
+  out->cr();
+  out->print_cr("Usage:");
 
   if (Metaspace::using_class_space()) {
-    vsm = msp->class_vsm();
-
-    capacity = vsm->sum_capacity_in_chunks_in_use() * BytesPerWord;
-    used = vsm->sum_used_in_chunks_in_use() * BytesPerWord;
-    free = vsm->sum_free_in_chunks_in_use() * BytesPerWord;
-    waste = vsm->sum_waste_in_chunks_in_use() * BytesPerWord;
-
-    MetadataStats class_stats(capacity, used, free, waste);
-    _total_class.add(class_stats);
-
-    if (anonymous) {
-      _total_anon_class.add(class_stats);
-    }
-
-    _out->print("  Class data ");
-    class_stats.print_on(_out, _scale);
-  }
-}
-
-void PrintCLDMetaspaceInfoClosure::print_summary() const {
-  const char* unit = scale_unit(_scale);
-  _out->cr();
-  _out->print_cr("Summary:");
-
-  MetadataStats total;
-  total.add(_total_metadata);
-  total.add(_total_class);
-
-  _out->print("  Total class loaders=" SIZE_FORMAT_W(6) " ", _total_count);
-  total.print_on(_out, _scale);
-
-  _out->print("                    Metadata ");
-  _total_metadata.print_on(_out, _scale);
+    out->print("  Non-class:  ");
+  }
+
+  // In its most basic form, we do not require walking the CLDG. Instead, just print the running totals from
+  // MetaspaceUtils.
+  const size_t cap_nc = MetaspaceUtils::capacity_words(Metaspace::NonClassType);
+  const size_t overhead_nc = MetaspaceUtils::overhead_words(Metaspace::NonClassType);
+  const size_t used_nc = MetaspaceUtils::used_words(Metaspace::NonClassType);
+  const size_t free_and_waste_nc = cap_nc - overhead_nc - used_nc;
+
+  print_scaled_words(out, cap_nc, scale, 5);
+  out->print(" capacity, ");
+  print_scaled_words_and_percentage(out, used_nc, cap_nc, scale, 5);
+  out->print(" used, ");
+  print_scaled_words_and_percentage(out, free_and_waste_nc, cap_nc, scale, 5);
+  out->print(" free+waste, ");
+  print_scaled_words_and_percentage(out, overhead_nc, cap_nc, scale, 5);
+  out->print(" overhead. ");
+  out->cr();
 
   if (Metaspace::using_class_space()) {
-    _out->print("                  Class data ");
-    _total_class.print_on(_out, _scale);
-  }
-  _out->cr();
-
-  MetadataStats total_anon;
-  total_anon.add(_total_anon_metadata);
-  total_anon.add(_total_anon_class);
-
-  _out->print("For anonymous classes=" SIZE_FORMAT_W(6) " ", _total_anon_count);
-  total_anon.print_on(_out, _scale);
-
-  _out->print("                    Metadata ");
-  _total_anon_metadata.print_on(_out, _scale);
-
-  if (Metaspace::using_class_space()) {
-    _out->print("                  Class data ");
-    _total_anon_class.print_on(_out, _scale);
-  }
-}
-
-void MetaspaceUtils::print_metadata_for_nmt(outputStream* out, size_t scale) {
-  const char* unit = scale_unit(scale);
-  out->print_cr("Metaspaces:");
-  out->print_cr("  Metadata space: reserved=" SIZE_FORMAT_W(10) "%s committed=" SIZE_FORMAT_W(10) "%s",
-    reserved_bytes(Metaspace::NonClassType) / scale, unit,
-    committed_bytes(Metaspace::NonClassType) / scale, unit);
-  if (Metaspace::using_class_space()) {
-    out->print_cr("  Class    space: reserved=" SIZE_FORMAT_W(10) "%s committed=" SIZE_FORMAT_W(10) "%s",
-    reserved_bytes(Metaspace::ClassType) / scale, unit,
-    committed_bytes(Metaspace::ClassType) / scale, unit);
+    const size_t cap_c = MetaspaceUtils::capacity_words(Metaspace::ClassType);
+    const size_t overhead_c = MetaspaceUtils::overhead_words(Metaspace::ClassType);
+    const size_t used_c = MetaspaceUtils::used_words(Metaspace::ClassType);
+    const size_t free_and_waste_c = cap_c - overhead_c - used_c;
+    out->print("      Class:  ");
+    print_scaled_words(out, cap_c, scale, 5);
+    out->print(" capacity, ");
+    print_scaled_words_and_percentage(out, used_c, cap_c, scale, 5);
+    out->print(" used, ");
+    print_scaled_words_and_percentage(out, free_and_waste_c, cap_c, scale, 5);
+    out->print(" free+waste, ");
+    print_scaled_words_and_percentage(out, overhead_c, cap_c, scale, 5);
+    out->print(" overhead. ");
+    out->cr();
+
+    out->print("       Both:  ");
+    const size_t cap = cap_nc + cap_c;
+
+    print_scaled_words(out, cap, scale, 5);
+    out->print(" capacity, ");
+    print_scaled_words_and_percentage(out, used_nc + used_c, cap, scale, 5);
+    out->print(" used, ");
+    print_scaled_words_and_percentage(out, free_and_waste_nc + free_and_waste_c, cap, scale, 5);
+    out->print(" free+waste, ");
+    print_scaled_words_and_percentage(out, overhead_nc + overhead_c, cap, scale, 5);
+    out->print(" overhead. ");
+    out->cr();
   }
 
   out->cr();
-  ChunkManager::print_all_chunkmanagers(out, scale);
+  out->print_cr("Virtual space:");
+
+  print_vs(out, scale);
 
   out->cr();
-  out->print_cr("Per-classloader metadata:");
+  out->print_cr("Chunk freelists:");
+
+  if (Metaspace::using_class_space()) {
+    out->print("   Non-Class:  ");
+  }
+  print_human_readable_size(out, Metaspace::chunk_manager_metadata()->free_chunks_total_words(), scale);
   out->cr();
-
-  PrintCLDMetaspaceInfoClosure cl(out, scale);
-  ClassLoaderDataGraph::cld_do(&cl);
+  if (Metaspace::using_class_space()) {
+    out->print("       Class:  ");
+    print_human_readable_size(out, Metaspace::chunk_manager_class()->free_chunks_total_words(), scale);
+    out->cr();
+    out->print("        Both:  ");
+    print_human_readable_size(out, Metaspace::chunk_manager_class()->free_chunks_total_words() +
+                              Metaspace::chunk_manager_metadata()->free_chunks_total_words(), scale);
+    out->cr();
+  }
+  out->cr();
+
 }
 
-
-// Dump global metaspace things from the end of ClassLoaderDataGraph
-void MetaspaceUtils::dump(outputStream* out) {
-  out->print_cr("All Metaspace:");
-  out->print("data space: "); print_on(out, Metaspace::NonClassType);
-  out->print("class space: "); print_on(out, Metaspace::ClassType);
-  print_waste(out);
-}
+void MetaspaceUtils::print_report(outputStream* out, size_t scale, int flags) {
+
+  const bool print_loaders = (flags & rf_show_loaders) > 0;
+  const bool print_by_chunktype = (flags & rf_break_down_by_chunktype) > 0;
+  const bool print_by_spacetype = (flags & rf_break_down_by_spacetype) > 0;
+
+  // Some report options require walking the class loader data graph.
+  PrintCLDMetaspaceInfoClosure cl(out, scale, print_loaders, print_by_chunktype);
+  if (print_loaders) {
+    out->cr();
+    out->print_cr("Usage per loader:");
+    out->cr();
+  }
+
+  ClassLoaderDataGraph::cld_do(&cl); // collect data and optionally print
+
+  // Print totals, broken up by space type.
+  if (print_by_spacetype) {
+    out->cr();
+    out->print_cr("Usage per space type:");
+    out->cr();
+    for (int space_type = (int)Metaspace::ZeroMetaspaceType;
+         space_type < (int)Metaspace::MetaspaceTypeCount; space_type ++)
+    {
+      uintx num = cl._num_loaders_by_spacetype[space_type];
+      out->print("%s (" UINTX_FORMAT " loader%s)%c",
+        space_type_name((Metaspace::MetaspaceType)space_type),
+        num, (num == 1 ? "" : "s"), (num > 0 ? ':' : '.'));
+      if (num > 0) {
+        cl._stats_by_spacetype[space_type].print_on(out, scale, print_by_chunktype);
+      }
+      out->cr();
+    }
+  }
+
+  // Print totals for in-use data:
+  out->cr();
+  out->print_cr("Total Usage ( " UINTX_FORMAT " loader%s)%c",
+      cl._num_loaders, (cl._num_loaders == 1 ? "" : "s"), (cl._num_loaders > 0 ? ':' : '.'));
+
+  cl._stats_total.print_on(out, scale, print_by_chunktype);
+
+  // -- Print Virtual space.
+  out->cr();
+  out->print_cr("Virtual space:");
+
+  print_vs(out, scale);
+
+  // -- Print VirtualSpaceList details.
+  if ((flags & rf_show_vslist) > 0) {
+    out->cr();
+    out->print_cr("Virtual space list%s:", Metaspace::using_class_space() ? "s" : "");
+
+    if (Metaspace::using_class_space()) {
+      out->print_cr("   Non-Class:");
+    }
+    Metaspace::space_list()->print_on(out, scale);
+    if (Metaspace::using_class_space()) {
+      out->print_cr("       Class:");
+      Metaspace::class_space_list()->print_on(out, scale);
+    }
+  }
+  out->cr();
+
+  // -- Print VirtualSpaceList map.
+  if ((flags & rf_show_vsmap) > 0) {
+    out->cr();
+    out->print_cr("Virtual space map:");
+
+    if (Metaspace::using_class_space()) {
+      out->print_cr("   Non-Class:");
+    }
+    Metaspace::space_list()->print_map(out);
+    if (Metaspace::using_class_space()) {
+      out->print_cr("       Class:");
+      Metaspace::class_space_list()->print_map(out);
+    }
+  }
+  out->cr();
+
+  // -- Print Freelists (ChunkManager) details
+  out->cr();
+  out->print_cr("Chunk freelist%s:", Metaspace::using_class_space() ? "s" : "");
+
+  ChunkManagerStatistics non_class_cm_stat;
+  Metaspace::chunk_manager_metadata()->collect_statistics(&non_class_cm_stat);
+
+  if (Metaspace::using_class_space()) {
+    out->print_cr("   Non-Class:");
+  }
+  non_class_cm_stat.print_on(out, scale);
+
+  if (Metaspace::using_class_space()) {
+    ChunkManagerStatistics class_cm_stat;
+    Metaspace::chunk_manager_class()->collect_statistics(&class_cm_stat);
+    out->print_cr("       Class:");
+    class_cm_stat.print_on(out, scale);
+  }
+
+  // As a convenience, print a summary of common waste.
+  out->cr();
+  out->print("Waste ");
+  // For all wastages, print percentages from total. As total use the total size of memory committed for metaspace.
+  const size_t committed_words = committed_bytes() / BytesPerWord;
+
+  out->print("(percentages refer to total committed size ");
+  print_scaled_words(out, committed_words, scale);
+  out->print_cr("):");
+
+  // Print space committed but not yet used by any class loader
+  const size_t unused_words_in_vs = MetaspaceUtils::free_in_vs_bytes() / BytesPerWord;
+  out->print("              Committed unused: ");
+  print_scaled_words_and_percentage(out, unused_words_in_vs, committed_words, scale, 6);
+  out->cr();
+
+  // Print waste for in-use chunks.
+  UsedChunksStatistics ucs_nonclass = cl._stats_total.nonclass_sm_stats().totals();
+  UsedChunksStatistics ucs_class = cl._stats_total.class_sm_stats().totals();
+  UsedChunksStatistics ucs_all;
+  ucs_all.add(ucs_nonclass);
+  ucs_all.add(ucs_class);
+
+  out->print("        Waste in chunks in use: ");
+  print_scaled_words_and_percentage(out, ucs_all.waste(), committed_words, scale, 6);
+  out->cr();
+  out->print("         Free in chunks in use: ");
+  print_scaled_words_and_percentage(out, ucs_all.free(), committed_words, scale, 6);
+  out->cr();
+  out->print("     Overhead in chunks in use: ");
+  print_scaled_words_and_percentage(out, ucs_all.overhead(), committed_words, scale, 6);
+  out->cr();
+
+  // Print waste in free chunks.
+  const size_t total_capacity_in_free_chunks =
+      Metaspace::chunk_manager_metadata()->free_chunks_total_words() +
+     (Metaspace::using_class_space() ? Metaspace::chunk_manager_class()->free_chunks_total_words() : 0);
+  out->print("                In free chunks: ");
+  print_scaled_words_and_percentage(out, total_capacity_in_free_chunks, committed_words, scale, 6);
+  out->cr();
+
+  // Print waste in deallocated blocks.
+  const uintx free_blocks_num =
+      cl._stats_total.nonclass_sm_stats().free_blocks_num() +
+      cl._stats_total.class_sm_stats().free_blocks_num();
+  const size_t free_blocks_cap_words =
+      cl._stats_total.nonclass_sm_stats().free_blocks_cap_words() +
+      cl._stats_total.class_sm_stats().free_blocks_cap_words();
+  out->print("Deallocated from chunks in use: ");
+  print_scaled_words_and_percentage(out, free_blocks_cap_words, committed_words, scale, 6);
+  out->print(" ("UINTX_FORMAT " blocks)", free_blocks_num);
+  out->cr();
+
+  // Print total waste.
+  const size_t total_waste = ucs_all.waste() + ucs_all.free() + ucs_all.overhead() + total_capacity_in_free_chunks
+      + free_blocks_cap_words + unused_words_in_vs;
+  out->print("                       -total-: ");
+  print_scaled_words_and_percentage(out, total_waste, committed_words, scale, 6);
+  out->cr();
+
+  // Print internal statistics
+#ifdef ASSERT
+  out->cr();
+  out->cr();
+  out->print_cr("Internal statistics:");
+  out->cr();
+  out->print_cr("Number of allocations: " UINTX_FORMAT ".", g_internal_statistics.num_allocs);
+  out->print_cr("Number of space births: " UINTX_FORMAT ".", g_internal_statistics.num_metaspace_births);
+  out->print_cr("Number of space deaths: " UINTX_FORMAT ".", g_internal_statistics.num_metaspace_deaths);
+  out->print_cr("Number of virtual space node births: " UINTX_FORMAT ".", g_internal_statistics.num_vsnodes_created);
+  out->print_cr("Number of virtual space node deaths: " UINTX_FORMAT ".", g_internal_statistics.num_vsnodes_purged);
+  out->print_cr("Number of times virtual space nodes were expanded: " UINTX_FORMAT ".", g_internal_statistics.num_committed_space_expanded);
+  out->print_cr("Number of deallocations: " UINTX_FORMAT " (" UINTX_FORMAT " external).", g_internal_statistics.num_deallocs, g_internal_statistics.num_external_deallocs);
+  out->print_cr("Allocations from deallocated blocks: " UINTX_FORMAT ".", g_internal_statistics.num_allocs_from_deallocated_blocks);
+  out->cr();
+#endif
+
+  // Print some interesting settings
+  out->cr();
+  out->cr();
+  out->print("MaxMetaspaceSize: ");
+  print_human_readable_size(out, MaxMetaspaceSize, scale);
+  out->cr();
+  out->print("InitialBootClassLoaderMetaspaceSize: ");
+  print_human_readable_size(out, InitialBootClassLoaderMetaspaceSize, scale);
+  out->cr();
+
+  out->print("UseCompressedClassPointers: %s", UseCompressedClassPointers ? "true" : "false");
+  out->cr();
+  if (Metaspace::using_class_space()) {
+    out->print("CompressedClassSpaceSize: ");
+    print_human_readable_size(out, CompressedClassSpaceSize, scale);
+  }
+
+  out->cr();
+  out->cr();
+
+} // MetaspaceUtils::print_report()
 
 // Prints an ASCII representation of the given space.
 void MetaspaceUtils::print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype) {
@@ -4240,53 +4212,37 @@
   }
 }
 
-void MetaspaceUtils::verify_capacity() {
-#ifdef ASSERT
-  size_t running_sum_capacity_bytes = capacity_bytes();
-  // For purposes of the running sum of capacity, verify against capacity
-  size_t capacity_in_use_bytes = capacity_bytes_slow();
-  assert(running_sum_capacity_bytes == capacity_in_use_bytes,
-         "capacity_words() * BytesPerWord " SIZE_FORMAT
-         " capacity_bytes_slow()" SIZE_FORMAT,
-         running_sum_capacity_bytes, capacity_in_use_bytes);
-  for (Metaspace::MetadataType i = Metaspace::ClassType;
-       i < Metaspace:: MetadataTypeCount;
-       i = (Metaspace::MetadataType)(i + 1)) {
-    size_t capacity_in_use_bytes = capacity_bytes_slow(i);
-    assert(capacity_bytes(i) == capacity_in_use_bytes,
-           "capacity_bytes(%u) " SIZE_FORMAT
-           " capacity_bytes_slow(%u)" SIZE_FORMAT,
-           i, capacity_bytes(i), i, capacity_in_use_bytes);
-  }
-#endif
-}
-
-void MetaspaceUtils::verify_used() {
+void MetaspaceUtils::verify_metrics() {
 #ifdef ASSERT
-  size_t running_sum_used_bytes = used_bytes();
-  // For purposes of the running sum of used, verify against used
-  size_t used_in_use_bytes = used_bytes_slow();
-  assert(used_bytes() == used_in_use_bytes,
-         "used_bytes() " SIZE_FORMAT
-         " used_bytes_slow()" SIZE_FORMAT,
-         used_bytes(), used_in_use_bytes);
-  for (Metaspace::MetadataType i = Metaspace::ClassType;
-       i < Metaspace:: MetadataTypeCount;
-       i = (Metaspace::MetadataType)(i + 1)) {
-    size_t used_in_use_bytes = used_bytes_slow(i);
-    assert(used_bytes(i) == used_in_use_bytes,
-           "used_bytes(%u) " SIZE_FORMAT
-           " used_bytes_slow(%u)" SIZE_FORMAT,
-           i, used_bytes(i), i, used_in_use_bytes);
-  }
+  // Please note: there are time windows where the internal counters are out of sync with
+  // reality. For example, when a newly created ClassLoaderMetaspace creates its first chunk -
+  // the ClassLoaderMetaspace is not yet attached to its ClassLoaderData object and hence will
+  // not be counted when iterating the CLDG. So be careful when you call this method.
+  ClassLoaderMetaspaceStatistics total_stat;
+  collect_statistics(&total_stat);
+  UsedChunksStatistics nonclass_chunk_stat = total_stat.nonclass_sm_stats().totals();
+  UsedChunksStatistics class_chunk_stat = total_stat.class_sm_stats().totals();
+
+  bool mismatch = false;
+  for (int i = 0; i < Metaspace::MetadataTypeCount; i ++) {
+    Metaspace::MetadataType mdtype = (Metaspace::MetadataType)i;
+    UsedChunksStatistics chunk_stat = total_stat.sm_stats(mdtype).totals();
+    if (capacity_words(mdtype) != chunk_stat.cap() ||
+        used_words(mdtype) != chunk_stat.used() ||
+        overhead_words(mdtype) != chunk_stat.overhead()) {
+      mismatch = true;
+      tty->print_cr("MetaspaceUtils::verify_metrics: counter mismatch for mdtype=%u:", mdtype);
+      tty->print_cr("Expected cap " SIZE_FORMAT ", used " SIZE_FORMAT ", overhead " SIZE_FORMAT ".",
+                    capacity_words(mdtype), used_words(mdtype), overhead_words(mdtype));
+      tty->print_cr("Got cap " SIZE_FORMAT ", used " SIZE_FORMAT ", overhead " SIZE_FORMAT ".",
+                    chunk_stat.cap(), chunk_stat.used(), chunk_stat.overhead());
+      tty->flush();
+    }
+  }
+  assert(mismatch == false, "MetaspaceUtils::verify_metrics: counter mismatch.");
 #endif
 }
 
-void MetaspaceUtils::verify_metrics() {
-  verify_capacity();
-  verify_used();
-}
-
 
 // Metaspace methods
 
@@ -4485,6 +4441,7 @@
     ResourceMark rm;
     LogStream ls(lt);
     print_compressed_class_space(&ls, requested_addr);
+    ls.cr(); // ~LogStream does not autoflush.
   }
 }
 
@@ -4706,12 +4663,13 @@
       if (loader_data->metaspace_or_null() != NULL) {
         LogStream ls(log.debug());
         loader_data->print_value_on(&ls);
+        ls.cr(); // ~LogStream does not autoflush.
       }
     }
     LogStream ls(log.info());
-    MetaspaceUtils::dump(&ls);
-    MetaspaceUtils::print_metaspace_map(&ls, mdtype);
-    ChunkManager::print_all_chunkmanagers(&ls);
+    // In case of an OOM, log out a short but still useful report.
+    MetaspaceUtils::print_basic_report(&ls, 0);
+    ls.cr(); // ~LogStream does not autoflush.
   }
 
   bool out_of_compressed_class_space = false;
@@ -4786,16 +4744,23 @@
 
 // ClassLoaderMetaspace
 
-ClassLoaderMetaspace::ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType type) {
+ClassLoaderMetaspace::ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType type)
+  : _lock(lock)
+  , _space_type(type)
+  , _vsm(NULL)
+  , _class_vsm(NULL)
+{
   initialize(lock, type);
 }
 
 ClassLoaderMetaspace::~ClassLoaderMetaspace() {
+  DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_metaspace_deaths));
   delete _vsm;
   if (Metaspace::using_class_space()) {
     delete _class_vsm;
   }
 }
+
 void ClassLoaderMetaspace::initialize_first_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype) {
   Metachunk* chunk = get_initialization_chunk(type, mdtype);
   if (chunk != NULL) {
@@ -4821,6 +4786,8 @@
 void ClassLoaderMetaspace::initialize(Mutex* lock, Metaspace::MetaspaceType type) {
   Metaspace::verify_global_initialization();
 
+  DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_metaspace_births));
+
   // Allocate SpaceManager for metadata objects.
   _vsm = new SpaceManager(Metaspace::NonClassType, type, lock);
 
@@ -4842,6 +4809,9 @@
 
 MetaWord* ClassLoaderMetaspace::allocate(size_t word_size, Metaspace::MetadataType mdtype) {
   Metaspace::assert_not_frozen();
+
+  DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_allocs));
+
   // Don't use class_vsm() unless UseCompressedClassPointers is true.
   if (Metaspace::is_class_space_allocation(mdtype)) {
     return  class_vsm()->allocate(word_size);
@@ -4877,52 +4847,14 @@
   return res;
 }
 
-size_t ClassLoaderMetaspace::used_words_slow(Metaspace::MetadataType mdtype) const {
-  if (mdtype == Metaspace::ClassType) {
-    return Metaspace::using_class_space() ? class_vsm()->sum_used_in_chunks_in_use() : 0;
-  } else {
-    return vsm()->sum_used_in_chunks_in_use();  // includes overhead!
-  }
-}
-
-size_t ClassLoaderMetaspace::free_words_slow(Metaspace::MetadataType mdtype) const {
-  Metaspace::assert_not_frozen();
-  if (mdtype == Metaspace::ClassType) {
-    return Metaspace::using_class_space() ? class_vsm()->sum_free_in_chunks_in_use() : 0;
-  } else {
-    return vsm()->sum_free_in_chunks_in_use();
-  }
-}
-
-// Space capacity in the Metaspace.  It includes
-// space in the list of chunks from which allocations
-// have been made. Don't include space in the global freelist and
-// in the space available in the dictionary which
-// is already counted in some chunk.
-size_t ClassLoaderMetaspace::capacity_words_slow(Metaspace::MetadataType mdtype) const {
-  if (mdtype == Metaspace::ClassType) {
-    return Metaspace::using_class_space() ? class_vsm()->sum_capacity_in_chunks_in_use() : 0;
-  } else {
-    return vsm()->sum_capacity_in_chunks_in_use();
-  }
-}
-
-size_t ClassLoaderMetaspace::used_bytes_slow(Metaspace::MetadataType mdtype) const {
-  return used_words_slow(mdtype) * BytesPerWord;
-}
-
-size_t ClassLoaderMetaspace::capacity_bytes_slow(Metaspace::MetadataType mdtype) const {
-  return capacity_words_slow(mdtype) * BytesPerWord;
-}
-
 size_t ClassLoaderMetaspace::allocated_blocks_bytes() const {
-  return vsm()->allocated_blocks_bytes() +
-      (Metaspace::using_class_space() ? class_vsm()->allocated_blocks_bytes() : 0);
+  return (vsm()->used_words() +
+      (Metaspace::using_class_space() ? class_vsm()->used_words() : 0)) * BytesPerWord;
 }
 
 size_t ClassLoaderMetaspace::allocated_chunks_bytes() const {
-  return vsm()->allocated_chunks_bytes() +
-      (Metaspace::using_class_space() ? class_vsm()->allocated_chunks_bytes() : 0);
+  return (vsm()->capacity_words() +
+      (Metaspace::using_class_space() ? class_vsm()->capacity_words() : 0)) * BytesPerWord;
 }
 
 void ClassLoaderMetaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) {
@@ -4930,6 +4862,8 @@
   assert(!SafepointSynchronize::is_at_safepoint()
          || Thread::current()->is_VM_thread(), "should be the VM thread");
 
+  DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_external_deallocs));
+
   MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
 
   if (is_class && Metaspace::using_class_space()) {
@@ -4961,16 +4895,18 @@
   }
 }
 
-void ClassLoaderMetaspace::dump(outputStream* const out) const {
-  out->print_cr("\nVirtual space manager: " INTPTR_FORMAT, p2i(vsm()));
-  vsm()->dump(out);
+void ClassLoaderMetaspace::add_to_statistics_locked(ClassLoaderMetaspaceStatistics* out) const {
+  assert_lock_strong(lock());
+  vsm()->add_to_statistics_locked(&out->nonclass_sm_stats());
   if (Metaspace::using_class_space()) {
-    out->print_cr("\nClass space manager: " INTPTR_FORMAT, p2i(class_vsm()));
-    class_vsm()->dump(out);
+    class_vsm()->add_to_statistics_locked(&out->class_sm_stats());
   }
 }
 
-
+void ClassLoaderMetaspace::add_to_statistics(ClassLoaderMetaspaceStatistics* out) const {
+  MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
+  add_to_statistics_locked(out);
+}
 
 #ifdef ASSERT
 static void do_verify_chunk(Metachunk* chunk) {
@@ -5316,12 +5252,12 @@
 
 extern void test_metaspace_retrieve_chunkmanager_statistics(Metaspace::MetadataType mdType, chunkmanager_statistics_t* out) {
   ChunkManager* const chunk_manager = Metaspace::get_chunk_manager(mdType);
-  ChunkManager::ChunkManagerStatistics stat;
-  chunk_manager->get_statistics(&stat);
-  out->num_specialized_chunks = (int)stat.num_by_type[SpecializedIndex];
-  out->num_small_chunks = (int)stat.num_by_type[SmallIndex];
-  out->num_medium_chunks = (int)stat.num_by_type[MediumIndex];
-  out->num_humongous_chunks = (int)stat.num_humongous_chunks;
+  ChunkManagerStatistics stat;
+  chunk_manager->collect_statistics(&stat);
+  out->num_specialized_chunks = (int)stat.chunk_stats(SpecializedIndex).num();
+  out->num_small_chunks = (int)stat.chunk_stats(SmallIndex).num();
+  out->num_medium_chunks = (int)stat.chunk_stats(MediumIndex).num();
+  out->num_humongous_chunks = (int)stat.chunk_stats(HumongousIndex).num();
 }
 
 struct chunk_geometry_t {
--- a/src/hotspot/share/memory/metaspace.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/memory/metaspace.hpp	Fri May 04 08:50:01 2018 -0700
@@ -68,6 +68,11 @@
 class VirtualSpaceList;
 class CollectedHeap;
 
+namespace metaspace {
+namespace internals {
+  class ClassLoaderMetaspaceStatistics;
+}}
+
 // Metaspaces each have a  SpaceManager and allocations
 // are done by the SpaceManager.  Allocations are done
 // out of the current Metachunk.  When the current Metachunk
@@ -94,10 +99,12 @@
     MetadataTypeCount
   };
   enum MetaspaceType {
-    StandardMetaspaceType,
-    BootMetaspaceType,
-    AnonymousMetaspaceType,
-    ReflectionMetaspaceType
+    ZeroMetaspaceType = 0,
+    StandardMetaspaceType = ZeroMetaspaceType,
+    BootMetaspaceType = StandardMetaspaceType + 1,
+    AnonymousMetaspaceType = BootMetaspaceType + 1,
+    ReflectionMetaspaceType = AnonymousMetaspaceType + 1,
+    MetaspaceTypeCount
   };
 
  private:
@@ -193,7 +200,6 @@
 
   static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size,
                             MetaspaceObj::Type type, TRAPS);
-  void deallocate(MetaWord* ptr, size_t byte_size, bool is_class);
 
   static bool contains(const void* ptr);
   static bool contains_non_shared(const void* ptr);
@@ -238,96 +244,97 @@
   void initialize_first_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype);
   Metachunk* get_initialization_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype);
 
+  const Metaspace::MetaspaceType _space_type;
+  Mutex* const  _lock;
   SpaceManager* _vsm;
+  SpaceManager* _class_vsm;
+
   SpaceManager* vsm() const { return _vsm; }
-
-  SpaceManager* _class_vsm;
   SpaceManager* class_vsm() const { return _class_vsm; }
   SpaceManager* get_space_manager(Metaspace::MetadataType mdtype) {
     assert(mdtype != Metaspace::MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
     return mdtype == Metaspace::ClassType ? class_vsm() : vsm();
   }
 
+  Mutex* lock() const { return _lock; }
+
   MetaWord* expand_and_allocate(size_t size, Metaspace::MetadataType mdtype);
 
   size_t class_chunk_size(size_t word_size);
 
+  // Adds to the given statistic object. Must be locked with CLD metaspace lock.
+  void add_to_statistics_locked(metaspace::internals::ClassLoaderMetaspaceStatistics* out) const;
+
  public:
 
   ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType type);
   ~ClassLoaderMetaspace();
 
+  Metaspace::MetaspaceType space_type() const { return _space_type; }
+
   // Allocate space for metadata of type mdtype. This is space
   // within a Metachunk and is used by
   //   allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS)
   MetaWord* allocate(size_t word_size, Metaspace::MetadataType mdtype);
 
-  size_t used_words_slow(Metaspace::MetadataType mdtype) const;
-  size_t free_words_slow(Metaspace::MetadataType mdtype) const;
-  size_t capacity_words_slow(Metaspace::MetadataType mdtype) const;
-
-  size_t used_bytes_slow(Metaspace::MetadataType mdtype) const;
-  size_t capacity_bytes_slow(Metaspace::MetadataType mdtype) const;
-
   size_t allocated_blocks_bytes() const;
   size_t allocated_chunks_bytes() const;
 
   void deallocate(MetaWord* ptr, size_t byte_size, bool is_class);
 
-  void dump(outputStream* const out) const;
-
   void print_on(outputStream* st) const;
   // Debugging support
   void verify();
 
+  // Adds to the given statistic object. Will lock with CLD metaspace lock.
+  void add_to_statistics(metaspace::internals::ClassLoaderMetaspaceStatistics* out) const;
+
 }; // ClassLoaderMetaspace
 
+class MetaspaceUtils : AllStatic {
 
-class MetaspaceUtils : AllStatic {
+  // Spacemanager updates running counters.
+  friend class SpaceManager;
+
+  // Running counters for statistics concerning in-use chunks.
+  // Note: capacity = used + free + waste + overhead. Note that we do not
+  // count free and waste. Their sum can be deduces from the three other values.
+  // For more details, one should call print_report() from within a safe point.
+  static size_t _capacity_words [Metaspace:: MetadataTypeCount];
+  static size_t _overhead_words [Metaspace:: MetadataTypeCount];
+  static volatile size_t _used_words [Metaspace:: MetadataTypeCount];
+
+  // Atomically decrement or increment in-use statistic counters
+  static void dec_capacity(Metaspace::MetadataType mdtype, size_t words);
+  static void inc_capacity(Metaspace::MetadataType mdtype, size_t words);
+  static void dec_used(Metaspace::MetadataType mdtype, size_t words);
+  static void inc_used(Metaspace::MetadataType mdtype, size_t words);
+  static void dec_overhead(Metaspace::MetadataType mdtype, size_t words);
+  static void inc_overhead(Metaspace::MetadataType mdtype, size_t words);
+
+
+  // Getters for the in-use counters.
+  static size_t capacity_words(Metaspace::MetadataType mdtype)        { return _capacity_words[mdtype]; }
+  static size_t used_words(Metaspace::MetadataType mdtype)            { return _used_words[mdtype]; }
+  static size_t overhead_words(Metaspace::MetadataType mdtype)        { return _overhead_words[mdtype]; }
+
   static size_t free_chunks_total_words(Metaspace::MetadataType mdtype);
 
-  // These methods iterate over the classloader data graph
-  // for the given Metaspace type.  These are slow.
-  static size_t used_bytes_slow(Metaspace::MetadataType mdtype);
-  static size_t free_bytes_slow(Metaspace::MetadataType mdtype);
-  static size_t capacity_bytes_slow(Metaspace::MetadataType mdtype);
-  static size_t capacity_bytes_slow();
+  // Helper for print_xx_report.
+  static void print_vs(outputStream* out, size_t scale);
 
-  // Running sum of space in all Metachunks that has been
-  // allocated to a Metaspace.  This is used instead of
-  // iterating over all the classloaders. One for each
-  // type of Metadata
-  static size_t _capacity_words[Metaspace:: MetadataTypeCount];
-  // Running sum of space in all Metachunks that
-  // are being used for metadata. One for each
-  // type of Metadata.
-  static volatile size_t _used_words[Metaspace:: MetadataTypeCount];
+public:
 
- public:
-  // Decrement and increment _allocated_capacity_words
-  static void dec_capacity(Metaspace::MetadataType type, size_t words);
-  static void inc_capacity(Metaspace::MetadataType type, size_t words);
-
-  // Decrement and increment _allocated_used_words
-  static void dec_used(Metaspace::MetadataType type, size_t words);
-  static void inc_used(Metaspace::MetadataType type, size_t words);
-
-  // Total of space allocated to metadata in all Metaspaces.
-  // This sums the space used in each Metachunk by
-  // iterating over the classloader data graph
-  static size_t used_bytes_slow() {
-    return used_bytes_slow(Metaspace::ClassType) +
-           used_bytes_slow(Metaspace::NonClassType);
-  }
+  // Collect used metaspace statistics. This involves walking the CLDG. The resulting
+  // output will be the accumulated values for all live metaspaces.
+  // Note: method does not do any locking.
+  static void collect_statistics(metaspace::internals::ClassLoaderMetaspaceStatistics* out);
 
   // Used by MetaspaceCounters
   static size_t free_chunks_total_words();
   static size_t free_chunks_total_bytes();
   static size_t free_chunks_total_bytes(Metaspace::MetadataType mdtype);
 
-  static size_t capacity_words(Metaspace::MetadataType mdtype) {
-    return _capacity_words[mdtype];
-  }
   static size_t capacity_words() {
     return capacity_words(Metaspace::NonClassType) +
            capacity_words(Metaspace::ClassType);
@@ -339,9 +346,6 @@
     return capacity_words() * BytesPerWord;
   }
 
-  static size_t used_words(Metaspace::MetadataType mdtype) {
-    return _used_words[mdtype];
-  }
   static size_t used_words() {
     return used_words(Metaspace::NonClassType) +
            used_words(Metaspace::ClassType);
@@ -353,8 +357,9 @@
     return used_words() * BytesPerWord;
   }
 
-  static size_t free_bytes();
-  static size_t free_bytes(Metaspace::MetadataType mdtype);
+  // Space committed but yet unclaimed by any class loader.
+  static size_t free_in_vs_bytes();
+  static size_t free_in_vs_bytes(Metaspace::MetadataType mdtype);
 
   static size_t reserved_bytes(Metaspace::MetadataType mdtype);
   static size_t reserved_bytes() {
@@ -373,7 +378,29 @@
     return min_chunk_size_words() * BytesPerWord;
   }
 
-  static void print_metadata_for_nmt(outputStream* out, size_t scale = K);
+  // Flags for print_report().
+  enum ReportFlag {
+    // Show usage by class loader.
+    rf_show_loaders                 = (1 << 0),
+    // Breaks report down by chunk type (small, medium, ...).
+    rf_break_down_by_chunktype      = (1 << 1),
+    // Breaks report down by space type (anonymous, reflection, ...).
+    rf_break_down_by_spacetype      = (1 << 2),
+    // Print details about the underlying virtual spaces.
+    rf_show_vslist                  = (1 << 3),
+    // Print metaspace map.
+    rf_show_vsmap                   = (1 << 4)
+  };
+
+  // This will print out a basic metaspace usage report but
+  // unlike print_report() is guaranteed not to lock or to walk the CLDG.
+  static void print_basic_report(outputStream* st, size_t scale);
+
+  // Prints a report about the current metaspace state.
+  // Optional parts can be enabled via flags.
+  // Function will walk the CLDG and will lock the expand lock; if that is not
+  // convenient, use print_basic_report() instead.
+  static void print_report(outputStream* out, size_t scale = 0, int flags = 0);
 
   static bool has_chunk_free_list(Metaspace::MetadataType mdtype);
   static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype);
@@ -381,20 +408,13 @@
   // Print change in used metadata.
   static void print_metaspace_change(size_t prev_metadata_used);
   static void print_on(outputStream * out);
-  static void print_on(outputStream * out, Metaspace::MetadataType mdtype);
-
-  static void print_class_waste(outputStream* out);
-  static void print_waste(outputStream* out);
 
   // Prints an ASCII representation of the given space.
   static void print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype);
 
   static void dump(outputStream* out);
   static void verify_free_chunks();
-  // Checks that the values returned by allocated_capacity_bytes() and
-  // capacity_bytes_slow() are the same.
-  static void verify_capacity();
-  static void verify_used();
+  // Check internal counters (capacity, used).
   static void verify_metrics();
 };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/memory/metaspace/metaspaceCommon.cpp	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, SAP and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+
+#include "memory/metaspace/metaspaceCommon.hpp"
+#include "utilities/globalDefinitions.hpp"
+#include "utilities/ostream.hpp"
+
+namespace metaspace {
+namespace internals {
+
+// Print a size, in words, scaled.
+void print_scaled_words(outputStream* st, size_t word_size, size_t scale, int width) {
+  print_human_readable_size(st, word_size * sizeof(MetaWord), scale, width);
+}
+
+// Convenience helper: prints a size value and a percentage.
+void print_scaled_words_and_percentage(outputStream* st, size_t word_size, size_t compare_word_size, size_t scale, int width) {
+  print_scaled_words(st, word_size, scale, width);
+  st->print(" (");
+  print_percentage(st, compare_word_size, word_size);
+  st->print(")");
+}
+
+
+// Print a human readable size.
+// byte_size: size, in bytes, to be printed.
+// scale: one of 1 (byte-wise printing), sizeof(word) (word-size printing), K, M, G (scaled by KB, MB, GB respectively,
+//         or 0, which means the best scale is choosen dynamically.
+// width: printing width.
+void print_human_readable_size(outputStream* st, size_t byte_size, size_t scale, int width)  {
+  if (scale == 0) {
+    // Dynamic mode. Choose scale for this value.
+    if (byte_size == 0) {
+      // Zero values are printed as bytes.
+      scale = 1;
+    } else {
+      if (byte_size >= G) {
+        scale = G;
+      } else if (byte_size >= M) {
+        scale = M;
+      } else if (byte_size >= K) {
+        scale = K;
+      } else {
+        scale = 1;
+      }
+    }
+    return print_human_readable_size(st, byte_size, scale, width);
+  }
+
+#ifdef ASSERT
+  assert(scale == 1 || scale == BytesPerWord || scale == K || scale == M || scale == G, "Invalid scale");
+  // Special case: printing wordsize should only be done with word-sized values
+  if (scale == BytesPerWord) {
+    assert(byte_size % BytesPerWord == 0, "not word sized");
+  }
+#endif
+
+  if (scale == 1) {
+    st->print("%*" PRIuPTR " bytes", width, byte_size);
+  } else if (scale == BytesPerWord) {
+    st->print("%*" PRIuPTR " words", width, byte_size / BytesPerWord);
+  } else {
+    const char* display_unit = "";
+    switch(scale) {
+      case 1: display_unit = "bytes"; break;
+      case BytesPerWord: display_unit = "words"; break;
+      case K: display_unit = "KB"; break;
+      case M: display_unit = "MB"; break;
+      case G: display_unit = "GB"; break;
+      default:
+        ShouldNotReachHere();
+    }
+    float display_value = (float) byte_size / scale;
+    // Since we use width to display a number with two trailing digits, increase it a bit.
+    width += 3;
+    // Prevent very small but non-null values showing up as 0.00.
+    if (byte_size > 0 && display_value < 0.01f) {
+      st->print("%*s %s", width, "<0.01", display_unit);
+    } else {
+      st->print("%*.2f %s", width, display_value, display_unit);
+    }
+  }
+}
+
+// Prints a percentage value. Values smaller than 1% but not 0 are displayed as "<1%", values
+// larger than 99% but not 100% are displayed as ">100%".
+void print_percentage(outputStream* st, size_t total, size_t part) {
+  if (total == 0) {
+    st->print("  ?%%");
+  } else if (part == 0) {
+    st->print("  0%%");
+  } else if (part == total) {
+    st->print("100%%");
+  } else {
+    // Note: clearly print very-small-but-not-0% and very-large-but-not-100% percentages.
+    float p = ((float)part / total) * 100.0f;
+    if (p < 1.0f) {
+      st->print(" <1%%");
+    } else if (p > 99.0f){
+      st->print(">99%%");
+    } else {
+      st->print("%3.0f%%", p);
+    }
+  }
+}
+
+} // namespace internals
+} // namespace metaspace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/memory/metaspace/metaspaceCommon.hpp	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP_
+#define SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP_
+
+#include "utilities/globalDefinitions.hpp"
+
+
+class outputStream;
+
+namespace metaspace {
+namespace internals {
+
+// Print a size, in words, scaled.
+void print_scaled_words(outputStream* st, size_t word_size, size_t scale = 0, int width = -1);
+
+// Convenience helper: prints a size value and a percentage.
+void print_scaled_words_and_percentage(outputStream* st, size_t word_size, size_t compare_word_size, size_t scale = 0, int width = -1);
+
+// Print a human readable size.
+// byte_size: size, in bytes, to be printed.
+// scale: one of 1 (byte-wise printing), sizeof(word) (word-size printing), K, M, G (scaled by KB, MB, GB respectively,
+//         or 0, which means the best scale is choosen dynamically.
+// width: printing width.
+void print_human_readable_size(outputStream* st, size_t byte_size, size_t scale = 0, int width = -1);
+
+// Prints a percentage value. Values smaller than 1% but not 0 are displayed as "<1%", values
+// larger than 99% but not 100% are displayed as ">100%".
+void print_percentage(outputStream* st, size_t total, size_t part);
+
+} // namespace internals
+} // namespace metaspace
+
+#endif /* SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/memory/metaspace/metaspaceDCmd.cpp	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#include "precompiled.hpp"
+#include "memory/metaspace.hpp"
+#include "memory/metaspace/metaspaceDCmd.hpp"
+#include "memory/resourceArea.hpp"
+#include "services/diagnosticCommand.hpp"
+#include "services/nmtCommon.hpp"
+
+namespace metaspace {
+
+MetaspaceDCmd::MetaspaceDCmd(outputStream* output, bool heap)
+  : DCmdWithParser(output, heap)
+  , _basic("basic", "Prints a basic summary (does not need a safepoint).", "BOOLEAN", false, "false")
+  , _show_loaders("show-loaders", "Shows usage by class loader.", "BOOLEAN", false, "false")
+  , _by_chunktype("by-chunktype", "Break down numbers by chunk type.", "BOOLEAN", false, "false")
+  , _by_spacetype("by-spacetype", "Break down numbers by loader type.", "BOOLEAN", false, "false")
+  , _show_vslist("vslist", "Shows details about the underlying virtual space.", "BOOLEAN", false, "false")
+  , _show_vsmap("vsmap", "Shows chunk composition of the underlying virtual spaces", "BOOLEAN", false, "false")
+  , _scale("scale", "Memory usage in which to scale. Valid values are: 1, KB, MB or GB (fixed scale) "
+           "or \"dynamic\" for a dynamically choosen scale.",
+     "STRING", false, "dynamic")
+{
+  _dcmdparser.add_dcmd_option(&_basic);
+  _dcmdparser.add_dcmd_option(&_show_loaders);
+  _dcmdparser.add_dcmd_option(&_by_chunktype);
+  _dcmdparser.add_dcmd_option(&_by_spacetype);
+  _dcmdparser.add_dcmd_option(&_show_vslist);
+  _dcmdparser.add_dcmd_option(&_show_vsmap);
+  _dcmdparser.add_dcmd_option(&_scale);
+}
+
+int MetaspaceDCmd::num_arguments() {
+  ResourceMark rm;
+  MetaspaceDCmd* dcmd = new MetaspaceDCmd(NULL, false);
+  if (dcmd != NULL) {
+    DCmdMark mark(dcmd);
+    return dcmd->_dcmdparser.num_arguments();
+  } else {
+    return 0;
+  }
+}
+
+void MetaspaceDCmd::execute(DCmdSource source, TRAPS) {
+  // Parse scale value.
+  const char* scale_value = _scale.value();
+  size_t scale = 0;
+  if (scale_value != NULL) {
+    if (strcasecmp("dynamic", scale_value) == 0) {
+      scale = 0;
+    } else {
+      scale = NMTUtil::scale_from_name(scale_value);
+      if (scale == 0) {
+        output()->print_cr("Invalid scale: \"%s\". Will use dynamic scaling.", scale_value);
+      }
+    }
+  }
+  if (_basic.value() == true) {
+    if (_show_loaders.value() || _by_chunktype.value() || _by_spacetype.value() ||
+        _show_vslist.value() || _show_vsmap.value()) {
+      // Basic mode. Just print essentials. Does not need to be at a safepoint.
+      output()->print_cr("In basic mode, additional arguments are ignored.");
+    }
+    MetaspaceUtils::print_basic_report(output(), scale);
+  } else {
+    // Full mode. Requires safepoint.
+    int flags = 0;
+    if (_show_loaders.value())         flags |= MetaspaceUtils::rf_show_loaders;
+    if (_by_chunktype.value())         flags |= MetaspaceUtils::rf_break_down_by_chunktype;
+    if (_by_spacetype.value())         flags |= MetaspaceUtils::rf_break_down_by_spacetype;
+    if (_show_vslist.value())          flags |= MetaspaceUtils::rf_show_vslist;
+    if (_show_vsmap.value())           flags |= MetaspaceUtils::rf_show_vsmap;
+    VM_PrintMetadata op(output(), scale, flags);
+    VMThread::execute(&op);
+  }
+}
+
+} // namespace metaspace
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/memory/metaspace/metaspaceDCmd.hpp	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_MEMORY_METASPACE_METASPACEDCMD_HPP_
+#define SHARE_MEMORY_METASPACE_METASPACEDCMD_HPP_
+
+#include "services/diagnosticCommand.hpp"
+
+class outputStream;
+
+namespace metaspace {
+
+class MetaspaceDCmd : public DCmdWithParser {
+  DCmdArgument<bool> _basic;
+  DCmdArgument<bool> _show_loaders;
+  DCmdArgument<bool> _by_spacetype;
+  DCmdArgument<bool> _by_chunktype;
+  DCmdArgument<bool> _show_vslist;
+  DCmdArgument<bool> _show_vsmap;
+  DCmdArgument<char*> _scale;
+public:
+  MetaspaceDCmd(outputStream* output, bool heap);
+  static const char* name() {
+    return "VM.metaspace";
+  }
+  static const char* description() {
+    return "Prints the statistics for the metaspace";
+  }
+  static const char* impact() {
+      return "Medium: Depends on number of classes loaded.";
+  }
+  static const JavaPermission permission() {
+    JavaPermission p = {"java.lang.management.ManagementPermission",
+                        "monitor", NULL};
+    return p;
+  }
+  static int num_arguments();
+  virtual void execute(DCmdSource source, TRAPS);
+};
+
+} // namespace metaspace
+
+#endif /* SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/memory/metaspace/metaspaceStatistics.cpp	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,278 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, SAP and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#include "precompiled.hpp"
+
+#include "memory/metachunk.hpp"
+#include "memory/metaspace/metaspaceCommon.hpp"
+#include "memory/metaspace/metaspaceStatistics.hpp"
+#include "utilities/debug.hpp"
+#include "utilities/globalDefinitions.hpp"
+#include "utilities/ostream.hpp"
+
+namespace metaspace {
+namespace internals {
+
+// FreeChunksStatistics methods
+
+FreeChunksStatistics::FreeChunksStatistics()
+: _num(0), _cap(0)
+{}
+
+void FreeChunksStatistics::reset() {
+  _num = 0; _cap = 0;
+}
+
+void FreeChunksStatistics::add(uintx n, size_t s) {
+  _num += n; _cap += s;
+}
+
+void FreeChunksStatistics::add(const FreeChunksStatistics& other) {
+  _num += other._num;
+  _cap += other._cap;
+}
+
+void FreeChunksStatistics::print_on(outputStream* st, size_t scale) const {
+  st->print(UINTX_FORMAT, _num);
+  st->print(" chunks, total capacity ");
+  print_scaled_words(st, _cap, scale);
+}
+
+// ChunkManagerStatistics methods
+
+void ChunkManagerStatistics::reset() {
+  for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
+    _chunk_stats[i].reset();
+  }
+}
+
+size_t ChunkManagerStatistics::total_capacity() const {
+  return _chunk_stats[SpecializedIndex].cap() +
+      _chunk_stats[SmallIndex].cap() +
+      _chunk_stats[MediumIndex].cap() +
+      _chunk_stats[HumongousIndex].cap();
+}
+
+void ChunkManagerStatistics::print_on(outputStream* st, size_t scale) const {
+  FreeChunksStatistics totals;
+  for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
+    st->cr();
+    st->print("%12s chunks: ", chunk_size_name(i));
+    if (_chunk_stats[i].num() > 0) {
+      st->print(UINTX_FORMAT_W(4) ", capacity ", _chunk_stats[i].num());
+      print_scaled_words(st, _chunk_stats[i].cap(), scale);
+    } else {
+      st->print("(none)");
+    }
+    totals.add(_chunk_stats[i]);
+  }
+  st->cr();
+  st->print("%19s: " UINTX_FORMAT_W(4) ", capacity=", "Total", totals.num());
+  print_scaled_words(st, totals.cap(), scale);
+  st->cr();
+}
+
+// UsedChunksStatistics methods
+
+UsedChunksStatistics::UsedChunksStatistics()
+: _num(0), _cap(0), _used(0), _free(0), _waste(0), _overhead(0)
+{}
+
+void UsedChunksStatistics::reset() {
+  _num = 0;
+  _cap = _overhead = _used = _free = _waste = 0;
+}
+
+void UsedChunksStatistics::add(const UsedChunksStatistics& other) {
+  _num += other._num;
+  _cap += other._cap;
+  _used += other._used;
+  _free += other._free;
+  _waste += other._waste;
+  _overhead += other._overhead;
+  DEBUG_ONLY(check_sanity());
+}
+
+void UsedChunksStatistics::print_on(outputStream* st, size_t scale) const {
+  int col = st->position();
+  st->print(UINTX_FORMAT_W(4) " chunk%s, ", _num, _num != 1 ? "s" : "");
+  if (_num > 0) {
+    col += 14; st->fill_to(col);
+
+    print_scaled_words(st, _cap, scale, 5);
+    st->print(" capacity, ");
+
+    col += 18; st->fill_to(col);
+    print_scaled_words_and_percentage(st, _used, _cap, scale, 5);
+    st->print(" used, ");
+
+    col += 20; st->fill_to(col);
+    print_scaled_words_and_percentage(st, _free, _cap, scale, 5);
+    st->print(" free, ");
+
+    col += 20; st->fill_to(col);
+    print_scaled_words_and_percentage(st, _waste, _cap, scale, 5);
+    st->print(" waste, ");
+
+    col += 20; st->fill_to(col);
+    print_scaled_words_and_percentage(st, _overhead, _cap, scale, 5);
+    st->print(" overhead");
+  }
+  DEBUG_ONLY(check_sanity());
+}
+
+#ifdef ASSERT
+void UsedChunksStatistics::check_sanity() const {
+  assert(_overhead == (Metachunk::overhead() * _num), "Sanity: Overhead.");
+  assert(_cap == _used + _free + _waste + _overhead, "Sanity: Capacity.");
+}
+#endif
+
+// SpaceManagerStatistics methods
+
+SpaceManagerStatistics::SpaceManagerStatistics() { reset(); }
+
+void SpaceManagerStatistics::reset() {
+  for (int i = 0; i < NumberOfInUseLists; i ++) {
+    _chunk_stats[i].reset();
+    _free_blocks_num = 0; _free_blocks_cap_words = 0;
+  }
+}
+
+void SpaceManagerStatistics::add_free_blocks_info(uintx num, size_t cap) {
+  _free_blocks_num += num;
+  _free_blocks_cap_words += cap;
+}
+
+void SpaceManagerStatistics::add(const SpaceManagerStatistics& other) {
+  for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
+    _chunk_stats[i].add(other._chunk_stats[i]);
+  }
+  _free_blocks_num += other._free_blocks_num;
+  _free_blocks_cap_words += other._free_blocks_cap_words;
+}
+
+// Returns total chunk statistics over all chunk types.
+UsedChunksStatistics SpaceManagerStatistics::totals() const {
+  UsedChunksStatistics stat;
+  for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
+    stat.add(_chunk_stats[i]);
+  }
+  return stat;
+}
+
+void SpaceManagerStatistics::print_on(outputStream* st, size_t scale,  bool detailed) const {
+  streamIndentor sti(st);
+  if (detailed) {
+    st->cr_indent();
+    st->print("Usage by chunk type:");
+    {
+      streamIndentor sti2(st);
+      for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
+        st->cr_indent();
+        st->print("%15s: ", chunk_size_name(i));
+        if (_chunk_stats[i].num() == 0) {
+          st->print(" (none)");
+        } else {
+          _chunk_stats[i].print_on(st, scale);
+        }
+      }
+
+      st->cr_indent();
+      st->print("%15s: ", "-total-");
+      totals().print_on(st, scale);
+    }
+    if (_free_blocks_num > 0) {
+      st->cr_indent();
+      st->print("deallocated: " UINTX_FORMAT " blocks with ", _free_blocks_num);
+      print_scaled_words(st, _free_blocks_cap_words, scale);
+    }
+  } else {
+    totals().print_on(st, scale);
+    st->print(", ");
+    st->print("deallocated: " UINTX_FORMAT " blocks with ", _free_blocks_num);
+    print_scaled_words(st, _free_blocks_cap_words, scale);
+  }
+}
+
+// ClassLoaderMetaspaceStatistics methods
+
+ClassLoaderMetaspaceStatistics::ClassLoaderMetaspaceStatistics() { reset(); }
+
+void ClassLoaderMetaspaceStatistics::reset() {
+  nonclass_sm_stats().reset();
+  if (Metaspace::using_class_space()) {
+    class_sm_stats().reset();
+  }
+}
+
+// Returns total space manager statistics for both class and non-class metaspace
+SpaceManagerStatistics ClassLoaderMetaspaceStatistics::totals() const {
+  SpaceManagerStatistics stats;
+  stats.add(nonclass_sm_stats());
+  if (Metaspace::using_class_space()) {
+    stats.add(class_sm_stats());
+  }
+  return stats;
+}
+
+void ClassLoaderMetaspaceStatistics::add(const ClassLoaderMetaspaceStatistics& other) {
+  nonclass_sm_stats().add(other.nonclass_sm_stats());
+  if (Metaspace::using_class_space()) {
+    class_sm_stats().add(other.class_sm_stats());
+  }
+}
+
+void ClassLoaderMetaspaceStatistics::print_on(outputStream* st, size_t scale, bool detailed) const {
+  streamIndentor sti(st);
+  st->cr_indent();
+  if (Metaspace::using_class_space()) {
+    st->print("Non-Class: ");
+  }
+  nonclass_sm_stats().print_on(st, scale, detailed);
+  if (detailed) {
+    st->cr();
+  }
+  if (Metaspace::using_class_space()) {
+    st->cr_indent();
+    st->print("    Class: ");
+    class_sm_stats().print_on(st, scale, detailed);
+    if (detailed) {
+      st->cr();
+    }
+    st->cr_indent();
+    st->print("     Both: ");
+    totals().print_on(st, scale, detailed);
+    if (detailed) {
+      st->cr();
+    }
+  }
+  st->cr();
+}
+
+
+} // end namespace internals
+} // end namespace metaspace
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/memory/metaspace/metaspaceStatistics.hpp	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, SAP and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP_
+#define SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP_
+
+#include "utilities/globalDefinitions.hpp"
+#include "memory/metachunk.hpp" // for ChunkIndex enum
+#include "memory/metaspace.hpp" // for MetadataType enum
+
+class outputStream;
+
+namespace metaspace {
+namespace internals {
+
+// Contains statistics for a number of free chunks.
+class FreeChunksStatistics {
+  uintx _num;         // Number of chunks
+  size_t _cap;        // Total capacity, in words
+
+public:
+  FreeChunksStatistics();
+
+  void reset();
+
+  uintx num() const { return _num; }
+  size_t cap() const { return _cap; }
+
+  void add(uintx n, size_t s);
+  void add(const FreeChunksStatistics& other);
+  void print_on(outputStream* st, size_t scale) const;
+
+}; // end: FreeChunksStatistics
+
+
+// Contains statistics for a ChunkManager.
+class ChunkManagerStatistics {
+
+  FreeChunksStatistics _chunk_stats[NumberOfInUseLists];
+
+public:
+
+  // Free chunk statistics, by chunk index.
+  const FreeChunksStatistics& chunk_stats(ChunkIndex index) const   { return _chunk_stats[index]; }
+  FreeChunksStatistics& chunk_stats(ChunkIndex index)               { return _chunk_stats[index]; }
+
+  void reset();
+  size_t total_capacity() const;
+
+  void print_on(outputStream* st, size_t scale) const;
+
+}; // ChunkManagerStatistics
+
+// Contains statistics for a number of chunks in use.
+// Each chunk has a used and free portion; however, there are current chunks (serving
+// potential future metaspace allocations) and non-current chunks. Unused portion of the
+// former is counted as free, unused portion of the latter counts as waste.
+class UsedChunksStatistics {
+  uintx _num;     // Number of chunks
+  size_t _cap;    // Total capacity in words.
+  size_t _used;   // Total used area, in words
+  size_t _free;   // Total free area (unused portions of current chunks), in words
+  size_t _waste;  // Total waste area (unused portions of non-current chunks), in words
+  size_t _overhead; // Total sum of chunk overheads, in words.
+
+public:
+
+  UsedChunksStatistics();
+
+  void reset();
+
+  uintx num() const { return _num; }
+
+  // Total capacity, in words
+  size_t cap() const { return _cap; }
+
+  // Total used area, in words
+  size_t used() const { return _used; }
+
+  // Total free area (unused portions of current chunks), in words
+  size_t free() const { return _free; }
+
+  // Total waste area (unused portions of non-current chunks), in words
+  size_t waste() const { return _waste; }
+
+  // Total area spent in overhead (chunk headers), in words
+  size_t overhead() const { return _overhead; }
+
+  void add_num(uintx n) { _num += n; }
+  void add_cap(size_t s) { _cap += s; }
+  void add_used(size_t s) { _used += s; }
+  void add_free(size_t s) { _free += s; }
+  void add_waste(size_t s) { _waste += s; }
+  void add_overhead(size_t s) { _overhead += s; }
+
+  void add(const UsedChunksStatistics& other);
+
+  void print_on(outputStream* st, size_t scale) const;
+
+#ifdef ASSERT
+  void check_sanity() const;
+#endif
+
+}; // UsedChunksStatistics
+
+// Class containing statistics for one or more space managers.
+class SpaceManagerStatistics {
+
+  UsedChunksStatistics _chunk_stats[NumberOfInUseLists];
+  uintx _free_blocks_num;
+  size_t _free_blocks_cap_words;
+
+public:
+
+  SpaceManagerStatistics();
+
+  // Chunk statistics by chunk index
+  const UsedChunksStatistics& chunk_stats(ChunkIndex index) const   { return _chunk_stats[index]; }
+  UsedChunksStatistics& chunk_stats(ChunkIndex index)               { return _chunk_stats[index]; }
+
+  uintx free_blocks_num () const                                    { return _free_blocks_num; }
+  size_t free_blocks_cap_words () const                             { return _free_blocks_cap_words; }
+
+  void reset();
+
+  void add_free_blocks_info(uintx num, size_t cap);
+
+  // Returns total chunk statistics over all chunk types.
+  UsedChunksStatistics totals() const;
+
+  void add(const SpaceManagerStatistics& other);
+
+  void print_on(outputStream* st, size_t scale,  bool detailed) const;
+
+}; // SpaceManagerStatistics
+
+class ClassLoaderMetaspaceStatistics {
+
+  SpaceManagerStatistics _sm_stats[Metaspace::MetadataTypeCount];
+
+public:
+
+  ClassLoaderMetaspaceStatistics();
+
+  const SpaceManagerStatistics& sm_stats(Metaspace::MetadataType mdType) const { return _sm_stats[mdType]; }
+  SpaceManagerStatistics& sm_stats(Metaspace::MetadataType mdType)             { return _sm_stats[mdType]; }
+
+  const SpaceManagerStatistics& nonclass_sm_stats() const { return sm_stats(Metaspace::NonClassType); }
+  SpaceManagerStatistics& nonclass_sm_stats()             { return sm_stats(Metaspace::NonClassType); }
+  const SpaceManagerStatistics& class_sm_stats() const    { return sm_stats(Metaspace::ClassType); }
+  SpaceManagerStatistics& class_sm_stats()                { return sm_stats(Metaspace::ClassType); }
+
+  void reset();
+
+  void add(const ClassLoaderMetaspaceStatistics& other);
+
+  // Returns total space manager statistics for both class and non-class metaspace
+  SpaceManagerStatistics totals() const;
+
+  void print_on(outputStream* st, size_t scale, bool detailed) const;
+
+}; // ClassLoaderMetaspaceStatistics
+
+} // namespace internals
+} // namespace metaspace
+
+#endif /* SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP_ */
--- a/src/hotspot/share/memory/metaspaceShared.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/memory/metaspaceShared.cpp	Fri May 04 08:50:01 2018 -0700
@@ -63,7 +63,7 @@
 #include "utilities/align.hpp"
 #include "utilities/defaultStream.hpp"
 #include "utilities/hashtable.inline.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1Allocator.inline.hpp"
 #include "gc/g1/g1CollectedHeap.hpp"
 #endif
--- a/src/hotspot/share/memory/universe.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/memory/universe.cpp	Fri May 04 08:50:01 2018 -0700
@@ -32,14 +32,10 @@
 #include "classfile/vmSymbols.hpp"
 #include "code/codeCache.hpp"
 #include "code/dependencies.hpp"
-#include "gc/shared/cardTableBarrierSet.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
 #include "gc/shared/gcArguments.hpp"
 #include "gc/shared/gcConfig.hpp"
-#include "gc/shared/gcLocker.hpp"
-#include "gc/shared/generation.hpp"
 #include "gc/shared/gcTraceTime.inline.hpp"
-#include "gc/shared/space.hpp"
 #include "interpreter/interpreter.hpp"
 #include "logging/log.hpp"
 #include "logging/logStream.hpp"
@@ -318,7 +314,7 @@
   } else
 #endif
   {
-    k->initialize_supers(ok, CHECK);
+    k->initialize_supers(ok, NULL, CHECK);
   }
   k->append_to_sibling_list();
 }
--- a/src/hotspot/share/oops/arrayKlass.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/arrayKlass.cpp	Fri May 04 08:50:01 2018 -0700
@@ -99,7 +99,7 @@
 // since a GC can happen. At this point all instance variables of the ArrayKlass must be setup.
 void ArrayKlass::complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module_entry, TRAPS) {
   ResourceMark rm(THREAD);
-  k->initialize_supers(super_klass, CHECK);
+  k->initialize_supers(super_klass, NULL, CHECK);
   k->vtable().initialize_vtable(false, CHECK);
 
   // During bootstrapping, before java.base is defined, the module_entry may not be present yet.
@@ -111,9 +111,11 @@
   java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(THREAD, module), Handle(), CHECK);
 }
 
-GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots) {
+GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots,
+                                                            Array<Klass*>* transitive_interfaces) {
   // interfaces = { cloneable_klass, serializable_klass };
   assert(num_extra_slots == 0, "sanity of primitive array type");
+  assert(transitive_interfaces == NULL, "sanity");
   // Must share this for correct bootstrapping!
   set_secondary_supers(Universe::the_array_interfaces_array());
   return NULL;
--- a/src/hotspot/share/oops/arrayKlass.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/arrayKlass.hpp	Fri May 04 08:50:01 2018 -0700
@@ -98,7 +98,8 @@
     return static_cast<const ArrayKlass*>(k);
   }
 
-  GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots);
+  GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
+                                                  Array<Klass*>* transitive_interfaces);
   bool compute_is_subtype_of(Klass* k);
 
   // Sizing
@@ -151,11 +152,11 @@
 #define OOP_OOP_ITERATE_DECL_RANGE(OopClosureType, nv_suffix)                                   \
   void oop_oop_iterate_range##nv_suffix(oop obj, OopClosureType* closure, int start, int end);
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 // Named NO_BACKWARDS because the definition used by *ArrayKlass isn't reversed, see below.
 #define OOP_OOP_ITERATE_DECL_NO_BACKWARDS(OopClosureType, nv_suffix)            \
   void oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure);
-#endif // INCLUDE_ALL_GCS
+#endif
 
 
 // Array oop iteration macros for definitions.
@@ -167,7 +168,7 @@
   oop_oop_iterate_range<nvs_to_bool(nv_suffix)>(obj, closure, start, end);                                \
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 #define OOP_OOP_ITERATE_DEFN_NO_BACKWARDS(KlassType, OopClosureType, nv_suffix)           \
 void KlassType::oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) {  \
   /* No reverse implementation ATM. */                                                    \
--- a/src/hotspot/share/oops/instanceClassLoaderKlass.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/instanceClassLoaderKlass.hpp	Fri May 04 08:50:01 2018 -0700
@@ -48,7 +48,7 @@
 
   // GC specific object visitors
   //
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   // Parallel Scavenge
   void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
   // Parallel Compact
@@ -68,7 +68,7 @@
   template <bool nv, class OopClosureType>
   inline void oop_oop_iterate(oop obj, OopClosureType* closure);
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
   // Reverse iteration
   // Iterate over the oop fields and metadata.
   template <bool nv, class OopClosureType>
@@ -85,10 +85,10 @@
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL)
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_BACKWARDS)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_BACKWARDS)
-#endif // INCLUDE_ALL_GCS
+#endif
 
 };
 
--- a/src/hotspot/share/oops/instanceClassLoaderKlass.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/instanceClassLoaderKlass.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -47,7 +47,7 @@
   }
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 template <bool nv, class OopClosureType>
 inline void InstanceClassLoaderKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) {
   InstanceKlass::oop_oop_iterate_reverse<nv>(obj, closure);
@@ -55,7 +55,7 @@
   assert(!Devirtualizer<nv>::do_metadata(closure),
       "Code to handle metadata is not implemented");
 }
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 
 
 template <bool nv, class OopClosureType>
--- a/src/hotspot/share/oops/instanceKlass.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/instanceKlass.cpp	Fri May 04 08:50:01 2018 -0700
@@ -918,9 +918,10 @@
     return Klass::can_be_primary_super_slow();
 }
 
-GrowableArray<Klass*>* InstanceKlass::compute_secondary_supers(int num_extra_slots) {
+GrowableArray<Klass*>* InstanceKlass::compute_secondary_supers(int num_extra_slots,
+                                                               Array<Klass*>* transitive_interfaces) {
   // The secondaries are the implemented interfaces.
-  Array<Klass*>* interfaces = transitive_interfaces();
+  Array<Klass*>* interfaces = transitive_interfaces;
   int num_secondaries = num_extra_slots + interfaces->length();
   if (num_secondaries == 0) {
     // Must share this for correct bootstrapping!
--- a/src/hotspot/share/oops/instanceKlass.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/instanceKlass.hpp	Fri May 04 08:50:01 2018 -0700
@@ -1013,7 +1013,8 @@
 
   // virtual operations from Klass
   bool is_leaf_class() const               { return _subklass == NULL; }
-  GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots);
+  GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
+                                                  Array<Klass*>* transitive_interfaces);
   bool compute_is_subtype_of(Klass* k);
   bool can_be_primary_super_slow() const;
   int oop_size(oop obj)  const             { return size_helper(); }
@@ -1149,9 +1150,11 @@
 #endif // INCLUDE_JVMTI
 
   void clean_weak_instanceklass_links();
+ private:
   void clean_implementors_list();
   void clean_method_data();
 
+ public:
   // Explicit metaspace deallocation of fields
   // For RedefineClasses and class file parsing errors, we need to deallocate
   // instanceKlasses and the metadata they point to.
@@ -1177,7 +1180,7 @@
 
   // GC specific object visitors
   //
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   // Parallel Scavenge
   void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
   // Parallel Compact
@@ -1214,7 +1217,7 @@
 
 
   // Reverse iteration
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
  public:
   // Iterate over all oop fields in the oop maps.
   template <bool nv, class OopClosureType>
@@ -1234,7 +1237,7 @@
   // Iterate over all oop fields in one oop map.
   template <bool nv, typename T, class OopClosureType>
   inline void oop_oop_iterate_oop_map_reverse(OopMapBlock* map, oop obj, OopClosureType* closure);
-#endif
+#endif // INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 
 
   // Bounded range iteration
@@ -1264,10 +1267,10 @@
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL)
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_BACKWARDS)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_BACKWARDS)
-#endif // INCLUDE_ALL_GCS
+#endif
 
   u2 idnum_allocated_count() const      { return _idnum_allocated_count; }
 
--- a/src/hotspot/share/oops/instanceKlass.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/instanceKlass.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -64,7 +64,7 @@
   }
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 template <bool nv, typename T, class OopClosureType>
 ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_map_reverse(OopMapBlock* map, oop obj, OopClosureType* closure) {
   T* const start = (T*)obj->obj_field_addr_raw<T>(map->offset());
@@ -110,7 +110,7 @@
   }
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 template <bool nv, typename T, class OopClosureType>
 ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps_specialized_reverse(oop obj, OopClosureType* closure) {
   OopMapBlock* const start_map = start_of_nonstatic_oop_maps();
@@ -142,7 +142,7 @@
   }
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 template <bool nv, class OopClosureType>
 ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps_reverse(oop obj, OopClosureType* closure) {
   if (UseCompressedOops) {
@@ -173,7 +173,7 @@
   return size_helper();
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 template <bool nv, class OopClosureType>
 ALWAYSINLINE int InstanceKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) {
   assert(!Devirtualizer<nv>::do_metadata(closure),
--- a/src/hotspot/share/oops/instanceMirrorKlass.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/instanceMirrorKlass.hpp	Fri May 04 08:50:01 2018 -0700
@@ -89,7 +89,7 @@
 
   // GC specific object visitors
   //
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   // Parallel Scavenge
   void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
   // Parallel Compact
@@ -121,7 +121,7 @@
 
 
   // Reverse iteration
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
   // Iterate over the oop fields and metadata.
   template <bool nv, class OopClosureType>
   inline void oop_oop_iterate_reverse(oop obj, OopClosureType* closure);
@@ -148,10 +148,10 @@
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL)
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_BACKWARDS)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_BACKWARDS)
-#endif // INCLUDE_ALL_GCS
+#endif
 };
 
 #endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
--- a/src/hotspot/share/oops/instanceMirrorKlass.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/instanceMirrorKlass.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -86,14 +86,14 @@
   oop_oop_iterate_statics<nv>(obj, closure);
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 template <bool nv, class OopClosureType>
 void InstanceMirrorKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) {
   InstanceKlass::oop_oop_iterate_reverse<nv>(obj, closure);
 
   InstanceMirrorKlass::oop_oop_iterate_statics<nv>(obj, closure);
 }
-#endif
+#endif // INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 
 template <bool nv, typename T, class OopClosureType>
 void InstanceMirrorKlass::oop_oop_iterate_statics_specialized_bounded(oop obj,
--- a/src/hotspot/share/oops/instanceRefKlass.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/instanceRefKlass.hpp	Fri May 04 08:50:01 2018 -0700
@@ -58,7 +58,7 @@
 
   // GC specific object visitors
   //
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   // Parallel Scavenge
   void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
   // Parallel Compact
@@ -80,11 +80,11 @@
   inline void oop_oop_iterate(oop obj, OopClosureType* closure);
 
   // Reverse iteration
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
   // Iterate over all oop fields and metadata.
   template <bool nv, class OopClosureType>
   inline void oop_oop_iterate_reverse(oop obj, OopClosureType* closure);
-#endif // INCLUDE_ALL_GCS
+#endif
 
   // Bounded range iteration
   // Iterate over all oop fields and metadata.
@@ -141,10 +141,10 @@
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL)
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_BACKWARDS)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_BACKWARDS)
-#endif // INCLUDE_ALL_GCS
+#endif
 
   // Update non-static oop maps so 'referent', 'nextPending' and
   // 'discovered' will look like non-oops
--- a/src/hotspot/share/oops/instanceRefKlass.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/instanceRefKlass.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -171,14 +171,14 @@
   oop_oop_iterate_ref_processing<nv>(obj, closure);
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 template <bool nv, class OopClosureType>
 void InstanceRefKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) {
   InstanceKlass::oop_oop_iterate_reverse<nv>(obj, closure);
 
   oop_oop_iterate_ref_processing<nv>(obj, closure);
 }
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 
 
 template <bool nv, class OopClosureType>
--- a/src/hotspot/share/oops/klass.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/klass.cpp	Fri May 04 08:50:01 2018 -0700
@@ -224,7 +224,7 @@
     return true;
 }
 
-void Klass::initialize_supers(Klass* k, TRAPS) {
+void Klass::initialize_supers(Klass* k, Array<Klass*>* transitive_interfaces, TRAPS) {
   if (FastSuperclassLimit == 0) {
     // None of the other machinery matters.
     set_super(k);
@@ -292,7 +292,7 @@
     ResourceMark rm(THREAD);  // need to reclaim GrowableArrays allocated below
 
     // Compute the "real" non-extra secondaries.
-    GrowableArray<Klass*>* secondaries = compute_secondary_supers(extras);
+    GrowableArray<Klass*>* secondaries = compute_secondary_supers(extras, transitive_interfaces);
     if (secondaries == NULL) {
       // secondary_supers set by compute_secondary_supers
       return;
@@ -342,8 +342,10 @@
   }
 }
 
-GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots) {
+GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots,
+                                                       Array<Klass*>* transitive_interfaces) {
   assert(num_extra_slots == 0, "override for complex klasses");
+  assert(transitive_interfaces == NULL, "sanity");
   set_secondary_supers(Universe::the_empty_klass_array());
   return NULL;
 }
@@ -382,8 +384,8 @@
   debug_only(verify();)
 }
 
-void Klass::clean_weak_klass_links(bool clean_alive_klasses) {
-  if (!ClassUnloading) {
+void Klass::clean_weak_klass_links(bool unloading_occurred, bool clean_alive_klasses) {
+  if (!ClassUnloading || !unloading_occurred) {
     return;
   }
 
--- a/src/hotspot/share/oops/klass.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/klass.hpp	Fri May 04 08:50:01 2018 -0700
@@ -189,12 +189,13 @@
   void set_super(Klass* k)           { _super = k; }
 
   // initializes _super link, _primary_supers & _secondary_supers arrays
-  void initialize_supers(Klass* k, TRAPS);
+  void initialize_supers(Klass* k, Array<Klass*>* transitive_interfaces, TRAPS);
   void initialize_supers_impl1(Klass* k);
   void initialize_supers_impl2(Klass* k);
 
   // klass-specific helper for initializing _secondary_supers
-  virtual GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots);
+  virtual GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
+                                                          Array<Klass*>* transitive_interfaces);
 
   // java_super is the Java-level super type as specified by Class.getSuperClass.
   virtual Klass* java_super() const  { return NULL; }
@@ -637,14 +638,14 @@
   // Klass is considered alive.  Has already been marked as unloading.
   bool is_loader_alive() const { return !class_loader_data()->is_unloading(); }
 
-  static void clean_weak_klass_links(bool clean_alive_klasses = true);
+  static void clean_weak_klass_links(bool unloading_occurred, bool clean_alive_klasses = true);
   static void clean_subklass_tree() {
-    clean_weak_klass_links(false /* clean_alive_klasses */);
+    clean_weak_klass_links(/*unloading_occurred*/ true , /* clean_alive_klasses */ false);
   }
 
   // GC specific object visitors
   //
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   // Parallel Scavenge
   virtual void oop_ps_push_contents(  oop obj, PSPromotionManager* pm)   = 0;
   // Parallel Compact
@@ -662,13 +663,13 @@
   ALL_OOP_OOP_ITERATE_CLOSURES_1(Klass_OOP_OOP_ITERATE_DECL)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(Klass_OOP_OOP_ITERATE_DECL)
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 #define Klass_OOP_OOP_ITERATE_DECL_BACKWARDS(OopClosureType, nv_suffix)                     \
   virtual void oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) = 0;
 
   ALL_OOP_OOP_ITERATE_CLOSURES_1(Klass_OOP_OOP_ITERATE_DECL_BACKWARDS)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(Klass_OOP_OOP_ITERATE_DECL_BACKWARDS)
-#endif // INCLUDE_ALL_GCS
+#endif
 
   virtual void array_klasses_do(void f(Klass* k)) {}
 
@@ -729,10 +730,10 @@
   void oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure);                        \
   void oop_oop_iterate_bounded##nv_suffix(oop obj, OopClosureType* closure, MemRegion mr);
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 #define OOP_OOP_ITERATE_DECL_BACKWARDS(OopClosureType, nv_suffix)               \
   void oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure);
-#endif // INCLUDE_ALL_GCS
+#endif
 
 
 // Oop iteration macros for definitions.
@@ -743,7 +744,7 @@
   oop_oop_iterate<nvs_to_bool(nv_suffix)>(obj, closure);                        \
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 #define OOP_OOP_ITERATE_DEFN_BACKWARDS(KlassType, OopClosureType, nv_suffix)              \
 void KlassType::oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) {  \
   oop_oop_iterate_reverse<nvs_to_bool(nv_suffix)>(obj, closure);                          \
--- a/src/hotspot/share/oops/method.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/method.cpp	Fri May 04 08:50:01 2018 -0700
@@ -28,7 +28,6 @@
 #include "code/codeCache.hpp"
 #include "code/debugInfoRec.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
-#include "gc/shared/generation.hpp"
 #include "interpreter/bytecodeStream.hpp"
 #include "interpreter/bytecodeTracer.hpp"
 #include "interpreter/bytecodes.hpp"
--- a/src/hotspot/share/oops/methodData.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/methodData.cpp	Fri May 04 08:50:01 2018 -0700
@@ -429,7 +429,7 @@
   ReceiverTypeData::clean_weak_method_links();
   for (uint row = 0; row < method_row_limit(); row++) {
     Method* p = method(row);
-    if (p != NULL && !p->on_stack()) {
+    if (p != NULL && p->is_old()) {
       clear_method_row(row);
     }
   }
@@ -1770,6 +1770,8 @@
   verify_extra_data_clean(&cl);
 }
 
+// This is called during redefinition to clean all "old" redefined
+// methods out of MethodData for all methods.
 void MethodData::clean_weak_method_links() {
   ResourceMark rm;
   for (ProfileData* data = first_data();
--- a/src/hotspot/share/oops/objArrayKlass.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/objArrayKlass.cpp	Fri May 04 08:50:01 2018 -0700
@@ -331,7 +331,9 @@
     return Klass::can_be_primary_super_slow();
 }
 
-GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots) {
+GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots,
+                                                               Array<Klass*>* transitive_interfaces) {
+  assert(transitive_interfaces == NULL, "sanity");
   // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
   Array<Klass*>* elem_supers = element_klass()->secondary_supers();
   int num_elem_supers = elem_supers == NULL ? 0 : elem_supers->length();
--- a/src/hotspot/share/oops/objArrayKlass.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/objArrayKlass.hpp	Fri May 04 08:50:01 2018 -0700
@@ -64,7 +64,8 @@
 
   // Dispatched operation
   bool can_be_primary_super_slow() const;
-  GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots);
+  GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
+                                                  Array<Klass*>* transitive_interfaces);
   bool compute_is_subtype_of(Klass* k);
   DEBUG_ONLY(bool is_objArray_klass_slow()  const  { return true; })
   int oop_size(oop obj) const;
@@ -116,7 +117,7 @@
 
   // GC specific object visitors
   //
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   // Parallel Scavenge
   void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
   // Parallel Compact
@@ -177,10 +178,10 @@
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_RANGE)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_RANGE)
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_NO_BACKWARDS)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_NO_BACKWARDS)
-#endif // INCLUDE_ALL_GCS
+#endif
 
   // JVM support
   jint compute_modifier_flags(TRAPS) const;
--- a/src/hotspot/share/oops/oop.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/oop.cpp	Fri May 04 08:50:01 2018 -0700
@@ -32,7 +32,7 @@
 #include "runtime/handles.inline.hpp"
 #include "runtime/thread.inline.hpp"
 #include "utilities/copy.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1Allocator.inline.hpp"
 #endif
 
--- a/src/hotspot/share/oops/oop.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/oop.hpp	Fri May 04 08:50:01 2018 -0700
@@ -259,13 +259,11 @@
   inline void forward_to(oop p);
   inline bool cas_forward_to(oop p, markOop compare);
 
-#if INCLUDE_ALL_GCS
   // Like "forward_to", but inserts the forwarding pointer atomically.
   // Exactly one thread succeeds in inserting the forwarding pointer, and
   // this call returns "NULL" for that thread; any other thread has the
   // value of the forwarding pointer returned and does not modify "this".
   inline oop forward_to_atomic(oop p);
-#endif // INCLUDE_ALL_GCS
 
   inline oop forwardee() const;
 
@@ -278,7 +276,7 @@
 
   // Garbage Collection support
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   // Parallel Compact
   inline void pc_follow_contents(ParCompactionManager* cm);
   inline void pc_update_contents(ParCompactionManager* cm);
@@ -303,7 +301,7 @@
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_SIZE_DECL)
 
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 
 #define OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix)  \
   inline void oop_iterate_backwards(OopClosureType* blk);
@@ -311,7 +309,7 @@
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_BACKWARDS_DECL)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_BACKWARDS_DECL)
 
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 
   inline int oop_iterate_no_header(OopClosure* bk);
   inline int oop_iterate_no_header(OopClosure* bk, MemRegion mr);
--- a/src/hotspot/share/oops/oop.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/oop.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -25,9 +25,7 @@
 #ifndef SHARE_VM_OOPS_OOP_INLINE_HPP
 #define SHARE_VM_OOPS_OOP_INLINE_HPP
 
-#include "gc/shared/ageTable.hpp"
 #include "gc/shared/collectedHeap.hpp"
-#include "gc/shared/generation.hpp"
 #include "oops/access.inline.hpp"
 #include "oops/arrayKlass.hpp"
 #include "oops/arrayOop.hpp"
@@ -350,7 +348,6 @@
   return cas_set_mark_raw(m, compare) == compare;
 }
 
-#if INCLUDE_ALL_GCS
 oop oopDesc::forward_to_atomic(oop p) {
   markOop oldMark = mark_raw();
   markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
@@ -372,7 +369,6 @@
   }
   return forwardee();
 }
-#endif
 
 // Note that the forwardee is not the same thing as the displaced_mark.
 // The forwardee is used when copying during scavenge and mark-sweep.
@@ -400,7 +396,7 @@
   }
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
 void oopDesc::pc_follow_contents(ParCompactionManager* cm) {
   klass()->oop_pc_follow_contents(this, cm);
 }
@@ -422,7 +418,7 @@
   }
   // Else skip it.  The TypeArrayKlass in the header never needs scavenging.
 }
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_PARALLELGC
 
 #define OOP_ITERATE_DEFN(OopClosureType, nv_suffix)                 \
                                                                     \
@@ -462,7 +458,7 @@
   return oop_iterate_size(&cl, mr);
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
 #define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)       \
                                                                     \
 inline void oopDesc::oop_iterate_backwards(OopClosureType* blk) {   \
@@ -470,7 +466,7 @@
 }
 #else
 #define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)
-#endif // INCLUDE_ALL_GCS
+#endif
 
 #define ALL_OOPDESC_OOP_ITERATE(OopClosureType, nv_suffix)  \
   OOP_ITERATE_DEFN(OopClosureType, nv_suffix)               \
--- a/src/hotspot/share/oops/typeArrayKlass.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/oops/typeArrayKlass.hpp	Fri May 04 08:50:01 2018 -0700
@@ -74,7 +74,7 @@
 
   // GC specific object visitors
   //
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
   // Parallel Scavenge
   void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
   // Parallel Compact
@@ -104,10 +104,10 @@
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_RANGE)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_RANGE)
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_NO_BACKWARDS)
   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_NO_BACKWARDS)
-#endif // INCLUDE_ALL_GCS
+#endif
 
 
  protected:
--- a/src/hotspot/share/opto/arraycopynode.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/opto/arraycopynode.cpp	Fri May 04 08:50:01 2018 -0700
@@ -644,6 +644,7 @@
 }
 
 static Node* step_over_gc_barrier(Node* c) {
+#if INCLUDE_G1GC
   if (UseG1GC && !GraphKit::use_ReduceInitialCardMarks() &&
       c != NULL && c->is_Region() && c->req() == 3) {
     for (uint i = 1; i < c->req(); i++) {
@@ -675,6 +676,7 @@
       }
     }
   }
+#endif // INCLUDE_G1GC
   return c;
 }
 
--- a/src/hotspot/share/opto/compile.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/opto/compile.cpp	Fri May 04 08:50:01 2018 -0700
@@ -73,9 +73,9 @@
 #include "runtime/timer.hpp"
 #include "utilities/align.hpp"
 #include "utilities/copy.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1ThreadLocalData.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
 
 // -------------------- Compile::mach_constant_base_node -----------------------
@@ -3753,6 +3753,7 @@
 // Currently supported:
 // - G1 pre-barriers (see GraphKit::g1_write_barrier_pre())
 void Compile::verify_barriers() {
+#if INCLUDE_G1GC
   if (UseG1GC) {
     // Verify G1 pre-barriers
     const int marking_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset());
@@ -3812,6 +3813,7 @@
       }
     }
   }
+#endif
 }
 
 #endif
--- a/src/hotspot/share/opto/escape.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/opto/escape.cpp	Fri May 04 08:50:01 2018 -0700
@@ -37,9 +37,9 @@
 #include "opto/phaseX.hpp"
 #include "opto/movenode.hpp"
 #include "opto/rootnode.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1ThreadLocalData.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
 ConnectionGraph::ConnectionGraph(Compile * C, PhaseIterGVN *igvn) :
   _nodes(C->comp_arena(), C->unique(), C->unique(), NULL),
@@ -538,6 +538,7 @@
           // Pointer stores in G1 barriers looks like unsafe access.
           // Ignore such stores to be able scalar replace non-escaping
           // allocations.
+#if INCLUDE_G1GC
           if (UseG1GC && adr->is_AddP()) {
             Node* base = get_addp_base(adr);
             if (base->Opcode() == Op_LoadP &&
@@ -555,6 +556,7 @@
               }
             }
           }
+#endif
           delayed_worklist->push(n); // Process unsafe access later.
           break;
         }
--- a/src/hotspot/share/opto/graphKit.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/opto/graphKit.cpp	Fri May 04 08:50:01 2018 -0700
@@ -25,9 +25,6 @@
 #include "precompiled.hpp"
 #include "ci/ciUtilities.hpp"
 #include "compiler/compileLog.hpp"
-#include "gc/g1/g1BarrierSet.hpp"
-#include "gc/g1/g1CardTable.hpp"
-#include "gc/g1/heapRegion.hpp"
 #include "gc/shared/barrierSet.hpp"
 #include "gc/shared/cardTable.hpp"
 #include "gc/shared/cardTableBarrierSet.hpp"
@@ -48,8 +45,10 @@
 #include "opto/runtime.hpp"
 #include "runtime/deoptimization.hpp"
 #include "runtime/sharedRuntime.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
+#include "gc/g1/g1CardTable.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
+#include "gc/g1/heapRegion.hpp"
 #endif // INCLUDE_ALL_GCS
 
 //----------------------------GraphKit-----------------------------------------
@@ -1565,9 +1564,12 @@
   BarrierSet* bs = BarrierSet::barrier_set();
   set_control(ctl);
   switch (bs->kind()) {
+
+#if INCLUDE_G1GC
     case BarrierSet::G1BarrierSet:
       g1_write_barrier_pre(do_load, obj, adr, adr_idx, val, val_type, pre_val, bt);
       break;
+#endif
 
     case BarrierSet::CardTableBarrierSet:
       break;
@@ -1581,8 +1583,11 @@
 bool GraphKit::can_move_pre_barrier() const {
   BarrierSet* bs = BarrierSet::barrier_set();
   switch (bs->kind()) {
+
+#if INCLUDE_G1GC
     case BarrierSet::G1BarrierSet:
       return true; // Can move it if no safepoint
+#endif
 
     case BarrierSet::CardTableBarrierSet:
       return true; // There is no pre-barrier
@@ -1604,9 +1609,11 @@
   BarrierSet* bs = BarrierSet::barrier_set();
   set_control(ctl);
   switch (bs->kind()) {
+#if INCLUDE_G1GC
     case BarrierSet::G1BarrierSet:
       g1_write_barrier_post(store, obj, adr, adr_idx, val, bt, use_precise);
       break;
+#endif
 
     case BarrierSet::CardTableBarrierSet:
       write_barrier_post(store, obj, adr, adr_idx, val, use_precise);
@@ -3929,6 +3936,9 @@
   // Final sync IdealKit and GraphKit.
   final_sync(ideal);
 }
+
+#if INCLUDE_G1GC
+
 /*
  * Determine if the G1 pre-barrier can be removed. The pre-barrier is
  * required by SATB to make sure all objects live at the start of the
@@ -4361,6 +4371,7 @@
 }
 #undef __
 
+#endif // INCLUDE_G1GC
 
 Node* GraphKit::load_String_length(Node* ctrl, Node* str) {
   Node* len = load_array_length(load_String_value(ctrl, str));
--- a/src/hotspot/share/opto/graphKit.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/opto/graphKit.hpp	Fri May 04 08:50:01 2018 -0700
@@ -768,6 +768,7 @@
   // Used for load_store operations which loads old value.
   bool can_move_pre_barrier() const;
 
+#if INCLUDE_G1GC
   // G1 pre/post barriers
   void g1_write_barrier_pre(bool do_load,
                             Node* obj,
@@ -794,6 +795,7 @@
   bool g1_can_remove_pre_barrier(PhaseTransform* phase, Node* adr, BasicType bt, uint adr_idx);
 
   bool g1_can_remove_post_barrier(PhaseTransform* phase, Node* store, Node* adr);
+#endif // INCLUDE_G1GC
 
   public:
   // Helper function to round double arguments before a call
--- a/src/hotspot/share/opto/macro.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/opto/macro.cpp	Fri May 04 08:50:01 2018 -0700
@@ -47,9 +47,9 @@
 #include "opto/subnode.hpp"
 #include "opto/type.hpp"
 #include "runtime/sharedRuntime.hpp"
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1ThreadLocalData.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
 
 //
@@ -246,7 +246,9 @@
       assert(mem->is_Store(), "store required");
       _igvn.replace_node(mem, mem->in(MemNode::Memory));
     }
-  } else {
+  }
+#if INCLUDE_G1GC
+  else {
     // G1 pre/post barriers
     assert(p2x->outcnt() <= 2, "expects 1 or 2 users: Xor and URShift nodes");
     // It could be only one user, URShift node, in Object.clone() intrinsic
@@ -326,6 +328,7 @@
     assert(p2x->outcnt() == 0 || p2x->unique_out()->Opcode() == Op_URShiftX, "");
     _igvn.replace_node(p2x, top());
   }
+#endif // INCLUDE_G1GC
 }
 
 // Search for a memory operation for the specified memory slice.
--- a/src/hotspot/share/opto/runtime.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/opto/runtime.cpp	Fri May 04 08:50:01 2018 -0700
@@ -141,8 +141,10 @@
   gen(env, _multianewarray4_Java           , multianewarray4_Type         , multianewarray4_C               ,    0 , true , false, false);
   gen(env, _multianewarray5_Java           , multianewarray5_Type         , multianewarray5_C               ,    0 , true , false, false);
   gen(env, _multianewarrayN_Java           , multianewarrayN_Type         , multianewarrayN_C               ,    0 , true , false, false);
+#if INCLUDE_G1GC
   gen(env, _g1_wb_pre_Java                 , g1_wb_pre_Type               , SharedRuntime::g1_wb_pre        ,    0 , false, false, false);
   gen(env, _g1_wb_post_Java                , g1_wb_post_Type              , SharedRuntime::g1_wb_post       ,    0 , false, false, false);
+#endif // INCLUDE_G1GC
   gen(env, _complete_monitor_locking_Java  , complete_monitor_enter_Type  , SharedRuntime::complete_monitor_locking_C, 0, false, false, false);
   gen(env, _monitor_notify_Java            , monitor_notify_Type          , monitor_notify_C                ,    0 , false, false, false);
   gen(env, _monitor_notifyAll_Java         , monitor_notify_Type          , monitor_notifyAll_C             ,    0 , false, false, false);
--- a/src/hotspot/share/precompiled/precompiled.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/precompiled/precompiled.hpp	Fri May 04 08:50:01 2018 -0700
@@ -84,8 +84,6 @@
 # include "compiler/disassembler.hpp"
 # include "compiler/methodLiveness.hpp"
 # include "compiler/oopMap.hpp"
-# include "gc/serial/cSpaceCounters.hpp"
-# include "gc/serial/defNewGeneration.hpp"
 # include "gc/shared/adaptiveSizePolicy.hpp"
 # include "gc/shared/ageTable.hpp"
 # include "gc/shared/barrierSet.hpp"
@@ -294,7 +292,7 @@
 #if INCLUDE_JVMCI
 # include "jvmci/jvmci_globals.hpp"
 #endif // INCLUDE_JVMCI
-#if INCLUDE_ALL_GCS
+#if INCLUDE_CMSGC
 # include "gc/cms/allocationStats.hpp"
 # include "gc/cms/compactibleFreeListSpace.hpp"
 # include "gc/cms/concurrentMarkSweepGeneration.hpp"
@@ -304,6 +302,8 @@
 # include "gc/cms/parOopClosures.hpp"
 # include "gc/cms/promotionInfo.hpp"
 # include "gc/cms/yieldingWorkgroup.hpp"
+#endif // INCLUDE_CMSGC
+#if INCLUDE_G1GC
 # include "gc/g1/dirtyCardQueue.hpp"
 # include "gc/g1/g1BlockOffsetTable.hpp"
 # include "gc/g1/g1OopClosures.hpp"
@@ -311,6 +311,8 @@
 # include "gc/g1/jvmFlagConstraintsG1.hpp"
 # include "gc/g1/ptrQueue.hpp"
 # include "gc/g1/satbMarkQueue.hpp"
+#endif // INCLUDE_G1GC
+#if INCLUDE_PARALLELGC
 # include "gc/parallel/gcAdaptivePolicyCounters.hpp"
 # include "gc/parallel/immutableSpace.hpp"
 # include "gc/parallel/jvmFlagConstraintsParallel.hpp"
@@ -326,8 +328,10 @@
 # include "gc/parallel/psVirtualspace.hpp"
 # include "gc/parallel/psYoungGen.hpp"
 # include "gc/parallel/spaceCounters.hpp"
-# include "gc/shared/gcPolicyCounters.hpp"
-# include "gc/shared/plab.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_PARALLELGC
+#if INCLUDE_SERIALGC
+# include "gc/serial/cSpaceCounters.hpp"
+# include "gc/serial/defNewGeneration.hpp"
+#endif // INCLUDE_SERIALGC
 
 #endif // !DONT_USE_PRECOMPILED_HEADER
--- a/src/hotspot/share/prims/forte.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/prims/forte.cpp	Fri May 04 08:50:01 2018 -0700
@@ -26,7 +26,6 @@
 #include "code/debugInfoRec.hpp"
 #include "code/pcDesc.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
-#include "gc/shared/space.hpp"
 #include "memory/universe.hpp"
 #include "oops/oop.inline.hpp"
 #include "prims/forte.hpp"
--- a/src/hotspot/share/prims/jni.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/prims/jni.cpp	Fri May 04 08:50:01 2018 -0700
@@ -38,6 +38,7 @@
 #include "classfile/vmSymbols.hpp"
 #include "gc/shared/gcLocker.inline.hpp"
 #include "interpreter/linkResolver.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/oopFactory.hpp"
--- a/src/hotspot/share/prims/jvmtiExport.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/prims/jvmtiExport.cpp	Fri May 04 08:50:01 2018 -0700
@@ -59,9 +59,6 @@
 #include "runtime/threadSMR.hpp"
 #include "runtime/vframe.inline.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/parallel/psMarkSweep.hpp"
-#endif // INCLUDE_ALL_GCS
 
 #ifdef JVMTI_TRACE
 #define EVT_TRACE(evt,out) if ((JvmtiTrace::event_trace_flags(evt) & JvmtiTrace::SHOW_EVENT_SENT) != 0) { SafeResourceMark rm; log_trace(jvmti) out; }
--- a/src/hotspot/share/prims/jvmtiExport.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/prims/jvmtiExport.hpp	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -170,19 +170,6 @@
   static void post_dynamic_code_generated(JvmtiEnv* env, const char *name, const void *code_begin,
                                           const void *code_end) NOT_JVMTI_RETURN;
 
-  // The RedefineClasses() API breaks some invariants in the "regular"
-  // system. For example, there are sanity checks when GC'ing nmethods
-  // that require the containing class to be unloading. However, when a
-  // method is redefined, the old method and nmethod can become GC'able
-  // without the containing class unloading. The state of becoming
-  // GC'able can be asynchronous to the RedefineClasses() call since
-  // the old method may still be running and cannot be GC'ed until
-  // after all old invocations have finished. Additionally, a method
-  // that has not been redefined may have an nmethod that depends on
-  // the redefined method. The dependent nmethod will get deopted in
-  // this case and may also be GC'able without the containing class
-  // being unloaded.
-  //
   // This flag indicates whether RedefineClasses() has ever redefined
   // one or more classes during the lifetime of the VM. The flag should
   // only be set by the friend class and can be queried by other sub
--- a/src/hotspot/share/prims/jvmtiTagMap.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/prims/jvmtiTagMap.cpp	Fri May 04 08:50:01 2018 -0700
@@ -29,6 +29,7 @@
 #include "classfile/vmSymbols.hpp"
 #include "code/codeCache.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/access.inline.hpp"
--- a/src/hotspot/share/prims/methodComparator.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/prims/methodComparator.cpp	Fri May 04 08:50:01 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/constantPool.inline.hpp"
 #include "oops/oop.inline.hpp"
--- a/src/hotspot/share/prims/resolvedMethodTable.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/prims/resolvedMethodTable.cpp	Fri May 04 08:50:01 2018 -0700
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/javaClasses.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/access.inline.hpp"
--- a/src/hotspot/share/prims/whitebox.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/prims/whitebox.cpp	Fri May 04 08:50:01 2018 -0700
@@ -73,14 +73,16 @@
 #if INCLUDE_CDS
 #include "prims/cdsoffsets.hpp"
 #endif // INCLUDE_CDS
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1ConcurrentMark.hpp"
 #include "gc/g1/g1ConcurrentMarkThread.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
+#endif // INCLUDE_G1GC
+#if INCLUDE_PARALLELGC
 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
 #include "gc/parallel/adjoiningGenerations.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_PARALLELGC
 #if INCLUDE_NMT
 #include "services/mallocSiteTable.hpp"
 #include "services/memTracker.hpp"
@@ -328,7 +330,7 @@
 
 WB_ENTRY(jboolean, WB_isObjectInOldGen(JNIEnv* env, jobject o, jobject obj))
   oop p = JNIHandles::resolve(obj);
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   if (UseG1GC) {
     G1CollectedHeap* g1h = G1CollectedHeap::heap();
     const HeapRegion* hr = g1h->heap_region_containing(p);
@@ -336,11 +338,14 @@
       return false;
     }
     return !(hr->is_young());
-  } else if (UseParallelGC) {
+  }
+#endif
+#if INCLUDE_PARALLELGC
+  if (UseParallelGC) {
     ParallelScavengeHeap* psh = ParallelScavengeHeap::heap();
     return !psh->is_in_young(p);
   }
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_PARALLELGC
   GenCollectedHeap* gch = GenCollectedHeap::heap();
   return !gch->is_in_young(p);
 WB_END
@@ -397,7 +402,8 @@
   return Universe::heap()->request_concurrent_phase(c_name);
 WB_END
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
+
 WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj))
   if (UseG1GC) {
     G1CollectedHeap* g1h = G1CollectedHeap::heap();
@@ -471,26 +477,29 @@
   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
 WB_END
 
+#endif // INCLUDE_G1GC
+
+#if INCLUDE_PARALLELGC
+
 WB_ENTRY(jlong, WB_PSVirtualSpaceAlignment(JNIEnv* env, jobject o))
-#if INCLUDE_ALL_GCS
   if (UseParallelGC) {
     return ParallelScavengeHeap::heap()->gens()->virtual_spaces()->alignment();
   }
-#endif // INCLUDE_ALL_GCS
   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_PSVirtualSpaceAlignment: Parallel GC is not enabled");
 WB_END
 
 WB_ENTRY(jlong, WB_PSHeapGenerationAlignment(JNIEnv* env, jobject o))
-#if INCLUDE_ALL_GCS
   if (UseParallelGC) {
     return ParallelScavengeHeap::heap()->generation_alignment();
   }
-#endif // INCLUDE_ALL_GCS
   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_PSHeapGenerationAlignment: Parallel GC is not enabled");
 WB_END
 
+#endif // INCLUDE_PARALLELGC
+
+#if INCLUDE_G1GC
+
 WB_ENTRY(jobject, WB_G1AuxiliaryMemoryUsage(JNIEnv* env))
-#if INCLUDE_ALL_GCS
   if (UseG1GC) {
     ResourceMark rm(THREAD);
     G1CollectedHeap* g1h = G1CollectedHeap::heap();
@@ -498,7 +507,6 @@
     Handle h = MemoryService::create_MemoryUsage_obj(usage, CHECK_NULL);
     return JNIHandles::make_local(env, h());
   }
-#endif // INCLUDE_ALL_GCS
   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1AuxiliaryMemoryUsage: G1 GC is not enabled");
 WB_END
 
@@ -561,7 +569,7 @@
   return (jlongArray) JNIHandles::make_local(env, result);
 WB_END
 
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
 #if INCLUDE_NMT
 // Alloc memory using the test memory type so that we can use that to see if
@@ -1218,12 +1226,12 @@
 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
   Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
   Universe::heap()->collect(GCCause::_wb_full_gc);
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   if (UseG1GC) {
     // Needs to be cleared explicitly for G1
     Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
   }
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 WB_END
 
 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
@@ -1960,7 +1968,7 @@
 #if INCLUDE_CDS
   {CC"getOffsetForName0", CC"(Ljava/lang/String;)I",  (void*)&WB_GetOffsetForName},
 #endif
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   {CC"g1InConcurrentMark", CC"()Z",                   (void*)&WB_G1InConcurrentMark},
   {CC"g1IsHumongous0",      CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous     },
   {CC"g1BelongsToHumongousRegion0", CC"(J)Z",         (void*)&WB_G1BelongsToHumongousRegion},
@@ -1971,10 +1979,12 @@
   {CC"g1StartConcMarkCycle",       CC"()Z",           (void*)&WB_G1StartMarkCycle  },
   {CC"g1AuxiliaryMemoryUsage", CC"()Ljava/lang/management/MemoryUsage;",
                                                       (void*)&WB_G1AuxiliaryMemoryUsage  },
+  {CC"g1GetMixedGCInfo",   CC"(I)[J",                 (void*)&WB_G1GetMixedGCInfo },
+#endif // INCLUDE_G1GC
+#if INCLUDE_PARALLELGC
   {CC"psVirtualSpaceAlignment",CC"()J",               (void*)&WB_PSVirtualSpaceAlignment},
   {CC"psHeapGenerationAlignment",CC"()J",             (void*)&WB_PSHeapGenerationAlignment},
-  {CC"g1GetMixedGCInfo",   CC"(I)[J",                 (void*)&WB_G1GetMixedGCInfo },
-#endif // INCLUDE_ALL_GCS
+#endif
 #if INCLUDE_NMT
   {CC"NMTMalloc",           CC"(J)J",                 (void*)&WB_NMTMalloc          },
   {CC"NMTMallocWithPseudoStack", CC"(JI)J",           (void*)&WB_NMTMallocWithPseudoStack},
--- a/src/hotspot/share/runtime/arguments.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/arguments.cpp	Fri May 04 08:50:01 2018 -0700
@@ -3317,7 +3317,7 @@
     FLAG_SET_ERGO(uintx, InitialTenuringThreshold, MaxTenuringThreshold);
   }
 
-#if !defined(COMPILER2) && !INCLUDE_JVMCI
+#if !COMPILER2_OR_JVMCI
   // Don't degrade server performance for footprint
   if (FLAG_IS_DEFAULT(UseLargePages) &&
       MaxHeapSize < LargePageHeapSizeThreshold) {
@@ -3333,7 +3333,7 @@
   }
 #endif
 
-#if !defined(COMPILER2) && !INCLUDE_JVMCI
+#if !COMPILER2_OR_JVMCI
   UNSUPPORTED_OPTION(ProfileInterpreter);
   NOT_PRODUCT(UNSUPPORTED_OPTION(TraceProfileInterpreter));
 #endif
--- a/src/hotspot/share/runtime/deoptimization.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/deoptimization.cpp	Fri May 04 08:50:01 2018 -0700
@@ -200,7 +200,7 @@
 #if COMPILER2_OR_JVMCI
   // Reallocate the non-escaping objects and restore their fields. Then
   // relock objects if synchronization on them was eliminated.
-#ifndef INCLUDE_JVMCI
+#if !INCLUDE_JVMCI
   if (DoEscapeAnalysis || EliminateNestedLocks) {
     if (EliminateAllocations) {
 #endif // INCLUDE_JVMCI
@@ -248,7 +248,7 @@
         // Restore result.
         deoptee.set_saved_oop_result(&map, return_value());
       }
-#ifndef INCLUDE_JVMCI
+#if !INCLUDE_JVMCI
     }
     if (EliminateLocks) {
 #endif // INCLUDE_JVMCI
@@ -283,7 +283,7 @@
 #endif // !PRODUCT
         }
       }
-#ifndef INCLUDE_JVMCI
+#if !INCLUDE_JVMCI
     }
   }
 #endif // INCLUDE_JVMCI
@@ -491,7 +491,7 @@
 
   assert(CodeCache::find_blob_unsafe(frame_pcs[0]) != NULL, "bad pc");
 
-#ifdef INCLUDE_JVMCI
+#if INCLUDE_JVMCI
   if (exceptionObject() != NULL) {
     thread->set_exception_oop(exceptionObject());
     exec_mode = Unpack_exception;
--- a/src/hotspot/share/runtime/flags/jvmFlagWriteableList.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/flags/jvmFlagWriteableList.cpp	Fri May 04 08:50:01 2018 -0700
@@ -23,7 +23,6 @@
  */
 
 #include "precompiled.hpp"
-#include "gc/shared/plab.hpp"
 #include "runtime/flags/jvmFlagWriteableList.hpp"
 #include "runtime/os.hpp"
 #ifdef COMPILER1
--- a/src/hotspot/share/runtime/init.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/init.cpp	Fri May 04 08:50:01 2018 -0700
@@ -46,7 +46,7 @@
 void mutex_init();
 void chunkpool_init();
 void perfMemory_init();
-void SuspendibleThreadSet_init() NOT_ALL_GCS_RETURN;
+void SuspendibleThreadSet_init();
 
 // Initialization done by Java thread in init_globals()
 void management_init();
@@ -62,7 +62,9 @@
 void gc_barrier_stubs_init();
 void interpreter_init();       // before any methods loaded
 void invocationCounter_init(); // before any methods loaded
+#if INCLUDE_SERIALGC
 void marksweep_init();
+#endif
 void accessFlags_init();
 void templateTable_init();
 void InterfaceSupport_init();
@@ -117,7 +119,7 @@
   gc_barrier_stubs_init();   // depends on universe_init, must be before interpreter_init
   interpreter_init();        // before any methods loaded
   invocationCounter_init();  // before any methods loaded
-  marksweep_init();
+  SERIALGC_ONLY(marksweep_init());
   accessFlags_init();
   templateTable_init();
   InterfaceSupport_init();
--- a/src/hotspot/share/runtime/java.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/java.cpp	Fri May 04 08:50:01 2018 -0700
@@ -74,10 +74,6 @@
 #include "utilities/histogram.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/vmError.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/cms/concurrentMarkSweepThread.hpp"
-#include "gc/parallel/psScavenge.hpp"
-#endif // INCLUDE_ALL_GCS
 #ifdef COMPILER1
 #include "c1/c1_Compiler.hpp"
 #include "c1/c1_Runtime1.hpp"
@@ -267,17 +263,17 @@
     IndexSet::print_statistics();
   }
 #endif // ASSERT
-#else
-#ifdef INCLUDE_JVMCI
+#else // COMPILER2
+#if INCLUDE_JVMCI
 #ifndef COMPILER1
   if ((TraceDeoptimization || LogVMOutput || LogCompilation) && UseCompiler) {
     FlagSetting fs(DisplayVMOutput, DisplayVMOutput && TraceDeoptimization);
     Deoptimization::print_statistics();
     SharedRuntime::print_statistics();
   }
-#endif
-#endif
-#endif
+#endif // COMPILER1
+#endif // INCLUDE_JVMCI
+#endif // COMPILER2
 
   if (PrintAOTStatistics) {
     AOTLoader::print_statistics();
--- a/src/hotspot/share/runtime/memprofiler.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/memprofiler.cpp	Fri May 04 08:50:01 2018 -0700
@@ -27,7 +27,6 @@
 #include "classfile/systemDictionary.hpp"
 #include "code/codeCache.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
-#include "gc/shared/generation.hpp"
 #include "interpreter/oopMapCache.hpp"
 #include "memory/resourceArea.hpp"
 #include "runtime/handles.inline.hpp"
--- a/src/hotspot/share/runtime/mutexLocker.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/mutexLocker.cpp	Fri May 04 08:50:01 2018 -0700
@@ -209,9 +209,7 @@
   }
   def(ParGCRareEvent_lock          , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_sometimes);
   def(DerivedPointerTableGC_lock   , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_never);
-#ifdef INCLUDE_ALL_GCS
   def(CGCPhaseManager_lock         , PaddedMonitor, leaf,        false, Monitor::_safepoint_check_sometimes);
-#endif
   def(CodeCache_lock               , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);
   def(RawMonitor_lock              , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);
   def(OopMapCacheAlloc_lock        , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for oop_map_cache allocation.
--- a/src/hotspot/share/runtime/os.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/os.cpp	Fri May 04 08:50:01 2018 -0700
@@ -251,6 +251,14 @@
   return (n != -1);
 }
 
+#if !defined(LINUX) && !defined(_WINDOWS)
+bool os::committed_in_range(address start, size_t size, address& committed_start, size_t& committed_size) {
+  committed_start = start;
+  committed_size = size;
+  return true;
+}
+#endif
+
 // Helper for dll_locate_lib.
 // Pass buffer and printbuffer as we already printed the path to buffer
 // when we called get_current_directory. This way we avoid another buffer
@@ -1243,6 +1251,33 @@
     return formatted_path;
 }
 
+// This function is a proxy to fopen, it tries to add a non standard flag ('e' or 'N')
+// that ensures automatic closing of the file on exec. If it can not find support in
+// the underlying c library, it will make an extra system call (fcntl) to ensure automatic
+// closing of the file on exec.
+FILE* os::fopen(const char* path, const char* mode) {
+  char modified_mode[20];
+  assert(strlen(mode) + 1 < sizeof(modified_mode), "mode chars plus one extra must fit in buffer");
+  sprintf(modified_mode, "%s" LINUX_ONLY("e") BSD_ONLY("e") WINDOWS_ONLY("N"), mode);
+  FILE* file = ::fopen(path, modified_mode);
+
+#if !(defined LINUX || defined BSD || defined _WINDOWS)
+  // assume fcntl FD_CLOEXEC support as a backup solution when 'e' or 'N'
+  // is not supported as mode in fopen
+  if (file != NULL) {
+    int fd = fileno(file);
+    if (fd != -1) {
+      int fd_flags = fcntl(fd, F_GETFD);
+      if (fd_flags != -1) {
+        fcntl(fd, F_SETFD, fd_flags | FD_CLOEXEC);
+      }
+    }
+  }
+#endif
+
+  return file;
+}
+
 bool os::set_boot_path(char fileSep, char pathSep) {
   const char* home = Arguments::get_java_home();
   int home_len = (int)strlen(home);
--- a/src/hotspot/share/runtime/os.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/os.hpp	Fri May 04 08:50:01 2018 -0700
@@ -273,6 +273,10 @@
   static void map_stack_shadow_pages(address sp);
   static bool stack_shadow_pages_available(Thread *thread, const methodHandle& method, address sp);
 
+  // Find committed memory region within specified range (start, start + size),
+  // return true if found any
+  static bool committed_in_range(address start, size_t size, address& committed_start, size_t& committed_size);
+
   // OS interface to Virtual Memory
 
   // Return the default page size.
@@ -547,6 +551,7 @@
   static const int default_file_open_flags();
   static int open(const char *path, int oflag, int mode);
   static FILE* open(int fd, const char* mode);
+  static FILE* fopen(const char* path, const char* mode);
   static int close(int fd);
   static jlong lseek(int fd, jlong offset, int whence);
   static char* native_path(char *path);
--- a/src/hotspot/share/runtime/reflection.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/reflection.cpp	Fri May 04 08:50:01 2018 -0700
@@ -32,6 +32,7 @@
 #include "classfile/verifier.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "interpreter/linkResolver.hpp"
+#include "logging/log.hpp"
 #include "memory/oopFactory.hpp"
 #include "memory/resourceArea.hpp"
 #include "memory/universe.hpp"
--- a/src/hotspot/share/runtime/sharedRuntime.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp	Fri May 04 08:50:01 2018 -0700
@@ -76,9 +76,9 @@
 #ifdef COMPILER1
 #include "c1/c1_Runtime1.hpp"
 #endif
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 #include "gc/g1/g1ThreadLocalData.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
 // Shared stub locations
 RuntimeStub*        SharedRuntime::_wrong_method_blob;
@@ -208,7 +208,7 @@
 }
 #endif // PRODUCT
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
 
 // G1 write-barrier pre: executed before a pointer store.
 JRT_LEAF(void, SharedRuntime::g1_wb_pre(oopDesc* orig, JavaThread *thread))
@@ -226,7 +226,7 @@
   G1ThreadLocalData::dirty_card_queue(thread).enqueue(card_addr);
 JRT_END
 
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
 
 JRT_LEAF(jlong, SharedRuntime::lmul(jlong y, jlong x))
--- a/src/hotspot/share/runtime/sharedRuntime.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/sharedRuntime.hpp	Fri May 04 08:50:01 2018 -0700
@@ -182,11 +182,11 @@
   static address raw_exception_handler_for_return_address(JavaThread* thread, address return_address);
   static address exception_handler_for_return_address(JavaThread* thread, address return_address);
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_G1GC
   // G1 write barriers
   static void g1_wb_pre(oopDesc* orig, JavaThread *thread);
   static void g1_wb_post(void* card_addr, JavaThread* thread);
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_G1GC
 
   // exception handling and implicit exceptions
   static address compute_compiled_exc_handler(CompiledMethod* nm, address ret_pc, Handle& exception,
--- a/src/hotspot/share/runtime/thread.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/thread.cpp	Fri May 04 08:50:01 2018 -0700
@@ -114,11 +114,9 @@
 #include "utilities/macros.hpp"
 #include "utilities/preserveException.hpp"
 #include "utilities/vmError.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/cms/concurrentMarkSweepThread.hpp"
-#include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
+#if INCLUDE_PARALLELGC
 #include "gc/parallel/pcTasks.hpp"
-#endif // INCLUDE_ALL_GCS
+#endif
 #if INCLUDE_JVMCI
 #include "jvmci/jvmciCompiler.hpp"
 #include "jvmci/jvmciRuntime.hpp"
@@ -243,7 +241,7 @@
   // This initial value ==> never claimed.
   _oops_do_parity = 0;
   _threads_hazard_ptr = NULL;
-  _nested_threads_hazard_ptr = NULL;
+  _threads_list_ptr = NULL;
   _nested_threads_hazard_ptr_cnt = 0;
   _rcu_counter = 0;
 
@@ -881,33 +879,11 @@
     st->print("tid=" INTPTR_FORMAT " ", p2i(this));
     osthread()->print_on(st);
   }
-  if (_threads_hazard_ptr != NULL) {
-    st->print("_threads_hazard_ptr=" INTPTR_FORMAT, p2i(_threads_hazard_ptr));
-  }
-  if (_nested_threads_hazard_ptr != NULL) {
-    print_nested_threads_hazard_ptrs_on(st);
-  }
+  ThreadsSMRSupport::print_info_on(this, st);
   st->print(" ");
   debug_only(if (WizardMode) print_owned_locks_on(st);)
 }
 
-void Thread::print_nested_threads_hazard_ptrs_on(outputStream* st) const {
-  assert(_nested_threads_hazard_ptr != NULL, "must be set to print");
-
-  if (EnableThreadSMRStatistics) {
-    st->print(", _nested_threads_hazard_ptr_cnt=%u", _nested_threads_hazard_ptr_cnt);
-  }
-  st->print(", _nested_threads_hazard_ptrs=");
-  for (NestedThreadsList* node = _nested_threads_hazard_ptr; node != NULL;
-       node = node->next()) {
-    if (node != _nested_threads_hazard_ptr) {
-      // First node does not need a comma-space separator.
-      st->print(", ");
-    }
-    st->print(INTPTR_FORMAT, p2i(node->t_list()));
-  }
-}
-
 // Thread::print_on_error() is called by fatal error handler. Don't use
 // any lock or allocate memory.
 void Thread::print_on_error(outputStream* st, char* buf, int buflen) const {
@@ -930,12 +906,7 @@
     st->print(" [id=%d]", osthread()->thread_id());
   }
 
-  if (_threads_hazard_ptr != NULL) {
-    st->print(" _threads_hazard_ptr=" INTPTR_FORMAT, p2i(_threads_hazard_ptr));
-  }
-  if (_nested_threads_hazard_ptr != NULL) {
-    print_nested_threads_hazard_ptrs_on(st);
-  }
+  ThreadsSMRSupport::print_info_on(this, st);
 }
 
 void Thread::print_value_on(outputStream* st) const {
@@ -2995,12 +2966,7 @@
             p2i(stack_end()), p2i(stack_base()));
   st->print("]");
 
-  if (_threads_hazard_ptr != NULL) {
-    st->print(" _threads_hazard_ptr=" INTPTR_FORMAT, p2i(_threads_hazard_ptr));
-  }
-  if (_nested_threads_hazard_ptr != NULL) {
-    print_nested_threads_hazard_ptrs_on(st);
-  }
+  ThreadsSMRSupport::print_info_on(this, st);
   return;
 }
 
@@ -4499,7 +4465,7 @@
   possibly_parallel_threads_do(is_par, &tc);
 }
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
 // Used by ParallelScavenge
 void Threads::create_thread_roots_tasks(GCTaskQueue* q) {
   ALL_JAVA_THREADS(p) {
@@ -4515,7 +4481,7 @@
   }
   q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread()));
 }
-#endif // INCLUDE_ALL_GCS
+#endif // INCLUDE_PARALLELGC
 
 void Threads::nmethods_do(CodeBlobClosure* cf) {
   ALL_JAVA_THREADS(p) {
--- a/src/hotspot/share/runtime/thread.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/thread.hpp	Fri May 04 08:50:01 2018 -0700
@@ -32,6 +32,7 @@
 #include "oops/oop.hpp"
 #include "prims/jvmtiExport.hpp"
 #include "runtime/frame.hpp"
+#include "runtime/globals.hpp"
 #include "runtime/handshake.hpp"
 #include "runtime/javaFrameAnchor.hpp"
 #include "runtime/jniHandles.hpp"
@@ -52,10 +53,10 @@
 # include "stack_zero.hpp"
 #endif
 
+class SafeThreadsListPtr;
 class ThreadSafepointState;
 class ThreadsList;
 class ThreadsSMRSupport;
-class NestedThreadsList;
 
 class JvmtiThreadState;
 class JvmtiGetLoadedClassesClosure;
@@ -135,13 +136,14 @@
   void*       _real_malloc_address;
 
   // JavaThread lifecycle support:
+  friend class SafeThreadsListPtr;  // for _threads_list_ptr, cmpxchg_threads_hazard_ptr(), {dec_,inc_,}nested_threads_hazard_ptr_cnt(), {g,s}et_threads_hazard_ptr(), inc_nested_handle_cnt(), tag_hazard_ptr() access
   friend class ScanHazardPtrGatherProtectedThreadsClosure;  // for cmpxchg_threads_hazard_ptr(), get_threads_hazard_ptr(), is_hazard_ptr_tagged() access
-  friend class ScanHazardPtrGatherThreadsListClosure;  // for get_nested_threads_hazard_ptr(), get_threads_hazard_ptr(), untag_hazard_ptr() access
+  friend class ScanHazardPtrGatherThreadsListClosure;  // for get_threads_hazard_ptr(), untag_hazard_ptr() access
   friend class ScanHazardPtrPrintMatchingThreadsClosure;  // for get_threads_hazard_ptr(), is_hazard_ptr_tagged() access
-  friend class ThreadsListSetter;  // for get_threads_hazard_ptr() access
-  friend class ThreadsSMRSupport;  // for get_threads_hazard_ptr() access
+  friend class ThreadsSMRSupport;  // for _nested_threads_hazard_ptr_cnt, _threads_hazard_ptr, _threads_list_ptr access
 
   ThreadsList* volatile _threads_hazard_ptr;
+  SafeThreadsListPtr*   _threads_list_ptr;
   ThreadsList*          cmpxchg_threads_hazard_ptr(ThreadsList* exchange_value, ThreadsList* compare_value);
   ThreadsList*          get_threads_hazard_ptr();
   void                  set_threads_hazard_ptr(ThreadsList* new_list);
@@ -154,15 +156,6 @@
   static ThreadsList*   untag_hazard_ptr(ThreadsList* list) {
     return (ThreadsList*)(intptr_t(list) & ~intptr_t(1));
   }
-  NestedThreadsList* _nested_threads_hazard_ptr;
-  NestedThreadsList* get_nested_threads_hazard_ptr() {
-    return _nested_threads_hazard_ptr;
-  }
-  void set_nested_threads_hazard_ptr(NestedThreadsList* value) {
-    assert(Threads_lock->owned_by_self(),
-           "must own Threads_lock for _nested_threads_hazard_ptr to be valid.");
-    _nested_threads_hazard_ptr = value;
-  }
   // This field is enabled via -XX:+EnableThreadSMRStatistics:
   uint _nested_threads_hazard_ptr_cnt;
   void dec_nested_threads_hazard_ptr_cnt() {
@@ -640,7 +633,6 @@
 
   // Printing
   virtual void print_on(outputStream* st) const;
-  virtual void print_nested_threads_hazard_ptrs_on(outputStream* st) const;
   void print() const { print_on(tty); }
   virtual void print_on_error(outputStream* st, char* buf, int buflen) const;
   void print_value_on(outputStream* st) const;
--- a/src/hotspot/share/runtime/thread.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/thread.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -26,6 +26,7 @@
 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP
 
 #include "runtime/atomic.hpp"
+#include "runtime/globals.hpp"
 #include "runtime/orderAccess.inline.hpp"
 #include "runtime/os.inline.hpp"
 #include "runtime/thread.hpp"
--- a/src/hotspot/share/runtime/threadSMR.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/threadSMR.cpp	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * 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,7 @@
 #include "services/threadService.hpp"
 #include "utilities/copy.hpp"
 #include "utilities/globalDefinitions.hpp"
+#include "utilities/ostream.hpp"
 #include "utilities/resourceHash.hpp"
 #include "utilities/vmError.hpp"
 
@@ -252,8 +253,6 @@
       current_list = thread->get_threads_hazard_ptr();
       // No hazard ptr so nothing more to do.
       if (current_list == NULL) {
-        assert(thread->get_nested_threads_hazard_ptr() == NULL,
-               "cannot have a nested hazard ptr with a NULL regular hazard ptr");
         return;
       }
 
@@ -278,13 +277,6 @@
     // ThreadsList.
     AddThreadHazardPointerThreadClosure add_cl(_table);
     current_list->threads_do(&add_cl);
-
-    // Any NestedThreadsLists are also protecting JavaThreads so
-    // gather those also; the ThreadsLists may be different.
-    for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr();
-         node != NULL; node = node->next()) {
-      node->t_list()->threads_do(&add_cl);
-    }
   }
 };
 
@@ -302,8 +294,6 @@
     if (thread == NULL) return;
     ThreadsList *threads = thread->get_threads_hazard_ptr();
     if (threads == NULL) {
-      assert(thread->get_nested_threads_hazard_ptr() == NULL,
-             "cannot have a nested hazard ptr with a NULL regular hazard ptr");
       return;
     }
     // In this closure we always ignore the tag that might mark this
@@ -315,16 +305,6 @@
     if (!_table->has_entry((void*)threads)) {
       _table->add_entry((void*)threads);
     }
-
-    // Any NestedThreadsLists are also protecting JavaThreads so
-    // gather those also; the ThreadsLists may be different.
-    for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr();
-         node != NULL; node = node->next()) {
-      threads = node->t_list();
-      if (!_table->has_entry((void*)threads)) {
-        _table->add_entry((void*)threads);
-      }
-    }
   }
 };
 
@@ -343,8 +323,6 @@
     if (thread == NULL) return;
     ThreadsList *current_list = thread->get_threads_hazard_ptr();
     if (current_list == NULL) {
-      assert(thread->get_nested_threads_hazard_ptr() == NULL,
-             "cannot have a nested hazard ptr with a NULL regular hazard ptr");
       return;
     }
     // If the hazard ptr is unverified, then ignore it.
@@ -362,25 +340,218 @@
         break;
       }
     }
+  }
+};
 
-    // Any NestedThreadsLists are also protecting JavaThreads so
-    // check those also; the ThreadsLists may be different.
-    for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr();
-         node != NULL; node = node->next()) {
-      JavaThreadIterator jti(node->t_list());
-      for (JavaThread *p = jti.first(); p != NULL; p = jti.next()) {
-        if (p == _thread) {
-          log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread1=" INTPTR_FORMAT " has a nested hazard pointer for thread2=" INTPTR_FORMAT, os::current_thread_id(), p2i(thread), p2i(_thread));
-          return;
-        }
-      }
+// Closure to determine if the specified JavaThread is found by
+// threads_do().
+//
+class VerifyHazardPtrThreadClosure : public ThreadClosure {
+ private:
+  bool _found;
+  Thread *_self;
+
+ public:
+  VerifyHazardPtrThreadClosure(Thread *self) : _found(false), _self(self) {}
+
+  bool found() const { return _found; }
+
+  virtual void do_thread(Thread *thread) {
+    if (thread == _self) {
+      _found = true;
     }
   }
 };
 
 
+// Acquire a stable ThreadsList.
+//
+void SafeThreadsListPtr::acquire_stable_list() {
+  assert(_thread != NULL, "sanity check");
+  _needs_release = true;
+  _previous = _thread->_threads_list_ptr;
+  _thread->_threads_list_ptr = this;
+
+  if (_thread->get_threads_hazard_ptr() == NULL) {
+    // The typical case is first.
+    acquire_stable_list_fast_path();
+    return;
+  }
+
+  // The nested case is rare.
+  acquire_stable_list_nested_path();
+}
+
+// Fast path way to acquire a stable ThreadsList.
+//
+void SafeThreadsListPtr::acquire_stable_list_fast_path() {
+  assert(_thread != NULL, "sanity check");
+  assert(_thread->get_threads_hazard_ptr() == NULL, "sanity check");
+
+  ThreadsList* threads;
+
+  // Stable recording of a hazard ptr for SMR. This code does not use
+  // locks so its use of the _smr_java_thread_list & _threads_hazard_ptr
+  // fields is racy relative to code that uses those fields with locks.
+  // OrderAccess and Atomic functions are used to deal with those races.
+  //
+  while (true) {
+    threads = ThreadsSMRSupport::get_java_thread_list();
+
+    // Publish a tagged hazard ptr to denote that the hazard ptr is not
+    // yet verified as being stable. Due to the fence after the hazard
+    // ptr write, it will be sequentially consistent w.r.t. the
+    // sequentially consistent writes of the ThreadsList, even on
+    // non-multiple copy atomic machines where stores can be observed
+    // in different order from different observer threads.
+    ThreadsList* unverified_threads = Thread::tag_hazard_ptr(threads);
+    _thread->set_threads_hazard_ptr(unverified_threads);
+
+    // If _smr_java_thread_list has changed, we have lost a race with
+    // Threads::add() or Threads::remove() and have to try again.
+    if (ThreadsSMRSupport::get_java_thread_list() != threads) {
+      continue;
+    }
+
+    // We try to remove the tag which will verify the hazard ptr as
+    // being stable. This exchange can race with a scanning thread
+    // which might invalidate the tagged hazard ptr to keep it from
+    // being followed to access JavaThread ptrs. If we lose the race,
+    // we simply retry. If we win the race, then the stable hazard
+    // ptr is officially published.
+    if (_thread->cmpxchg_threads_hazard_ptr(threads, unverified_threads) == unverified_threads) {
+      break;
+    }
+  }
+
+  // A stable hazard ptr has been published letting other threads know
+  // that the ThreadsList and the JavaThreads reachable from this list
+  // are protected and hence they should not be deleted until everyone
+  // agrees it is safe to do so.
+
+  _list = threads;
+
+  verify_hazard_ptr_scanned();
+}
+
+// Acquire a nested stable ThreadsList; this is rare so it uses
+// reference counting.
+//
+void SafeThreadsListPtr::acquire_stable_list_nested_path() {
+  assert(_thread != NULL, "sanity check");
+  assert(_thread->get_threads_hazard_ptr() != NULL,
+         "cannot have a NULL regular hazard ptr when acquiring a nested hazard ptr");
+
+  // The thread already has a hazard ptr (ThreadsList ref) so we need
+  // to create a nested ThreadsListHandle with the current ThreadsList
+  // since it might be different than our current hazard ptr. To remedy
+  // the situation, the ThreadsList pointed to by the pre-existing
+  // stable hazard ptr is reference counted before the hazard ptr may
+  // be released and moved to a new ThreadsList. The old ThreadsList
+  // is remembered in the ThreadsListHandle.
+
+  ThreadsList* current_list = _previous->_list;
+  if (EnableThreadSMRStatistics) {
+    _thread->inc_nested_threads_hazard_ptr_cnt();
+  }
+  current_list->inc_nested_handle_cnt();
+  _previous->_has_ref_count = true;  // promote SafeThreadsListPtr to be reference counted
+  _thread->_threads_hazard_ptr = NULL;  // clear the hazard ptr so we can go through the fast path below
+
+  if (EnableThreadSMRStatistics && _thread->nested_threads_hazard_ptr_cnt() > ThreadsSMRSupport::_nested_thread_list_max) {
+    ThreadsSMRSupport::_nested_thread_list_max = _thread->nested_threads_hazard_ptr_cnt();
+  }
+
+  acquire_stable_list_fast_path();
+
+  verify_hazard_ptr_scanned();
+
+  log_debug(thread, smr)("tid=" UINTX_FORMAT ": SafeThreadsListPtr::acquire_stable_list: add nested list pointer to ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(_list));
+}
+
+// Release a stable ThreadsList.
+//
+void SafeThreadsListPtr::release_stable_list() {
+  assert(_thread != NULL, "sanity check");
+  assert(_thread->_threads_list_ptr == this, "sanity check");
+  _thread->_threads_list_ptr = _previous;
+
+  if (_has_ref_count) {
+    // If a SafeThreadsListPtr has been promoted to use reference counting
+    // due to nesting of ThreadsListHandles, then the reference count must be
+    // decremented, at which point it may be freed. The forgotten value of
+    // the list no longer matters at this point and should already be NULL.
+    assert(_thread->get_threads_hazard_ptr() == NULL, "sanity check");
+    if (EnableThreadSMRStatistics) {
+      _thread->dec_nested_threads_hazard_ptr_cnt();
+    }
+    _list->dec_nested_handle_cnt();
+
+    log_debug(thread, smr)("tid=" UINTX_FORMAT ": SafeThreadsListPtr::release_stable_list: delete nested list pointer to ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(_list));
+  } else {
+    // The normal case: a leaf ThreadsListHandle. This merely requires setting
+    // the thread hazard ptr back to NULL.
+    assert(_thread->get_threads_hazard_ptr() != NULL, "sanity check");
+    _thread->set_threads_hazard_ptr(NULL);
+  }
+
+  // After releasing the hazard ptr, other threads may go ahead and
+  // free up some memory temporarily used by a ThreadsList snapshot.
+
+  // We use double-check locking to reduce traffic on the system
+  // wide Thread-SMR delete_lock.
+  if (ThreadsSMRSupport::delete_notify()) {
+    // An exiting thread might be waiting in smr_delete(); we need to
+    // check with delete_lock to be sure.
+    ThreadsSMRSupport::release_stable_list_wake_up(_has_ref_count);
+  }
+}
+
+// Verify that the stable hazard ptr used to safely keep threads
+// alive is scanned by threads_do() which is a key piece of honoring
+// the Thread-SMR protocol.
+void SafeThreadsListPtr::verify_hazard_ptr_scanned() {
+#ifdef ASSERT
+  assert(_list != NULL, "_list must not be NULL");
+
+  // The closure will attempt to verify that the calling thread can
+  // be found by threads_do() on the specified ThreadsList. If it
+  // is successful, then the specified ThreadsList was acquired as
+  // a stable hazard ptr by the calling thread in a way that honored
+  // the Thread-SMR protocol.
+  //
+  // If the calling thread cannot be found by threads_do() and if
+  // it is not the shutdown thread, then the calling thread is not
+  // honoring the Thread-SMR ptotocol. This means that the specified
+  // ThreadsList is not a stable hazard ptr and can be freed by
+  // another thread from the to-be-deleted list at any time.
+  //
+  // Note: The shutdown thread has removed itself from the Threads
+  // list and is safe to have a waiver from this check because
+  // VM_Exit::_shutdown_thread is not set until after the VMThread
+  // has started the final safepoint which holds the Threads_lock
+  // for the remainder of the VM's life.
+  //
+  VerifyHazardPtrThreadClosure cl(_thread);
+  ThreadsSMRSupport::threads_do(&cl, _list);
+
+  // If the calling thread is not honoring the Thread-SMR protocol,
+  // then we will either crash in threads_do() above because 'threads'
+  // was freed by another thread or we will fail the assert() below.
+  // In either case, we won't get past this point with a badly placed
+  // ThreadsListHandle.
+
+  assert(cl.found() || _thread == VM_Exit::shutdown_thread(), "Acquired a ThreadsList snapshot from a thread not recognized by the Thread-SMR protocol.");
+#endif
+}
+
 // 'entries + 1' so we always have at least one entry.
-ThreadsList::ThreadsList(int entries) : _length(entries), _threads(NEW_C_HEAP_ARRAY(JavaThread*, entries + 1, mtThread)), _next_list(NULL) {
+ThreadsList::ThreadsList(int entries) :
+  _length(entries),
+  _next_list(NULL),
+  _threads(NEW_C_HEAP_ARRAY(JavaThread*, entries + 1, mtThread)),
+  _nested_handle_cnt(0)
+{
   *(JavaThread**)(_threads + entries) = NULL;  // Make sure the extra entry is NULL.
 }
 
@@ -405,6 +576,15 @@
   return new_list;
 }
 
+void ThreadsList::dec_nested_handle_cnt() {
+  // The decrement needs to be MO_ACQ_REL. At the moment, the Atomic::dec
+  // backend on PPC does not yet conform to these requirements. Therefore
+  // the decrement is simulated with an Atomic::sub(1, &addr).
+  // Without this MO_ACQ_REL Atomic::dec simulation, the nested SMR mechanism
+  // is not generally safe to use.
+  Atomic::sub(1, &_nested_handle_cnt);
+}
+
 int ThreadsList::find_index_of_JavaThread(JavaThread *target) {
   if (target == NULL) {
     return -1;
@@ -432,6 +612,22 @@
   return NULL;
 }
 
+void ThreadsList::inc_nested_handle_cnt() {
+  // The increment needs to be MO_SEQ_CST. At the moment, the Atomic::inc
+  // backend on PPC does not yet conform to these requirements. Therefore
+  // the increment is simulated with a load phi; cas phi + 1; loop.
+  // Without this MO_SEQ_CST Atomic::inc simulation, the nested SMR mechanism
+  // is not generally safe to use.
+  intx sample = OrderAccess::load_acquire(&_nested_handle_cnt);
+  for (;;) {
+    if (Atomic::cmpxchg(sample + 1, &_nested_handle_cnt, sample) == sample) {
+      return;
+    } else {
+      sample = OrderAccess::load_acquire(&_nested_handle_cnt);
+    }
+  }
+}
+
 bool ThreadsList::includes(const JavaThread * const p) const {
   if (p == NULL) {
     return false;
@@ -468,7 +664,7 @@
   return new_list;
 }
 
-ThreadsListHandle::ThreadsListHandle(Thread *self) : _list(ThreadsSMRSupport::acquire_stable_list(self, /* is_ThreadsListSetter */ false)), _self(self) {
+ThreadsListHandle::ThreadsListHandle(Thread *self) : _list_ptr(self, /* acquire */ true) {
   assert(self == Thread::current(), "sanity check");
   if (EnableThreadSMRStatistics) {
     _timer.start();
@@ -476,7 +672,6 @@
 }
 
 ThreadsListHandle::~ThreadsListHandle() {
-  ThreadsSMRSupport::release_stable_list(_self);
   if (EnableThreadSMRStatistics) {
     _timer.stop();
     uint millis = (uint)_timer.milliseconds();
@@ -536,210 +731,17 @@
   return true;
 }
 
-ThreadsListSetter::~ThreadsListSetter() {
-  if (_target_needs_release) {
-    // The hazard ptr in the target needs to be released.
-    ThreadsSMRSupport::release_stable_list(_target);
-  }
-}
-
-// Closure to determine if the specified JavaThread is found by
-// threads_do().
-//
-class VerifyHazardPointerThreadClosure : public ThreadClosure {
- private:
-  bool _found;
-  Thread *_self;
-
- public:
-  VerifyHazardPointerThreadClosure(Thread *self) : _found(false), _self(self) {}
-
-  bool found() const { return _found; }
-
-  virtual void do_thread(Thread *thread) {
-    if (thread == _self) {
-      _found = true;
-    }
-  }
-};
-
-// Apply the closure to all threads in the system, with a snapshot of
-// all JavaThreads provided by the list parameter.
-void ThreadsSMRSupport::threads_do(ThreadClosure *tc, ThreadsList *list) {
-  list->threads_do(tc);
-  Threads::non_java_threads_do(tc);
-}
-
-// Apply the closure to all threads in the system.
-void ThreadsSMRSupport::threads_do(ThreadClosure *tc) {
-  threads_do(tc, _java_thread_list);
-}
-
-// Verify that the stable hazard pointer used to safely keep threads
-// alive is scanned by threads_do() which is a key piece of honoring
-// the Thread-SMR protocol.
-void ThreadsSMRSupport::verify_hazard_pointer_scanned(Thread *self, ThreadsList *threads) {
-#ifdef ASSERT
-  assert(threads != NULL, "threads must not be NULL");
-
-  // The closure will attempt to verify that the calling thread can
-  // be found by threads_do() on the specified ThreadsList. If it
-  // is successful, then the specified ThreadsList was acquired as
-  // a stable hazard pointer by the calling thread in a way that
-  // honored the Thread-SMR protocol.
-  //
-  // If the calling thread cannot be found by threads_do() and if
-  // it is not the shutdown thread, then the calling thread is not
-  // honoring the Thread-SMR ptotocol. This means that the specified
-  // ThreadsList is not a stable hazard pointer and can be freed
-  // by another thread from the to-be-deleted list at any time.
-  //
-  // Note: The shutdown thread has removed itself from the Threads
-  // list and is safe to have a waiver from this check because
-  // VM_Exit::_shutdown_thread is not set until after the VMThread
-  // has started the final safepoint which holds the Threads_lock
-  // for the remainder of the VM's life.
-  //
-  VerifyHazardPointerThreadClosure cl(self);
-  threads_do(&cl, threads);
-
-  // If the calling thread is not honoring the Thread-SMR protocol,
-  // then we will either crash in threads_do() above because 'threads'
-  // was freed by another thread or we will fail the assert() below.
-  // In either case, we won't get past this point with a badly placed
-  // ThreadsListHandle.
-
-  assert(cl.found() || self == VM_Exit::shutdown_thread(), "Acquired a ThreadsList snapshot from a thread not recognized by the Thread-SMR protocol.");
-#endif
-}
-
-void ThreadsListSetter::set() {
-  assert(_target->get_threads_hazard_ptr() == NULL, "hazard ptr should not already be set");
-  (void) ThreadsSMRSupport::acquire_stable_list(_target, /* is_ThreadsListSetter */ true);
-  _target_needs_release = true;
-}
-
-// Acquire a stable ThreadsList.
-//
-ThreadsList *ThreadsSMRSupport::acquire_stable_list(Thread *self, bool is_ThreadsListSetter) {
-  assert(self != NULL, "sanity check");
-  // acquire_stable_list_nested_path() will grab the Threads_lock
-  // so let's make sure the ThreadsListHandle is in a safe place.
-  // ThreadsListSetter cannot make this check on this code path.
-  debug_only(if (!is_ThreadsListSetter && StrictSafepointChecks) self->check_for_valid_safepoint_state(/* potential_vm_operation */ false);)
-
-  if (self->get_threads_hazard_ptr() == NULL) {
-    // The typical case is first.
-    return acquire_stable_list_fast_path(self);
-  }
-
-  // The nested case is rare.
-  return acquire_stable_list_nested_path(self);
-}
-
-// Fast path (and lock free) way to acquire a stable ThreadsList.
-//
-ThreadsList *ThreadsSMRSupport::acquire_stable_list_fast_path(Thread *self) {
-  assert(self != NULL, "sanity check");
-  assert(self->get_threads_hazard_ptr() == NULL, "sanity check");
-  assert(self->get_nested_threads_hazard_ptr() == NULL,
-         "cannot have a nested hazard ptr with a NULL regular hazard ptr");
-
-  ThreadsList* threads;
-
-  // Stable recording of a hazard ptr for SMR. This code does not use
-  // locks so its use of the _java_thread_list & _threads_hazard_ptr
-  // fields is racy relative to code that uses those fields with locks.
-  // OrderAccess and Atomic functions are used to deal with those races.
-  //
-  while (true) {
-    threads = get_java_thread_list();
-
-    // Publish a tagged hazard ptr to denote that the hazard ptr is not
-    // yet verified as being stable. Due to the fence after the hazard
-    // ptr write, it will be sequentially consistent w.r.t. the
-    // sequentially consistent writes of the ThreadsList, even on
-    // non-multiple copy atomic machines where stores can be observed
-    // in different order from different observer threads.
-    ThreadsList* unverified_threads = Thread::tag_hazard_ptr(threads);
-    self->set_threads_hazard_ptr(unverified_threads);
-
-    // If _java_thread_list has changed, we have lost a race with
-    // Threads::add() or Threads::remove() and have to try again.
-    if (get_java_thread_list() != threads) {
-      continue;
-    }
-
-    // We try to remove the tag which will verify the hazard ptr as
-    // being stable. This exchange can race with a scanning thread
-    // which might invalidate the tagged hazard ptr to keep it from
-    // being followed to access JavaThread ptrs. If we lose the race,
-    // we simply retry. If we win the race, then the stable hazard
-    // ptr is officially published.
-    if (self->cmpxchg_threads_hazard_ptr(threads, unverified_threads) == unverified_threads) {
-      break;
-    }
-  }
-
-  // A stable hazard ptr has been published letting other threads know
-  // that the ThreadsList and the JavaThreads reachable from this list
-  // are protected and hence they should not be deleted until everyone
-  // agrees it is safe to do so.
-
-  verify_hazard_pointer_scanned(self, threads);
-
-  return threads;
-}
-
-// Acquire a nested stable ThreadsList; this is rare so it uses
-// Threads_lock.
-//
-ThreadsList *ThreadsSMRSupport::acquire_stable_list_nested_path(Thread *self) {
-  assert(self != NULL, "sanity check");
-  assert(self->get_threads_hazard_ptr() != NULL,
-         "cannot have a NULL regular hazard ptr when acquiring a nested hazard ptr");
-
-  // The thread already has a hazard ptr (ThreadsList ref) so we need
-  // to create a nested ThreadsListHandle with the current ThreadsList
-  // since it might be different than our current hazard ptr. The need
-  // for a nested ThreadsListHandle is rare so we do this while holding
-  // the Threads_lock so we don't race with the scanning code; the code
-  // is so much simpler this way.
-
-  NestedThreadsList* node;
-  {
-    // Only grab the Threads_lock if we don't already own it.
-    MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
-    node = new NestedThreadsList(get_java_thread_list());
-    // We insert at the front of the list to match up with the delete
-    // in release_stable_list().
-    node->set_next(self->get_nested_threads_hazard_ptr());
-    self->set_nested_threads_hazard_ptr(node);
-    if (EnableThreadSMRStatistics) {
-      self->inc_nested_threads_hazard_ptr_cnt();
-      if (self->nested_threads_hazard_ptr_cnt() > _nested_thread_list_max) {
-        _nested_thread_list_max = self->nested_threads_hazard_ptr_cnt();
-      }
-    }
-  }
-  log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::acquire_stable_list: add NestedThreadsList node containing ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(node->t_list()));
-
-  verify_hazard_pointer_scanned(self, node->t_list());
-
-  return node->t_list();
-}
-
 void ThreadsSMRSupport::add_thread(JavaThread *thread){
-  ThreadsList *new_list = ThreadsList::add_thread(ThreadsSMRSupport::get_java_thread_list(), thread);
+  ThreadsList *new_list = ThreadsList::add_thread(get_java_thread_list(), thread);
   if (EnableThreadSMRStatistics) {
-    ThreadsSMRSupport::inc_java_thread_list_alloc_cnt();
-    ThreadsSMRSupport::update_java_thread_list_max(new_list->length());
+    inc_java_thread_list_alloc_cnt();
+    update_java_thread_list_max(new_list->length());
   }
   // Initial _java_thread_list will not generate a "Threads::add" mesg.
   log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::add: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list));
 
-  ThreadsList *old_list = ThreadsSMRSupport::xchg_java_thread_list(new_list);
-  ThreadsSMRSupport::free_list(old_list);
+  ThreadsList *old_list = xchg_java_thread_list(new_list);
+  free_list(old_list);
 }
 
 // set_delete_notify() and clear_delete_notify() are called
@@ -787,6 +789,8 @@
   ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size);
   ScanHazardPtrGatherThreadsListClosure scan_cl(scan_table);
   threads_do(&scan_cl);
+  OrderAccess::acquire(); // Must order reads of hazard ptr before reads of
+                          // nested reference counters
 
   // Walk through the linked list of pending freeable ThreadsLists
   // and free the ones that are not referenced from hazard ptrs.
@@ -796,7 +800,7 @@
   bool threads_is_freed = false;
   while (current != NULL) {
     next = current->next_list();
-    if (!scan_table->has_entry((void*)current)) {
+    if (!scan_table->has_entry((void*)current) && current->_nested_handle_cnt == 0) {
       // This ThreadsList is not referenced by a hazard ptr.
       if (prev != NULL) {
         prev->set_next_list(next);
@@ -849,6 +853,22 @@
   ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size);
   ScanHazardPtrGatherProtectedThreadsClosure scan_cl(scan_table);
   threads_do(&scan_cl);
+  OrderAccess::acquire(); // Must order reads of hazard ptr before reads of
+                          // nested reference counters
+
+  // Walk through the linked list of pending freeable ThreadsLists
+  // and include the ones that are currently in use by a nested
+  // ThreadsListHandle in the search set.
+  ThreadsList* current = _to_delete_list;
+  while (current != NULL) {
+    if (current->_nested_handle_cnt != 0) {
+      // 'current' is in use by a nested ThreadsListHandle so the hazard
+      // ptr is protecting all the JavaThreads on that ThreadsList.
+      AddThreadHazardPointerThreadClosure add_cl(scan_table);
+      current->threads_do(&add_cl);
+    }
+    current = current->next_list();
+  }
 
   bool thread_is_protected = false;
   if (scan_table->has_entry((void*)thread)) {
@@ -858,87 +878,11 @@
   return thread_is_protected;
 }
 
-// Release a stable ThreadsList.
-//
-void ThreadsSMRSupport::release_stable_list(Thread *self) {
-  assert(self != NULL, "sanity check");
-  // release_stable_list_nested_path() will grab the Threads_lock
-  // so let's make sure the ThreadsListHandle is in a safe place.
-  debug_only(if (StrictSafepointChecks) self->check_for_valid_safepoint_state(/* potential_vm_operation */ false);)
-
-  if (self->get_nested_threads_hazard_ptr() == NULL) {
-    // The typical case is first.
-    release_stable_list_fast_path(self);
-    return;
-  }
-
-  // The nested case is rare.
-  release_stable_list_nested_path(self);
-}
-
-// Fast path way to release a stable ThreadsList. The release portion
-// is lock-free, but the wake up portion is not.
-//
-void ThreadsSMRSupport::release_stable_list_fast_path(Thread *self) {
-  assert(self != NULL, "sanity check");
-  assert(self->get_threads_hazard_ptr() != NULL, "sanity check");
-  assert(self->get_nested_threads_hazard_ptr() == NULL,
-         "cannot have a nested hazard ptr when releasing a regular hazard ptr");
-
-  // After releasing the hazard ptr, other threads may go ahead and
-  // free up some memory temporarily used by a ThreadsList snapshot.
-  self->set_threads_hazard_ptr(NULL);
-
-  // We use double-check locking to reduce traffic on the system
-  // wide Thread-SMR delete_lock.
-  if (ThreadsSMRSupport::delete_notify()) {
-    // An exiting thread might be waiting in smr_delete(); we need to
-    // check with delete_lock to be sure.
-    release_stable_list_wake_up((char *) "regular hazard ptr");
-  }
-}
-
-// Release a nested stable ThreadsList; this is rare so it uses
-// Threads_lock.
-//
-void ThreadsSMRSupport::release_stable_list_nested_path(Thread *self) {
-  assert(self != NULL, "sanity check");
-  assert(self->get_nested_threads_hazard_ptr() != NULL, "sanity check");
-  assert(self->get_threads_hazard_ptr() != NULL,
-         "must have a regular hazard ptr to have nested hazard ptrs");
-
-  // We have a nested ThreadsListHandle so we have to release it first.
-  // The need for a nested ThreadsListHandle is rare so we do this while
-  // holding the Threads_lock so we don't race with the scanning code;
-  // the code is so much simpler this way.
-
-  NestedThreadsList *node;
-  {
-    // Only grab the Threads_lock if we don't already own it.
-    MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
-    // We remove from the front of the list to match up with the insert
-    // in acquire_stable_list().
-    node = self->get_nested_threads_hazard_ptr();
-    self->set_nested_threads_hazard_ptr(node->next());
-    if (EnableThreadSMRStatistics) {
-      self->dec_nested_threads_hazard_ptr_cnt();
-    }
-  }
-
-  // An exiting thread might be waiting in smr_delete(); we need to
-  // check with delete_lock to be sure.
-  release_stable_list_wake_up((char *) "nested hazard ptr");
-
-  log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::release_stable_list: delete NestedThreadsList node containing ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(node->t_list()));
-
-  delete node;
-}
-
 // Wake up portion of the release stable ThreadsList protocol;
 // uses the delete_lock().
 //
-void ThreadsSMRSupport::release_stable_list_wake_up(char *log_str) {
-  assert(log_str != NULL, "sanity check");
+void ThreadsSMRSupport::release_stable_list_wake_up(bool is_nested) {
+  const char* log_str = is_nested ? "nested hazard ptr" : "regular hazard ptr";
 
   // Note: delete_lock is held in smr_delete() for the entire
   // hazard ptr search so that we do not lose this notify() if
@@ -1014,6 +958,13 @@
         if (log_is_enabled(Debug, os, thread)) {
           ScanHazardPtrPrintMatchingThreadsClosure scan_cl(thread);
           threads_do(&scan_cl);
+          ThreadsList* current = _to_delete_list;
+          while (current != NULL) {
+            if (current->_nested_handle_cnt != 0 && current->includes(thread)) {
+              log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: found nested hazard pointer to thread=" INTPTR_FORMAT, os::current_thread_id(), p2i(thread));
+            }
+            current = current->next_list();
+          }
         }
       }
     } // We have to drop the Threads_lock to wait or delete the thread
@@ -1055,9 +1006,32 @@
   log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread=" INTPTR_FORMAT " is deleted.", os::current_thread_id(), p2i(thread));
 }
 
+// Apply the closure to all threads in the system, with a snapshot of
+// all JavaThreads provided by the list parameter.
+void ThreadsSMRSupport::threads_do(ThreadClosure *tc, ThreadsList *list) {
+  list->threads_do(tc);
+  Threads::non_java_threads_do(tc);
+}
+
+// Apply the closure to all threads in the system.
+void ThreadsSMRSupport::threads_do(ThreadClosure *tc) {
+  threads_do(tc, _java_thread_list);
+}
+
 
 // Debug, logging, and printing stuff at the end:
 
+// Print SMR info for a SafeThreadsListPtr to a given output stream.
+void SafeThreadsListPtr::print_on(outputStream* st) {
+  if (this == _thread->_threads_list_ptr) {
+    // The top level hazard ptr.
+    st->print(" _threads_hazard_ptr=" INTPTR_FORMAT, p2i(_list));
+  } else {
+    // Nested hazard ptrs.
+    st->print(", _nested_threads_hazard_ptr=" INTPTR_FORMAT, p2i(_list));
+  }
+}
+
 // Log Threads class SMR info.
 void ThreadsSMRSupport::log_statistics() {
   LogTarget(Info, thread, smr) log;
@@ -1067,6 +1041,30 @@
   }
 }
 
+// Print SMR info for a thread to a given output stream.
+void ThreadsSMRSupport::print_info_on(const Thread* thread, outputStream* st) {
+  if (thread->_threads_hazard_ptr != NULL) {
+    st->print(" _threads_hazard_ptr=" INTPTR_FORMAT, p2i(thread->_threads_hazard_ptr));
+  }
+  if (EnableThreadSMRStatistics && thread->_threads_list_ptr != NULL) {
+    // The count is only interesting if we have a _threads_list_ptr.
+    st->print(", _nested_threads_hazard_ptr_cnt=%u", thread->_nested_threads_hazard_ptr_cnt);
+  }
+  if (SafepointSynchronize::is_at_safepoint() || Thread::current() == thread) {
+    // It is only safe to walk the list if we're at a safepoint or the
+    // calling thread is walking its own list.
+    SafeThreadsListPtr* current = thread->_threads_list_ptr;
+    if (current != NULL) {
+      // Skip the top nesting level as it is always printed above.
+      current = current->previous();
+    }
+    while (current != NULL) {
+      current->print_on(st);
+      current = current->previous();
+    }
+  }
+}
+
 // Print Threads class SMR info.
 void ThreadsSMRSupport::print_info_on(outputStream* st) {
   // Only grab the Threads_lock if we don't already own it
@@ -1096,8 +1094,8 @@
   if (!EnableThreadSMRStatistics) {
     return;
   }
-  st->print_cr("_java_thread_list_alloc_cnt=" UINT64_FORMAT ","
-               "_java_thread_list_free_cnt=" UINT64_FORMAT ","
+  st->print_cr("_java_thread_list_alloc_cnt=" UINT64_FORMAT ", "
+               "_java_thread_list_free_cnt=" UINT64_FORMAT ", "
                "_java_thread_list_max=%u, "
                "_nested_thread_list_max=%u",
                _java_thread_list_alloc_cnt,
--- a/src/hotspot/share/runtime/threadSMR.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/threadSMR.hpp	Fri May 04 08:50:01 2018 -0700
@@ -28,6 +28,10 @@
 #include "memory/allocation.hpp"
 #include "runtime/timer.hpp"
 
+class JavaThread;
+class Monitor;
+class outputStream;
+class Thread;
 class ThreadClosure;
 
 // Thread Safe Memory Reclamation (Thread-SMR) support.
@@ -82,6 +86,8 @@
 // SMR Support for the Threads class.
 //
 class ThreadsSMRSupport : AllStatic {
+  friend class SafeThreadsListPtr;  // for _nested_thread_list_max, delete_notify(), release_stable_list_wake_up() access
+
   // The coordination between ThreadsSMRSupport::release_stable_list() and
   // ThreadsSMRSupport::smr_delete() uses the delete_lock in order to
   // reduce the traffic on the Threads_lock.
@@ -122,24 +128,20 @@
   static void inc_java_thread_list_alloc_cnt();
   static void inc_tlh_cnt();
   static bool is_a_protected_JavaThread(JavaThread *thread);
-  static void release_stable_list_fast_path(Thread *self);
-  static void release_stable_list_nested_path(Thread *self);
-  static void release_stable_list_wake_up(char *log_str);
+  static void release_stable_list_wake_up(bool is_nested);
   static void set_delete_notify();
   static void threads_do(ThreadClosure *tc);
   static void threads_do(ThreadClosure *tc, ThreadsList *list);
   static void update_deleted_thread_time_max(uint new_value);
   static void update_java_thread_list_max(uint new_value);
   static void update_tlh_time_max(uint new_value);
-  static void verify_hazard_pointer_scanned(Thread *self, ThreadsList *threads);
+  static void verify_hazard_ptr_scanned(Thread *self, ThreadsList *threads);
   static ThreadsList* xchg_java_thread_list(ThreadsList* new_list);
 
  public:
-  static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter);
   static void add_thread(JavaThread *thread);
   static ThreadsList* get_java_thread_list();
   static bool is_a_protected_JavaThread_with_lock(JavaThread *thread);
-  static void release_stable_list(Thread *self);
   static void remove_thread(JavaThread *thread);
   static void smr_delete(JavaThread *thread);
   static void update_tlh_stats(uint millis);
@@ -148,16 +150,19 @@
   static void log_statistics();
   static void print_info_elements_on(outputStream* st, ThreadsList* t_list);
   static void print_info_on(outputStream* st);
+  static void print_info_on(const Thread* thread, outputStream* st);
 };
 
 // A fast list of JavaThreads.
 //
 class ThreadsList : public CHeapObj<mtThread> {
-  friend class ThreadsSMRSupport;  // for next_list(), set_next_list() access
+  friend class SafeThreadsListPtr;  // for {dec,inc}_nested_handle_cnt() access
+  friend class ThreadsSMRSupport;  // for _nested_handle_cnt, {add,remove}_thread(), {,set_}next_list() access
 
   const uint _length;
   ThreadsList* _next_list;
   JavaThread *const *const _threads;
+  volatile intx _nested_handle_cnt;
 
   template <class T>
   void threads_do_dispatch(T *cl, JavaThread *const thread) const;
@@ -165,6 +170,9 @@
   ThreadsList *next_list() const        { return _next_list; }
   void set_next_list(ThreadsList *list) { _next_list = list; }
 
+  void inc_nested_handle_cnt();
+  void dec_nested_handle_cnt();
+
   static ThreadsList* add_thread(ThreadsList* list, JavaThread* java_thread);
   static ThreadsList* remove_thread(ThreadsList* list, JavaThread* java_thread);
 
@@ -187,20 +195,60 @@
   bool includes(const JavaThread * const p) const;
 };
 
-// Linked list of ThreadsLists to support nested ThreadsListHandles.
-class NestedThreadsList : public CHeapObj<mtThread> {
-  ThreadsList*const _t_list;
-  NestedThreadsList* _next;
+// An abstract safe ptr to a ThreadsList comprising either a stable hazard ptr
+// for leaves, or a retained reference count for nested uses. The user of this
+// API does not need to know which mechanism is providing the safety.
+class SafeThreadsListPtr {
+  friend class ThreadsListSetter;
+
+  SafeThreadsListPtr* _previous;
+  Thread*                 _thread;
+  ThreadsList*            _list;
+  bool                    _has_ref_count;
+  bool                    _needs_release;
+
+  void acquire_stable_list();
+  void acquire_stable_list_fast_path();
+  void acquire_stable_list_nested_path();
+
+  void release_stable_list();
+
+  void verify_hazard_ptr_scanned();
 
 public:
-  NestedThreadsList(ThreadsList* t_list) : _t_list(t_list) {
-    assert(Threads_lock->owned_by_self(),
-           "must own Threads_lock for saved t_list to be valid.");
+  // Constructor that attaches the list onto a thread.
+  SafeThreadsListPtr(Thread *thread, bool acquire) :
+    _previous(NULL),
+    _thread(thread),
+    _list(NULL),
+    _has_ref_count(false),
+    _needs_release(false)
+  {
+    if (acquire) {
+      acquire_stable_list();
+    }
   }
 
-  ThreadsList* t_list() { return _t_list; }
-  NestedThreadsList* next() { return _next; }
-  void set_next(NestedThreadsList* value) { _next = value; }
+  // Constructor that transfers ownership of the pointer.
+  SafeThreadsListPtr(SafeThreadsListPtr& other) :
+    _previous(other._previous),
+    _thread(other._thread),
+    _list(other._list),
+    _has_ref_count(other._has_ref_count),
+    _needs_release(other._needs_release)
+  {
+    other._needs_release = false;
+  }
+
+  ~SafeThreadsListPtr() {
+    if (_needs_release) {
+      release_stable_list();
+    }
+  }
+
+  ThreadsList* list() const { return _list; }
+  SafeThreadsListPtr* previous() const { return _previous; }
+  void print_on(outputStream* st);
 };
 
 // A helper to optionally set the hazard ptr in ourself. This helper can
@@ -209,24 +257,20 @@
 //
 class ThreadsListSetter : public StackObj {
 private:
-  bool _target_needs_release;  // needs release only when set()
-  Thread * _target;
+  SafeThreadsListPtr _list_ptr;
 
 public:
-  ThreadsListSetter() : _target_needs_release(false), _target(Thread::current()) {
-  }
-  ~ThreadsListSetter();
-  ThreadsList* list();
-  void set();
-  bool target_needs_release() { return _target_needs_release; }
+  ThreadsListSetter() : _list_ptr(Thread::current(), /* acquire */ false) {}
+  ThreadsList* list() { return _list_ptr.list(); }
+  void set() { _list_ptr.acquire_stable_list(); }
+  bool is_set() { return _list_ptr._needs_release; }
 };
 
 // This stack allocated ThreadsListHandle keeps all JavaThreads in the
 // ThreadsList from being deleted until it is safe.
 //
 class ThreadsListHandle : public StackObj {
-  ThreadsList * _list;
-  Thread *const _self;
+  SafeThreadsListPtr _list_ptr;
   elapsedTimer _timer;  // Enabled via -XX:+EnableThreadSMRStatistics.
 
 public:
@@ -234,22 +278,22 @@
   ~ThreadsListHandle();
 
   ThreadsList *list() const {
-    return _list;
+    return _list_ptr.list();
   }
 
   template <class T>
   void threads_do(T *cl) const {
-    return _list->threads_do(cl);
+    return list()->threads_do(cl);
   }
 
   bool cv_internal_thread_to_JavaThread(jobject jthread, JavaThread ** jt_pp, oop * thread_oop_p);
 
   bool includes(JavaThread* p) {
-    return _list->includes(p);
+    return list()->includes(p);
   }
 
   uint length() const {
-    return _list->length();
+    return list()->length();
   }
 };
 
--- a/src/hotspot/share/runtime/threadSMR.inline.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/threadSMR.inline.hpp	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,14 +77,6 @@
   }
 }
 
-
-inline ThreadsList* ThreadsListSetter::list() {
-  ThreadsList *ret = _target->get_threads_hazard_ptr();
-  assert(ret != NULL, "hazard ptr should be set");
-  assert(!Thread::is_hazard_ptr_tagged(ret), "hazard ptr should be validated");
-  return ret;
-}
-
 inline ThreadsList* ThreadsSMRSupport::get_java_thread_list() {
   return (ThreadsList*)OrderAccess::load_acquire(&_java_thread_list);
 }
--- a/src/hotspot/share/runtime/unhandledOops.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/unhandledOops.cpp	Fri May 04 08:50:01 2018 -0700
@@ -24,7 +24,6 @@
 
 #include "precompiled.hpp"
 #include "gc/shared/collectedHeap.hpp"
-#include "gc/shared/gcLocker.hpp"
 #include "memory/universe.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/thread.hpp"
--- a/src/hotspot/share/runtime/vm_operations.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/vm_operations.cpp	Fri May 04 08:50:01 2018 -0700
@@ -235,7 +235,7 @@
 }
 
 void VM_PrintMetadata::doit() {
-  MetaspaceUtils::print_metadata_for_nmt(_out, _scale);
+  MetaspaceUtils::print_report(_out, _scale, _flags);
 }
 
 VM_FindDeadlocks::~VM_FindDeadlocks() {
--- a/src/hotspot/share/runtime/vm_operations.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/runtime/vm_operations.hpp	Fri May 04 08:50:01 2018 -0700
@@ -391,10 +391,14 @@
 
 class VM_PrintMetadata : public VM_Operation {
  private:
-  outputStream* _out;
-  size_t        _scale;
+  outputStream* const _out;
+  const size_t        _scale;
+  const int           _flags;
+
  public:
-  VM_PrintMetadata(outputStream* out, size_t scale) : _out(out), _scale(scale) {};
+  VM_PrintMetadata(outputStream* out, size_t scale, int flags)
+    : _out(out), _scale(scale), _flags(flags)
+  {};
 
   VMOp_Type type() const  { return VMOp_PrintMetadata; }
   void doit();
--- a/src/hotspot/share/services/diagnosticCommand.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/services/diagnosticCommand.cpp	Fri May 04 08:50:01 2018 -0700
@@ -29,6 +29,7 @@
 #include "compiler/compileBroker.hpp"
 #include "compiler/directivesParser.hpp"
 #include "gc/shared/vmGCOperations.hpp"
+#include "memory/metaspace/metaspaceDCmd.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
@@ -90,7 +91,7 @@
   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
-  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<MetaspaceDCmd>(full_export, true, false));
+  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<metaspace::MetaspaceDCmd>(full_export, true, false));
 #if INCLUDE_JVMTI // Both JVMTI and SERVICES have to be enabled to have this dcmd
   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
 #endif // INCLUDE_JVMTI
--- a/src/hotspot/share/services/diagnosticCommand.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/services/diagnosticCommand.hpp	Fri May 04 08:50:01 2018 -0700
@@ -866,25 +866,4 @@
   virtual void execute(DCmdSource source, TRAPS);
 };
 
-class MetaspaceDCmd : public DCmd {
-public:
-  MetaspaceDCmd(outputStream* output, bool heap);
-  static const char* name() {
-    return "VM.metaspace";
-  }
-  static const char* description() {
-    return "Prints the statistics for the metaspace";
-  }
-  static const char* impact() {
-      return "Medium: Depends on number of classes loaded.";
-  }
-  static const JavaPermission permission() {
-    JavaPermission p = {"java.lang.management.ManagementPermission",
-                        "monitor", NULL};
-    return p;
-  }
-  static int num_arguments() { return 0; }
-  virtual void execute(DCmdSource source, TRAPS);
-};
-
 #endif // SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP
--- a/src/hotspot/share/services/memReporter.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/services/memReporter.cpp	Fri May 04 08:50:01 2018 -0700
@@ -201,7 +201,7 @@
   size_t used = MetaspaceUtils::used_bytes(type);
   size_t free = (MetaspaceUtils::capacity_bytes(type) - used)
               + MetaspaceUtils::free_chunks_total_bytes(type)
-              + MetaspaceUtils::free_bytes(type);
+              + MetaspaceUtils::free_in_vs_bytes(type);
 
   assert(committed >= used + free, "Sanity");
   size_t waste = committed - (used + free);
--- a/src/hotspot/share/services/memTracker.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/services/memTracker.cpp	Fri May 04 08:50:01 2018 -0700
@@ -177,10 +177,12 @@
     } else {
       MemDetailReporter rpt(baseline, output);
       rpt.report();
-
+      output->print("Metaspace:");
       // Metadata reporting requires a safepoint, so avoid it if VM is not in good state.
       assert(!VMError::fatal_error_in_progress(), "Do not report metadata in error report");
-      VM_PrintMetadata vmop(output, K);
+      VM_PrintMetadata vmop(output, K,
+          MetaspaceUtils::rf_show_loaders |
+          MetaspaceUtils::rf_break_down_by_spacetype);
       VMThread::execute(&vmop);
     }
   }
--- a/src/hotspot/share/services/memTracker.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/services/memTracker.hpp	Fri May 04 08:50:01 2018 -0700
@@ -246,7 +246,7 @@
     if (addr != NULL) {
       // uses thread stack malloc slot for book keeping number of threads
       MallocMemorySummary::record_malloc(0, mtThreadStack);
-      record_virtual_memory_reserve_and_commit(addr, size, CALLER_PC, mtThreadStack);
+      record_virtual_memory_reserve(addr, size, CALLER_PC, mtThreadStack);
     }
   }
 
--- a/src/hotspot/share/services/metaspaceDCmd.cpp	Wed May 02 22:11:35 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-#include "precompiled.hpp"
-#include "memory/metaspace.hpp"
-#include "services/diagnosticCommand.hpp"
-
-MetaspaceDCmd::MetaspaceDCmd(outputStream* output, bool heap): DCmd(output, heap) {
-}
-
-void MetaspaceDCmd::execute(DCmdSource source, TRAPS) {
-  const size_t scale = 1 * K;
-  VM_PrintMetadata op(output(), scale);
-  VMThread::execute(&op);
-}
-
--- a/src/hotspot/share/services/nmtCommon.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/services/nmtCommon.cpp	Fri May 04 08:50:01 2018 -0700
@@ -23,6 +23,7 @@
  */
 #include "precompiled.hpp"
 #include "services/nmtCommon.hpp"
+#include "utilities/globalDefinitions.hpp"
 
 const char* NMTUtil::_memory_type_names[] = {
   "Java Heap",
@@ -59,14 +60,13 @@
 
 size_t NMTUtil::scale_from_name(const char* scale) {
   assert(scale != NULL, "Null pointer check");
-  if (strncmp(scale, "KB", 2) == 0 ||
-      strncmp(scale, "kb", 2) == 0) {
+  if (strcasecmp(scale, "1") == 0 || strcasecmp(scale, "b") == 0) {
+    return 1;
+  } else if (strcasecmp(scale, "kb") == 0 || strcasecmp(scale, "k") == 0) {
     return K;
-  } else if (strncmp(scale, "MB", 2) == 0 ||
-             strncmp(scale, "mb", 2) == 0) {
+  } else if (strcasecmp(scale, "mb") == 0 || strcasecmp(scale, "m") == 0) {
     return M;
-  } else if (strncmp(scale, "GB", 2) == 0 ||
-             strncmp(scale, "gb", 2) == 0) {
+  } else if (strcasecmp(scale, "gb") == 0 || strcasecmp(scale, "g") == 0) {
     return G;
   } else {
     return 0; // Invalid value
--- a/src/hotspot/share/services/threadService.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/services/threadService.hpp	Fri May 04 08:50:01 2018 -0700
@@ -377,7 +377,7 @@
   ThreadSnapshot*      snapshots()                      { return _snapshots; }
   void                 set_t_list()                     { _setter.set(); }
   ThreadsList*         t_list();
-  bool                 t_list_has_been_set()            { return _setter.target_needs_release(); }
+  bool                 t_list_has_been_set()            { return _setter.is_set(); }
   void                 oops_do(OopClosure* f);
   void                 metadata_do(void f(Metadata*));
 };
--- a/src/hotspot/share/services/virtualMemoryTracker.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/services/virtualMemoryTracker.cpp	Fri May 04 08:50:01 2018 -0700
@@ -23,6 +23,7 @@
  */
 #include "precompiled.hpp"
 
+#include "logging/log.hpp"
 #include "memory/metaspace.hpp"
 #include "runtime/atomic.hpp"
 #include "runtime/os.hpp"
@@ -38,6 +39,12 @@
   ::new ((void*)_snapshot) VirtualMemorySnapshot();
 }
 
+void VirtualMemorySummary::snapshot(VirtualMemorySnapshot* s) {
+  // Snapshot current thread stacks
+  VirtualMemoryTracker::snapshot_thread_stacks();
+  as_snapshot()->copy_to(s);
+}
+
 SortedLinkedList<ReservedMemoryRegion, compare_reserved_region_base>* VirtualMemoryTracker::_reserved_regions;
 
 int compare_committed_region(const CommittedMemoryRegion& r1, const CommittedMemoryRegion& r2) {
@@ -286,6 +293,26 @@
   }
 }
 
+address ReservedMemoryRegion::thread_stack_uncommitted_bottom() const {
+  assert(flag() == mtThreadStack, "Only for thread stack");
+  LinkedListNode<CommittedMemoryRegion>* head = _committed_regions.head();
+  address bottom = base();
+  address top = base() + size();
+  while (head != NULL) {
+    address committed_top = head->data()->base() + head->data()->size();
+    if (committed_top < top) {
+      // committed stack guard pages, skip them
+      bottom = head->data()->base() + head->data()->size();
+      head = head->next();
+    } else {
+      assert(top == committed_top, "Sanity");
+      break;
+    }
+  }
+
+  return bottom;
+}
+
 bool VirtualMemoryTracker::initialize(NMT_TrackingLevel level) {
   if (level >= NMT_summary) {
     VirtualMemorySummary::initialize();
@@ -460,6 +487,80 @@
   }
 }
 
+// Iterate the range, find committed region within its bound.
+class RegionIterator : public StackObj {
+private:
+  const address _start;
+  const size_t  _size;
+
+  address _current_start;
+  size_t  _current_size;
+public:
+  RegionIterator(address start, size_t size) :
+    _start(start), _size(size), _current_start(start), _current_size(size) {
+  }
+
+  // return true if committed region is found
+  bool next_committed(address& start, size_t& size);
+private:
+  address end() const { return _start + _size; }
+};
+
+bool RegionIterator::next_committed(address& committed_start, size_t& committed_size) {
+  if (end() <= _current_start) return false;
+
+  const size_t page_sz = os::vm_page_size();
+  assert(_current_start + _current_size == end(), "Must be");
+  if (os::committed_in_range(_current_start, _current_size, committed_start, committed_size)) {
+    assert(committed_start != NULL, "Must be");
+    assert(committed_size > 0 && is_aligned(committed_size, os::vm_page_size()), "Must be");
+
+    size_t remaining_size = (_current_start + _current_size) - (committed_start + committed_size);
+    _current_start = committed_start + committed_size;
+    _current_size = remaining_size;
+    return true;
+  } else {
+    return false;
+  }
+}
+
+// Walk all known thread stacks, snapshot their committed ranges.
+class SnapshotThreadStackWalker : public VirtualMemoryWalker {
+public:
+  SnapshotThreadStackWalker() {}
+
+  bool do_allocation_site(const ReservedMemoryRegion* rgn) {
+    if (rgn->flag() == mtThreadStack) {
+      address stack_bottom = rgn->thread_stack_uncommitted_bottom();
+      address committed_start;
+      size_t  committed_size;
+      size_t stack_size = rgn->base() + rgn->size() - stack_bottom;
+
+      ReservedMemoryRegion* region = const_cast<ReservedMemoryRegion*>(rgn);
+      NativeCallStack ncs; // empty stack
+
+      RegionIterator itr(stack_bottom, stack_size);
+      DEBUG_ONLY(bool found_stack = false;)
+      while (itr.next_committed(committed_start, committed_size)) {
+        assert(committed_start != NULL, "Should not be null");
+        assert(committed_size > 0, "Should not be 0");
+        region->add_committed_region(committed_start, committed_size, ncs);
+        DEBUG_ONLY(found_stack = true;)
+      }
+#ifdef ASSERT
+      if (!found_stack) {
+        log_debug(thread)("Thread exited without proper cleanup, may leak thread object");
+      }
+#endif
+    }
+    return true;
+  }
+};
+
+void VirtualMemoryTracker::snapshot_thread_stacks() {
+  SnapshotThreadStackWalker walker;
+  walk_virtual_memory(&walker);
+}
 
 bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) {
   assert(_reserved_regions != NULL, "Sanity check");
@@ -516,7 +617,7 @@
 
   size_t free_in_bytes = (MetaspaceUtils::capacity_bytes(type) - MetaspaceUtils::used_bytes(type))
                        + MetaspaceUtils::free_chunks_total_bytes(type)
-                       + MetaspaceUtils::free_bytes(type);
+                       + MetaspaceUtils::free_in_vs_bytes(type);
   mss._free_in_bytes[type] = free_in_bytes;
 }
 
--- a/src/hotspot/share/services/virtualMemoryTracker.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/services/virtualMemoryTracker.hpp	Fri May 04 08:50:01 2018 -0700
@@ -160,9 +160,7 @@
     as_snapshot()->by_type(to)->commit_memory(size);
   }
 
-  static inline void snapshot(VirtualMemorySnapshot* s) {
-    as_snapshot()->copy_to(s);
-  }
+  static void snapshot(VirtualMemorySnapshot* s);
 
   static VirtualMemorySnapshot* as_snapshot() {
     return (VirtualMemorySnapshot*)_snapshot;
@@ -336,6 +334,9 @@
     return compare(rgn) == 0;
   }
 
+  // uncommitted thread stack bottom, above guard pages if there is any.
+  address thread_stack_uncommitted_bottom() const;
+
   bool    add_committed_region(address addr, size_t size, const NativeCallStack& stack);
   bool    remove_uncommitted_region(address addr, size_t size);
 
@@ -389,6 +390,7 @@
 // Main class called from MemTracker to track virtual memory allocations, commits and releases.
 class VirtualMemoryTracker : AllStatic {
   friend class VirtualMemoryTrackerTest;
+  friend class CommittedVirtualMemoryTest;
 
  public:
   static bool initialize(NMT_TrackingLevel level);
@@ -408,6 +410,9 @@
 
   static bool transition(NMT_TrackingLevel from, NMT_TrackingLevel to);
 
+  // Snapshot current thread stacks
+  static void snapshot_thread_stacks();
+
  private:
   static SortedLinkedList<ReservedMemoryRegion, compare_reserved_region_base>* _reserved_regions;
 };
--- a/src/hotspot/share/utilities/hashtable.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/utilities/hashtable.cpp	Fri May 04 08:50:01 2018 -0700
@@ -31,6 +31,7 @@
 #include "classfile/placeholders.hpp"
 #include "classfile/protectionDomainCache.hpp"
 #include "classfile/stringTable.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/metaspaceShared.hpp"
 #include "memory/resourceArea.hpp"
@@ -242,9 +243,7 @@
 // For oops and Strings the size of the literal is interesting. For other types, nobody cares.
 static int literal_size(ConstantPool*) { return 0; }
 static int literal_size(Klass*)        { return 0; }
-#if INCLUDE_ALL_GCS
 static int literal_size(nmethod*)      { return 0; }
-#endif
 
 static int literal_size(Symbol *symbol) {
   return symbol->size() * HeapWordSize;
@@ -447,11 +446,9 @@
 #endif // PRODUCT
 
 // Explicitly instantiate these types
-#if INCLUDE_ALL_GCS
 template class Hashtable<nmethod*, mtGC>;
 template class HashtableEntry<nmethod*, mtGC>;
 template class BasicHashtable<mtGC>;
-#endif
 template class Hashtable<ConstantPool*, mtClass>;
 template class RehashableHashtable<Symbol*, mtSymbol>;
 template class RehashableHashtable<oop, mtSymbol>;
--- a/src/hotspot/share/utilities/macros.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/utilities/macros.hpp	Fri May 04 08:50:01 2018 -0700
@@ -131,26 +131,85 @@
 #define NOT_MANAGEMENT_RETURN_(code) { return code; }
 #endif // INCLUDE_MANAGEMENT
 
-/*
- * When INCLUDE_ALL_GCS is false the only garbage collectors
- * included in the JVM are defaultNewGeneration and markCompact.
- *
- * When INCLUDE_ALL_GCS is true all garbage collectors are
- * included in the JVM.
- */
-#ifndef INCLUDE_ALL_GCS
-#define INCLUDE_ALL_GCS 1
-#endif // INCLUDE_ALL_GCS
+#ifndef INCLUDE_CMSGC
+#define INCLUDE_CMSGC 1
+#endif // INCLUDE_CMSGC
+
+#if INCLUDE_CMSGC
+#define CMSGC_ONLY(x) x
+#define CMSGC_ONLY_ARG(arg) arg,
+#define NOT_CMSGC(x)
+#define NOT_CMSGC_RETURN        /* next token must be ; */
+#define NOT_CMSGC_RETURN_(code) /* next token must be ; */
+#else
+#define CMSGC_ONLY(x)
+#define CMSGC_ONLY_ARG(x)
+#define NOT_CMSGC(x) x
+#define NOT_CMSGC_RETURN        {}
+#define NOT_CMSGC_RETURN_(code) { return code; }
+#endif // INCLUDE_CMSGC
+
+#ifndef INCLUDE_G1GC
+#define INCLUDE_G1GC 1
+#endif // INCLUDE_G1GC
+
+#if INCLUDE_G1GC
+#define G1GC_ONLY(x) x
+#define G1GC_ONLY_ARG(arg) arg,
+#define NOT_G1GC(x)
+#define NOT_G1GC_RETURN        /* next token must be ; */
+#define NOT_G1GC_RETURN_(code) /* next token must be ; */
+#else
+#define G1GC_ONLY(x)
+#define G1GC_ONLY_ARG(arg)
+#define NOT_G1GC(x) x
+#define NOT_G1GC_RETURN        {}
+#define NOT_G1GC_RETURN_(code) { return code; }
+#endif // INCLUDE_G1GC
+
+#ifndef INCLUDE_PARALLELGC
+#define INCLUDE_PARALLELGC 1
+#endif // INCLUDE_PARALLELGC
 
-#if INCLUDE_ALL_GCS
-#define ALL_GCS_ONLY(x) x
-#define NOT_ALL_GCS_RETURN        /* next token must be ; */
-#define NOT_ALL_GCS_RETURN_(code) /* next token must be ; */
+#if INCLUDE_PARALLELGC
+#define PARALLELGC_ONLY(x) x
+#define PARALLELGC_ONLY_ARG(arg) arg,
+#define NOT_PARALLELGC(x)
+#define NOT_PARALLELGC_RETURN        /* next token must be ; */
+#define NOT_PARALLELGC_RETURN_(code) /* next token must be ; */
 #else
-#define ALL_GCS_ONLY(x)
-#define NOT_ALL_GCS_RETURN        {}
-#define NOT_ALL_GCS_RETURN_(code) { return code; }
-#endif // INCLUDE_ALL_GCS
+#define PARALLELGC_ONLY(x)
+#define PARALLELGC_ONLY_ARG(arg)
+#define NOT_PARALLELGC(x) x
+#define NOT_PARALLELGC_RETURN        {}
+#define NOT_PARALLELGC_RETURN_(code) { return code; }
+#endif // INCLUDE_PARALLELGC
+
+#ifndef INCLUDE_SERIALGC
+#define INCLUDE_SERIALGC 1
+#endif // INCLUDE_SERIALGC
+
+#if INCLUDE_SERIALGC
+#define SERIALGC_ONLY(x) x
+#define SERIALGC_ONLY_ARG(arg) arg,
+#define NOT_SERIALGC(x)
+#define NOT_SERIALGC_RETURN        /* next token must be ; */
+#define NOT_SERIALGC_RETURN_(code) /* next token must be ; */
+#else
+#define SERIALGC_ONLY(x)
+#define SERIALGC_ONLY_ARG(arg)
+#define NOT_SERIALGC(x) x
+#define NOT_SERIALGC_RETURN        {}
+#define NOT_SERIALGC_RETURN_(code) { return code; }
+#endif // INCLUDE_SERIALGC
+
+#if INCLUDE_CMSGC || INCLUDE_G1GC || INCLUDE_PARALLELGC
+#define INCLUDE_NOT_ONLY_SERIALGC 1
+#else
+#define INCLUDE_NOT_ONLY_SERIALGC 0
+#endif
+
+#define INCLUDE_OOP_OOP_ITERATE_BACKWARDS INCLUDE_NOT_ONLY_SERIALGC
 
 #ifndef INCLUDE_NMT
 #define INCLUDE_NMT 1
@@ -172,12 +231,12 @@
 #define INCLUDE_JVMCI 1
 #endif
 
-#ifdef INCLUDE_AOT
-# if INCLUDE_AOT && !(INCLUDE_JVMCI)
-#   error "Must have JVMCI for AOT"
-# endif
-#else
-# define INCLUDE_AOT 0
+#ifndef INCLUDE_AOT
+#define INCLUDE_AOT 1
+#endif
+
+#if INCLUDE_AOT && !INCLUDE_JVMCI
+#  error "Must have JVMCI for AOT"
 #endif
 
 #if INCLUDE_JVMCI
@@ -524,7 +583,7 @@
     non_atomic_decl
 #endif
 
-#if INCLUDE_CDS && INCLUDE_ALL_GCS && defined(_LP64) && !defined(_WINDOWS)
+#if INCLUDE_CDS && INCLUDE_G1GC && defined(_LP64) && !defined(_WINDOWS)
 #define INCLUDE_CDS_JAVA_HEAP 1
 #define CDS_JAVA_HEAP_ONLY(x) x
 #define NOT_CDS_JAVA_HEAP(x)
--- a/src/hotspot/share/utilities/ostream.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/utilities/ostream.cpp	Fri May 04 08:50:01 2018 -0700
@@ -206,6 +206,10 @@
   this->write("\n", 1);
 }
 
+void outputStream::cr_indent() {
+  cr(); indent();
+}
+
 void outputStream::stamp() {
   if (! _stamp.is_updated()) {
     _stamp.update(); // start at 0 on first call to stamp()
--- a/src/hotspot/share/utilities/ostream.hpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/utilities/ostream.hpp	Fri May 04 08:50:01 2018 -0700
@@ -102,8 +102,10 @@
    void put(char ch);
    void sp(int count = 1);
    void cr();
+   void cr_indent();
    void bol() { if (_position > 0)  cr(); }
 
+
    // Time stamp
    TimeStamp& time_stamp() { return _stamp; }
    void stamp();
@@ -152,7 +154,6 @@
   ~streamIndentor() { _str->dec(_amount); }
 };
 
-
 // advisory locking for the shared tty stream:
 class ttyLocker: StackObj {
   friend class ttyUnlocker;
--- a/src/hotspot/share/utilities/vmError.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/src/hotspot/share/utilities/vmError.cpp	Fri May 04 08:50:01 2018 -0700
@@ -862,6 +862,13 @@
        st->cr();
      }
 
+  STEP("printing metaspace information")
+
+     if (_verbose && Universe::is_fully_initialized()) {
+       st->print_cr("Metaspace:");
+       MetaspaceUtils::print_basic_report(st, 0);
+     }
+
   STEP("printing code cache information")
 
      if (_verbose && Universe::is_fully_initialized()) {
@@ -1046,6 +1053,13 @@
     st->cr();
   }
 
+  // STEP("printing metaspace information")
+
+  if (Universe::is_fully_initialized()) {
+    st->print_cr("Metaspace:");
+    MetaspaceUtils::print_basic_report(st, 0);
+  }
+
   // STEP("printing code cache information")
 
   if (Universe::is_fully_initialized()) {
--- a/src/java.base/share/classes/java/lang/Class.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/java.base/share/classes/java/lang/Class.java	Fri May 04 08:50:01 2018 -0700
@@ -1524,13 +1524,22 @@
      * @since 1.5
      */
     public String getSimpleName() {
-        if (isArray())
-            return getComponentType().getSimpleName()+"[]";
-
+        ReflectionData<T> rd = reflectionData();
+        String simpleName = rd.simpleName;
+        if (simpleName == null) {
+            rd.simpleName = simpleName = getSimpleName0();
+        }
+        return simpleName;
+    }
+
+    private String getSimpleName0() {
+        if (isArray()) {
+            return getComponentType().getSimpleName() + "[]";
+        }
         String simpleName = getSimpleBinaryName();
         if (simpleName == null) { // top level class
             simpleName = getName();
-            return simpleName.substring(simpleName.lastIndexOf('.')+1); // strip the package name
+            simpleName = simpleName.substring(simpleName.lastIndexOf('.') + 1); // strip the package name
         }
         return simpleName;
     }
@@ -1546,10 +1555,10 @@
             try {
                 Class<?> cl = this;
                 int dimensions = 0;
-                while (cl.isArray()) {
+                do {
                     dimensions++;
                     cl = cl.getComponentType();
-                }
+                } while (cl.isArray());
                 StringBuilder sb = new StringBuilder();
                 sb.append(cl.getName());
                 for (int i = 0; i < dimensions; i++) {
@@ -1572,22 +1581,31 @@
      * @since 1.5
      */
     public String getCanonicalName() {
+        ReflectionData<T> rd = reflectionData();
+        String canonicalName = rd.canonicalName;
+        if (canonicalName == null) {
+            rd.canonicalName = canonicalName = getCanonicalName0();
+        }
+        return canonicalName == ReflectionData.NULL_SENTINEL? null : canonicalName;
+    }
+
+    private String getCanonicalName0() {
         if (isArray()) {
             String canonicalName = getComponentType().getCanonicalName();
             if (canonicalName != null)
                 return canonicalName + "[]";
             else
-                return null;
+                return ReflectionData.NULL_SENTINEL;
         }
         if (isLocalOrAnonymousClass())
-            return null;
+            return ReflectionData.NULL_SENTINEL;
         Class<?> enclosingClass = getEnclosingClass();
         if (enclosingClass == null) { // top level class
             return getName();
         } else {
             String enclosingName = enclosingClass.getCanonicalName();
             if (enclosingName == null)
-                return null;
+                return ReflectionData.NULL_SENTINEL;
             return enclosingName + "." + getSimpleName();
         }
     }
@@ -2895,7 +2913,8 @@
      * Reflection support.
      */
 
-    // reflection data that might get invalidated when JVM TI RedefineClasses() is called
+    // Reflection data caches various derived names and reflective members. Cached
+    // values may be invalidated when JVM TI RedefineClasses() is called
     private static class ReflectionData<T> {
         volatile Field[] declaredFields;
         volatile Field[] publicFields;
@@ -2908,6 +2927,11 @@
         volatile Method[] declaredPublicMethods;
         volatile Class<?>[] interfaces;
 
+        // Cached names
+        String simpleName;
+        String canonicalName;
+        static final String NULL_SENTINEL = new String();
+
         // Value of classRedefinedCount when we created this ReflectionData instance
         final int redefinedCount;
 
--- a/src/java.base/share/classes/java/lang/ref/Reference.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/java.base/share/classes/java/lang/ref/Reference.java	Fri May 04 08:50:01 2018 -0700
@@ -300,6 +300,20 @@
         return this.queue.enqueue(this);
     }
 
+    /**
+     * Throws {@link CloneNotSupportedException}. A {@code Reference} cannot be
+     * meaningfully cloned. Construct a new {@code Reference} instead.
+     *
+     * @returns never returns normally
+     * @throws  CloneNotSupportedException always
+     *
+     * @since 11
+     */
+    @Override
+    protected Object clone() throws CloneNotSupportedException {
+        throw new CloneNotSupportedException();
+    }
+
     /* -- Constructors -- */
 
     Reference(T referent) {
--- a/src/java.base/share/classes/java/nio/X-Buffer.java.template	Wed May 02 22:11:35 2018 -0700
+++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template	Fri May 04 08:50:01 2018 -0700
@@ -700,7 +700,7 @@
      *
      * <pre>{@code
      *     for (int i = off; i < off + len; i++)
-     *         dst[i] = src.get():
+     *         dst[i] = src.get();
      * }</pre>
      *
      * except that it first checks that there are sufficient $type$s in
--- a/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -4262,7 +4262,7 @@
          * @return the position after the parse
          */
         private int parseOffsetBased(DateTimeParseContext context, CharSequence text, int prefixPos, int position, OffsetIdPrinterParser parser) {
-            String prefix = text.toString().substring(prefixPos, position).toUpperCase();
+            String prefix = text.subSequence(prefixPos, position).toString().toUpperCase();
             if (position >= text.length()) {
                 context.setParsed(ZoneId.of(prefix));
                 return position;
--- a/src/java.base/share/classes/java/util/Arrays.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/java.base/share/classes/java/util/Arrays.java	Fri May 04 08:50:01 2018 -0700
@@ -4723,27 +4723,16 @@
         int result = 1;
 
         for (Object element : a) {
-            int elementHash = 0;
-            if (element instanceof Object[])
+            final int elementHash;
+            final Class<?> cl;
+            if (element == null)
+                elementHash = 0;
+            else if ((cl = element.getClass().getComponentType()) == null)
+                elementHash = element.hashCode();
+            else if (element instanceof Object[])
                 elementHash = deepHashCode((Object[]) element);
-            else if (element instanceof byte[])
-                elementHash = hashCode((byte[]) element);
-            else if (element instanceof short[])
-                elementHash = hashCode((short[]) element);
-            else if (element instanceof int[])
-                elementHash = hashCode((int[]) element);
-            else if (element instanceof long[])
-                elementHash = hashCode((long[]) element);
-            else if (element instanceof char[])
-                elementHash = hashCode((char[]) element);
-            else if (element instanceof float[])
-                elementHash = hashCode((float[]) element);
-            else if (element instanceof double[])
-                elementHash = hashCode((double[]) element);
-            else if (element instanceof boolean[])
-                elementHash = hashCode((boolean[]) element);
-            else if (element != null)
-                elementHash = element.hashCode();
+            else
+                elementHash = primitiveArrayHashCode(element, cl);
 
             result = 31 * result + elementHash;
         }
@@ -4751,6 +4740,20 @@
         return result;
     }
 
+    private static int primitiveArrayHashCode(Object a, Class<?> cl) {
+        return
+            (cl == byte.class)    ? hashCode((byte[]) a)    :
+            (cl == int.class)     ? hashCode((int[]) a)     :
+            (cl == long.class)    ? hashCode((long[]) a)    :
+            (cl == char.class)    ? hashCode((char[]) a)    :
+            (cl == short.class)   ? hashCode((short[]) a)   :
+            (cl == boolean.class) ? hashCode((boolean[]) a) :
+            (cl == double.class)  ? hashCode((double[]) a)  :
+            // If new primitive types are ever added, this method must be
+            // expanded or we will fail here with ClassCastException.
+            hashCode((float[]) a);
+    }
+
     /**
      * Returns {@code true} if the two specified arrays are <i>deeply
      * equal</i> to one another.  Unlike the {@link #equals(Object[],Object[])}
--- a/src/java.base/share/classes/java/util/Random.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/java.base/share/classes/java/util/Random.java	Fri May 04 08:50:01 2018 -0700
@@ -110,7 +110,7 @@
         // Different Sizes and Good Lattice Structure", 1999
         for (;;) {
             long current = seedUniquifier.get();
-            long next = current * 181783497276652981L;
+            long next = current * 1181783497276652981L;
             if (seedUniquifier.compareAndSet(current, next))
                 return next;
         }
--- a/src/java.base/unix/native/libnet/Inet4AddressImpl.c	Wed May 02 22:11:35 2018 -0700
+++ b/src/java.base/unix/native/libnet/Inet4AddressImpl.c	Fri May 04 08:50:01 2018 -0700
@@ -41,11 +41,6 @@
 extern jobjectArray lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6);
 #endif
 
-/* the initial size of our hostent buffers */
-#ifndef NI_MAXHOST
-#define NI_MAXHOST 1025
-#endif
-
 #define SET_NONBLOCKING(fd) {       \
     int flags = fcntl(fd, F_GETFL); \
     flags |= O_NONBLOCK;            \
@@ -66,10 +61,10 @@
     char hostname[NI_MAXHOST + 1];
 
     hostname[0] = '\0';
-    if (gethostname(hostname, NI_MAXHOST) != 0) {
+    if (gethostname(hostname, sizeof(hostname)) != 0) {
         strcpy(hostname, "localhost");
+    } else {
 #if defined(__solaris__)
-    } else {
         // try to resolve hostname via nameservice
         // if it is known but getnameinfo fails, hostname will still be the
         // value from gethostname
@@ -82,17 +77,15 @@
         hints.ai_family = AF_INET;
 
         if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
-            getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST,
+            getnameinfo(res->ai_addr, res->ai_addrlen, hostname, sizeof(hostname),
                         NULL, 0, NI_NAMEREQD);
             freeaddrinfo(res);
         }
-    }
 #else
-    } else {
         // make sure string is null-terminated
         hostname[NI_MAXHOST] = '\0';
+#endif
     }
-#endif
     return (*env)->NewStringUTF(env, hostname);
 }
 
@@ -248,7 +241,7 @@
     sa.sin_family = AF_INET;
 
     if (getnameinfo((struct sockaddr *)&sa, sizeof(struct sockaddr_in),
-                    host, NI_MAXHOST, NULL, 0, NI_NAMEREQD)) {
+                    host, sizeof(host), NULL, 0, NI_NAMEREQD)) {
         JNU_ThrowByName(env, "java/net/UnknownHostException", NULL);
     } else {
         ret = (*env)->NewStringUTF(env, host);
--- a/src/java.base/unix/native/libnet/Inet6AddressImpl.c	Wed May 02 22:11:35 2018 -0700
+++ b/src/java.base/unix/native/libnet/Inet6AddressImpl.c	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,11 +42,6 @@
 #include "java_net_Inet4AddressImpl.h"
 #include "java_net_Inet6AddressImpl.h"
 
-/* the initial size of our hostent buffers */
-#ifndef NI_MAXHOST
-#define NI_MAXHOST 1025
-#endif
-
 #define SET_NONBLOCKING(fd) {       \
     int flags = fcntl(fd, F_GETFL); \
     flags |= O_NONBLOCK;            \
@@ -67,10 +62,10 @@
     char hostname[NI_MAXHOST + 1];
 
     hostname[0] = '\0';
-    if (gethostname(hostname, NI_MAXHOST) != 0) {
+    if (gethostname(hostname, sizeof(hostname)) != 0) {
         strcpy(hostname, "localhost");
+    } else {
 #if defined(__solaris__)
-    } else {
         // try to resolve hostname via nameservice
         // if it is known but getnameinfo fails, hostname will still be the
         // value from gethostname
@@ -83,17 +78,15 @@
         hints.ai_family = AF_UNSPEC;
 
         if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
-            getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST,
+            getnameinfo(res->ai_addr, res->ai_addrlen, hostname, sizeof(hostname),
                         NULL, 0, NI_NAMEREQD);
             freeaddrinfo(res);
         }
-    }
 #else
-    } else {
         // make sure string is null-terminated
         hostname[NI_MAXHOST] = '\0';
+#endif
     }
-#endif
     return (*env)->NewStringUTF(env, hostname);
 }
 
@@ -103,7 +96,7 @@
 lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6)
 {
     jobjectArray result = NULL;
-    char myhostname[NI_MAXHOST+1];
+    char myhostname[NI_MAXHOST + 1];
     struct ifaddrs *ifa = NULL;
     int familyOrder = 0;
     int count = 0, i, j;
@@ -120,7 +113,7 @@
      * the name (if the name actually matches something in DNS etc.
      */
     myhostname[0] = '\0';
-    if (gethostname(myhostname, NI_MAXHOST) == -1) {
+    if (gethostname(myhostname, sizeof(myhostname)) == -1) {
         /* Something went wrong, maybe networking is not setup? */
         return NULL;
     }
@@ -445,7 +438,7 @@
         len = sizeof(struct sockaddr_in6);
     }
 
-    if (getnameinfo(&sa.sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD)) {
+    if (getnameinfo(&sa.sa, len, host, sizeof(host), NULL, 0, NI_NAMEREQD)) {
         JNU_ThrowByName(env, "java/net/UnknownHostException", NULL);
     } else {
         ret = (*env)->NewStringUTF(env, host);
--- a/src/java.base/unix/native/libnet/net_util_md.h	Wed May 02 22:11:35 2018 -0700
+++ b/src/java.base/unix/native/libnet/net_util_md.h	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,11 @@
 #define NET_NSEC_PER_SEC  1000000000
 #define NET_NSEC_PER_USEC 1000
 
+/* in case NI_MAXHOST is not defined in netdb.h */
+#ifndef NI_MAXHOST
+#define NI_MAXHOST 1025
+#endif
+
 /* Defines SO_REUSEPORT */
 #ifndef SO_REUSEPORT
 #ifdef __linux__
--- a/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEventReaderImpl.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEventReaderImpl.java	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -153,9 +153,9 @@
             //space, cdata, characters and entity reference
             //nextEvent() would also set the last event.
             event = nextEvent();
-            while(event.getEventType() != XMLEvent.END_ELEMENT){
-                if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
-                type == XMLEvent.CDATA){
+            while ((type = event.getEventType()) != XMLEvent.END_ELEMENT) {
+                if (type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
+                    type == XMLEvent.CDATA){
                     data = event.asCharacters().getData();
                 }
                 else if(type == XMLEvent.ENTITY_REFERENCE){
@@ -163,6 +163,7 @@
                 }
                 else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
                     //ignore
+                    data = null;
                 } else if(type == XMLEvent.END_DOCUMENT) {
                     throw new XMLStreamException("unexpected end of document when reading element text content");
                 } else if(type == XMLEvent.START_ELEMENT) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/JNIWriter.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/JNIWriter.java	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -190,7 +190,7 @@
         try {
             write(out, c);
             if (verbose)
-                log.printVerbose("wrote.file", outFile);
+                log.printVerbose("wrote.file", outFile.getName());
             out.close();
             out = null;
         } finally {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -784,7 +784,7 @@
             try (BufferedWriter out = new BufferedWriter(outFile.openWriter())) {
                 new Pretty(out, true).printUnit(env.toplevel, cdef);
                 if (verbose)
-                    log.printVerbose("wrote.file", outFile);
+                    log.printVerbose("wrote.file", outFile.getName());
             }
             return outFile;
         }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java	Fri May 04 08:50:01 2018 -0700
@@ -44,7 +44,7 @@
     private final HtmlDoclet htmlDoclet;
 
     public StandardDoclet() {
-        htmlDoclet = new HtmlDoclet();
+        htmlDoclet = new HtmlDoclet(this);
     }
 
     @Override
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Fri May 04 08:50:01 2018 -0700
@@ -31,6 +31,7 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
+import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.doclet.Reporter;
 import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet;
@@ -59,8 +60,8 @@
  */
 public class HtmlDoclet extends AbstractDoclet {
 
-    public HtmlDoclet() {
-        configuration = new HtmlConfiguration(this);
+    public HtmlDoclet(Doclet parent) {
+        configuration = new HtmlConfiguration(parent);
     }
 
     @Override // defined by Doclet
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java	Fri May 04 08:50:01 2018 -0700
@@ -42,6 +42,9 @@
 import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.doclet.Reporter;
+import jdk.javadoc.doclet.StandardDoclet;
+import jdk.javadoc.doclet.Taglet;
+import jdk.javadoc.internal.doclets.formats.html.HtmlDoclet;
 import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;
 import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
@@ -356,7 +359,15 @@
     /**
      * Constructs the configurations needed by the doclet.
      *
-     * @param doclet the doclet that created this configuration
+     * @apiNote
+     * The {@code doclet} parameter is used when {@link Taglet#init(DocletEnvironment, Doclet)
+     * initializing tags}.
+     * Some doclets (such as the {@link StandardDoclet), may delegate to another
+     * (such as the {@link HtmlDoclet}).  In such cases, the primary doclet (i.e
+     * {@code StandardDoclet}) should be provided here, and not any internal
+     * class like {@code HtmlDoclet}.
+     *
+     * @param doclet the doclet for this run of javadoc
      */
     public BaseConfiguration(Doclet doclet) {
         this.doclet = doclet;
--- a/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java	Wed May 02 22:11:35 2018 -0700
+++ b/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,10 @@
         setCount(Math.max(getCount(), trap.getCount()));
     }
 
+    public String toString() {
+        return "uncommon trap " + bytecode + " " + getReason() + " " + getAction();
+    }
+
     public void print(PrintStream stream, boolean printID) {
         if (printID) {
             stream.print(getId() + " ");
@@ -92,6 +96,20 @@
         this.count = count;
     }
 
+    private boolean trapReasonsAreEqual(String otherReason) {
+        if (otherReason.equals(getReason())) {
+            return true;
+        }
+
+        // Optimization may combine 2 if's into 1
+        if (otherReason.equals("unstable_if")
+                && getReason().equals("unstable_fused_if")) {
+            return true;
+        }
+
+        return false;
+    }
+
     /**
      * Set the compilation for this event. This involves identifying the call
      * site to which this uncommon trap event belongs. In addition to setting
@@ -127,13 +145,14 @@
             }
             for (UncommonTrap trap : traps) {
                 if (trap.getBCI() == jvmsBCIs.get(i) &&
-                    trap.getReason().equals(getReason()) &&
+                    trapReasonsAreEqual(trap.getReason()) &&
                     trap.getAction().equals(getAction())) {
                     bytecode = trap.getBytecode();
                     return;
                 }
             }
-            throw new InternalError("couldn't find bytecode");
+            throw new InternalError("couldn't find bytecode for [" + this + "] in Compilation:" + compilation);
+
         } catch (Exception e) {
             bytecode = "<unknown>";
         }
--- a/test/hotspot/gtest/gc/parallel/test_psAdaptiveSizePolicy.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/gtest/gc/parallel/test_psAdaptiveSizePolicy.cpp	Fri May 04 08:50:01 2018 -0700
@@ -23,11 +23,11 @@
  */
 
 #include "precompiled.hpp"
+#include "gc/parallel/psAdaptiveSizePolicy.hpp"
 #include "utilities/macros.hpp"
-#include "gc/parallel/psAdaptiveSizePolicy.hpp"
 #include "unittest.hpp"
 
-#if INCLUDE_ALL_GCS
+#if INCLUDE_PARALLELGC
 
   TEST_VM(gc, oldFreeSpaceCalculation) {
 
--- a/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp	Fri May 04 08:50:01 2018 -0700
@@ -22,13 +22,12 @@
  */
 
 #include "precompiled.hpp"
-#include <string.h>
+#include "gc/shared/memset_with_concurrent_readers.hpp"
 #include "utilities/globalDefinitions.hpp"
-#include <sstream>
-#include "gc/shared/memset_with_concurrent_readers.hpp"
 #include "unittest.hpp"
 
-#if INCLUDE_ALL_GCS
+#include <string.h>
+#include <sstream>
 
 static unsigned line_byte(const char* line, size_t i) {
   return unsigned(line[i]) & 0xFF;
@@ -96,4 +95,3 @@
     }
   }
 }
-#endif
--- a/test/hotspot/gtest/gc/shared/test_oopStorage.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/gtest/gc/shared/test_oopStorage.cpp	Fri May 04 08:50:01 2018 -0700
@@ -53,9 +53,10 @@
 public:
   typedef OopStorage::Block Block;
   typedef OopStorage::BlockList BlockList;
+  typedef OopStorage::BlockArray BlockArray;
 
-  static BlockList& active_list(OopStorage& storage) {
-    return storage._active_list;
+  static BlockArray& active_array(const OopStorage& storage) {
+    return *storage._active_array;
   }
 
   static BlockList& allocate_list(OopStorage& storage) {
@@ -96,20 +97,25 @@
   static size_t memory_per_block() {
     return Block::allocation_size();
   }
+
+  static void block_array_set_block_count(BlockArray* blocks, size_t count) {
+    blocks->_block_count = count;
+  }
 };
 
 typedef OopStorage::TestAccess TestAccess;
-// --- FIXME: Should be just Block, but that collides with opto Block
-//     when building with precompiled headers.  There really should be
-//     an opto namespace.
+
+// The "Oop" prefix is to avoid collision with similar opto names when
+// building with precompiled headers, or for consistency with that
+// workaround.  There really should be an opto namespace.
 typedef TestAccess::Block OopBlock;
-// --- FIXME: Similarly, this typedef collides with opto BlockList.
-// typedef TestAccess::BlockList BlockList;
+typedef TestAccess::BlockList OopBlockList;
+typedef TestAccess::BlockArray OopBlockArray;
 
 // Using EXPECT_EQ can't use NULL directly. Otherwise AIX build breaks.
 const OopBlock* const NULL_BLOCK = NULL;
 
-static size_t list_length(const TestAccess::BlockList& list) {
+static size_t list_length(const OopBlockList& list) {
   size_t result = 0;
   for (const OopBlock* block = list.chead();
        block != NULL;
@@ -119,7 +125,7 @@
   return result;
 }
 
-static void clear_list(TestAccess::BlockList& list) {
+static void clear_list(OopBlockList& list) {
   OopBlock* next;
   for (OopBlock* block = list.head(); block != NULL; block = next) {
     next = list.next(*block);
@@ -127,7 +133,7 @@
   }
 }
 
-static bool is_list_empty(const TestAccess::BlockList& list) {
+static bool is_list_empty(const OopBlockList& list) {
   return list.chead() == NULL;
 }
 
@@ -149,7 +155,7 @@
 }
 
 static size_t empty_block_count(const OopStorage& storage) {
-  const TestAccess::BlockList& list = TestAccess::allocate_list(storage);
+  const OopBlockList& list = TestAccess::allocate_list(storage);
   size_t count = 0;
   for (const OopBlock* block = list.ctail();
        (block != NULL) && block->is_empty();
@@ -158,6 +164,20 @@
   return count;
 }
 
+static size_t active_count(const OopStorage& storage) {
+  return TestAccess::active_array(storage).block_count();
+}
+
+static OopBlock* active_head(const OopStorage& storage) {
+  OopBlockArray& ba = TestAccess::active_array(storage);
+  size_t count = ba.block_count();
+  if (count == 0) {
+    return NULL;
+  } else {
+    return ba.at(count - 1);
+  }
+}
+
 class OopStorageTest : public ::testing::Test {
 public:
   OopStorageTest();
@@ -188,7 +208,6 @@
 
 OopStorageTest::~OopStorageTest() {
   clear_list(TestAccess::allocate_list(_storage));
-  clear_list(TestAccess::active_list(_storage));
 }
 
 class OopStorageTestWithAllocation : public OopStorageTest {
@@ -227,7 +246,7 @@
 static bool is_allocate_list_sorted(const OopStorage& storage) {
   // The allocate_list isn't strictly sorted.  Rather, all empty
   // blocks are segregated to the end of the list.
-  const TestAccess::BlockList& list = TestAccess::allocate_list(storage);
+  const OopBlockList& list = TestAccess::allocate_list(storage);
   const OopBlock* block = list.ctail();
   for ( ; (block != NULL) && block->is_empty(); block = list.prev(*block)) {}
   for ( ; block != NULL; block = list.prev(*block)) {
@@ -238,25 +257,25 @@
   return true;
 }
 
-static size_t total_allocation_count(const TestAccess::BlockList& list) {
+static size_t total_allocation_count(const OopStorage& storage) {
   size_t total_count = 0;
-  for (const OopBlock* block = list.chead();
-       block != NULL;
-       block = list.next(*block)) {
-    total_count += TestAccess::block_allocation_count(*block);
+  const OopBlockArray& ba = TestAccess::active_array(storage);
+  size_t limit = active_count(storage);
+  for (size_t i = 0; i < limit; ++i) {
+    total_count += TestAccess::block_allocation_count(*ba.at(i));
   }
   return total_count;
 }
 
 TEST_VM_F(OopStorageTest, allocate_one) {
-  EXPECT_TRUE(is_list_empty(TestAccess::active_list(_storage)));
+  EXPECT_EQ(0u, active_count(_storage));
   EXPECT_TRUE(is_list_empty(TestAccess::allocate_list(_storage)));
 
   oop* ptr = _storage.allocate();
   EXPECT_TRUE(ptr != NULL);
   EXPECT_EQ(1u, _storage.allocation_count());
 
-  EXPECT_EQ(1u, list_length(TestAccess::active_list(_storage)));
+  EXPECT_EQ(1u, active_count(_storage));
   EXPECT_EQ(1u, _storage.block_count());
   EXPECT_EQ(1u, list_length(TestAccess::allocate_list(_storage)));
 
@@ -264,7 +283,7 @@
 
   const OopBlock* block = TestAccess::allocate_list(_storage).chead();
   EXPECT_NE(block, (OopBlock*)NULL);
-  EXPECT_EQ(block, (TestAccess::active_list(_storage).chead()));
+  EXPECT_EQ(block, active_head(_storage));
   EXPECT_FALSE(TestAccess::block_is_empty(*block));
   EXPECT_FALSE(TestAccess::block_is_full(*block));
   EXPECT_EQ(1u, TestAccess::block_allocation_count(*block));
@@ -272,7 +291,7 @@
   release_entry(_storage, ptr);
   EXPECT_EQ(0u, _storage.allocation_count());
 
-  EXPECT_EQ(1u, list_length(TestAccess::active_list(_storage)));
+  EXPECT_EQ(1u, active_count(_storage));
   EXPECT_EQ(1u, _storage.block_count());
   EXPECT_EQ(1u, list_length(TestAccess::allocate_list(_storage)));
 
@@ -280,7 +299,7 @@
 
   const OopBlock* new_block = TestAccess::allocate_list(_storage).chead();
   EXPECT_EQ(block, new_block);
-  EXPECT_EQ(block, (TestAccess::active_list(_storage).chead()));
+  EXPECT_EQ(block, active_head(_storage));
   EXPECT_TRUE(TestAccess::block_is_empty(*block));
   EXPECT_FALSE(TestAccess::block_is_full(*block));
   EXPECT_EQ(0u, TestAccess::block_allocation_count(*block));
@@ -290,20 +309,19 @@
   static const size_t max_entries = 1000;
   oop* entries[max_entries];
 
-  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
-  TestAccess::BlockList& allocate_list = TestAccess::allocate_list(_storage);
+  OopBlockList& allocate_list = TestAccess::allocate_list(_storage);
 
-  EXPECT_TRUE(is_list_empty(active_list));
+  EXPECT_EQ(0u, active_count(_storage));
   EXPECT_EQ(0u, _storage.block_count());
   EXPECT_TRUE(is_list_empty(allocate_list));
 
   size_t allocated = 0;
   for ( ; allocated < max_entries; ++allocated) {
     EXPECT_EQ(allocated, _storage.allocation_count());
-    if (!is_list_empty(active_list)) {
-      EXPECT_EQ(1u, list_length(active_list));
+    if (active_count(_storage) != 0) {
+      EXPECT_EQ(1u, active_count(_storage));
       EXPECT_EQ(1u, _storage.block_count());
-      const OopBlock& block = *active_list.chead();
+      const OopBlock& block = *TestAccess::active_array(_storage).at(0);
       EXPECT_EQ(allocated, TestAccess::block_allocation_count(block));
       if (TestAccess::block_is_full(block)) {
         break;
@@ -316,10 +334,10 @@
   }
 
   EXPECT_EQ(allocated, _storage.allocation_count());
-  EXPECT_EQ(1u, list_length(active_list));
+  EXPECT_EQ(1u, active_count(_storage));
   EXPECT_EQ(1u, _storage.block_count());
   EXPECT_TRUE(is_list_empty(allocate_list));
-  const OopBlock& block = *active_list.chead();
+  const OopBlock& block = *TestAccess::active_array(_storage).at(0);
   EXPECT_TRUE(TestAccess::block_is_full(block));
   EXPECT_EQ(allocated, TestAccess::block_allocation_count(block));
 
@@ -336,19 +354,18 @@
   static const size_t max_entries = 1000;
   oop* entries[max_entries];
 
-  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
-  TestAccess::BlockList& allocate_list = TestAccess::allocate_list(_storage);
+  OopBlockList& allocate_list = TestAccess::allocate_list(_storage);
 
   EXPECT_EQ(0u, empty_block_count(_storage));
 
   entries[0] = _storage.allocate();
   ASSERT_TRUE(entries[0] != NULL);
-  EXPECT_EQ(1u, list_length(active_list));
+  EXPECT_EQ(1u, active_count(_storage));
   EXPECT_EQ(1u, _storage.block_count());
   EXPECT_EQ(1u, list_length(allocate_list));
   EXPECT_EQ(0u, empty_block_count(_storage));
 
-  const OopBlock* block = active_list.chead();
+  const OopBlock* block = TestAccess::active_array(_storage).at(0);
   EXPECT_EQ(1u, TestAccess::block_allocation_count(*block));
   EXPECT_EQ(block, allocate_list.chead());
 
@@ -363,14 +380,14 @@
       EXPECT_EQ(1u, list_length(allocate_list));
       block = allocate_list.chead();
       EXPECT_EQ(1u, TestAccess::block_allocation_count(*block));
-      EXPECT_EQ(block, active_list.chead());
+      EXPECT_EQ(block, active_head(_storage));
     } else if (TestAccess::block_is_full(*block)) {
       EXPECT_TRUE(is_list_empty(allocate_list));
       block = NULL;
     } else {
       EXPECT_FALSE(is_list_empty(allocate_list));
       EXPECT_EQ(block, allocate_list.chead());
-      EXPECT_EQ(block, active_list.chead());
+      EXPECT_EQ(block, active_head(_storage));
     }
   }
 
@@ -378,20 +395,18 @@
     EXPECT_NE(0u, TestAccess::block_allocation_count(*block));
     EXPECT_FALSE(is_list_empty(allocate_list));
     EXPECT_EQ(block, allocate_list.chead());
-    EXPECT_EQ(block, active_list.chead());
+    EXPECT_EQ(block, active_head(_storage));
   }
 
-  size_t active_count = list_length(active_list);
-
   for (size_t i = 0; i < max_entries; ++i) {
     release_entry(_storage, entries[i]);
     EXPECT_TRUE(is_allocate_list_sorted(_storage));
-    EXPECT_EQ(max_entries - (i + 1), total_allocation_count(active_list));
+    EXPECT_EQ(max_entries - (i + 1), total_allocation_count(_storage));
   }
 
-  EXPECT_EQ(list_length(active_list), list_length(allocate_list));
-  EXPECT_EQ(list_length(active_list), _storage.block_count());
-  EXPECT_EQ(list_length(active_list), empty_block_count(_storage));
+  EXPECT_EQ(active_count(_storage), list_length(allocate_list));
+  EXPECT_EQ(active_count(_storage), _storage.block_count());
+  EXPECT_EQ(active_count(_storage), empty_block_count(_storage));
   for (const OopBlock* block = allocate_list.chead();
        block != NULL;
        block = allocate_list.next(*block)) {
@@ -405,10 +420,9 @@
 
   EXPECT_EQ(0u, empty_block_count(_storage));
 
-  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
-  TestAccess::BlockList& allocate_list = TestAccess::allocate_list(_storage);
+  OopBlockList& allocate_list = TestAccess::allocate_list(_storage);
 
-  EXPECT_EQ(_max_entries, total_allocation_count(active_list));
+  EXPECT_EQ(_max_entries, total_allocation_count(_storage));
   EXPECT_GE(1u, list_length(allocate_list));
 
   // Release all entries in "random" order.
@@ -418,14 +432,14 @@
       release_entry(_storage, _entries[i]);
       _entries[i] = NULL;
       ++released;
-      EXPECT_EQ(_max_entries - released, total_allocation_count(active_list));
+      EXPECT_EQ(_max_entries - released, total_allocation_count(_storage));
       EXPECT_TRUE(is_allocate_list_sorted(_storage));
     }
   }
 
-  EXPECT_EQ(list_length(active_list), list_length(allocate_list));
-  EXPECT_EQ(list_length(active_list), _storage.block_count());
-  EXPECT_EQ(0u, total_allocation_count(active_list));
+  EXPECT_EQ(active_count(_storage), list_length(allocate_list));
+  EXPECT_EQ(active_count(_storage), _storage.block_count());
+  EXPECT_EQ(0u, total_allocation_count(_storage));
   EXPECT_EQ(list_length(allocate_list), empty_block_count(_storage));
 }
 
@@ -436,10 +450,9 @@
 
   EXPECT_EQ(0u, empty_block_count(_storage));
 
-  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
-  TestAccess::BlockList& allocate_list = TestAccess::allocate_list(_storage);
+  OopBlockList& allocate_list = TestAccess::allocate_list(_storage);
 
-  EXPECT_EQ(_max_entries, total_allocation_count(active_list));
+  EXPECT_EQ(_max_entries, total_allocation_count(_storage));
   EXPECT_GE(1u, list_length(allocate_list));
 
   // Release all entries in "random" order, "randomly" interspersed
@@ -452,20 +465,20 @@
       _entries[i] = NULL;
       ++released;
       ++total_released;
-      EXPECT_EQ(_max_entries - released, total_allocation_count(active_list));
+      EXPECT_EQ(_max_entries - released, total_allocation_count(_storage));
       EXPECT_TRUE(is_allocate_list_sorted(_storage));
       if (total_released % allocate_step == 0) {
         _entries[i] = _storage.allocate();
         --released;
-        EXPECT_EQ(_max_entries - released, total_allocation_count(active_list));
+        EXPECT_EQ(_max_entries - released, total_allocation_count(_storage));
         EXPECT_TRUE(is_allocate_list_sorted(_storage));
       }
     }
   }
 
-  EXPECT_EQ(list_length(active_list), list_length(allocate_list));
-  EXPECT_EQ(list_length(active_list), _storage.block_count());
-  EXPECT_EQ(0u, total_allocation_count(active_list));
+  EXPECT_EQ(active_count(_storage), list_length(allocate_list));
+  EXPECT_EQ(active_count(_storage), _storage.block_count());
+  EXPECT_EQ(0u, total_allocation_count(_storage));
   EXPECT_EQ(list_length(allocate_list), empty_block_count(_storage));
 }
 
@@ -1015,9 +1028,7 @@
 }
 
 TEST_VM_F(OopStorageTestWithAllocation, delete_empty_blocks_safepoint) {
-  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
-
-  size_t initial_active_size = list_length(active_list);
+  size_t initial_active_size = active_count(_storage);
   EXPECT_EQ(initial_active_size, _storage.block_count());
   ASSERT_LE(3u, initial_active_size); // Need at least 3 blocks for test
 
@@ -1026,7 +1037,7 @@
     release_entry(_storage, _entries[i]);
   }
 
-  EXPECT_EQ(initial_active_size, list_length(active_list));
+  EXPECT_EQ(initial_active_size, active_count(_storage));
   EXPECT_EQ(initial_active_size, _storage.block_count());
   EXPECT_EQ(3u, empty_block_count(_storage));
 
@@ -1036,14 +1047,12 @@
     VMThread::execute(&op);
   }
   EXPECT_EQ(0u, empty_block_count(_storage));
-  EXPECT_EQ(initial_active_size - 3, list_length(active_list));
+  EXPECT_EQ(initial_active_size - 3, active_count(_storage));
   EXPECT_EQ(initial_active_size - 3, _storage.block_count());
 }
 
 TEST_VM_F(OopStorageTestWithAllocation, delete_empty_blocks_concurrent) {
-  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
-
-  size_t initial_active_size = list_length(active_list);
+  size_t initial_active_size = active_count(_storage);
   EXPECT_EQ(initial_active_size, _storage.block_count());
   ASSERT_LE(3u, initial_active_size); // Need at least 3 blocks for test
 
@@ -1052,13 +1061,13 @@
     release_entry(_storage, _entries[i]);
   }
 
-  EXPECT_EQ(initial_active_size, list_length(active_list));
+  EXPECT_EQ(initial_active_size, active_count(_storage));
   EXPECT_EQ(initial_active_size, _storage.block_count());
   EXPECT_EQ(3u, empty_block_count(_storage));
 
   _storage.delete_empty_blocks_concurrent();
   EXPECT_EQ(0u, empty_block_count(_storage));
-  EXPECT_EQ(initial_active_size - 3, list_length(active_list));
+  EXPECT_EQ(initial_active_size - 3, active_count(_storage));
   EXPECT_EQ(initial_active_size - 3, _storage.block_count());
 }
 
@@ -1161,23 +1170,21 @@
 
 #endif // !PRODUCT
 
-//////////////////////////////////////////////////////////////////////////////
-// Unit tests for block lists
-
-class OopStorageBlockListTest : public ::testing::Test {
-public:
-  OopStorageBlockListTest() {
+class OopStorageBlockCollectionTest : public ::testing::Test {
+protected:
+  OopStorageBlockCollectionTest() {
     for (size_t i = 0; i < nvalues; ++i) {
       values[i] = OopBlock::new_block(pseudo_owner());
     }
   }
 
-  ~OopStorageBlockListTest() {
+  ~OopStorageBlockCollectionTest() {
     for (size_t i = 0; i < nvalues; ++i) {
       OopBlock::delete_block(*values[i]);
     }
   }
 
+public:
   static const size_t nvalues = 10;
   OopBlock* values[nvalues];
 
@@ -1190,11 +1197,13 @@
   }
 };
 
-const size_t OopStorageBlockListTest::nvalues;
-const void* const OopStorageBlockListTest::_pseudo_owner[] = {};
+const size_t OopStorageBlockCollectionTest::nvalues;
+const void* const OopStorageBlockCollectionTest::_pseudo_owner[] = {};
+
+class OopStorageBlockListTest : public OopStorageBlockCollectionTest {};
 
 TEST_F(OopStorageBlockListTest, empty_list) {
-  TestAccess::BlockList list(&OopBlock::get_active_entry);
+  OopBlockList list(&OopBlock::get_allocate_entry);
 
   EXPECT_TRUE(is_list_empty(list));
   EXPECT_EQ(NULL_BLOCK, list.head());
@@ -1203,7 +1212,7 @@
 }
 
 TEST_F(OopStorageBlockListTest, push_back) {
-  TestAccess::BlockList list(&OopBlock::get_active_entry);
+  OopBlockList list(&OopBlock::get_allocate_entry);
 
   for (size_t i = 0; i < nvalues; ++i) {
     list.push_back(*values[i]);
@@ -1233,7 +1242,7 @@
 }
 
 TEST_F(OopStorageBlockListTest, push_front) {
-  TestAccess::BlockList list(&OopBlock::get_active_entry);
+  OopBlockList list(&OopBlock::get_allocate_entry);
 
   for (size_t i = 0; i < nvalues; ++i) {
     list.push_front(*values[i]);
@@ -1264,7 +1273,7 @@
 
 class OopStorageBlockListTestWithList : public OopStorageBlockListTest {
 public:
-  OopStorageBlockListTestWithList() : list(&OopBlock::get_active_entry) {
+  OopStorageBlockListTestWithList() : list(&OopBlock::get_allocate_entry) {
     for (size_t i = 0; i < nvalues; ++i) {
       list.push_back(*values[i]);
     }
@@ -1274,7 +1283,7 @@
     clear_list(list);
   }
 
-  TestAccess::BlockList list;
+  OopBlockList list;
 };
 
 TEST_F(OopStorageBlockListTestWithList, unlink_front) {
@@ -1336,7 +1345,7 @@
 }
 
 TEST_F(OopStorageBlockListTest, single) {
-  TestAccess::BlockList list(&OopBlock::get_active_entry);
+  OopBlockList list(&OopBlock::get_allocate_entry);
 
   list.push_back(*values[0]);
   EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));
@@ -1351,31 +1360,79 @@
   EXPECT_EQ(NULL_BLOCK, list.ctail());
 }
 
-TEST_F(OopStorageBlockListTestWithList, two_lists) {
-  TestAccess::BlockList list2(&OopBlock::get_allocate_entry);
-  for (size_t i = 0; i < nvalues; ++i) {
-    list2.push_front(*values[i]);
+class OopStorageBlockArrayTest : public OopStorageBlockCollectionTest {};
+
+TEST_F(OopStorageBlockArrayTest, empty_array) {
+  OopBlockArray* a = OopBlockArray::create(nvalues);
+
+  EXPECT_EQ(nvalues, a->size());
+  EXPECT_EQ(0u, a->block_count_acquire());
+  TestAccess::block_array_set_block_count(a, 2);
+  EXPECT_EQ(2u, a->block_count_acquire());
+  TestAccess::block_array_set_block_count(a, 0);
+  a->increment_refcount();
+  a->increment_refcount();
+  EXPECT_FALSE(a->decrement_refcount());
+  EXPECT_TRUE(a->decrement_refcount());
+
+  OopBlockArray::destroy(a);
+}
+
+TEST_F(OopStorageBlockArrayTest, push) {
+  OopBlockArray* a = OopBlockArray::create(nvalues - 1);
+
+  for (size_t i = 0; i < nvalues - 1; ++i) {
+    EXPECT_TRUE(a->push(values[i]));
+    EXPECT_EQ(i + 1, a->block_count_acquire());
+    EXPECT_EQ(values[i], a->at(i));
+  }
+  EXPECT_FALSE(a->push(values[nvalues - 1]));
+
+  TestAccess::block_array_set_block_count(a, 0);
+  OopBlockArray::destroy(a);
+}
+
+class OopStorageBlockArrayTestWithArray : public OopStorageBlockArrayTest {
+public:
+  OopStorageBlockArrayTestWithArray() : a(OopBlockArray::create(nvalues)) {
+    for (size_t i = 0; i < nvalues; ++i) {
+      a->push(values[i]);
+    }
   }
 
-  const OopBlock* active_block = list.chead();
-  const OopBlock* allocate_block = list2.ctail();
-  for (size_t i = 0; i < nvalues; ++i) {
-    EXPECT_EQ(active_block, allocate_block);
-    active_block = list.next(*active_block);
-    allocate_block = list2.prev(*allocate_block);
+  ~OopStorageBlockArrayTestWithArray() {
+    TestAccess::block_array_set_block_count(a, 0);
+    OopBlockArray::destroy(a);
   }
-  EXPECT_EQ(NULL_BLOCK, active_block);
-  EXPECT_EQ(NULL_BLOCK, allocate_block);
+
+  OopBlockArray* a;
+};
+
+TEST_F(OopStorageBlockArrayTestWithArray, remove0) {
+  a->remove(values[0]);
+  EXPECT_EQ(nvalues - 1, a->block_count_acquire());
+  EXPECT_EQ(values[nvalues - 1], a->at(0));
+  for (size_t i = 1; i < nvalues - 1; ++i) {
+    EXPECT_EQ(values[i], a->at(i));
+  }
+}
 
-  for (size_t i = 0; i < nvalues; ++i) {
-    list2.unlink(*values[i]);
+TEST_F(OopStorageBlockArrayTestWithArray, remove3) {
+  a->remove(values[3]);
+  EXPECT_EQ(nvalues - 1, a->block_count_acquire());
+  for (size_t i = 0; i < 3; ++i) {
+    EXPECT_EQ(values[i], a->at(i));
   }
-  EXPECT_TRUE(is_list_empty(list2));
+  EXPECT_EQ(values[nvalues - 1], a->at(3));
+  for (size_t i = 4; i < nvalues - 1; ++i) {
+    EXPECT_EQ(values[i], a->at(i));
+  }
+}
 
-  active_block = list.chead();
-  for (size_t i = 0; i < nvalues; ++i) {
-    EXPECT_EQ(active_block, values[i]);
-    active_block = list.next(*active_block);
+TEST_F(OopStorageBlockArrayTestWithArray, remove_last) {
+  a->remove(values[nvalues - 1]);
+  EXPECT_EQ(nvalues - 1, a->block_count_acquire());
+  for (size_t i = 0; i < nvalues - 1; ++i) {
+    EXPECT_EQ(values[i], a->at(i));
   }
-  EXPECT_EQ(NULL_BLOCK, active_block);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/gtest/gc/shared/test_oopStorage_parperf.cpp	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "precompiled.hpp"
+#include "gc/shared/oopStorage.inline.hpp"
+#include "gc/shared/oopStorageParState.inline.hpp"
+#include "gc/shared/workgroup.hpp"
+#include "logging/log.hpp"
+#include "logging/logConfiguration.hpp"
+#include "memory/allocation.inline.hpp"
+#include "memory/iterator.inline.hpp"
+#include "runtime/interfaceSupport.inline.hpp"
+#include "runtime/os.hpp"
+#include "runtime/thread.hpp"
+#include "runtime/vm_operations.hpp"
+#include "runtime/vmThread.hpp"
+#include "utilities/debug.hpp"
+#include "utilities/ostream.hpp"
+#include "utilities/ticks.inline.hpp"
+
+#include "unittest.hpp"
+
+// This "test" doesn't really verify much.  Rather, it's mostly a
+// microbenchmark for OopStorage parallel iteration.  It executes
+// parallel iteration with varying numbers of threads on an storage
+// object containing a large number of entries, and logs some stats
+// about the distribution and performance of the iteration.
+
+// Parallel iteration not available unless INCLUDE_ALL_GCS
+#if INCLUDE_ALL_GCS
+
+const uint _max_workers = 10;
+static uint _num_workers = 0;
+const size_t _storage_entries = 1000000;
+
+class OopStorageParIterPerf : public ::testing::Test {
+public:
+  OopStorageParIterPerf();
+  ~OopStorageParIterPerf();
+
+  WorkGang* workers() const;
+
+  class VM_ParStateTime;
+  class Task;
+  class Closure;
+
+  Tickspan run_task(Task* task, uint nthreads);
+  void show_task(const Task* task, Tickspan duration, uint nthreads);
+  void run_test(uint nthreads);
+
+  static WorkGang* _workers;
+
+  static const int _active_rank = Mutex::leaf - 1;
+  static const int _allocate_rank = Mutex::leaf;
+
+  Mutex _allocate_mutex;
+  Mutex _active_mutex;
+  OopStorage _storage;
+  oop* _entries[_storage_entries];
+};
+
+WorkGang* OopStorageParIterPerf::_workers = NULL;
+
+WorkGang* OopStorageParIterPerf::workers() const {
+  if (_workers == NULL) {
+    WorkGang* wg = new WorkGang("OopStorageParIterPerf workers",
+                                _num_workers,
+                                false,
+                                false);
+    wg->initialize_workers();
+    wg->update_active_workers(_num_workers);
+    _workers = wg;
+  }
+  return _workers;
+}
+
+OopStorageParIterPerf::OopStorageParIterPerf() :
+  _allocate_mutex(_allocate_rank,
+                  "test_OopStorage_parperf_allocate",
+                  false,
+                  Mutex::_safepoint_check_never),
+  _active_mutex(_active_rank,
+                "test_OopStorage_parperf_active",
+                false,
+                Mutex::_safepoint_check_never),
+  _storage("Test Storage", &_allocate_mutex, &_active_mutex)
+{
+  for (size_t i = 0; i < _storage_entries; ++i) {
+    _entries[i] = _storage.allocate();
+  }
+  _num_workers = MIN2(_max_workers, (uint)os::processor_count());
+}
+
+OopStorageParIterPerf::~OopStorageParIterPerf() {
+  _storage.release(_entries, ARRAY_SIZE(_entries));
+}
+
+class OopStorageParIterPerf::VM_ParStateTime : public VM_GTestExecuteAtSafepoint {
+public:
+  VM_ParStateTime(WorkGang* workers, AbstractGangTask* task, uint nthreads) :
+    _workers(workers), _task(task), _nthreads(nthreads)
+  {}
+
+  void doit() {
+    _workers->run_task(_task, _nthreads);
+  }
+
+private:
+  WorkGang* _workers;
+  AbstractGangTask* _task;
+  uint _nthreads;
+};
+
+class OopStorageParIterPerf::Task : public AbstractGangTask {
+  typedef OopStorage::ParState<false, false> StateType;
+
+  Tickspan* _worker_times;
+  StateType _state;
+  OopClosure* _closure;
+
+public:
+  Task(OopStorage* storage, OopClosure* closure, uint nthreads) :
+    AbstractGangTask("OopStorageParIterPerf::Task"),
+    _worker_times(NULL),
+    _state(storage, nthreads),
+    _closure(closure)
+  {
+    Tickspan* wtimes = NEW_C_HEAP_ARRAY(Tickspan, _num_workers, mtInternal);
+    for (uint i = 0; i < _num_workers; ++i) {
+      new (&wtimes[i]) Tickspan();
+    }
+    _worker_times = wtimes;
+  }
+
+  ~Task() {
+    FREE_C_HEAP_ARRAY(Tickspan, _worker_times);
+  }
+
+  virtual void work(uint worker_id) {
+    Ticks start_time = Ticks::now();
+    _state.oops_do(_closure);
+    _worker_times[worker_id] = Ticks::now() - start_time;
+  }
+
+  const Tickspan* worker_times() const { return _worker_times; }
+};
+
+class OopStorageParIterPerf::Closure : public OopClosure {
+public:
+  virtual void do_oop(oop* p) { guarantee(*p == NULL, "expected NULL"); }
+  virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
+};
+
+Tickspan OopStorageParIterPerf::run_task(Task* task, uint nthreads) {
+  tty->print_cr("Running test with %u threads", nthreads);
+  VM_ParStateTime op(workers(), task, nthreads);
+  ThreadInVMfromNative invm(JavaThread::current());
+  Ticks start_time = Ticks::now();
+  VMThread::execute(&op);
+  return Ticks::now() - start_time;
+}
+
+void OopStorageParIterPerf::show_task(const Task* task, Tickspan duration, uint nthreads) {
+  tty->print_cr("Run test with %u threads: " JLONG_FORMAT, nthreads, duration.value());
+  const Tickspan* wtimes = task->worker_times();
+  for (uint i = 0; i < _num_workers; ++i) {
+    if (wtimes[i] != Tickspan()) {
+      tty->print_cr("  %u: " JLONG_FORMAT, i, wtimes[i].value());
+    }
+  }
+  tty->cr();
+}
+
+void OopStorageParIterPerf::run_test(uint nthreads) {
+  if (nthreads <= _num_workers) {
+    SCOPED_TRACE(err_msg("Running test with %u threads", nthreads).buffer());
+    Closure closure;
+    Task task(&_storage, &closure, nthreads);
+    Tickspan t = run_task(&task, nthreads);
+    show_task(&task, t, nthreads);
+  }
+}
+
+TEST_VM_F(OopStorageParIterPerf, test) {
+  // Enable additional interesting logging.
+#define TEST_TAGS oopstorage, blocks, stats
+  // There isn't an obvious way to capture the old log level so it
+  // can be restored here, so just use Warning as the "default".
+  LogLevelType old_level = LogLevel::Warning;
+  if (log_is_enabled(Debug, TEST_TAGS)) {
+    old_level = LogLevel::Debug;
+  } else if (log_is_enabled(Info, TEST_TAGS)) {
+    old_level = LogLevel::Info;
+  }
+  bool debug_enabled = old_level == LogLevel::Debug;
+  if (!debug_enabled) {
+    LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(TEST_TAGS));
+  }
+
+  run_test(1);
+  run_test(2);
+  run_test(3);
+  run_test(4);
+  run_test(6);
+  run_test(8);
+  run_test(10);
+
+  if (!debug_enabled) {
+    LogConfiguration::configure_stdout(old_level, true, LOG_TAGS(TEST_TAGS));
+  }
+}
+
+#endif // INCLUDE_ALL_GCS
--- a/test/hotspot/gtest/logging/test_logStream.cpp	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/gtest/logging/test_logStream.cpp	Fri May 04 08:50:01 2018 -0700
@@ -71,8 +71,10 @@
   const int max_line_len = 1024;
   char* const test_string = (char*) os::malloc(max_line_len, mtLogging);
   memset(test_string, 'A', max_line_len);
+  Log(gc) log;
+  set_log_config(TestLogFileName, "gc=debug");
   for (int interval = 1; interval < max_line_len; interval++) {
-    LogStream ls(Log(logging)::info());
+    LogStream ls(log.debug());
     int written = 0;
     while (written < max_line_len) {
       const int to_write = MIN2(interval, max_line_len - written);
@@ -84,7 +86,6 @@
       }
       ASSERT_TRUE(line_buffer[written] == '\0');
     }
-    ls.cr(); // I do not expect printout, nor do I care. Just call cr() to flush and avoid assert in ~LogStream().
   }
 }
 
@@ -100,3 +101,14 @@
   // reset to prevent assert for unflushed content
   ls._current_line.reset();
 }
+
+TEST_VM_F(LogStreamTest, autoflush_on_destruction) {
+  Log(gc) log;
+  set_log_config(TestLogFileName, "gc=debug");
+  {
+    LogStream stream(log.debug());
+    stream.print("ABCD"); // Unfinished line. I expect not to assert upon leaving the scope.
+  }
+  EXPECT_TRUE(file_contains_substring(TestLogFileName, "ABCD\n"));
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "precompiled.hpp"
+
+// Included early because the NMT flags don't include it.
+#include "utilities/macros.hpp"
+
+#include "runtime/thread.hpp"
+#include "services/memTracker.hpp"
+#include "services/virtualMemoryTracker.hpp"
+#include "utilities/globalDefinitions.hpp"
+#include "unittest.hpp"
+
+
+class CommittedVirtualMemoryTest {
+public:
+  static void test() {
+    Thread* thr = Thread::current();
+    address stack_end = thr->stack_end();
+    size_t  stack_size = thr->stack_size();
+
+    MemTracker::record_thread_stack(stack_end, stack_size);
+
+    VirtualMemoryTracker::add_reserved_region(stack_end, stack_size, CALLER_PC, mtThreadStack);
+
+    // snapshot current stack usage
+    VirtualMemoryTracker::snapshot_thread_stacks();
+
+    ReservedMemoryRegion* rmr = VirtualMemoryTracker::_reserved_regions->find(ReservedMemoryRegion(stack_end, stack_size));
+    ASSERT_TRUE(rmr != NULL);
+
+    ASSERT_EQ(rmr->base(), stack_end);
+    ASSERT_EQ(rmr->size(), stack_size);
+
+    CommittedRegionIterator iter = rmr->iterate_committed_regions();
+    int i = 0;
+    address i_addr = (address)&i;
+    bool found_i_addr = false;
+
+    // stack grows downward
+    address stack_top = stack_end + stack_size;
+    bool found_stack_top = false;
+
+    for (const CommittedMemoryRegion* region = iter.next(); region != NULL; region = iter.next()) {
+      if (region->base() + region->size() == stack_top) {
+        ASSERT_TRUE(region->size() <= stack_size);
+        found_stack_top = true;
+      }
+
+      if(i_addr < stack_top && i_addr >= region->base()) {
+        found_i_addr = true;
+      }
+
+      i++;
+    }
+
+    // stack and guard pages may be contiguous as one region
+    ASSERT_TRUE(i >= 1);
+    ASSERT_TRUE(found_stack_top);
+    ASSERT_TRUE(found_i_addr);
+  }
+
+  static void check_covered_pages(address addr, size_t size, address base, size_t touch_pages, int* page_num) {
+    const size_t page_sz = os::vm_page_size();
+    size_t index;
+    for (index = 0; index < touch_pages; index ++) {
+      address page_addr = base + page_num[index] * page_sz;
+      // The range covers this page, marks the page
+      if (page_addr >= addr && page_addr < addr + size) {
+        page_num[index] = -1;
+      }
+    }
+  }
+
+  static void test_committed_region_impl(size_t num_pages, size_t touch_pages, int* page_num) {
+    const size_t page_sz = os::vm_page_size();
+    const size_t size = num_pages * page_sz;
+    char* base = os::reserve_memory(size, NULL, page_sz, mtThreadStack);
+    bool result = os::commit_memory(base, size, false);
+    size_t index;
+    ASSERT_NE(base, (char*)NULL);
+    for (index = 0; index < touch_pages; index ++) {
+      char* touch_addr = base + page_sz * page_num[index];
+      *touch_addr = 'a';
+    }
+
+    address frame = (address)0x1235;
+    NativeCallStack stack(&frame, 1);
+    VirtualMemoryTracker::add_reserved_region((address)base, size, stack, mtThreadStack);
+
+    // trigger the test
+    VirtualMemoryTracker::snapshot_thread_stacks();
+
+    ReservedMemoryRegion* rmr = VirtualMemoryTracker::_reserved_regions->find(ReservedMemoryRegion((address)base, size));
+    ASSERT_TRUE(rmr != NULL);
+
+    bool precise_tracking_supported = false;
+    CommittedRegionIterator iter = rmr->iterate_committed_regions();
+    for (const CommittedMemoryRegion* region = iter.next(); region != NULL; region = iter.next()) {
+      if (region->size() == size) {
+        // platforms that do not support precise tracking.
+        ASSERT_TRUE(iter.next() == NULL);
+        break;
+      } else {
+        precise_tracking_supported = true;
+        check_covered_pages(region->base(), region->size(), (address)base, touch_pages, page_num);
+      }
+    }
+
+    if (precise_tracking_supported) {
+      // All touched pages should be committed
+      for (size_t index = 0; index < touch_pages; index ++) {
+        ASSERT_EQ(page_num[index], -1);
+      }
+    }
+
+    // Cleanup
+    os::free_memory(base, size, page_sz);
+    VirtualMemoryTracker::remove_released_region((address)base, size);
+
+    rmr = VirtualMemoryTracker::_reserved_regions->find(ReservedMemoryRegion((address)base, size));
+    ASSERT_TRUE(rmr == NULL);
+  }
+
+  static void test_committed_region() {
+    // On Linux, we scan 1024 pages at a time.
+    // Here, we test scenario that scans < 1024 pages.
+    int small_range[] = {3, 9, 46};
+    int mid_range[] = {0, 45, 100, 399, 400, 1000, 1031};
+    int large_range[] = {100, 301, 1024, 2047, 2048, 2049, 2050, 3000};
+
+    test_committed_region_impl(47, 3, small_range);
+    test_committed_region_impl(1088, 5, mid_range);
+    test_committed_region_impl(3074, 8, large_range);
+  }
+
+  static void test_partial_region() {
+    bool   result;
+    size_t committed_size;
+    address committed_start;
+    size_t index;
+
+    const size_t page_sz = os::vm_page_size();
+    const size_t num_pages = 4;
+    const size_t size = num_pages * page_sz;
+    char* base = os::reserve_memory(size, NULL, page_sz, mtTest);
+    ASSERT_NE(base, (char*)NULL);
+    result = os::commit_memory(base, size, false);
+
+    ASSERT_TRUE(result);
+    // touch all pages
+    for (index = 0; index < num_pages; index ++) {
+      *(base + index * page_sz) = 'a';
+    }
+
+    // Test whole range
+    result = os::committed_in_range((address)base, size, committed_start, committed_size);
+    ASSERT_TRUE(result);
+    ASSERT_EQ(num_pages * page_sz, committed_size);
+    ASSERT_EQ(committed_start, (address)base);
+
+    // Test beginning of the range
+    result = os::committed_in_range((address)base, 2 * page_sz, committed_start, committed_size);
+    ASSERT_TRUE(result);
+    ASSERT_EQ(2 * page_sz, committed_size);
+    ASSERT_EQ(committed_start, (address)base);
+
+    // Test end of the range
+    result = os::committed_in_range((address)(base + page_sz), 3 * page_sz, committed_start, committed_size);
+    ASSERT_TRUE(result);
+    ASSERT_EQ(3 * page_sz, committed_size);
+    ASSERT_EQ(committed_start, (address)(base + page_sz));
+
+    // Test middle of the range
+    result = os::committed_in_range((address)(base + page_sz), 2 * page_sz, committed_start, committed_size);
+    ASSERT_TRUE(result);
+    ASSERT_EQ(2 * page_sz, committed_size);
+    ASSERT_EQ(committed_start, (address)(base + page_sz));
+  }
+};
+
+TEST_VM(CommittedVirtualMemoryTracker, test_committed_virtualmemory_region) {
+  VirtualMemoryTracker::initialize(NMT_detail);
+  VirtualMemoryTracker::late_initialize(NMT_detail);
+
+  CommittedVirtualMemoryTest::test();
+  CommittedVirtualMemoryTest::test_committed_region();
+  CommittedVirtualMemoryTest::test_partial_region();
+}
--- a/test/hotspot/jtreg/ProblemList.txt	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/jtreg/ProblemList.txt	Fri May 04 08:50:01 2018 -0700
@@ -52,6 +52,7 @@
 compiler/c2/Test8007294.java 8192992 generic-all
 
 applications/ctw/modules/java_desktop.java 8189604 windows-all
+applications/ctw/modules/java_desktop_2.java 8189604 windows-all
 applications/ctw/modules/jdk_jconsole.java 8189604 windows-all
 
 #############################################################################
@@ -93,3 +94,19 @@
 
 compiler/c2/Test8007294.java                                                   8194310    generic-all  Java EE Module Removal
 compiler/c2/Test6852078.java                                                   8194310    generic-all  Java EE Module Removal
+
+#############################################################################
+
+# :vmTestbase_*
+
+#############################################################################
+
+vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded003/TestDescription.java 8153598 generic-all
+vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001/TestDescription.java 8198668 generic-all
+vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded002/TestDescription.java 8153598 generic-all
+vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded003/TestDescription.java 8198668 generic-all
+vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded004/TestDescription.java 8153598 generic-all
+vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005/TestDescription.java 8153598 generic-all
+vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestDescription.java 8060733 generic-all
+
+#############################################################################
--- a/test/hotspot/jtreg/TEST.ROOT	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/jtreg/TEST.ROOT	Fri May 04 08:50:01 2018 -0700
@@ -27,7 +27,7 @@
 # It also contains test-suite configuration information.
 
 # The list of keywords supported in this test suite
-keys=cte_test jcmd nmt regression gc stress
+keys=cte_test jcmd nmt regression gc stress metaspace
 
 groups=TEST.groups
 
--- a/test/hotspot/jtreg/TEST.groups	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/jtreg/TEST.groups	Fri May 04 08:50:01 2018 -0700
@@ -317,3 +317,274 @@
   -:tier1_runtime_appcds_exclude \
   -:hotspot_nmt \
   -:hotspot_tier2_runtime_platform_agnostic
+
+# Stress tests against information provided by VM via JMX
+vmTestbase_nsk_monitoring = \
+  vmTestbase/nsk/monitoring
+
+vmTestbase_nsk_monitoring_quick = \
+  vmTestbase/nsk/monitoring/MemoryNotificationInfo/MemoryNotificationInfo/info001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryNotificationInfo/from/from001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryNotificationInfo/getCount/getcount001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryNotificationInfo/getPoolName/getpoolname001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryNotificationInfo/getUsage/getusage001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold002/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold003/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold004/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold005/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryUsage/MemoryUsage/memoryusage001/TestDescription.java \
+  vmTestbase/nsk/monitoring/MemoryUsage/from/from001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadInfo/from_c/from_c001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadInfo/getLockName/getlockname001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadInfo/isInNative/isinnative001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find006/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset005/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel001/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel002/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel003/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel004/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel005/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel001/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel002/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel003/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel004/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel005/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername001/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername002/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername003/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername004/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername005/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames001/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames002/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames003/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames004/TestDescription.java \
+  vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames005/TestDescription.java \
+  vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount001/TestDescription.java \
+  vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount002/TestDescription.java \
+  vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount003/TestDescription.java \
+  vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount004/TestDescription.java \
+  vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount005/TestDescription.java \
+  vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime001/TestDescription.java \
+  vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime002/TestDescription.java \
+  vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime003/TestDescription.java \
+  vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime004/TestDescription.java \
+  vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime005/TestDescription.java \
+  vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean001/RuntimeMXBean001.java \
+  vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean002/TestDescription.java \
+  vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean003/TestDescription.java \
+  vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean004/TestDescription.java \
+  vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean005/TestDescription.java \
+  vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean006/RuntimeMXBean006.java \
+  vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean007/TestDescription.java \
+  vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean008/TestDescription.java \
+  vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean009/TestDescription.java \
+  vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean010/TestDescription.java \
+  vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon001/comptimemon001.java \
+  vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon002/TestDescription.java \
+  vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon003/TestDescription.java \
+  vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon004/TestDescription.java \
+  vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread001/RunningThread001.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock002/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock003/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock004/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock005/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/NativeDeadlock001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/SynchronizerDeadlock001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/SynchronizedMethodDeadlock001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/MixedDeadlock001/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_directly/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_server_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_server_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_proxy_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_proxy_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_directly/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_server_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_server_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_proxy_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_proxy_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_directly/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_server_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_server_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_proxy_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_proxy_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_directly/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_server_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_server_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_proxy_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_proxy_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_directly_array/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_default_array/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_custom_array/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_default_array/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_custom_array/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_directly_string/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_default_string/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_custom_string/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_default_string/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_custom_string/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_directly_array/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_default_array/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_custom_array/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_default_array/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_custom_array/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_directly_string/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_default_string/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_custom_string/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_default_string/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_custom_string/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_directly/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_server_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_server_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_proxy_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_proxy_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_directly/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_server_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_server_custom/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_proxy_default/TestDescription.java \
+  vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_proxy_custom/TestDescription.java
+
+
--- a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java	Fri May 04 08:50:01 2018 -0700
@@ -134,8 +134,6 @@
         // Humongous Eager Reclaim
         new LogMessageWithLevel("Humongous Reclaim", Level.DEBUG),
         new LogMessageWithLevel("Humongous Register", Level.DEBUG),
-        // Preserve CM Referents
-        new LogMessageWithLevel("Preserve CM Refs", Level.DEBUG),
         // Merge PSS
         new LogMessageWithLevel("Merge Per-Thread State", Level.DEBUG),
         // TLAB handling
--- a/test/hotspot/jtreg/gtest/GTestWrapper.java	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/jtreg/gtest/GTestWrapper.java	Fri May 04 08:50:01 2018 -0700
@@ -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
@@ -30,6 +30,7 @@
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Stream;
 import java.util.stream.Collectors;
 
@@ -59,12 +60,31 @@
         if (!path.toFile().exists()) {
             throw new Error("TESTBUG: the library has not been found in " + nativePath);
         }
-        path = path.resolve("gtestLauncher" + (Platform.isWindows() ? ".exe" : ""));
-        ProcessTools.executeCommand(new String[] {
-                path.toString(),
-                "-jdk",
-                System.getProperty("test.jdk")
-        }).shouldHaveExitValue(0);
+
+        Path execPath = path.resolve("gtestLauncher" + (Platform.isWindows() ? ".exe" : ""));
+        ProcessBuilder pb = new ProcessBuilder();
+        Map<String, String> env = pb.environment();
+
+        // The GTestWrapper was started using the normal java launcher, which
+        // may have set LD_LIBRARY_PATH or LIBPATH to point to the jdk libjvm. In
+        // that case, prepend the path with the location of the gtest library."
+
+        String ldLibraryPath = System.getenv("LD_LIBRARY_PATH");
+        if (ldLibraryPath != null) {
+            env.put("LD_LIBRARY_PATH", path + ":" + ldLibraryPath);
+        }
+
+        String libPath = System.getenv("LIBPATH");
+        if (libPath != null) {
+            env.put("LIBPATH", path + ":" + libPath);
+        }
+
+        pb.command(new String[] {
+            execPath.toString(),
+            "-jdk",
+            System.getProperty("test.jdk")
+        });
+        ProcessTools.executeCommand(pb).shouldHaveExitValue(0);
     }
 
     private static String getJVMVariantSubDir() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,148 @@
+import static java.io.File.createTempFile;
+import static java.lang.Long.parseLong;
+import static java.lang.System.getProperty;
+import static java.lang.management.ManagementFactory.getOperatingSystemMXBean;
+import static java.nio.file.Files.readAllBytes;
+import static jdk.test.lib.process.ProcessTools.createJavaProcessBuilder;
+
+import java.io.File;
+import java.io.IOException;
+
+import com.sun.management.UnixOperatingSystemMXBean;
+
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 TestInheritFD
+ * @bug 8176717 8176809
+ * @summary a new process should not inherit open file descriptors
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ */
+
+/**
+ * Test that HotSpot does not leak logging file descriptors.
+ *
+ * This test is performed in three steps. The first VM starts a second VM with
+ * gc logging enabled. The second VM starts a third VM and redirects the third
+ * VMs output to the first VM, it then exits and hopefully closes its log file.
+ *
+ * The third VM waits for the second to exit and close its log file. After that,
+ * the third VM tries to rename the log file of the second VM. If it succeeds in
+ * doing so it means that the third VM did not inherit the open log file
+ * (windows can not rename opened files easily)
+ *
+ * The third VM communicates the success to rename the file by printing "CLOSED
+ * FD". The first VM checks that the string was printed by the third VM.
+ *
+ * On unix like systems, UnixOperatingSystemMXBean is used to check open file
+ * descriptors.
+ */
+
+public class TestInheritFD {
+
+    public static final String LEAKS_FD = "VM RESULT => LEAKS FD";
+    public static final String RETAINS_FD = "VM RESULT => RETAINS FD";
+    public static final String EXIT = "VM RESULT => VM EXIT";
+
+    // first VM
+    public static void main(String[] args) throws Exception {
+        String logPath = createTempFile("logging", ".log").getName();
+        File commFile = createTempFile("communication", ".txt");
+
+        ProcessBuilder pb = createJavaProcessBuilder(
+            "-Xlog:gc:\"" + logPath + "\"",
+            "-Dtest.jdk=" + getProperty("test.jdk"),
+            VMStartedWithLogging.class.getName(),
+            logPath);
+
+        pb.redirectOutput(commFile); // use temp file to communicate between processes
+        pb.start();
+
+        String out = "";
+        do {
+            out = new String(readAllBytes(commFile.toPath()));
+            Thread.sleep(100);
+            System.out.println("SLEEP 100 millis");
+        } while (!out.contains(EXIT));
+
+        System.out.println(out);
+        if (out.contains(RETAINS_FD)) {
+            System.out.println("Log file was not inherited by third VM");
+        } else {
+            throw new RuntimeException("could not match: " + RETAINS_FD);
+        }
+    }
+
+    static class VMStartedWithLogging {
+        // second VM
+        public static void main(String[] args) throws IOException, InterruptedException {
+            ProcessBuilder pb = createJavaProcessBuilder(
+                "-Dtest.jdk=" + getProperty("test.jdk"),
+                VMShouldNotInheritFileDescriptors.class.getName(),
+                args[0],
+                "" + ProcessHandle.current().pid(),
+                "" + (supportsUnixMXBean()?+unixNrFD():-1));
+            pb.inheritIO(); // in future, redirect information from third VM to first VM
+            pb.start();
+        }
+    }
+
+    static class VMShouldNotInheritFileDescriptors {
+        // third VM
+        public static void main(String[] args) throws InterruptedException {
+            File logFile = new File(args[0]);
+            long parentPid = parseLong(args[1]);
+            long parentFDCount = parseLong(args[2]);
+
+            if(supportsUnixMXBean()){
+                long thisFDCount = unixNrFD();
+                System.out.println("This VM FD-count (" + thisFDCount + ") should be strictly less than parent VM FD-count (" + parentFDCount + ") as log file should have been closed");
+                System.out.println(thisFDCount<parentFDCount?RETAINS_FD:LEAKS_FD);
+            } else if (getProperty("os.name").toLowerCase().contains("win")) {
+                windows(logFile, parentPid);
+            } else {
+                System.out.println(LEAKS_FD); // default fail on unknown configuration
+            }
+            System.out.println(EXIT);
+        }
+    }
+
+    static boolean supportsUnixMXBean() {
+        return getOperatingSystemMXBean() instanceof UnixOperatingSystemMXBean;
+    }
+
+    static long unixNrFD() {
+        UnixOperatingSystemMXBean osBean = (UnixOperatingSystemMXBean) getOperatingSystemMXBean();
+        return osBean.getOpenFileDescriptorCount();
+    }
+
+    static void windows(File f, long parentPid) throws InterruptedException {
+        System.out.println("waiting for pid: " + parentPid);
+        ProcessHandle.of(parentPid).ifPresent(handle -> handle.onExit().join());
+        System.out.println("trying to rename file to the same name: " + f);
+        System.out.println(f.renameTo(f)?RETAINS_FD:LEAKS_FD); // this parts communicates a closed file descriptor by printing "CLOSED FD"
+    }
+}
\ No newline at end of file
--- a/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * 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,14 +85,14 @@
     Pattern [] pattern = new Pattern[] {
         // The "Current thread" line should show a hazard ptr and
         // a nested hazard ptr:
-        Pattern.compile("Current thread .* _threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*, _nested_threads_hazard_ptr_cnt=1, _nested_threads_hazard_ptrs=0x.*"),
+        Pattern.compile("Current thread .* _threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*, _nested_threads_hazard_ptr_cnt=1, _nested_threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*.*"),
         // We should have a section of Threads class SMR info:
         Pattern.compile("Threads class SMR info:"),
         // We should have one nested ThreadsListHandle:
         Pattern.compile(".*, _nested_thread_list_max=1"),
         // The current thread (marked with '=>') in the threads list
-        // should show a hazard ptr:
-        Pattern.compile("=>.* JavaThread \"main\" .*_threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*, _nested_threads_hazard_ptr_cnt=1, _nested_threads_hazard_ptrs=0x.*"),
+        // should show a hazard ptr and a nested hazard ptr:
+        Pattern.compile("=>.* JavaThread \"main\" .* _threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*, _nested_threads_hazard_ptr_cnt=1, _nested_threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*.*"),
     };
     int currentPattern = 0;
 
--- a/test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,13 +83,14 @@
     String line = null;
 
     Pattern [] pattern = new Pattern[] {
-        // The "Current thread" line should show a hazard ptr:
-        Pattern.compile("Current thread .* _threads_hazard_ptr=0x.*"),
+        // The "Current thread" line should show a hazard ptr
+        // and no nested hazard ptrs:
+        Pattern.compile("Current thread .* _threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*, _nested_threads_hazard_ptr_cnt=0.*"),
         // We should have a section of Threads class SMR info:
         Pattern.compile("Threads class SMR info:"),
         // The current thread (marked with '=>') in the threads list
-        // should show a hazard ptr:
-        Pattern.compile("=>.* JavaThread \"main\" .*_threads_hazard_ptr=0x.*"),
+        // should show a hazard ptr and no nested hazard ptrs:
+        Pattern.compile("=>.* JavaThread \"main\" .* _threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*, _nested_threads_hazard_ptr_cnt=0.*"),
     };
     int currentPattern = 0;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, SAP and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.JDKToolFinder;
+
+/*
+ * @test
+ * @key metaspace jcmd
+ * @summary Test the VM.metaspace command
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ * @run main/othervm -XX:MaxMetaspaceSize=201M -XX:+VerifyMetaspace -XX:+UseCompressedClassPointers PrintMetaspaceDcmd with-compressed-class-space
+ * @run main/othervm -XX:MaxMetaspaceSize=201M -XX:+VerifyMetaspace -XX:-UseCompressedClassPointers PrintMetaspaceDcmd without-compressed-class-space
+ */
+
+public class PrintMetaspaceDcmd {
+
+    // Run jcmd VM.metaspace against a VM with CompressedClassPointers on.
+    // The report should detail Non-Class and Class portions separately.
+    private static void doTheTest(boolean usesCompressedClassSpace) throws Exception {
+        ProcessBuilder pb = new ProcessBuilder();
+        OutputAnalyzer output;
+        // Grab my own PID
+        String pid = Long.toString(ProcessTools.getProcessId());
+
+        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "basic"});
+        output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+        if (usesCompressedClassSpace) {
+            output.shouldContain("Non-Class:");
+            output.shouldContain("Class:");
+        }
+        output.shouldContain("Virtual space:");
+        output.shouldContain("Chunk freelists:");
+
+
+        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace"});
+        output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+        if (usesCompressedClassSpace) {
+            output.shouldContain("Non-Class:");
+            output.shouldContain("Class:");
+        }
+        output.shouldContain("Virtual space:");
+        output.shouldContain("Chunk freelist");
+        output.shouldContain("Waste");
+        output.shouldMatch("MaxMetaspaceSize:.*201.00.*MB");
+
+        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "show-loaders"});
+        output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+        output.shouldMatch("ClassLoaderData.*for <bootloader>");
+
+        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "by-chunktype"});
+        output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+        output.shouldContain("specialized:");
+        output.shouldContain("small:");
+        output.shouldContain("medium:");
+        output.shouldContain("humongous:");
+
+        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "vslist"});
+        output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+        output.shouldContain("Virtual space list");
+        output.shouldMatch("node.*reserved.*committed.*used.*");
+
+        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "vsmap"});
+        output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+        output.shouldContain("Virtual space map:");
+        output.shouldContain("HHHHHHHHHHH");
+
+        // Test with different scales
+        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "scale=G"});
+        output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+        output.shouldMatch("MaxMetaspaceSize:.*0.2.*GB");
+
+        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "scale=K"});
+        output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+        output.shouldMatch("MaxMetaspaceSize:.*205824.00 KB");
+
+        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "scale=1"});
+        output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+        output.shouldMatch("MaxMetaspaceSize:.*210763776 bytes");
+    }
+
+    public static void main(String args[]) throws Exception {
+        boolean testForCompressedClassSpace = false;
+        if (args[0].equals("with-compressed-class-space")) {
+            testForCompressedClassSpace = true;
+        } else if (args[0].equals("without-compressed-class-space")) {
+            testForCompressedClassSpace = false;
+        } else {
+            throw new IllegalArgumentException("Invalid argument: " + args[0]);
+        }
+        doTheTest(testForCompressedClassSpace);
+    }
+}
--- a/test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java	Fri May 04 08:50:01 2018 -0700
@@ -46,6 +46,10 @@
     OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
     output_detail.shouldContain("Virtual memory map:");
     output_detail.shouldContain("Details:");
+
+    // PrintNMTStatistics also prints out metaspace statistics as a convenience.
+    output_detail.shouldContain("Metaspace:");
+
     output_detail.shouldHaveExitValue(0);
 
     // Make sure memory reserved for Module processing is recorded.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon001/comptimemon001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/CompilationMXBean/comptimemon001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         CompilationMBean.isCompilationTimeMonitoringSupported()
+ *     method returns true. The test performs directly access to management
+ *     metrics within the same JVM.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ *     The test passes, if the JVM has no compilation system, for example the
+ *     test is invoked with -Xint option.
+ * COMMENT
+ *     Fixed the bug:
+ *     4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/timeout=300 nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001
+ */
+
+package nsk.monitoring.CompilationMXBean.comptimemon001;
+
+import java.io.*;
+import nsk.share.test.*;
+import nsk.share.TestFailure;
+import nsk.monitoring.share.*;
+import java.lang.management.*;
+
+public class comptimemon001 extends MonitoringTestBase implements Initializable {
+        private CompilationMXBean compilation;
+        private int iterations = 30;
+
+        public void initialize() {
+                if (monitoringFactory.hasCompilationMXBean())
+                        compilation = monitoringFactory.getCompilationMXBean();
+        }
+
+        public boolean testCompilationTimeMonitoringSupported() {
+                if (compilation == null) {
+                        // The JVM has no compilation system, for example the test is
+                        // invoked with -Xint option
+                        log.info("The JVM has no compilation system.");
+                        return false;
+                } else if (!compilation.isCompilationTimeMonitoringSupported()) {
+                        // Check the method is... for the specified way of access to MBeans
+                        log.error("Monitoring of compilation time is not supported.\n");
+                        setFailed(true);
+                        return false;
+                }
+                return true;
+        }
+
+        private void testCompilationTimeOne() {
+                long sleepTime = LocalRandom.randomPauseTime();
+                long startTime = compilation.getTotalCompilationTime();
+                if (startTime < 0)
+                        throw new TestFailure("getTotalCompilationTime < 0: " + startTime);
+                try {
+                        Thread.sleep(sleepTime);
+                } catch (InterruptedException e) {
+                        throw new TestFailure("Sleep was interrupted.");
+                }
+                long finishTime = compilation.getTotalCompilationTime();
+                if (finishTime < 0)
+                        throw new TestFailure("getTotalCompilationTime < 0: " + finishTime);
+                if (finishTime < startTime)
+                        throw new TestFailure("getTotalCompilationTime before sleep: " + startTime
+                                + " > getTotalCompilationTime after sleep: " + finishTime);
+        }
+
+        public void testCompilationTime() {
+                for (int i = 0; i < iterations; ++i)
+                        testCompilationTimeOne();
+        }
+
+        public void run() {
+                if (!testCompilationTimeMonitoringSupported())
+                        return;
+                testCompilationTime();
+        }
+
+        public static void main(String[] args) {
+                Monitoring.runTest(new comptimemon001(), args);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/CompilationMXBean/comptimemon002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         CompilationMBean.isCompilationTimeMonitoringSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through default MBeanServer.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ *     The test passes, if the JVM has no compilation system, for example the
+ *     test is invoked with -Xint option.
+ * COMMENTS
+ *     Fixed the bug:
+ *     4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/timeout=300
+ *      nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/CompilationMXBean/comptimemon003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         CompilationMBean.isCompilationTimeMonitoringSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through custom MBeanServer (developed and saved in
+ *     $TESTBASE/src/nsk/monitoring/share).
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ *     The test passes, if the JVM has no compilation system, for example the
+ *     test is invoked with -Xint option.
+ * COMMENTS
+ *     Fixed the bug:
+ *     4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/timeout=300
+ *      nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/CompilationMXBean/comptimemon004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         CompilationMBean.isCompilationTimeMonitoringSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through default MBeanServer proxy.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ *     The test passes, if the JVM has no compilation system, for example the
+ *     test is invoked with -Xint option.
+ * COMMENTS
+ *     Fixed the bug:
+ *     4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/timeout=300
+ *      nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/CompilationMXBean/comptimemon005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         CompilationMBean.isCompilationTimeMonitoringSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through custom MBeanServer proxy (developed and saved in
+ *     $TESTBASE/src/nsk/monitoring/share).
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ *     The test passes, if the JVM has no compilation system, for example the
+ *     test is invoked with -Xint option.
+ * COMMENTS
+ *     Fixed the bug:
+ *     4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/timeout=300
+ *      nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters001/CollectionCounters001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters001.
+ * VM Testbase keywords: [monitoring]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
+ *      -testMode=directly
+ */
+
+package nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001;
+
+import java.util.List;
+import java.lang.management.*;
+import nsk.share.TestFailure;
+import nsk.share.test.*;
+import nsk.monitoring.share.*;
+import nsk.share.gc.Algorithms;
+import nsk.share.runner.RunParams;
+import nsk.share.runner.RunParamsAware;
+
+/**
+ * Test counters from GarbageCollectorMXBean.
+ *
+ * In this test, we do some operations on heap and check that total
+ * counters from all GarbageCollectorBeans do not decrease and actually
+ * increase in some situations.
+ *
+ * This also checks that counters increase after MemoryMXBean.gc().
+ *
+ * Note: we assume that System.gc() increases collection count and
+ * time. It may be false with -XX:+DisableExplicitGC.
+ */
+public class CollectionCounters001 extends MonitoringTestBase implements RunParamsAware, Initializable {
+        private List<GarbageCollectorMXBean> gcBeans;
+        private MemoryMXBean memory;
+        Stresser stresser;
+        RunParams runParams;
+        private long collectionCount;
+        private long collectionTime;
+        private long collectionCountOld;
+        private long collectionTimeOld;
+
+        public void initialize() {
+                gcBeans = monitoringFactory.getGarbageCollectorMXBeans();
+                memory = monitoringFactory.getMemoryMXBean();
+        }
+
+        private void runOne(ExecutionController stresser) {
+                updateCounters();
+                validate();
+                Algorithms.eatMemory(stresser);
+                        if(stresser.continueExecution()) {
+                    updateCounters();
+                    validateNonTrivial();
+                    System.gc();
+                    updateCounters();
+                    validateNonTrivial();
+                    memory.gc();
+                    updateCounters();
+                    validateNonTrivial();
+                        }
+        }
+
+        public void run() {
+                stresser = new Stresser(runParams.getStressOptions());
+                stresser.start(runParams.getIterations());
+                while (stresser.iteration()) {
+                    runOne(stresser);
+                }
+        }
+
+        private void validate() {
+                if (collectionCount < 0)
+                        throw new TestFailure("collectionCount negative: " + collectionCount);
+                if (collectionTime < 0)
+                        throw new TestFailure("collectionTime negative: " + collectionTime);
+                if (collectionCount < collectionCountOld)
+                        throw new TestFailure("collectionCount decreased: " + collectionCount + " -> " + collectionCountOld);
+                if (collectionTime < collectionTimeOld)
+                        throw new TestFailure("collectionTime decreased: " + collectionTime + " -> " + collectionTimeOld);
+        }
+
+        private void validateNonTrivial() {
+                if (collectionCount < 0)
+                        throw new TestFailure("collectionCount negative: " + collectionCount);
+                if (collectionTime < 0)
+                        throw new TestFailure("collectionTime negative: " + collectionTime);
+                if (collectionCount <= collectionCountOld)
+                        throw new TestFailure("collectionCount not increased: " + collectionCount + " -> " + collectionCountOld);
+                if (collectionTime < collectionTimeOld)
+                        throw new TestFailure("collection time became smaller: " + collectionTime + " -> " + collectionTimeOld);
+        }
+
+        private void updateCounters() {
+                collectionCountOld = collectionCount;
+                collectionTimeOld = collectionTime;
+                collectionCount = 0;
+                collectionTime = 0;
+                for (GarbageCollectorMXBean gcBean : gcBeans) {
+                        collectionCount += gcBean.getCollectionCount();
+                        collectionTime += gcBean.getCollectionTime();
+                }
+        }
+
+        public static void main(String[] args) {
+                Monitoring.runTest(new CollectionCounters001(), args);
+        }
+
+    @Override
+    public void setRunParams(RunParams runParams) {
+        this.runParams = runParams;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters002.
+ * VM Testbase keywords: [monitoring]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters003.
+ * VM Testbase keywords: [monitoring]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters004.
+ * VM Testbase keywords: [monitoring]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters005.
+ * VM Testbase keywords: [monitoring]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.GarbageCollectorMXBean.getCollectionCount;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class getcollectioncount001 {
+
+    private static boolean testFailed = false;
+
+    public static void main(String[] args) {
+
+        System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
+    }
+
+    private static Log log;
+
+    static int run(String[] args, PrintStream out) {
+
+        ArgumentHandler argumentHandler = new ArgumentHandler(args);
+        log = new Log(out, argumentHandler);
+
+        // Test case 1. check that
+        // getCollectionCount() does not throw unexpected exceptions
+
+        System.gc();
+        System.gc();
+        System.gc();
+
+        GarbageCollectorMonitor gcMonitor =
+        Monitor.getGarbageCollectorMonitor(log, argumentHandler);
+
+        Object[] pool = gcMonitor.getGarbageCollectorMXBeans();
+        for (int i=0; i<pool.length; i++) {
+
+            String beanName = "";
+            long collectionCount = gcMonitor.getCollectionCount(pool[i]);
+
+            if (pool[i] instanceof javax.management.ObjectName) {
+                beanName = ((javax.management.ObjectName)pool[i]).toString();
+            } else {
+                beanName = ((java.lang.management.GarbageCollectorMXBean)
+                    pool[i]).getName();
+            }
+            log.display(beanName+": getCollectionCount() = "+collectionCount);
+
+            if (collectionCount < -1) {
+                // value can be non-negative or -1 if if the collection count
+                // is undefined for this collector.
+                log.complain("FAILURE 1.");
+                log.complain("getCollectionCount() returns unexpected value: " +
+                    collectionCount);
+                testFailed = true;
+            }
+        }
+
+        if (testFailed)
+            log.complain("TEST FAILED");
+
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.GarbageCollectorMXBean
+ *         Method: getCollectionCount()
+ *         This method returns the total number of collections that have occurred
+ *         Access to metrics is provided in following way: directly.
+ *     The test checks that
+ *         1. Returns the total number of collections that have occurred.
+ *         2. This method returns -1 if the collection count is undefined for this
+ *             collector.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.GarbageCollectorMXBean.getCollectionCount.getcollectioncount001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.GarbageCollectorMXBean
+ *         Method: getCollectionCount()
+ *         This method returns the total number of collections that have occurred
+ *         Access to metrics is provided in following way: default MBeanServer.
+ *     The test checks that
+ *         1. Returns the total number of collections that have occurred.
+ *         2. This method returns -1 if the collection count is undefined for this
+ *             collector.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.getCollectionCount.getcollectioncount001
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.GarbageCollectorMXBean
+ *         Method: getCollectionCount()
+ *         This method returns the total number of collections that have occurred
+ *         Access to metrics is provided in following way: custom MBeanServer.
+ *     The test checks that
+ *         1. Returns the total number of collections that have occurred.
+ *         2. This method returns -1 if the collection count is undefined for this
+ *             collector.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.getCollectionCount.getcollectioncount001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.GarbageCollectorMXBean
+ *         Method: getCollectionCount()
+ *         This method returns the total number of collections that have occurred
+ *         Access to metrics is provided in following way: default MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. Returns the total number of collections that have occurred.
+ *         2. This method returns -1 if the collection count is undefined for this
+ *             collector.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.getCollectionCount.getcollectioncount001
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.GarbageCollectorMXBean
+ *         Method: getCollectionCount()
+ *         This method returns the total number of collections that have occurred
+ *         Access to metrics is provided in following way: custom MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. Returns the total number of collections that have occurred.
+ *         2. This method returns -1 if the collection count is undefined for this
+ *             collector.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.getCollectionCount.getcollectioncount001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.GarbageCollectorMXBean.getCollectionTime;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class getcollectiontime001 {
+
+    private static boolean testFailed = false;
+
+    public static void main(String[] args) {
+
+        System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
+    }
+
+    private static Log log;
+
+    static int run(String[] args, PrintStream out) {
+
+        ArgumentHandler argumentHandler = new ArgumentHandler(args);
+        log = new Log(out, argumentHandler);
+
+        // Test case 1. check that
+        // getCollectionTime() does not throw unexpected exceptions
+
+        System.gc();
+        System.gc();
+        System.gc();
+
+        GarbageCollectorMonitor gcMonitor = Monitor.getGarbageCollectorMonitor(
+            log,
+            argumentHandler);
+
+        Object[] pool = gcMonitor.getGarbageCollectorMXBeans();
+        for (int i=0; i<pool.length; i++) {
+
+            String beanName = "";
+            long collectionTime = gcMonitor.getCollectionTime(pool[i]);
+
+            if (pool[i] instanceof javax.management.ObjectName) {
+                beanName = ((javax.management.ObjectName)pool[i]).toString();
+            } else {
+                beanName = ((java.lang.management.GarbageCollectorMXBean)
+                    pool[i]).getName();
+            }
+            log.display(beanName+": getCollectionTime() = "+collectionTime);
+
+            if (collectionTime < -1) {
+                // value can be non-negative or -1 if if the collection elapsed
+                // time is undefined for this collector.
+                log.complain("FAILURE 1.");
+                log.complain("getCollectionTime() returns unexpected value: " +
+                collectionTime);
+                testFailed = true;
+            }
+        }
+
+        if (testFailed)
+            log.complain("TEST FAILED");
+
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.GarbageCollectorMXBean
+ *         Method: getCollectionTime()
+ *         This method returns the approximate accumulated collection elapsed time
+ *             in milliseconds
+ *         Access to metrics is provided in following way: directly.
+ *     The test checks that
+ *         1. Returns the total number of collections that have occurred.
+ *         2. This method returns -1 if the collection count is undefined for this
+ *             collector.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.GarbageCollectorMXBean.getCollectionTime.getcollectiontime001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.GarbageCollectorMXBean
+ *         Method: getCollectionTime()
+ *         This method returns the approximate accumulated collection elapsed time
+ *             in milliseconds
+ *         Access to metrics is provided in following way: default MBeanServer.
+ *     The test checks that
+ *         1. Returns the total number of collections that have occurred.
+ *         2. This method returns -1 if the collection count is undefined for this
+ *             collector.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.getCollectionTime.getcollectiontime001
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.GarbageCollectorMXBean
+ *         Method: getCollectionTime()
+ *         This method returns the approximate accumulated collection elapsed time
+ *             in milliseconds
+ *         Access to metrics is provided in following way: custom MBeanServer.
+ *     The test checks that
+ *         1. Returns the total number of collections that have occurred.
+ *         2. This method returns -1 if the collection count is undefined for this
+ *             collector.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.getCollectionTime.getcollectiontime001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.GarbageCollectorMXBean
+ *         Method: getCollectionTime()
+ *         This method returns the approximate accumulated collection elapsed time
+ *             in milliseconds
+ *         Access to metrics is provided in following way: default MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. Returns the total number of collections that have occurred.
+ *         2. This method returns -1 if the collection count is undefined for this
+ *             collector.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.getCollectionTime.getcollectiontime001
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.GarbageCollectorMXBean
+ *         Method: getCollectionTime()
+ *         This method returns the approximate accumulated collection elapsed time
+ *             in milliseconds
+ *         Access to metrics is provided in following way: custom MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. Returns the total number of collections that have occurred.
+ *         2. This method returns -1 if the collection count is undefined for this
+ *             collector.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.GarbageCollectorMXBean.getCollectionTime.getcollectiontime001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LockTest/LockTest001/LockTest001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LockTest/LockTest001.
+ * VM Testbase keywords: [monitoring, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.LockTest.LockTest001.LockTest001
+ */
+
+package nsk.monitoring.LockTest.LockTest001;
+
+import java.lang.management.ThreadInfo;
+import java.lang.management.ManagementFactory;
+
+import nsk.share.TestFailure;
+
+public class LockTest001
+{
+  private Object syncObj = new Object();
+
+  public LockTest001()
+  {  }
+
+  public void test()
+  {
+
+    int localVar0, localVar1, localVar2, localVar3, localVar4, localVar5, localVar6, localVar7, localVar8, localVar9;
+    int localVar10, localVar11, localVar12, localVar13, localVar14, localVar15, localVar16, localVar17, localVar18, localVar19;
+    int localVar20, localVar21, localVar22, localVar23, localVar24, localVar25, localVar26, localVar27, localVar28, localVar29;
+    int localVar30, localVar31, localVar32, localVar33, localVar34, localVar35, localVar36, localVar37, localVar38, localVar39;
+    int localVar40, localVar41, localVar42, localVar43, localVar44, localVar45, localVar46, localVar47, localVar48, localVar49;
+
+    String threadName = Thread.currentThread().getName();
+    System.out.println(threadName + ": Entering test()");
+
+    synchronized (syncObj)
+    {
+      int n = 0;
+      for (int i = 0; i < 10000000; i++)
+        n += i;
+      logMonitors((n & 1) >>> (n & 1));
+    } // end sync
+
+    logMonitors(1);
+
+    synchronized (syncObj)
+    {
+      logMonitors(2);
+    }
+    logMonitors(3);
+
+    System.out.println(threadName + ": Leaving test()");
+    return;
+  }
+
+  public static void logMonitors(int n)
+  {
+    String threadName = Thread.currentThread().getName();
+    java.lang.management.MonitorInfo[] monitors = java.lang.management.ManagementFactory.getThreadMXBean()
+                                                  .getThreadInfo(new long[] { Thread.currentThread().getId() }, true, true)[0].getLockedMonitors();
+    System.out.println(threadName + ": Checkpoint #" + n + ", number of monitors: " + monitors.length);
+    if ((n == 3) && (monitors.length > 0))
+      System.out.println(threadName + ": MONITOR HELD AFTER EXITING SYNCHRONIZED BLOCK!");
+    for (int i = 0; i < monitors.length; i++)
+    {
+      java.lang.management.MonitorInfo monitor = monitors[i];
+      System.out.println(threadName + ": MonitorInfo[" + i + "]=" + monitor.toString() + ", StackDepth=" + monitor.getLockedStackDepth()
+                         + ", frame=" + ((monitor.getLockedStackFrame() == null) ? "No Frame" : monitor.getLockedStackFrame().toString()));
+    }
+    return;
+  }
+
+  public static void main(String[] argv)
+  {
+    LockTest001 lt = new LockTest001();
+    RunLockTest rlt = new RunLockTest(lt, 10000);
+    Thread t = new Thread(rlt);
+    System.out.println("main: About to start first thread: " + t.getName());
+    t.start();
+
+    synchronized (rlt)
+    {
+      while (!rlt.finishedTest)
+      {
+        try
+        {  rlt.wait();  }
+        catch (Exception e)
+        {  }
+      }
+    }
+
+    rlt = new RunLockTest(lt, 0);
+    t = new Thread(rlt);
+    System.out.println("main: About to start second thread: " + t.getName());
+    t.start();
+
+    // amount of time to wait for the thread. In case of buggy behavior, the thread will hang forever.
+    // but long enough to complete test on busy boxes
+    long endTime = System.currentTimeMillis() + 5 * 60 * 1000;
+
+    boolean isError = true;
+
+    while (System.currentTimeMillis() < endTime)
+    {
+      if (t.getState() == Thread.State.TERMINATED)
+      {
+          isError = false;
+          break;
+      }
+      try
+      {  Thread.currentThread().sleep(1000);  }
+      catch (Exception e)
+      {  }
+      ThreadInfo[] tis = ManagementFactory.getThreadMXBean().getThreadInfo(new long[] { t.getId() }, true, true);
+      if (tis.length == 0)
+        System.out.println("Unable to find the thread " + t.getName());
+      else
+      {
+        ThreadInfo ti = tis[0];
+        if (ti == null)
+          System.out.println("Unable to get info for thread: " + t.getName());
+        else
+          System.out.println(t.getName() + " state: " + ti.getThreadState().toString() +
+                             ", LockName: " + ti.getLockName() + ", LockOwnerName: " + ti.getLockOwnerName());
+      }
+    }
+
+    if (!isError)
+        System.out.println("TEST PASSED");
+    else
+        throw new TestFailure("TEST FAILED");
+    return;
+  }
+
+  public static class RunLockTest implements Runnable
+  {
+    public LockTest001 lt;
+    public boolean finishedTest = false;
+    public long sleepLength;
+
+    public RunLockTest(LockTest001 _lt, long _sleepLength)
+    {
+      lt = _lt;
+      sleepLength = _sleepLength;
+    }
+
+    public void run()
+    {
+      lt.test();
+      synchronized (this)
+      {
+        finishedTest = true;
+        this.notify();
+      }
+      if (sleepLength > 0)
+      {
+        try
+        {  Thread.currentThread().sleep(sleepLength);  }
+        catch (Exception e)
+        {  }
+      }
+      System.out.println(Thread.currentThread().getName() + ": exiting");
+      return;
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LockTest/LockTest002/LockTest002.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LockTest/LockTest002.
+ * VM Testbase keywords: [monitoring, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.LockTest.LockTest002.LockTest002
+ */
+
+package nsk.monitoring.LockTest.LockTest002;
+
+import java.lang.management.ThreadInfo;
+import java.lang.management.ManagementFactory;
+
+import nsk.share.TestFailure;
+
+public class LockTest002
+{
+  private Object syncObj = new Object();
+
+  public LockTest002()
+  {  }
+
+  public synchronized void test()
+  {
+
+    int localVar0, localVar1, localVar2, localVar3, localVar4, localVar5, localVar6, localVar7, localVar8, localVar9;
+    int localVar10, localVar11, localVar12, localVar13, localVar14, localVar15, localVar16, localVar17, localVar18, localVar19;
+    int localVar20, localVar21, localVar22, localVar23, localVar24, localVar25, localVar26, localVar27, localVar28, localVar29;
+    int localVar30, localVar31, localVar32, localVar33, localVar34, localVar35, localVar36, localVar37, localVar38, localVar39;
+    int localVar40, localVar41, localVar42, localVar43, localVar44, localVar45, localVar46, localVar47, localVar48, localVar49;
+
+    String threadName = Thread.currentThread().getName();
+    System.out.println(threadName + ": Entering test()");
+
+    int n = 0;
+    for (int i = 0; i < 10000000; i++)
+      n += i;
+    System.out.println(threadName + ": Leaving test(), n=" + n);
+    return;
+  }
+
+  public static void logMonitors()
+  {
+    String threadName = Thread.currentThread().getName();
+    java.lang.management.MonitorInfo[] monitors = java.lang.management.ManagementFactory.getThreadMXBean()
+                                                  .getThreadInfo(new long[] { Thread.currentThread().getId() }, true, true)[0].getLockedMonitors();
+    System.out.println(threadName + ": Number of monitors: " + monitors.length);
+    for (int i = 0; i < monitors.length; i++)
+    {
+      java.lang.management.MonitorInfo monitor = monitors[i];
+      System.out.println(threadName + ": MonitorInfo[" + i + "]=" + monitor.toString() + ", StackDepth=" + monitor.getLockedStackDepth()
+                         + ", frame=" + ((monitor.getLockedStackFrame() == null) ? "No Frame" : monitor.getLockedStackFrame().toString()));
+    }
+    return;
+  }
+
+  public static void main(String[] argv)
+  {
+    LockTest002 lt = new LockTest002();
+    RunLockTest rlt = new RunLockTest(lt, 10000);
+    Thread t = new Thread(rlt);
+    System.out.println("main: About to start first thread: " + t.getName());
+    t.start();
+
+    synchronized (rlt)
+    {
+      while (!rlt.finishedTest)
+      {
+        try
+        {  rlt.wait();  }
+        catch (Exception e)
+        {  }
+      }
+    }
+
+    rlt = new RunLockTest(lt, 0);
+    t = new Thread(rlt);
+    System.out.println("main: About to start second thread: " + t.getName());
+    t.start();
+
+    // amount of time to wait for the thread. In case of buggy behavior, the thread will hang forever.
+    // but long enough to complete test on busy boxes
+    long endTime = System.currentTimeMillis() + 5 * 60 * 1000;
+
+    boolean isError = true;
+
+    while (System.currentTimeMillis() < endTime)
+    {
+      if (t.getState() == Thread.State.TERMINATED)
+      {
+          isError = false;
+          break;
+      }
+      try
+      {  Thread.currentThread().sleep(1000);  }
+      catch (Exception e)
+      {  }
+      ThreadInfo[] tis = ManagementFactory.getThreadMXBean().getThreadInfo(new long[] { t.getId() }, true, true);
+      if (tis.length == 0)
+        System.out.println("Unable to find the thread " + t.getName());
+      else
+      {
+        ThreadInfo ti = tis[0];
+        if (ti == null)
+          System.out.println("Unable to get info for thread: " + t.getName());
+        else
+          System.out.println(t.getName() + " state: " + ti.getThreadState().toString() +
+                             ", LockName: " + ti.getLockName() + ", LockOwnerName: " + ti.getLockOwnerName());
+      }
+    }
+
+    if (!isError)
+        System.out.println("TEST PASSED");
+    else
+        throw new TestFailure("TEST FAILED");
+    return;
+  }
+
+  public static class RunLockTest implements Runnable
+  {
+    public LockTest002 lt;
+    public boolean finishedTest = false;
+    public long sleepLength;
+
+    public RunLockTest(LockTest002 _lt, long _sleepLength)
+    {
+      lt = _lt;
+      sleepLength = _sleepLength;
+    }
+
+    public void run()
+    {
+      logMonitors();
+      lt.test();
+      logMonitors();
+      synchronized (this)
+      {
+        finishedTest = true;
+        this.notify();
+      }
+      if (sleepLength > 0)
+      {
+        try
+        {  Thread.currentThread().sleep(sleepLength);  }
+        catch (Exception e)
+        {  }
+      }
+      System.out.println(Thread.currentThread().getName() + ": exiting");
+      return;
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.LoggingMXBean.getLoggerLevel;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import java.util.logging.*;
+
+public class getloggerlevel001 {
+
+    private static boolean testFailed = false;
+
+    public static void main(String[] args) {
+
+        System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
+    }
+
+    private static Log log;
+
+    private static final Level[] LogLevels = new Level[] {
+
+        Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST,
+        Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING
+    };
+
+    static int run(String[] args, PrintStream out) {
+
+        ArgumentHandler argumentHandler = new ArgumentHandler(args);
+        log = new Log(out, argumentHandler);
+
+        LoggingMonitor loggingMonitor = Monitor.getLoggingMonitor(log,
+            argumentHandler);
+
+        // Test case 1. check that
+        // it returns the name of the log level associated with the specified
+        // logger
+        String testLog1Name = getloggerlevel001.class.getName();
+        Logger testLog1 = Logger.getLogger(testLog1Name);
+
+        for (int i=0; i<LogLevels.length; i++) {
+
+            testLog1.setLevel(LogLevels[i]);
+            String mxbeanLevel = loggingMonitor.getLoggerLevel(testLog1Name);
+            if (! LogLevels[i].toString().equals(mxbeanLevel)) {
+
+                testFailed = true;
+                log.complain("Failure 1.");
+                log.complain("LogLevels[i] = "+LogLevels[i].toString());
+                log.complain("loggingMXBean.getLoggerLevel() method returns "
+                    + "unexpected value");
+            }
+        }
+
+
+        // Test case 2. check
+        // if the specified logger does not exist, null is returned
+        if (loggingMonitor.getLoggerLevel("no such logger") != null) {
+
+            testFailed = true;
+            log.complain("Failure 2.");
+            log.complain("loggingMXBean.getLoggerLevel(\"no such logger\") does "
+                + "not return null");
+        }
+
+
+        // A Logger object created with the call Logger.getLogger(testLogName),
+        // stores it in a method local and expects it to be alive in the method scope
+        // after it is not used anymore.
+        // The java.util.logging.LogManager which is used by loggingMonitor stores a WeakReference to
+        // the Logger object being created into a Hashtable.
+        // The WeakReference becomes stale after a GC event, so the tests
+        // are not able to retrieve the expected info about the parent logger
+        // using the child logger name.
+        //
+        // So this synchronized block is needed to guarantee that testLog1 will still be alive
+        // when loggingMonitor.getLoggerLevel is invoked
+        synchronized (testLog1) {
+            // Test case 3. check
+            // if the Level of the specified logger is null, an empty string will
+            // be returned.
+            testLog1.setLevel(null);
+            String returnedLevel = loggingMonitor.getLoggerLevel(testLog1Name);
+            if (returnedLevel == null || !returnedLevel.equals("")) {
+
+                testFailed = true;
+                log.complain("Failure 3.");
+                log.complain("Level of the specified logger is null, but returned "
+                    + "string was not empty: "+returnedLevel);
+            }
+        }
+
+        if (testFailed)
+            log.complain("TEST FAILED");
+
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getLoggerLevel(String loggerName)
+ *         This method first finds the logger of the given name and then returns
+ *             the name of the log level
+ *             by calling: Logger.getLevel().getName()
+ *         Access to metrics is provided in following way: directly.
+ *     The test checks that
+ *         1. it returns the name of the log level associated with the specified
+ *             logger
+ *         2. if the specified logger does not exist, null is returned
+ *         3. if the Level of the specified logger is null, which means that this
+ *             logger's effective level
+ *             is inherited from its parent, an empty string will be returned
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.LoggingMXBean.getLoggerLevel.getloggerlevel001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getLoggerLevel(String loggerName)
+ *         This method first finds the logger of the given name and then returns
+ *             the name of the log level
+ *         by calling: Logger.getLevel().getName()
+ *         Access to metrics is provided in following way: default MBeanServer.
+ *     The test checks that
+ *         1. it returns the name of the log level associated with the specified
+ *             logger
+ *         2. if the specified logger does not exist, null is returned
+ *         3. if the Level of the specified logger is null, which means that this
+ *             logger's effective level
+ *             is inherited from its parent, an empty string will be returned
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getLoggerLevel.getloggerlevel001
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getLoggerLevel(String loggerName)
+ *         This method first finds the logger of the given name and then returns
+ *             the name of the log level
+ *         by calling: Logger.getLevel().getName()
+ *         Access to metrics is provided in following way: custom MBeanServer.
+ *     The test checks that
+ *         1. it returns the name of the log level associated with the specified
+ *             logger
+ *         2. if the specified logger does not exist, null is returned
+ *         3. if the Level of the specified logger is null, which means that this
+ *             logger's effective level
+ *             is inherited from its parent, an empty string will be returned
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getLoggerLevel.getloggerlevel001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getLoggerLevel(String loggerName)
+ *         This method first finds the logger of the given name and then returns
+ *             the name of the log level
+ *         by calling: Logger.getLevel().getName()
+ *         Access to metrics is provided in following way: default MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. it returns the name of the log level associated with the specified
+ *             logger
+ *         2. if the specified logger does not exist, null is returned
+ *         3. if the Level of the specified logger is null, which means that this
+ *             logger's effective level
+ *             is inherited from its parent, an empty string will be returned
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getLoggerLevel.getloggerlevel001
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getLoggerLevel(String loggerName)
+ *         This method first finds the logger of the given name and then returns
+ *             the name of the log level
+ *         by calling: Logger.getLevel().getName()
+ *         Access to metrics is provided in following way: custom MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. it returns the name of the log level associated with the specified
+ *             logger
+ *         2. if the specified logger does not exist, null is returned
+ *         3. if the Level of the specified logger is null, which means that this
+ *             logger's effective level
+ *             is inherited from its parent, an empty string will be returned
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getLoggerLevel.getloggerlevel001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.LoggingMXBean.getLoggerNames;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import java.util.*;
+import java.util.logging.*;
+
+import javax.management.*;
+
+public class getloggernames001 {
+
+    private static boolean testFailed = false;
+
+    public static void main(String[] args) {
+
+        System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
+    }
+
+    private static Log log;
+
+    private static final Level[] LogLevels = new Level[] {
+
+        Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST,
+        Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING
+    };
+
+    static int run(String[] args, PrintStream out) {
+
+        ArgumentHandler argumentHandler = new ArgumentHandler(args);
+        log = new Log(out, argumentHandler);
+
+        LoggingMonitor loggingMonitor = Monitor.getLoggingMonitor(log,
+            argumentHandler);
+
+        // Test case 1. check that
+        // This method calls LogManager.getLoggerNames() and returns a
+        // list of the logger names
+
+        // create logger
+        String testLog1Name = getloggernames001.class.getName();
+        Logger testLog1 = Logger.getLogger(testLog1Name);
+
+        Enumeration loggerNamesEn = LogManager.getLogManager().getLoggerNames();
+        List loggerMXBeanNamesList = loggingMonitor.getLoggerNames();
+
+        // check that all elements from loggerNamesEn contain in
+        // loggerMXBeanNamesList
+        while (loggerNamesEn.hasMoreElements()) {
+
+            Object loggerName = loggerNamesEn.nextElement();
+            //log.display("loggerName="+loggerName);
+
+            boolean isInvolved = false;
+            for (int i=0; i<loggerMXBeanNamesList.size(); i++) {
+
+                Object loggerMXBeanName = loggerMXBeanNamesList.get(i);
+                if ( loggerName.equals(loggerMXBeanName) ) {
+
+                    isInvolved = true;
+                    break;
+                }
+            }
+
+            if (! isInvolved) {
+
+                log.complain("FAILURE 1.");
+                log.complain("LoggingMonitor.getLoggerNames() does not return "
+                    + "the next logger name: "+loggerName);
+                testFailed = true;
+            }
+        }
+
+        // check that all elements from loggerMXBeanNamesList contain in
+        // loggerNamesEn
+        loggerNamesEn = LogManager.getLogManager().getLoggerNames();
+        for (int i=0; i<loggerMXBeanNamesList.size(); i++) {
+
+            Object loggerMXBeanName = loggerMXBeanNamesList.get(i);
+            //log.display("loggerMXBeanName="+loggerMXBeanName);
+
+            boolean isInvolved = false;
+
+            while (loggerNamesEn.hasMoreElements()) {
+
+                Object loggerName = loggerNamesEn.nextElement();
+                if ( loggerName.equals(loggerMXBeanName) ) {
+
+                    isInvolved = true;
+                    break;
+                }
+            }
+
+            if (! isInvolved) {
+
+                log.complain("FAILURE 2.");
+                log.complain("LoggingMonitor.getLoggerNames() does not return "
+                    + "unknown logger name: "+loggerMXBeanName);
+                testFailed = true;
+            }
+        }
+
+
+        if (testFailed)
+            log.complain("TEST FAILED");
+
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getLoggerNames()
+ *         Returns the list of currently registered loggers
+ *         Access to metrics is provided in following way: directly.
+ *     The test checks that
+ *         1. This method calls LogManager.getLoggerNames() and returns a
+ *             list of the logger names.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.LoggingMXBean.getLoggerNames.getloggernames001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getLoggerNames()
+ *         Returns the list of currently registered loggers
+ *         Access to metrics is provided in following way: default MBeanServer.
+ *     The test checks that
+ *         1. This method calls LogManager.getLoggerNames() and returns a
+ *             list of the logger names.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getLoggerNames.getloggernames001
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getLoggerNames()
+ *         Returns the list of currently registered loggers
+ *         Access to metrics is provided in following way: custom MBeanServer.
+ *     The test checks that
+ *         1. This method calls LogManager.getLoggerNames() and returns a
+ *             list of the logger names.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getLoggerNames.getloggernames001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getLoggerNames()
+ *         Returns the list of currently registered loggers
+ *         Access to metrics is provided in following way: default MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. This method calls LogManager.getLoggerNames() and returns a
+ *             list of the logger names.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getLoggerNames.getloggernames001
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getLoggerNames()
+ *         Returns the list of currently registered loggers
+ *         Access to metrics is provided in following way: custom MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. This method calls LogManager.getLoggerNames() and returns a
+ *             list of the logger names.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getLoggerNames.getloggernames001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.LoggingMXBean.getParentLoggerName;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import java.util.logging.*;
+
+public class getparentloggername001 {
+
+    private static boolean testFailed = false;
+
+    public static void main(String[] args) {
+
+        System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
+    }
+
+    private static Log log;
+
+    static int run(String[] args, PrintStream out) {
+
+        ArgumentHandler argumentHandler = new ArgumentHandler(args);
+        log = new Log(out, argumentHandler);
+
+        LoggingMonitor loggingMonitor = Monitor.getLoggingMonitor(log,
+            argumentHandler);
+
+        // Test case 1. check that
+        // it returns the name of the parent for the specified logger
+        String testLogName = getparentloggername001.class.getName()+".child";
+        String testLogParentName = getparentloggername001.class.getName();
+        Logger testLog = Logger.getLogger(testLogName);
+        Logger testLogParent = Logger.getLogger(testLogParentName);
+
+        // This synchronized block guarantees that testLog will still be alive
+        // when loggingMonitor is getting an information about logger
+        synchronized (testLog) {
+        synchronized (testLogParent) {
+
+            String mxbeanParentName = loggingMonitor.getParentLoggerName(
+                testLogName);
+            if (! testLogParentName.equals(mxbeanParentName)) {
+
+                testFailed = true;
+                log.complain("Failure 1.");
+                log.complain("loggingMXBean.getParentLoggerName() returns "
+                    + "unexpected name of parent logger");
+                log.complain("Parent name is "+testLogParentName+", obtained name "
+                    +"is "+mxbeanParentName);
+            }
+
+
+            // Test case 2. check
+            // if the specified logger does not exist, null is returned
+            if (loggingMonitor.getParentLoggerName("no such logger") != null) {
+
+                testFailed = true;
+                log.complain("Failure 2.");
+                log.complain("loggingMXBean.getParentLoggerName(\"no such logger\") "
+                    + "does not return null");
+            }
+
+
+            // Test case 3. check
+            // if the specified logger is the root Logger in the namespace, the
+            // result will be an empty string.
+            String parentName = loggingMonitor.getParentLoggerName(
+                testLogParentName);
+            if (parentName == null || !parentName.equals("")) {
+
+                testFailed = true;
+                log.complain("Failure 3.");
+                log.complain("The specified logger was the root Logger in the "
+                    + "namespace, but returned string is not empty: "+parentName);
+            }
+        }}
+
+        if (testFailed)
+            log.complain("TEST FAILED");
+
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getParentLoggerName(String loggerName)
+ *         Returns the name of the parent for the specified logger.
+ *         Access to metrics is provided in following way: directly.
+ *     The test checks that
+ *         1. it returns the name of the parent for the specified logger
+ *         2. if the specified logger does not exist, null is returned
+ *         3. if the specified logger is the root Logger in the namespace, the
+ *             result will be an empty string
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.LoggingMXBean.getParentLoggerName.getparentloggername001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getParentLoggerName(String loggerName)
+ *         Returns the name of the parent for the specified logger.
+ *         Access to metrics is provided in following way: default MBeanServer.
+ *     The test checks that
+ *         1. it returns the name of the parent for the specified logger
+ *         2. if the specified logger does not exist, null is returned
+ *         3. if the specified logger is the root Logger in the namespace, the
+ *             result will be an empty string
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getParentLoggerName.getparentloggername001
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getParentLoggerName(String loggerName)
+ *         Returns the name of the parent for the specified logger.
+ *         Access to metrics is provided in following way: custom MBeanServer.
+ *     The test checks that
+ *         1. it returns the name of the parent for the specified logger
+ *         2. if the specified logger does not exist, null is returned
+ *         3. if the specified logger is the root Logger in the namespace, the
+ *             result will be an empty string
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getParentLoggerName.getparentloggername001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getParentLoggerName(String loggerName)
+ *         Returns the name of the parent for the specified logger.
+ *         Access to metrics is provided in following way: default MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. it returns the name of the parent for the specified logger
+ *         2. if the specified logger does not exist, null is returned
+ *         3. if the specified logger is the root Logger in the namespace, the
+ *             result will be an empty string
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getParentLoggerName.getparentloggername001
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: getParentLoggerName(String loggerName)
+ *         Returns the name of the parent for the specified logger.
+ *         Access to metrics is provided in following way: custom MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. it returns the name of the parent for the specified logger
+ *         2. if the specified logger does not exist, null is returned
+ *         3. if the specified logger is the root Logger in the namespace, the
+ *             result will be an empty string
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.getParentLoggerName.getparentloggername001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.LoggingMXBean.setLoggerLevel;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import java.util.logging.*;
+
+public class setloggerlevel001 {
+
+    private static boolean testFailed = false;
+
+    public static void main(String[] args) {
+
+        System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
+    }
+
+    private static Log log;
+
+    private static final Level[] LogLevels = new Level[] {
+
+        Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST,
+        Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING
+    };
+
+    static int run(String[] args, PrintStream out) {
+
+        ArgumentHandler argumentHandler = new ArgumentHandler(args);
+        log = new Log(out, argumentHandler);
+        LoggingMXBean loggingMXBean = LogManager.getLoggingMXBean();
+
+
+
+        // Test case 1. check that
+        // if the levelName is not null, the level of the specified
+        // logger is set to the parsed Level matching the levelName
+        String testLog1Name = setloggerlevel001.class.getName();
+        Logger testLog1 = Logger.getLogger(testLog1Name);
+
+        for (int i=0; i<LogLevels.length; i++) {
+
+            loggingMXBean.setLoggerLevel(testLog1Name, LogLevels[i].toString());
+            if (! LogLevels[i].equals(testLog1.getLevel())) {
+
+                testFailed = true;
+                log.complain("Failure 1.");
+                log.complain("LogLevels[i] = "+LogLevels[i].toString());
+                log.complain("testLog1.getLevel() = "+testLog1.getLevel());
+                log.complain("loggingMXBean.setLoggerLevel() failed");
+            }
+        }
+
+        // Test case 2. check
+        // if the levelName is null, the level of the specified logger is set
+        // to null
+        loggingMXBean.setLoggerLevel(testLog1Name, null);
+        if (testLog1.getLevel() != null) {
+
+            testFailed = true;
+            log.complain("Failure 2.");
+            log.complain("Level of the specified logger was not set to null: "+
+            testLog1.getLevel());
+        }
+
+        if (testFailed)
+            log.complain("TEST FAILED");
+
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: setLoggerLevel(java.lang.String loggerName,
+ *                                java.lang.String levelName)
+ *         sets the specified logger to the specified new level
+ *         Access to metrics is provided in following way: directly.
+ *     The test checks that
+ *         1. if the levelName is not null, the level of the specified
+ *             logger is set to the parsed Level matching the levelName
+ *         2. if the levelName is null, the level of the specified logger
+ *             is set to null
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.LoggingMXBean.setLoggerLevel.setloggerlevel001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: setLoggerLevel(java.lang.String loggerName,
+ *                                java.lang.String levelName)
+ *         sets the specified logger to the specified new level
+ *         Access to metrics is provided in following way: default MBeanServer.
+ *     The test checks that
+ *         1. if the levelName is not null, the level of the specified
+ *             logger is set to the parsed Level matching the levelName
+ *         2. if the levelName is null, the level of the specified logger
+ *             is set to null
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.setLoggerLevel.setloggerlevel001
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: setLoggerLevel(java.lang.String loggerName,
+ *                                java.lang.String levelName)
+ *         sets the specified logger to the specified new level
+ *         Access to metrics is provided in following way: custom MBean.
+ *     The test checks that
+ *         1. if the levelName is not null, the level of the specified
+ *             logger is set to the parsed Level matching the levelName
+ *         2. if the levelName is null, the level of the specified logger
+ *             is set to null
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.setLoggerLevel.setloggerlevel001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: setLoggerLevel(java.lang.String loggerName,
+ *                                java.lang.String levelName)
+ *         sets the specified logger to the specified new level
+ *         Access to metrics is provided in following way: default MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. if the levelName is not null, the level of the specified
+ *             logger is set to the parsed Level matching the levelName
+ *         2. if the levelName is null, the level of the specified logger
+ *             is set to null
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.setLoggerLevel.setloggerlevel001
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *         Interface: java.util.logging.LoggingMXBean
+ *         Method: setLoggerLevel(java.lang.String loggerName,
+ *                                java.lang.String levelName)
+ *         sets the specified logger to the specified new level
+ *         Access to metrics is provided in following way: custom MBeanServer
+ *             through proxy.
+ *     The test checks that
+ *         1. if the levelName is not null, the level of the specified
+ *             logger is set to the parsed Level matching the levelName
+ *         2. if the levelName is null, the level of the specified logger
+ *             is set to null
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.LoggingMXBean.setLoggerLevel.setloggerlevel001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryNotificationInfo/MemoryNotificationInfo/info001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryNotificationInfo.MemoryNotificationInfo;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+
+public class info001 {
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        MemoryUsage mu = new MemoryUsage(1, 2, 3, 4);
+
+        test("name", mu, 1, out, "if correct parameters are passed.");
+        test("", mu, 1, out, "if empty pool name is passed.");
+        test(null, mu, 1, out, "if null pool name is passed.");
+        test("name", null, 1, out, "if null MemoryUsage is passed.");
+        test("name", mu, -2, out, "if negative count is passed.");
+        test("name", mu, 0, out, "if zero count is passed.");
+        test("name", mu, Long.MAX_VALUE, out, "if Long.MAX_VALUE, count is "
+                                            + "passed.");
+        test("name", mu, Long.MIN_VALUE, out, "if Long.MIN_VALUE, count is "
+                                            + "passed.");
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    private static void test(String name, MemoryUsage usage, long count,
+                                              PrintStream out, String message) {
+        MemoryNotificationInfo info;
+
+        try {
+            info = new MemoryNotificationInfo(name, usage, count);
+            if ((name == null) || (usage == null)) {
+                out.println("NullPointerException was not thrown, " + message);
+                testFailed = true;
+            }
+        } catch (NullPointerException e) {
+            if ((name != null) && (usage != null)) {
+                out.println("Unexpected NullPointerException, " + message);
+                e.printStackTrace(out);
+                testFailed = true;
+            }
+        } catch (Exception e) {
+            out.println("Exception, " + message);
+            e.printStackTrace(out);
+            testFailed = true;
+        }
+    } // test()
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryNotificationInfo/MemoryNotificationInfo/info001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryNotificationInfo/MemoryNotificationInfo/info001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that constructor
+ *         MemoryNotificationInfo()
+ *     does not throw any exception for various sets of arguments:
+ *     1. correct set of arguments;
+ *     2. empty pool name;
+ *     3. negative count;
+ *     4. zero count;
+ *     5. Long.MAX_VALUE as count;
+ *     6. Long.MIN_VALUE as count.
+ *     NullpointerException is expected for the following sets of arguments:
+ *     1. null pool name;
+ *     2. null MemoryUsage;
+ * COMMENT
+ *     Fixed the bug:
+ *     5013995 null pointer exception in MM nsk test todata001.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryNotificationInfo.MemoryNotificationInfo.info001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryNotificationInfo/from/from001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryNotificationInfo.from;
+
+import java.lang.management.*;
+import javax.management.*;
+import javax.management.openmbean.*;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.SynchronousQueue;
+import nsk.share.*;
+import nsk.share.gc.Algorithms;
+import nsk.share.gc.Memory;
+import nsk.share.gc.gp.GarbageUtils;
+import nsk.monitoring.share.*;
+import nsk.share.test.Stresser;
+
+public class from001 {
+
+    private static boolean testFailed = false;
+
+    public static void main(String[] args) {
+
+        ArgumentHandler argHandler = new ArgumentHandler(args);
+        Log log = new Log(System.out, argHandler);
+
+        log.display("MemoryNotificationInfo/from/from001/from001.java test started.");
+
+        MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler);
+        MBeanServer mbs = Monitor.getMBeanServer();
+
+        // 1. Check null CompositeData - null must be returned
+        MemoryNotificationInfo result = MemoryNotificationInfo.from(null);
+
+        if (result != null) {
+            log.complain("FAILURE 1.");
+            log.complain("MemoryNotificationInfo.from(null) returned " + result
+                      + ", expected: null.");
+            testFailed = true;
+        }
+
+        log.display("null CompositeData check passed.");
+
+        // 2. Check CompositeData that doest not represnt
+        // MemoryNotificationInfo - IllegalArgumentException must be thrown
+
+        ObjectName mbeanObjectName = null;
+        CompositeData cdata = null;
+        try {
+            mbeanObjectName = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
+            cdata = (CompositeData )mbs.getAttribute(mbeanObjectName,
+                                                                "HeapMemoryUsage");
+        } catch (Exception e) {
+            log.complain("Unexpected exception " + e);
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+
+        try {
+            result = MemoryNotificationInfo.from(cdata);
+            log.complain("FAILURE 2.");
+            log.complain("MemoryNotificationInfo.from(CompositeData) returned "
+                      + result + ", expected: IllegalArgumentException.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+
+            // Expected: CompositeData doest not represnt MemoryNotificationInfo
+        }
+
+        log.display("check for CompositeData doest not represnt MemoryNotificationInfo passed.");
+
+        // 3. Check correct CompositeData
+        Object poolObject = null;
+        try {
+            mbeanObjectName = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
+            mbs.addNotificationListener(mbeanObjectName, new from001Listener(),
+                                                              null, null);
+            List<?> pools = monitor.getMemoryPoolMBeans();
+            if (pools.isEmpty()) {
+               log.complain("No Memory Pool Beans found. Test case will hang/fail.");
+               testFailed = true;
+            }
+
+            for (int i = 0; i < pools.size(); i++) {
+                Object pool = pools.get(i);
+                if (monitor.isUsageThresholdSupported(pool)) {
+                    if (monitor.getType(pool).equals(MemoryType.HEAP)) {
+                        poolObject = pool;
+                        monitor.setUsageThreshold(pool, 1);
+                        log.display("Usage threshold set for pool :" + poolObject);
+                        break;
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.complain("Unexpected exception " + e);
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+
+        if (testFailed) {
+            throw new TestFailure("TEST FAILED. See log.");
+        }
+
+        // eat memory just to emmit notification
+        Stresser stresser = new Stresser(args) {
+
+            @Override
+            public boolean continueExecution() {
+                return from001Listener.data.get() == null
+                        && super.continueExecution();
+            }
+        };
+        stresser.start(0);// we use timeout, not iterations
+        GarbageUtils.eatMemory(stresser);
+
+        boolean messageNotRecieved = true;
+        while(messageNotRecieved) {
+            try {
+                from001Listener.queue.take();
+                messageNotRecieved = false;
+            } catch (InterruptedException e) {
+                messageNotRecieved = true;
+            }
+        }
+
+        result = MemoryNotificationInfo.from(from001Listener.data.get());
+        try {
+           ObjectName poolObjectName = new ObjectName(monitor.getName(poolObject));
+           ObjectName resultObjectName = new ObjectName(
+                     ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE +
+                     ",name=" + result.getPoolName());
+
+           log.display("poolObjectName : " + poolObjectName +
+                              " resultObjectName : " + resultObjectName);
+
+           if (!poolObjectName.equals(resultObjectName)) {
+              log.complain("FAILURE 3.");
+              log.complain("Wrong pool name : " + resultObjectName +
+                           ", expected : " + poolObjectName);
+              testFailed = true;
+           }
+
+        } catch (Exception e) {
+            log.complain("Unexpected exception " + e);
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+
+        if (testFailed) {
+            throw new TestFailure("TEST FAILED. See log.");
+        }
+
+        log.display("Test passed.");
+    }
+}
+
+
+class from001Listener implements NotificationListener {
+
+    static AtomicReference<CompositeData> data = new AtomicReference<CompositeData>();
+    static SynchronousQueue<Object> queue = new SynchronousQueue<Object>();
+
+    public void handleNotification(Notification notification, Object handback) {
+        if (data.get() != null)
+            return;
+        data.set((CompositeData) notification.getUserData());
+
+        boolean messageNotSent = true;
+        while(messageNotSent){
+            try {
+                queue.put(new Object());
+                messageNotSent = false;
+            } catch(InterruptedException e) {
+                messageNotSent = true;
+            }
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryNotificationInfo/from/from001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryNotificationInfo/from/from001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryNotificationInfo.from(CompositeData)
+ *     returns correct results:
+ *     1. null, if CompositeData is null;
+ *     2. trows IllegalArgumentException, if CompositeData doest not represnt
+ *        MemoryNotificationInfo;
+ *     3. correct MemoryNotificationInfo object, if CompositeData is correst (i.e
+ *        all attributes of the CompositeData must have correct values: pool name,
+ *        count; init, used, committed, max (from MemoryUsage).
+ * COMMENT
+ *     Updated according to:
+ *     5024531 Fix MBeans design flaw that restricts to use JMX CompositeData
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.MemoryNotificationInfo.from.from001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryNotificationInfo/getCount/getcount001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryNotificationInfo.getCount;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+
+public class getcount001 {
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        MemoryUsage mu = new MemoryUsage(1, 2, 3, 4);
+
+        // Check positive count
+        MemoryNotificationInfo mn
+            = new MemoryNotificationInfo("poolName", mu, 1);
+        long count = mn.getCount();
+        if (count != 1) {
+            out.println("FAILURE 1.");
+            out.println("Wrong count: " + count + ", expected: 1");
+            testFailed = true;
+        }
+
+        // Check negative count
+        mn = new MemoryNotificationInfo("poolName", mu, -1);
+        count = mn.getCount();
+        if (count != -1) {
+            out.println("FAILURE 2.");
+            out.println("Wrong count: " + count + ", expected: -1");
+            testFailed = true;
+        }
+
+        // Check zero count
+        mn = new MemoryNotificationInfo("poolName", mu, -2);
+        mn = new MemoryNotificationInfo("poolName", mu, 0);
+        count = mn.getCount();
+        if (count != 0) {
+            out.println("FAILURE 3.");
+            out.println("Wrong count: " + count + ", expected: 0");
+            testFailed = true;
+        }
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryNotificationInfo/getCount/getcount001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryNotificationInfo/getCount/getcount001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryNotificationInfo.getCount()
+ *     returns correct values, if
+ *     1. count is positive;
+ *     2. count is negative;
+ *     3. count is zero.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryNotificationInfo.getCount.getcount001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryNotificationInfo/getPoolName/getpoolname001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryNotificationInfo.getPoolName;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+
+public class getpoolname001 {
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        MemoryUsage mu = new MemoryUsage(1, 2, 3, 4);
+
+        // Check not-empty string
+        MemoryNotificationInfo mn
+            = new MemoryNotificationInfo("poolName", mu, 1);
+        String name = mn.getPoolName();
+        if (!"poolName".equals(name)) {
+            out.println("FAILURE 1.");
+            out.println("Wrong pool name: \"" + name + "\", expected: "
+                      + "\"poolName\"");
+            testFailed = true;
+        }
+
+        // Check empty string
+        mn  = new MemoryNotificationInfo("", mu, 1);
+        name = mn.getPoolName();
+        if (!"".equals(name)) {
+            out.println("FAILURE 2.");
+            out.println("Wrong pool name: \"" + name + "\", expected: \"\"");
+            testFailed = true;
+        }
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryNotificationInfo/getPoolName/getpoolname001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryNotificationInfo/getPoolName/getpoolname001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryNotificationInfo.getPoolName()
+ *     returns correct values, if
+ *     1. pool name is not-empty string;
+ *     2. pool name is empty string;
+ * COMMENT
+ *     Fixed the bug:
+ *     5013995 null pointer exception in MM nsk test todata001.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryNotificationInfo.getPoolName.getpoolname001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryNotificationInfo/getUsage/getusage001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryNotificationInfo.getUsage;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+
+public class getusage001 {
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+
+        // Check not-null object
+        MemoryUsage expectedUsage = new MemoryUsage(1, 2, 3, 4);
+
+        MemoryNotificationInfo mn
+            = new MemoryNotificationInfo("poolName", expectedUsage, 1);
+        MemoryUsage realUsage = mn.getUsage();
+        long committed = realUsage.getCommitted();
+        long init = realUsage.getInit();
+        long max = realUsage.getMax();
+        long used = realUsage.getUsed();
+        String s = realUsage.toString();
+
+        if (committed != 3) {
+            out.println("FAILURE 1.");
+            out.println("Wrong committed value: " + committed + ", expected: "
+                      + "3");
+            testFailed = true;
+        }
+
+        if (init != 1) {
+            out.println("FAILURE 2.");
+            out.println("Wrong init value: " + init + ", expected: 1");
+            testFailed = true;
+        }
+
+        if (max != 4) {
+            out.println("FAILURE 3.");
+            out.println("Wrong max value: " + max + ", expected: 4");
+            testFailed = true;
+        }
+
+        if (used != 2) {
+            out.println("FAILURE 4.");
+            out.println("Wrong used value: " + used + ", expected: 2");
+            testFailed = true;
+        }
+
+        if (!expectedUsage.toString().equals(s)) {
+            out.println("FAILURE 5.");
+            out.println("Wrong toString() value: \"" + s + "\", expected: \""
+                      + expectedUsage.toString() + "\"");
+            testFailed = true;
+        }
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryNotificationInfo/getUsage/getusage001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryNotificationInfo/getUsage/getusage001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryNotificationInfo.getUsage()
+ *     returns correct MemoryUsage object - the same that was passed to the
+ *     MemoryNotificationInfo() constructor. The test checks
+ *     1. not-null MemoryUsage;
+ * COMMENT
+ *     Fixed the bug:
+ *     5013995 null pointer exception in MM nsk test todata001.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryNotificationInfo.getUsage.getusage001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.getCollectionUsage;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class getusage001 {
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+
+            try {
+                monitor.getCollectionUsage(pool);
+            } catch (Exception e) {
+                log.complain("Unexpected exception " + e);
+                e.printStackTrace(log.getOutStream());
+                testFailed = true;
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsage()
+ *     does not throw any exception.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getCollectionUsage.getusage001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsage()
+ *     does not throw any exception.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getCollectionUsage.getusage001 -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsage()
+ *     does not throw any exception.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getCollectionUsage.getusage001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage004.
+ * VM Testbase keywords: [quick, monitoring, quarantine]
+ * VM Testbase comments: JDK-8016181
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsage()
+ *     does not throw any exception.
+ *     The test implements access to the metrics via default for MBean server
+ *     proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getCollectionUsage.getusage001 -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsage()
+ *     does not throw any exception.
+ *     The test implements access to the metrics via custom MBean server
+ *     proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getCollectionUsage.getusage001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class getthreshold001 {
+    private static boolean testFailed = false;
+    private static MemoryMonitor monitor;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            log.display(i + " pool " + monitor.getName(pool));
+
+            boolean isSupported = monitor.isCollectionThresholdSupported(pool);
+            if (isSupported) {
+                log.display("  supports collection usage thresholds");
+
+                // Test three values for the threshold
+                long max = monitor.getUsage(pool).getMax();
+                long used = monitor.getUsage(pool).getUsed();
+
+                // max value can be -1, so take an absolute value
+                test(monitor, pool, Math.abs(max), log);
+                test(monitor, pool, 0, log);
+                test(monitor, pool, used, log);
+            } else {
+                log.display("  does not support collection usage thresholds");
+
+                // UnsupportedOperationException is expected
+                try {
+                    long threshold = monitor.getCollectionThreshold(pool);
+                    log.complain("Threshold " + threshold + " is returned "
+                               + "instead of UnsupportedOperationException "
+                               + "in pool " + monitor.getName(pool));
+                    testFailed = true;
+                } catch (Exception e) {
+                    Throwable unwrapped = unwrap(e);
+
+                    if (unwrapped instanceof UnsupportedOperationException) {
+                        log.display("  UnsupportedOperationException is "
+                                  + "thrown");
+                    } else {
+                        log.complain("Incorrect execption " + unwrapped
+                                   + " is thrown, "
+                                   + "UnsupportedOperationException is "
+                                   + "expected in pool "
+                                   + monitor.getName(pool));
+                        unwrapped.printStackTrace(log.getOutStream());
+                        testFailed = true;
+                    }
+                } // try
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    private static void test(MemoryMonitor monitor, Object pool,
+                                                      long threshold, Log log) {
+        log.display("  setting threshold " + threshold);
+        try {
+            monitor.setCollectionThreshold(pool, threshold);
+        } catch (Exception e) {
+            log.complain("Unexpected exception " + e + " in pool "
+                       + monitor.getName(pool));
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+            return;
+        }
+        log.display("  threshold " + threshold + " is set");
+
+        long result = monitor.getCollectionThreshold(pool);
+        if (threshold != result) {
+            log.complain("Threshold value is " + result + " in pool "
+                       + monitor.getName(pool) + ", " + threshold
+                       + " expected");
+            testFailed = true;
+        }
+        log.display("  threshold " + threshold + " is read");
+    } // test()
+
+
+    static Throwable unwrap(Throwable throwable) {
+
+        Throwable unwrapped, t = throwable;
+
+        do {
+            unwrapped = t;
+
+            if (unwrapped instanceof UnsupportedOperationException) {
+                break;
+            }
+
+            t = unwrapped.getCause();
+
+        } while (t != null);
+
+        return unwrapped;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsageThreshold()
+ *     1. returns the correct threshold value that was just set to the pool,
+ *        if the pool supports collection usage thresholds. Three values are
+ *        tested:
+ *            - 0;
+ *            - used value for the pool;
+ *            - max value for the pool.
+ *     2. throws UnsupportedOperationException, if the pool does not support
+ *        collection usage thresholds.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *     Fixed the bug:
+ *     5035038 Chain of JMX exceptions impact on monitoring tests
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold.getthreshold001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsageThreshold()
+ *     1. returns the correct threshold value that was just set to the pool,
+ *        if the pool supports collection usage thresholds. Three values are
+ *        tested:
+ *            - 0;
+ *            - used value for the pool;
+ *            - max value for the pool.
+ *     2. throws UnsupportedOperationException, if the pool does not support
+ *        collection usage thresholds.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold.getthreshold001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsageThreshold()
+ *     1. returns the correct threshold value that was just set to the pool,
+ *        if the pool supports collection usage thresholds. Three values are
+ *        tested:
+ *            - 0;
+ *            - used value for the pool;
+ *            - max value for the pool.
+ *     2. throws UnsupportedOperationException, if the pool does not support
+ *        collection usage thresholds.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold.getthreshold001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsageThreshold()
+ *     1. returns the correct threshold value that was just set to the pool,
+ *        if the pool supports collection usage thresholds. Three values are
+ *        tested:
+ *            - 0;
+ *            - used value for the pool;
+ *            - max value for the pool.
+ *     2. throws UnsupportedOperationException, if the pool does not support
+ *        collection usage thresholds.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold.getthreshold001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsageThreshold()
+ *     1. returns the correct threshold value that was just set to the pool,
+ *        if the pool supports collection usage thresholds. Three values are
+ *        tested:
+ *            - 0;
+ *            - used value for the pool;
+ *            - max value for the pool.
+ *     2. throws UnsupportedOperationException, if the pool does not support
+ *        collection usage thresholds.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold.getthreshold001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class getcount001 {
+    private static boolean testFailed = false;
+    static MemoryMonitor monitor;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            log.display(i + " pool " + monitor.getName(pool));
+
+            boolean isSupported = monitor.isCollectionThresholdSupported(pool);
+
+            if (isSupported) {
+
+                // Check that the method returns non-negative count
+                log.display("  supports collection usage thresholds");
+                long count = monitor.getCollectionThresholdCount(pool);
+                if (count < 0) {
+                    log.complain("Threshold count is less than zero: " + count
+                               + " in pool " + monitor.getName(pool));
+                    testFailed = true;
+                } else
+                    log.display("  getUsageThresholdCount() returned " + count);
+            } else {
+
+                // UnsupportedOperationException is expected
+                log.display("  does not support collection usage thresholds");
+                try {
+                    long count = monitor.getCollectionThresholdCount(pool);
+                    log.complain("Threshold ount " + count + " is returned "
+                               + "instead of UnsupportedOperationException in "
+                               + "pool " + monitor.getName(pool));
+                    testFailed = true;
+                } catch (Exception e) {
+
+                    Throwable unwrapped = unwrap(e);
+
+                    if (unwrapped instanceof UnsupportedOperationException)
+                        log.display("  UnsupportedOperationException is "
+                                  + "thrown");
+                     else {
+                         log.complain("Incorrect execption " + unwrapped
+                                    + " is thrown, "
+                                    + "UnsupportedOperationException is "
+                                    + "expected");
+                         unwrapped.printStackTrace(log.getOutStream());
+                         testFailed = true;
+                     }
+                } // try
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+
+    static Throwable unwrap(Throwable throwable) {
+
+        Throwable unwrapped, t = throwable;
+
+        do {
+            unwrapped = t;
+
+            if (unwrapped instanceof UnsupportedOperationException) {
+                break;
+            }
+
+            t = unwrapped.getCause();
+
+        } while (t != null);
+
+        return unwrapped;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsageThresholdCount()
+ *     1. returns not-negative value, if collection usage thresholds are supported;
+ *     2. throws UnsupportedOperationException, if collection usage thresholds are
+ *        not supported.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *     Fixed the bug:
+ *     5035038 Chain of JMX exceptions impact on monitoring tests
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount.getcount001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsageThresholdCount()
+ *     1. returns not-negative value, if collection usage thresholds are supported;
+ *     2. throws UnsupportedOperationException, if collection usage thresholds are
+ *        not supported.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount.getcount001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsageThresholdCount()
+ *     1. returns not-negative value, if collection usage thresholds are supported;
+ *     2. throws UnsupportedOperationException, if collection usage thresholds are
+ *        not supported.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount.getcount001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsageThresholdCount()
+ *     1. returns not-negative value, if collection usage thresholds are supported;
+ *     2. throws UnsupportedOperationException, if collection usage thresholds are
+ *        not supported.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount.getcount001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getCollectionUsageThresholdCount()
+ *     1. returns not-negative value, if collection usage thresholds are supported;
+ *     2. throws UnsupportedOperationException, if collection usage thresholds are
+ *        not supported.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount.getcount001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.getPeakUsage;
+
+import java.io.*;
+import java.lang.management.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class getpeak001 {
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+        MemoryUsage usage = null;
+
+        for (int i = 0; i < pools.size(); i++) {
+            byte[] b = new byte[10 * 1024]; // Eat 10K
+            Object pool = pools.get(i);
+
+            // No exceptions should be thrown
+            try {
+                usage = monitor.getPeakUsage(pool);
+                log.display(i + " " + monitor.getName(pool) + ": " + usage);
+            } catch (Throwable t) {
+                if (t instanceof ThreadDeath)
+                    throw (ThreadDeath) t;
+                log.complain("Unexpected exception in pool "
+                           + monitor.getName(pool));
+                t.printStackTrace(log.getOutStream());
+                testFailed = true;
+                continue;
+            }
+
+            boolean isValid = monitor.isValid(pool);
+            if (isValid) {
+                if (usage == null) {
+                    log.complain("getPeakUsage() returned null for the valid "
+                           + "pool " + monitor.getName(pool));
+                    testFailed = true;
+                }
+            } else {
+                if (usage != null) {
+                    log.complain("getPeakUsage() returned not-null: " + usage
+                               + " for invalid pool " + monitor.getName(pool));
+                    testFailed = true;
+                }
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getPeakUsage()
+ *     1. does not throw any exceptions;
+ *     2. returns null, if the pool is invalid, and not-null MemoryUsage object,
+ *        if the pool is valid.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getPeakUsage.getpeak001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getPeakUsage()
+ *     1. does not throw any exceptions;
+ *     2. returns null, if the pool is invalid, and not-null MemoryUsage object,
+ *        if the pool is valid.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getPeakUsage.getpeak001 -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getPeakUsage()
+ *     1. does not throw any exceptions;
+ *     2. returns null, if the pool is invalid, and not-null MemoryUsage object,
+ *        if the pool is valid.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getPeakUsage.getpeak001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getPeakUsage()
+ *     1. does not throw any exceptions;
+ *     2. returns null, if the pool is invalid, and not-null MemoryUsage object,
+ *        if the pool is valid.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getPeakUsage.getpeak001 -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getPeakUsage()
+ *     1. does not throw any exceptions;
+ *     2. returns null, if the pool is invalid, and not-null MemoryUsage object,
+ *        if the pool is valid.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getPeakUsage.getpeak001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.getUsage;
+
+import java.io.*;
+import java.lang.management.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class getusage001 {
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+        MemoryUsage usage = null;
+
+        for (int i = 0; i < pools.size(); i++) {
+            byte[] b = new byte[10 * 1024]; // Eat 10K
+            Object pool = pools.get(i);
+
+            // No exceptions should be thrown
+            try {
+                usage = monitor.getUsage(pool);
+                log.display(i + " " + monitor.getName(pool) + ": " + usage);
+            } catch (Throwable t) {
+                if (t instanceof ThreadDeath)
+                    throw (ThreadDeath) t;
+                log.complain("Unexpected exception in pool "
+                           + monitor.getName(pool));
+                t.printStackTrace(log.getOutStream());
+                testFailed = true;
+                continue;
+            }
+
+            boolean isValid = monitor.isValid(pool);
+            if (isValid) {
+                if (usage == null) {
+                    log.complain("getPeakUsage() returned null for the valid "
+                           + "pool " + monitor.getName(pool));
+                    testFailed = true;
+                }
+            } else {
+                if (usage != null) {
+                    log.complain("getPeakUsage() returned not-null: " + usage
+                               + " for invalid pool " + monitor.getName(pool));
+                    testFailed = true;
+                }
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsage/getusage001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsage()
+ *     1. does not throw any exceptions;
+ *     2. returns null, if the pool is invalid, and not-null MemoryUsage object,
+ *        if the pool is valid.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getUsage.getusage001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsage/getusage002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsage()
+ *     1. does not throw any exceptions;
+ *     2. returns null, if the pool is invalid, and not-null MemoryUsage object,
+ *        if the pool is valid.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getUsage.getusage001 -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsage/getusage003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsage()
+ *     1. does not throw any exceptions;
+ *     2. returns null, if the pool is invalid, and not-null MemoryUsage object,
+ *        if the pool is valid.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getUsage.getusage001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsage/getusage004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsage()
+ *     1. does not throw any exceptions;
+ *     2. returns null, if the pool is invalid, and not-null MemoryUsage object,
+ *        if the pool is valid.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getUsage.getusage001 -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsage/getusage005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsage()
+ *     1. does not throw any exceptions;
+ *     2. returns null, if the pool is invalid, and not-null MemoryUsage object,
+ *        if the pool is valid.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getUsage.getusage001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.getUsageThreshold;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class getthreshold001 {
+    private static boolean testFailed = false;
+    static MemoryMonitor monitor;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            log.display(i + " pool " + monitor.getName(pool));
+
+            boolean isSupported = monitor.isUsageThresholdSupported(pool);
+            if (isSupported) {
+                log.display("  supports usage thresholds");
+
+                // Test three values for the threshold
+                long max = monitor.getUsage(pool).getMax();
+                long used = monitor.getUsage(pool).getUsed();
+
+                // max value can be -1, so take an absolute value
+                test(monitor, pool, Math.abs(max), log);
+                test(monitor, pool, 0, log);
+                test(monitor, pool, used, log);
+            } else {
+                log.display("  does not support usage thresholds");
+
+                // UnsupportedOperationException is expected
+                try {
+                    long threshold = monitor.getUsageThreshold(pool);
+                    log.complain("Threshold " + threshold + " is returned "
+                               + "instead of UnsupportedOperationException "
+                               + "in pool " + monitor.getName(pool));
+                    testFailed = true;
+                } catch (Exception e) {
+
+                    Throwable unwrapped = unwrap(e);
+
+                    if (unwrapped instanceof UnsupportedOperationException) {
+                        log.display("  UnsupportedOperationException is "
+                                  + "thrown");
+                    } else {
+                        log.complain("Incorrect execption " + unwrapped
+                                   + " is thrown, "
+                                   + "UnsupportedOperationException is "
+                                   + "expected in pool "
+                                   + monitor.getName(pool));
+                        unwrapped.printStackTrace(log.getOutStream());
+                        testFailed = true;
+                    }
+                } // try
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    private static void test(MemoryMonitor monitor, Object pool,
+                                                      long threshold, Log log) {
+        log.display("  setting threshold " + threshold);
+        try {
+            monitor.setUsageThreshold(pool, threshold);
+        } catch (Exception e) {
+            log.complain("Unexpected exception " + e);
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+            return;
+        }
+        log.display("  threshold " + threshold + " is set");
+
+        long result = monitor.getUsageThreshold(pool);
+        if (threshold != result) {
+            log.complain("Threshold value is " + result + " in pool "
+                       + monitor.getName(pool) + ", " + threshold
+                       + " expected");
+            testFailed = true;
+        }
+        log.display("  threshold " + threshold + " is read");
+    } // test()
+
+    static Throwable unwrap(Throwable throwable) {
+
+        Throwable unwrapped, t = throwable;
+
+        do {
+            unwrapped = t;
+
+            if (unwrapped instanceof UnsupportedOperationException) {
+                break;
+            }
+
+            t = unwrapped.getCause();
+
+        } while (t != null);
+
+        return unwrapped;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsageThreshold()
+ *     1. returns the correct threshold value that was just set to the pool,
+ *        if the pool supports usage thresholds. The tested values of the
+ *        threshold are:
+ *            - 0;
+ *            - max value for the pool;
+ *            - used value for the pool.
+ *     2. throws UnsupportedOperationException, if the pool does not support
+ *        usage thresholds.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *     Fixed the bug:
+ *     5035038 Chain of JMX exceptions impact on monitoring tests
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getUsageThreshold.getthreshold001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsageThreshold()
+ *     1. returns the correct threshold value that was just set to the pool,
+ *        if the pool supports usage thresholds. The tested values of the
+ *        threshold are:
+ *            - 0;
+ *            - max value for the pool;
+ *            - used value for the pool.
+ *     2. returns -1, if the pool does not support usage thresholds.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getUsageThreshold.getthreshold001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsageThreshold()
+ *     1. returns the correct threshold value that was just set to the pool,
+ *        if the pool supports usage thresholds. The tested values of the
+ *        threshold are:
+ *            - 0;
+ *            - max value for the pool;
+ *            - used value for the pool.
+ *     2. returns -1, if the pool does not support usage thresholds.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getUsageThreshold.getthreshold001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsageThreshold()
+ *     1. returns the correct threshold value that was just set to the pool,
+ *        if the pool supports usage thresholds. The tested values of the
+ *        threshold are:
+ *            - 0;
+ *            - max value for the pool;
+ *            - used value for the pool.
+ *     2. returns -1, if the pool does not support usage thresholds.
+ *     The test implements access to the metrics via default MBean server
+ *     proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getUsageThreshold.getthreshold001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsageThreshold()
+ *     1. returns the correct threshold value that was just set to the pool,
+ *        if the pool supports usage thresholds. The tested values of the
+ *        threshold are:
+ *            - 0;
+ *            - max value for the pool;
+ *            - used value for the pool.
+ *     2. returns -1, if the pool does not support usage thresholds.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getUsageThreshold.getthreshold001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.getUsageThresholdCount;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class getcount001 {
+    private static boolean testFailed = false;
+    static MemoryMonitor monitor;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            log.display(i + " pool " + monitor.getName(pool));
+
+            boolean isSupported = monitor.isUsageThresholdSupported(pool);
+
+            if (isSupported) {
+                log.display("  supports usage thresholds");
+                long count = monitor.getUsageThresholdCount(pool);
+                if (count < 0) {
+                    log.complain("Threshold count is less than zero: " + count
+                               + " in pool " + monitor.getName(pool));
+                    testFailed = true;
+                } else
+                    log.display("  getUsageThresholdCount() returned " + count);
+            } else {
+
+                // UnsupportedOperationException is expected
+                log.display("  does not support usage thresholds");
+                try {
+                    monitor.getUsageThresholdCount(pool);
+                    log.complain("UnsupportedOperationException is not thrown "
+                               + "in pool " + monitor.getName(pool));
+                    testFailed = true;
+                } catch (Exception e) {
+
+                    Throwable unwrapped = unwrap(e);
+
+                    if (unwrapped instanceof UnsupportedOperationException)
+                        log.display("  UnsupportedOperationException is "
+                                  + "thrown");
+                     else {
+                         log.complain("  Incorrect execption " + unwrapped
+                                    + " is thrown, "
+                                    + "UnsupportedOperationException is "
+                                    + "expected");
+                         unwrapped.printStackTrace(log.getOutStream());
+                         testFailed = true;
+                     }
+                } // try
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    static Throwable unwrap(Throwable throwable) {
+
+        Throwable unwrapped, t = throwable;
+
+        do {
+            unwrapped = t;
+
+            if (unwrapped instanceof UnsupportedOperationException) {
+                break;
+            }
+
+            t = unwrapped.getCause();
+
+        } while (t != null);
+
+        return unwrapped;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsageThresholdCount()
+ *     1. returns not-negative value, if usage thresholds are supported;
+ *     2. throws UnsupportedOperationException, if usage thresholds are not
+ *        supported.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *     Fixed the bug:
+ *     5035038 Chain of JMX exceptions impact on monitoring tests
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.getUsageThresholdCount.getcount001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsageThresholdCount()
+ *     1. returns not-negative value, if usage thresholds are supported;
+ *     2. throws UnsupportedOperationException, if usage thresholds are not
+ *        supported.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getUsageThresholdCount.getcount001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsageThresholdCount()
+ *     1. returns not-negative value, if usage thresholds are supported;
+ *     2. throws UnsupportedOperationException, if usage thresholds are not
+ *        supported.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getUsageThresholdCount.getcount001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsageThresholdCount()
+ *     1. returns not-negative value, if usage thresholds are supported;
+ *     2. throws UnsupportedOperationException, if usage thresholds are not
+ *        supported.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getUsageThresholdCount.getcount001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.getUsageThresholdCount()
+ *     1. returns not-negative value, if usage thresholds are supported;
+ *     2. throws UnsupportedOperationException, if usage thresholds are not
+ *        supported.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.getUsageThresholdCount.getcount001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdExceeded;
+
+import java.lang.management.*;
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class isexceeded001 {
+    private static boolean testFailed = false;
+    static MemoryMonitor monitor;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            log.display(i + " pool " + monitor.getName(pool));
+
+            if (!monitor.isCollectionThresholdSupported(pool)) {
+                log.display("  does not support collection usage thresholds");
+
+                // UnsupportedOperationException is expected
+                try {
+                    boolean isExceeded
+                        = monitor.isCollectionThresholdExceeded(pool);
+                    log.complain("isCollectionUsageThresholdExceeded() returned"
+                               + " " + isExceeded + "instead of "
+                               + "UnsupportedOperationException in pool "
+                               + monitor.getName(pool));
+                    testFailed = true;
+                } catch (Exception e) {
+
+                    Throwable unwrapped = unwrap(e);
+
+                    if (unwrapped instanceof UnsupportedOperationException) {
+                        log.display("  UnsupportedOperationException is "
+                                  + "thrown");
+                    } else {
+                        log.complain("Incorrect execption " + unwrapped
+                                   + " is thrown, "
+                                   + "UnsupportedOperationException is "
+                                   + "expected");
+                        unwrapped.printStackTrace(log.getOutStream());
+                        testFailed = true;
+                    }
+                } // try
+                continue;
+            } // if
+
+            log.display("  supports collection usage thresholds");
+
+            // Set a threshold that is greater than used value
+            MemoryUsage usage = monitor.getCollectionUsage(pool);
+            long used = usage.getUsed();
+            long max = usage.getMax();
+            long threshold = used + 1;
+
+            if ( (max > -1) && (threshold > max) )
+                threshold = max;
+            log.display("  setting threshold " + threshold + " "
+                      + monitor.getCollectionUsage(pool));
+            try {
+                monitor.setCollectionThreshold(pool, threshold);
+            } catch (Exception e) {
+                log.complain("Unexpected " + e + " in pool "
+                           + monitor.getName(pool));
+                e.printStackTrace(log.getOutStream());
+                testFailed = true;
+                continue;
+            }
+            boolean isExceeded = monitor.isCollectionThresholdExceeded(pool);
+            log.display("  threshold " + threshold + " is set, (used = " + used
+                      + ", isExceeded = " + isExceeded + ")");
+
+            // Eat some memory - provoke usage of the pool to cross the
+            // threshold value
+            byte[] b = new byte[100 * 1024]; // Eat 100K
+
+            threshold = monitor.getCollectionThreshold(pool);
+            usage = monitor.getCollectionUsage(pool);
+            used = usage.getUsed();
+
+            if (used >= threshold) {
+                log.display("  used value (" + used + ") crossed the threshold "
+                          + "value (" + threshold + ")");
+
+                isExceeded = monitor.isCollectionThresholdExceeded(pool);
+                if (!isExceeded) {
+
+                    // Refresh the values
+                    threshold = monitor.getCollectionThreshold(pool);
+                    usage = monitor.getCollectionUsage(pool);
+                    if (used >= threshold) {
+                        log.complain("isCollectionUsageThresholdExceeded() "
+                                   + "returned false, while threshold = "
+                                   + threshold + " and " + "used = " + used);
+                        testFailed = true;
+                    }
+                }
+            } else {
+                log.display("  used value (" + used + ") did not cross the "
+                          + "threshold value (" + threshold + ")");
+
+                isExceeded = monitor.isCollectionThresholdExceeded(pool);
+                if (isExceeded) {
+
+                    // Refresh the values
+                    threshold = monitor.getCollectionThreshold(pool);
+                    usage = monitor.getCollectionUsage(pool);
+                    if (used < threshold) {
+                        log.complain("isCollectionUsageThresholdExceeded() "
+                                   + "returned true, while threshold = "
+                                   + threshold + " and " + "used = " + used);
+                        testFailed = true;
+                    }
+                }
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    static Throwable unwrap(Throwable throwable) {
+
+        Throwable unwrapped, t = throwable;
+
+        do {
+            unwrapped = t;
+
+            if (unwrapped instanceof UnsupportedOperationException) {
+                break;
+            }
+
+            t = unwrapped.getCause();
+
+        } while (t != null);
+
+        return unwrapped;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isCollectionUsageThresholdExceeded()
+ *     returns correct results, if the pool supports collection usage thresholds.
+ *     The test sets a threshold that is greater than used value, allocates 100K,
+ *     and checks that getCollectionUsageThreshold(), getUsed(),
+ *     isCollectionUsageThresholdExceeded() do not contradict each other, i.e.:
+ *         1. if used value is greater or equal than threshold, then
+ *            isCollectionUsageThresholdExceeded() is expected to return true;
+ *         2. if used value is less than threshold, then
+ *            isCollectionUsageThresholdExceeded() is expected to return false.
+ *     If the collection usage thresholds are not supported,
+ *     UnsupportedOperationException is expected to be thrown by the method.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated according to 4982289, 4985742
+ *     Fixed the bug:
+ *     5035038 Chain of JMX exceptions impact on monitoring tests
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdExceeded.isexceeded001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isCollectionUsageThresholdExceeded()
+ *     returns correct results, if the pool supports collection usage thresholds.
+ *     The test sets a threshold that is greater than used value, allocates 100K,
+ *     and checks that getCollectionUsageThreshold(), getUsed(),
+ *     isCollectionUsageThresholdExceeded() do not contradict each other, i.e.:
+ *         1. if used value is greater or equal than threshold, then
+ *            isCollectionUsageThresholdExceeded() is expected to return true;
+ *         2. if used value is less than threshold, then
+ *            isCollectionUsageThresholdExceeded() is expected to return false.
+ *     If the collection usage thresholds are not supported,
+ *     UnsupportedOperationException is expected to be thrown by the method.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdExceeded.isexceeded001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded003.
+ * VM Testbase keywords: [quick, monitoring, quarantine]
+ * VM Testbase comments: JDK-8153598
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isCollectionUsageThresholdExceeded()
+ *     returns correct results, if the pool supports collection usage thresholds.
+ *     The test sets a threshold that is greater than used value, allocates 100K,
+ *     and checks that getCollectionUsageThreshold(), getUsed(),
+ *     isCollectionUsageThresholdExceeded() do not contradict each other, i.e.:
+ *         1. if used value is greater or equal than threshold, then
+ *            isCollectionUsageThresholdExceeded() is expected to return true;
+ *         2. if used value is less than threshold, then
+ *            isCollectionUsageThresholdExceeded() is expected to return false.
+ *     If the collection usage thresholds are not supported,
+ *     UnsupportedOperationException is expected to be thrown by the method.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdExceeded.isexceeded001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isCollectionUsageThresholdExceeded()
+ *     returns correct results, if the pool supports collection usage thresholds.
+ *     The test sets a threshold that is greater than used value, allocates 100K,
+ *     and checks that getCollectionUsageThreshold(), getUsed(),
+ *     isCollectionUsageThresholdExceeded() do not contradict each other, i.e.:
+ *         1. if used value is greater or equal than threshold, then
+ *            isCollectionUsageThresholdExceeded() is expected to return true;
+ *         2. if used value is less than threshold, then
+ *            isCollectionUsageThresholdExceeded() is expected to return false.
+ *     If the collection usage thresholds are not supported,
+ *     UnsupportedOperationException is expected to be thrown by the method.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdExceeded.isexceeded001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isCollectionUsageThresholdExceeded()
+ *     returns correct results, if the pool supports collection usage thresholds.
+ *     The test sets a threshold that is greater than used value, allocates 100K,
+ *     and checks that getCollectionUsageThreshold(), getUsed(),
+ *     isCollectionUsageThresholdExceeded() do not contradict each other, i.e.:
+ *         1. if used value is greater or equal than threshold, then
+ *            isCollectionUsageThresholdExceeded() is expected to return true;
+ *         2. if used value is less than threshold, then
+ *            isCollectionUsageThresholdExceeded() is expected to return false.
+ *     If the collection usage thresholds are not supported,
+ *     UnsupportedOperationException is expected to be thrown by the method.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdExceeded.isexceeded001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdSupported;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class issupported001 {
+    private static boolean testFailed = false;
+    static MemoryMonitor monitor;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            log.display(i + " pool " + monitor.getName(pool));
+            boolean isSupported
+                = monitor.isCollectionThresholdSupported(pool);
+
+            if (isSupported) {
+
+                log.display("  supports collection usage thresholds");
+
+                // No exceptions are expected
+                try {
+                    long threshold = monitor.getCollectionThreshold(pool);
+                    log.display("  threshold " + threshold + " is read");
+                } catch (Exception e) {
+                    log.complain(e + " is thrown in pool "
+                               + monitor.getName(pool));
+                    e.printStackTrace(log.getOutStream());
+                    testFailed = true;
+                }
+            } else {
+
+                log.display("  does not support collection usage thresholds");
+
+                // UnsupportedOperationException is expected
+                try {
+                    long threshold = monitor.getCollectionThreshold(pool);
+                    log.complain("Threshold " + threshold + " is returned "
+                               + "instead of UnsupportedOperationException "
+                               + "in pool " + monitor.getName(pool));
+                    testFailed = true;
+                } catch (Exception e) {
+
+                    Throwable unwrapped = unwrap(e);
+
+                    if (unwrapped instanceof UnsupportedOperationException) {
+                        log.display("  UnsupportedOperationException is "
+                                  + "thrown");
+                    } else {
+                        log.complain("Incorrect execption " + unwrapped
+                                   + " is thrown, "
+                                   + "UnsupportedOperationException is "
+                                   + "expected");
+                        unwrapped.printStackTrace(log.getOutStream());
+                        testFailed = true;
+                    }
+                } // try
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    static Throwable unwrap(Throwable throwable) {
+
+        Throwable unwrapped, t = throwable;
+
+        do {
+            unwrapped = t;
+
+            if (unwrapped instanceof UnsupportedOperationException) {
+                break;
+            }
+
+            t = unwrapped.getCause();
+
+        } while (t != null);
+
+        return unwrapped;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isCollectionUsageThresholdSupported()
+ *     correctly detects if a pool supports collection thresholds.
+ *     1. getCollectionUsageThreshold() must not throw any exceptions, if
+ *        isCollectionUsageThresholdSupported() returns true for a pool;
+ *     2. getCollectionUsageThreshold() must throw UnsupportedOperationException,
+ *        if isCollectionUsageThresholdSupported() returns false for a pool;
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *     Fixed the bug:
+ *     5035038 Chain of JMX exceptions impact on monitoring tests
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdSupported.issupported001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isCollectionUsageThresholdSupported()
+ *     correctly detects if a pool supports collection thresholds.
+ *     1. getCollectionUsageThreshold() must not throw any exceptions, if
+ *        isCollectionUsageThresholdSupported() returns true for a pool;
+ *     2. getCollectionUsageThreshold() must throw UnsupportedOperationException,
+ *        if isCollectionUsageThresholdSupported() returns false for a pool;
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdSupported.issupported001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isCollectionUsageThresholdSupported()
+ *     correctly detects if a pool supports collection thresholds.
+ *     1. getCollectionUsageThreshold() must not throw any exceptions, if
+ *        isCollectionUsageThresholdSupported() returns true for a pool;
+ *     2. getCollectionUsageThreshold() must throw UnsupportedOperationException,
+ *        if isCollectionUsageThresholdSupported() returns false for a pool;
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdSupported.issupported001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isCollectionUsageThresholdSupported()
+ *     correctly detects if a pool supports collection thresholds.
+ *     1. getCollectionUsageThreshold() must not throw any exceptions, if
+ *        isCollectionUsageThresholdSupported() returns true for a pool;
+ *     2. getCollectionUsageThreshold() must throw UnsupportedOperationException,
+ *        if isCollectionUsageThresholdSupported() returns false for a pool;
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdSupported.issupported001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isCollectionUsageThresholdSupported()
+ *     correctly detects if a pool supports collection thresholds.
+ *     1. getCollectionUsageThreshold() must not throw any exceptions, if
+ *        isCollectionUsageThresholdSupported() returns true for a pool;
+ *     2. getCollectionUsageThreshold() must throw UnsupportedOperationException,
+ *        if isCollectionUsageThresholdSupported() returns false for a pool;
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isCollectionUsageThresholdSupported.issupported001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.isUsageThresholdExceeded;
+
+import java.lang.management.*;
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.Notification;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.openmbean.CompositeData;
+
+public class isexceeded001 {
+    private static boolean testFailed = false;
+    private static final int INCREMENT = 100 * 1024; // 100kb
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    static byte[] b;
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            log.display(i + " pool " + monitor.getName(pool));
+
+            if (!monitor.isUsageThresholdSupported(pool)) {
+                log.display("  does not support usage thresholds");
+                continue;
+            } else
+                log.display("  supports usage thresholds");
+
+            // Set a threshold that is greater than used value
+            MemoryUsage usage = monitor.getUsage(pool);
+            long used = usage.getUsed();
+            long max = usage.getMax();
+            long threshold = used + 1;
+
+            if ( (max > -1) && (threshold > max) ) {
+                // we can't test threshold - not enough memory
+                log.display("not enough memory for testing threshold:" +
+                 " used=" + used +
+                 ", max = " + max );
+            }
+
+            monitor.setUsageThreshold(pool, threshold);
+            log.display("  threshold " + threshold + " is set, used = " + used );
+
+            monitor.resetPeakUsage(pool);
+            log.display("  resetting peak usage");
+            log.display("  peak usage = " + monitor.getPeakUsage(pool).getUsed());
+
+            // Eat some memory - provoke usage of the pool to cross the
+            // threshold value
+            b = new byte[INCREMENT]; // Eat 100K
+
+            boolean isExceeded = monitor.isUsageThresholdExceeded(pool);
+            usage = monitor.getPeakUsage(pool);
+            used = usage.getUsed();
+
+            log.display("  used value is " + used);
+
+            if (used < threshold && isExceeded) {
+                // There're problems with isUsageThresholdExceeded()
+                log.complain("isUsageThresholdExceeded() returned "
+                    + "true, while threshold = " + threshold
+                    + " and used peak = " + used);
+                    testFailed = true;
+            } else
+            if (used >= threshold && !isExceeded) {
+                // we can introduce some imprecision during pooling memory usage
+                // value at the Code Cache memory pool. Amount of used memory
+                // was changed after we'd calculated isExceeded value
+
+                if (monitor.isUsageThresholdExceeded(pool)) {
+                    // that's mean such imprecision
+                    log.display("isUsageThresholdExceeded() returned false,"
+                        + " while threshold = " + threshold + " and "
+                        + "used peak = " + used);
+                } else {
+                    // some other problems with isUsageThresholdExceeded()
+                    log.complain("isUsageThresholdExceeded() returned false,"
+                        + " while threshold = " + threshold + " and "
+                        + "used peak = " + used);
+                        testFailed = true;
+                }
+            }
+
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.
+ * VM Testbase keywords: [quick, monitoring, quarantine]
+ * VM Testbase comments: JDK-8153598
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isUsageThresholdExceeded()
+ *     returns correct results, if the pool supports usage thresholds.
+ *     The test sets a threshold that is greater than used value, allocates 100K,
+ *     and chechs that getUsageThreshold(), getUsed(), isUsageThresholdExceeded()
+ *     do not contradict each other, i.e.:
+ *         1. if used value is greater or equal than threshold, then
+ *            isUsageThresholdExceeded() is expected to return true;
+ *         2. If used value is less than threshold, then isUsageThresholdExceeded()
+ *            is expected to return false.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.isUsageThresholdExceeded.isexceeded001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded002.
+ * VM Testbase keywords: [quick, monitoring, quarantine]
+ * VM Testbase comments: JDK-8153598
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isUsageThresholdExceeded()
+ *     returns correct results, if the pool supports usage thresholds.
+ *     The test sets a threshold that is greater than used value, allocates 100K,
+ *     and chechs that getUsageThreshold(), getUsed(), isUsageThresholdExceeded()
+ *     do not contradict each other, i.e.:
+ *         1. if used value is greater or equal than threshold, then
+ *            isUsageThresholdExceeded() is expected to return true;
+ *         2. If used value is less than threshold, then isUsageThresholdExceeded()
+ *            is expected to return false.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isUsageThresholdExceeded.isexceeded001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded003.
+ * VM Testbase keywords: [quick, monitoring, quarantine]
+ * VM Testbase comments: JDK-8153598
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isUsageThresholdExceeded()
+ *     returns correct results, if the pool supports usage thresholds.
+ *     The test sets a threshold that is greater than used value, allocates 100K,
+ *     and chechs that getUsageThreshold(), getUsed(), isUsageThresholdExceeded()
+ *     do not contradict each other, i.e.:
+ *         1. if used value is greater or equal than threshold, then
+ *            isUsageThresholdExceeded() is expected to return true;
+ *         2. If used value is less than threshold, then isUsageThresholdExceeded()
+ *            is expected to return false.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isUsageThresholdExceeded.isexceeded001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded004.
+ * VM Testbase keywords: [quick, monitoring, quarantine]
+ * VM Testbase comments: JDK-8153598
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isUsageThresholdExceeded()
+ *     returns correct results, if the pool supports usage thresholds.
+ *     The test sets a threshold that is greater than used value, allocates 100K,
+ *     and chechs that getUsageThreshold(), getUsed(), isUsageThresholdExceeded()
+ *     do not contradict each other, i.e.:
+ *         1. if used value is greater or equal than threshold, then
+ *            isUsageThresholdExceeded() is expected to return true;
+ *         2. If used value is less than threshold, then isUsageThresholdExceeded()
+ *            is expected to return false.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isUsageThresholdExceeded.isexceeded001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005.
+ * VM Testbase keywords: [quick, monitoring, quarantine]
+ * VM Testbase comments: JDK-8153598
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isUsageThresholdExceeded()
+ *     returns correct results, if the pool supports usage thresholds.
+ *     The test sets a threshold that is greater than used value, allocates 100K,
+ *     and chechs that getUsageThreshold(), getUsed(), isUsageThresholdExceeded()
+ *     do not contradict each other, i.e.:
+ *         1. if used value is greater or equal than threshold, then
+ *            isUsageThresholdExceeded() is expected to return true;
+ *         2. If used value is less than threshold, then isUsageThresholdExceeded()
+ *            is expected to return false.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isUsageThresholdExceeded.isexceeded001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.isUsageThresholdSupported;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class issupported001 {
+    private static boolean testFailed = false;
+    static MemoryMonitor monitor;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            boolean isSupported = monitor.isUsageThresholdSupported(pool);
+
+            if (isSupported) {
+                log.display("  supports usage thresholds");
+
+                // No exceptions are expected
+                try {
+                    long threshold = monitor.getUsageThreshold(pool);
+                    log.display("  threshold " + threshold + " is read");
+                } catch (Exception e) {
+                    log.complain(e + " is thrown in pool "
+                               + monitor.getName(pool));
+                    e.printStackTrace(log.getOutStream());
+                    testFailed = true;
+                }
+            } else {
+                log.display("  does not support usage thresholds");
+
+                // UnsupportedOperationException is expected
+                try {
+                    long threshold = monitor.getUsageThreshold(pool);
+                    log.complain("Threshold " + threshold + " is returned "
+                               + "instead of UnsupportedOperationException "
+                               + "in pool " + monitor.getName(pool));
+                    testFailed = true;
+                } catch (Exception e) {
+
+                    Throwable unwrapped = unwrap(e);
+
+                    if (unwrapped instanceof UnsupportedOperationException) {
+                        log.display("  UnsupportedOperationException is "
+                                  + "thrown");
+                    } else {
+                        log.complain("Incorrect execption " + unwrapped
+                                   + " is thrown, "
+                                   + "UnsupportedOperationException is "
+                                   + "expected");
+                        unwrapped.printStackTrace(log.getOutStream());
+                        testFailed = true;
+                    }
+                } // try
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    static Throwable unwrap(Throwable throwable) {
+
+        Throwable unwrapped, t = throwable;
+
+        do {
+            unwrapped = t;
+
+            if (unwrapped instanceof UnsupportedOperationException) {
+                break;
+            }
+
+            t = unwrapped.getCause();
+
+        } while (t != null);
+
+        return unwrapped;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isUsageThresholdSupported()
+ *     returns correct results.
+ *     The test checks that for each memory pool
+ *         1. isUsageThresholdSupported() returns true and getUsageThreshold()
+ *            returns not -1 value, or
+ *         2. isUsageThresholdSupported() returns false and getUsageThreshold()
+ *            returns -1 value
+ *     Otherwise, the test fails.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *     Adjusted the bug to Tiger-b40.
+ *     Fixed the bug:
+ *     5035038 Chain of JMX exceptions impact on monitoring tests
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.isUsageThresholdSupported.issupported001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isUsageThresholdSupported()
+ *     returns correct results.
+ *     The test checks that for each memory pool
+ *         1. isUsageThresholdSupported() returns true and getUsageThreshold()
+ *            returns not -1 value, or
+ *         2. isUsageThresholdSupported() returns false and getUsageThreshold()
+ *            returns -1 value
+ *     Otherwise, the test fails.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isUsageThresholdSupported.issupported001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isUsageThresholdSupported()
+ *     returns correct results.
+ *     The test checks that for each memory pool
+ *         1. isUsageThresholdSupported() returns true and getUsageThreshold()
+ *            returns not -1 value, or
+ *         2. isUsageThresholdSupported() returns false and getUsageThreshold()
+ *            returns -1 value
+ *     Otherwise, the test fails.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isUsageThresholdSupported.issupported001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isUsageThresholdSupported()
+ *     returns correct results.
+ *     The test checks that for each memory pool
+ *         1. isUsageThresholdSupported() returns true and getUsageThreshold()
+ *            returns not -1 value, or
+ *         2. isUsageThresholdSupported() returns false and getUsageThreshold()
+ *            returns -1 value
+ *     Otherwise, the test fails.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isUsageThresholdSupported.issupported001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.isUsageThresholdSupported()
+ *     returns correct results.
+ *     The test checks that for each memory pool
+ *         1. isUsageThresholdSupported() returns true and getUsageThreshold()
+ *            returns not -1 value, or
+ *         2. isUsageThresholdSupported() returns false and getUsageThreshold()
+ *            returns -1 value
+ *     Otherwise, the test fails.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.isUsageThresholdSupported.issupported001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.resetPeakUsage;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class reset001 {
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            byte[] b = new byte[10 * 1024]; // Eat 10K
+            Object pool = pools.get(i);
+
+            // No exceptions should be thrown
+            try {
+                monitor.resetPeakUsage(pool);
+            } catch (Throwable t) {
+                if (t instanceof ThreadDeath)
+                    throw (ThreadDeath) t;
+                log.complain("Unexpected exception in pool "
+                           + monitor.getName(pool));
+                t.printStackTrace(log.getOutStream());
+                testFailed = true;
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.resetPeakUsage()
+ *     does not throw any exceptions.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.resetPeakUsage.reset001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.resetPeakUsage()
+ *     does not throw any exceptions.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.resetPeakUsage.reset001 -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.resetPeakUsage()
+ *     does not throw any exceptions.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.resetPeakUsage.reset001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.resetPeakUsage()
+ *     does not throw any exceptions.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.resetPeakUsage.reset001 -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.resetPeakUsage()
+ *     does not throw any exceptions.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.resetPeakUsage.reset001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,242 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.setCollectionUsageThreshold;
+
+import java.io.*;
+import java.util.*;
+import java.lang.management.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class setthreshold001 {
+    private static class TestParameters {
+        private final long max, validThreshold, invalidThreshold;
+        private final boolean supportsMax;
+
+        public TestParameters(MemoryUsage usg) {
+            max = usg.getMax();
+            supportsMax = (max != -1);
+            validThreshold = supportsMax ? max : 1;
+            invalidThreshold = supportsMax ? max * 2 : Long.MAX_VALUE;
+        }
+    }
+    private static MemoryMonitor monitor;
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            log.display(i + " pool " + monitor.getName(pool));
+
+            boolean isSupported = monitor.isCollectionThresholdSupported(pool);
+            MemoryUsage usage = monitor.getCollectionUsage(pool);
+            if (usage == null) {
+                log.display("  getCollectionUsage() is not supported: it "
+                          + "returned null");
+                continue;
+            }
+
+            if (isSupported) {
+                // Usage thresholds are supported
+                log.display("  supports collection usage thresholds");
+                testcase1(log, pool);
+                testcase2(log, pool);
+                testcase3(log, pool);
+            } else {
+                log.display("  does not support usage thresholds");
+                testcase4(log, pool);
+
+
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    private static void testcase4(Log log, Object pool) {
+        // 4. If the usage thresholds are not supported, the method
+        // must throw UnsupportedOperationException
+        TestParameters tp = new TestParameters(monitor.getUsage(pool));
+        try {
+            monitor.setUsageThreshold(pool, tp.validThreshold);
+            log.complain("UnsupportedOperationException is not thrown "
+                       + "in pool " + monitor.getName(pool));
+            testFailed = true;
+        } catch (Exception e) {
+
+            // The exception is expected, since the usage thresholds are
+            // not supported
+            handleUOE(e, log, "Testcase 4.");
+        }
+    }
+
+    private static void testcase3(Log log, Object pool) {
+        // 3. Try to set threshold that is greater than max value
+        //    or somehow invalid
+        TestParameters tp = new TestParameters(monitor.getUsage(pool));
+        if (tp.supportsMax) {
+            try {
+                // setCollectionThreshold() should throw an exception
+                // given that the threshold is invalid
+
+                monitor.setCollectionThreshold(pool, tp.invalidThreshold);
+                log.complain("IllegalArgumentException is not thrown "
+                             + "in pool " + monitor.getName(pool) + " for "
+                             + "threshold " + tp.invalidThreshold + " ("
+                             + monitor.getCollectionUsage(pool) + ")");
+                testFailed = true;
+            } catch (Exception e) {
+                // The exception is expected, since the threshold is invalid
+                handleIAE(e, log, "Testcase 3.");
+            }
+        } else {
+            try {
+                // setCollectionThreshold() should not throw
+                // an exception given that the memory pool
+                // does not support a max, even though the
+                // threshold is invalid
+
+                monitor.setCollectionThreshold(pool, tp.invalidThreshold);
+                log.display("  threshold " + tp.invalidThreshold + " is set");
+                long used = monitor.getCollectionUsage(pool).getUsed();
+                monitor.setCollectionThreshold(pool, used);
+                log.display("  threshold " + used + " is set");
+                long threshold = monitor.getCollectionThreshold(pool);
+                if (threshold != used) {
+                    log.complain("Threshold value is " + threshold + ", "
+                                 + "but " + used + " was set in pool "
+                                 + monitor.getName(pool));
+                    testFailed = true;
+                } else
+                    log.display("  threshold " + threshold + " is read");
+            } catch (Exception e) {
+                log.complain("Unexpected " + e + " in pool "
+                             + monitor.getName(pool));
+                e.printStackTrace(log.getOutStream());
+                testFailed = true;
+            }
+        }
+    }
+
+    private static void testcase2(Log log, Object pool) {
+        // 2. Try to set negative threshold
+        try {
+            monitor.setCollectionThreshold(pool, -1);
+            log.complain("IllegalArgumentException is not thrown "
+                       + "in pool " + monitor.getName(pool) + " for "
+                       + "negative threshold");
+            testFailed = true;
+        } catch (Exception e) {
+
+            // The IllegalArgumentException  is expected, since the
+            // threshold is negative
+            handleIAE(e, log, "Testcase 2.");
+        }
+    }
+
+    private static void testcase1(Log log, Object pool) {
+        // 1. Try to set two different values of thresholds
+        try {
+            TestParameters tp = new TestParameters(monitor.getUsage(pool));
+
+            monitor.setCollectionThreshold(pool, tp.validThreshold);
+            log.display("  threshold " + tp.validThreshold + " is set");
+            long used = monitor.getCollectionUsage(pool).getUsed();
+            monitor.setCollectionThreshold(pool, used);
+            log.display("  threshold " + used + " is set");
+            long threshold = monitor.getCollectionThreshold(pool);
+            if (threshold != used) {
+                log.complain("Threshold value is " + threshold + ", "
+                           + "but " + used + " was set in pool "
+                           + monitor.getName(pool));
+                testFailed = true;
+            } else
+                log.display("  threshold " + threshold + " is read");
+        } catch (Exception e) {
+            log.complain("Unexpected " + e + " in pool "
+                       + monitor.getName(pool));
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+    }
+
+    // Handle UnsupportedOperationException
+    private static void handleUOE(Throwable e, Log log, String testcase) {
+        Throwable tmp = unwrap(e);
+
+        if (tmp instanceof UnsupportedOperationException) {
+            log.display("  " + testcase + " UnsupportedOperationException is "
+                      + "thrown");
+        } else {
+            log.complain("  " + testcase + " Incorrect execption " + tmp + " is "
+                       + "thrown, UnsupportedOperationException is expected");
+            tmp.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+    }
+
+    // Handle IllegalArgumentException
+    private static void handleIAE(Throwable e, Log log, String testcase) {
+        Throwable tmp = unwrap(e);
+
+        if (tmp instanceof IllegalArgumentException) {
+            log.display("  " + testcase + " IllegalArgumentException is "
+                      + "thrown");
+        } else {
+            log.complain("  " + testcase + " Incorrect execption " + tmp + " is "
+                       + "thrown, IllegalArgumentException is expected");
+            tmp.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+    }
+
+    static Throwable unwrap(Throwable throwable) {
+
+        Throwable unwrapped, t = throwable;
+
+        do {
+            unwrapped = t;
+
+            if (unwrapped instanceof UnsupportedOperationException) {
+                break;
+            }
+
+            t = unwrapped.getCause();
+
+        } while (t != null);
+
+        return unwrapped;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.setCollectionUsageThreshold()
+ *     sets values correctly.
+ *     If collection usage thresholds are supported in the pool, the test
+ *         1. sets two different values and expects that
+ *            getCollectionUsageThreshold() returns the latest one;
+ *         2. sets negative threshold and expects IllegalArgumentException;
+ *         3. sets threshold that has value greater than max value and expects
+ *            IllegalArgumentException.
+ *     If collection usage thresholds are not supported, the test sets a
+ *     threshold and expects UnsupportedOperationException.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *     Fixed the bug:
+ *     5035038 Chain of JMX exceptions impact on monitoring tests
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.setCollectionUsageThreshold.setthreshold001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.setCollectionUsageThreshold()
+ *     sets values correctly.
+ *     If collection usage thresholds are supported in the pool, the test
+ *         1. sets two different values and expects that
+ *            getCollectionUsageThreshold() returns the latest one;
+ *         2. sets negative threshold and expects IllegalArgumentException;
+ *         3. sets threshold that has value greater than max value and expects
+ *            IllegalArgumentException.
+ *     If collection usage thresholds are not supported, the test sets a
+ *     threshold and expects UnsupportedOperationException.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.setCollectionUsageThreshold.setthreshold001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.setCollectionUsageThreshold()
+ *     sets values correctly.
+ *     If collection usage thresholds are supported in the pool, the test
+ *         1. sets two different values and expects that
+ *            getCollectionUsageThreshold() returns the latest one;
+ *         2. sets negative threshold and expects IllegalArgumentException;
+ *         3. sets threshold that has value greater than max value and expects
+ *            IllegalArgumentException.
+ *     If collection usage thresholds are not supported, the test sets a
+ *     threshold and expects UnsupportedOperationException.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.setCollectionUsageThreshold.setthreshold001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.setCollectionUsageThreshold()
+ *     sets values correctly.
+ *     If collection usage thresholds are supported in the pool, the test
+ *         1. sets two different values and expects that
+ *            getCollectionUsageThreshold() returns the latest one;
+ *         2. sets negative threshold and expects IllegalArgumentException;
+ *         3. sets threshold that has value greater than max value and expects
+ *            IllegalArgumentException.
+ *     If collection usage thresholds are not supported, the test sets a
+ *     threshold and expects UnsupportedOperationException.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.setCollectionUsageThreshold.setthreshold001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.setCollectionUsageThreshold()
+ *     sets values correctly.
+ *     If collection usage thresholds are supported in the pool, the test
+ *         1. sets two different values and expects that
+ *            getCollectionUsageThreshold() returns the latest one;
+ *         2. sets negative threshold and expects IllegalArgumentException;
+ *         3. sets threshold that has value greater than max value and expects
+ *            IllegalArgumentException.
+ *     If collection usage thresholds are not supported, the test sets a
+ *     threshold and expects UnsupportedOperationException.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.setCollectionUsageThreshold.setthreshold001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryPoolMBean.setUsageThreshold;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class setthreshold001 {
+    private static MemoryMonitor monitor;
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        monitor = Monitor.getMemoryMonitor(log, argHandler);
+        List pools = monitor.getMemoryPoolMBeans();
+
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            log.display(i + " pool " + monitor.getName(pool));
+
+            boolean isSupported = monitor.isUsageThresholdSupported(pool);
+            long max = monitor.getUsage(pool).getMax();
+            boolean supportsMax = true;
+            long validThreshold = 0;
+            long invalidThreshold = 0;
+            if (max == -1) {
+                // max is undefined for this pool.
+                supportsMax = false;
+                validThreshold = 1;
+                invalidThreshold = Long.MAX_VALUE;
+            } else {
+                supportsMax = true;
+                validThreshold = max;
+                invalidThreshold = max + 1;
+            }
+
+            if (isSupported) {
+
+                // Usage thresholds are supported
+                log.display("  supports usage thresholds");
+
+                // 1. Try to set two different values of thresholds
+                monitor.setUsageThreshold(pool, validThreshold);
+                log.display("  threshold " + validThreshold + " is set");
+                long used = monitor.getUsage(pool).getUsed();
+                monitor.setUsageThreshold(pool, used);
+                log.display("  threshold " + used + " is set");
+
+                long threshold = monitor.getUsageThreshold(pool);
+                if (threshold != used) {
+                    log.complain("Threshold value is " + threshold + ", but "
+                               + used + " was set in pool "
+                               + monitor.getName(pool));
+                    testFailed = true;
+                } else
+                    log.display("  threshold " + threshold + " is read");
+
+                // 2. Try to set negative threshold
+                try {
+                    monitor.setUsageThreshold(pool, -1);
+                    log.complain("IllegalArgumentException is not thrown "
+                               + "in pool " + monitor.getName(pool) + " for "
+                               + "negative threshold");
+                    testFailed = true;
+                } catch (Exception e) {
+
+                    // The IllegalArgumentException  is expected, since the
+                    // threshold is negative
+                    handleIAE(e, log, "Testcase 2.");
+                }
+
+                // 3. Try to set threshold that is invalid
+                if (supportsMax) {
+                    try {
+                        // setUsageThreshold() should throw an exception
+                        // given that the threshold is invalid
+                        monitor.setUsageThreshold(pool, invalidThreshold);
+                        log.complain("IllegalArgumentException is not thrown "
+                                     + "in pool " + monitor.getName(pool) + " for "
+                                     + " threshold " + invalidThreshold + " ("
+                                     + monitor.getUsage(pool) + ")");
+                        testFailed = true;
+                    } catch (Exception e) {
+
+                        // The exception is expected, since the threshold is invalid
+                        handleIAE(e, log, "Testcase 3.");
+                    }
+                } else {
+                    // setUsageThreshold() should not throw an
+                    // exception given that the memory pool does not
+                    // support a max, even though the threshold is invalid
+
+                    monitor.setUsageThreshold(pool, invalidThreshold);
+                    log.display("  threshold " + invalidThreshold + " is set");
+                    long used2 = monitor.getUsage(pool).getUsed();
+                    monitor.setUsageThreshold(pool, used2);
+                    log.display("  threshold " + used2 + " is set");
+
+                    long threshold2 = monitor.getUsageThreshold(pool);
+                    if (threshold2 != used2) {
+                        log.complain("Threshold value is " + threshold2 + ", but "
+                                     + used2 + " was set in pool "
+                                     + monitor.getName(pool));
+                        testFailed = true;
+                    } else
+                        log.display("  threshold " + threshold2 + " is read");
+                }
+            } else {
+
+                // 4. If the usage thresholds are not supported, the method
+                // must throw UnsupportedOperationException
+                log.display("  does not support usage thresholds");
+
+                try {
+                    monitor.setUsageThreshold(pool, max);
+                    log.complain("UnsupportedOperationException is not thrown "
+                               + "in pool " + monitor.getName(pool));
+                    testFailed = true;
+                } catch (Exception e) {
+
+                    // The exception is expected, since the usage thresholds are
+                    // not supported
+                    handleUOE(e, log, "Testcase 4.");
+                }
+            }
+        } // for i
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    // Handle UnsupportedOperationException
+    private static void handleUOE(Throwable e, Log log, String testcase) {
+        Throwable tmp = unwrap(e);
+
+        if (tmp instanceof UnsupportedOperationException) {
+            log.display("  " + testcase + " UnsupportedOperationException is "
+                      + "thrown");
+        } else {
+            log.complain("  " + testcase + " Incorrect execption " + tmp + " is "
+                       + "thrown, UnsupportedOperationException is expected");
+            tmp.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+    }
+
+    // Handle IllegalArgumentException
+    private static void handleIAE(Throwable e, Log log, String testcase) {
+        Throwable tmp = unwrap(e);
+
+        if (tmp instanceof IllegalArgumentException) {
+            log.display("  " + testcase + " IllegalArgumentException is "
+                      + "thrown");
+        } else {
+            log.complain("  " + testcase + " Incorrect execption " + tmp + " is "
+                       + "thrown, IllegalArgumentException is expected");
+            tmp.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+    }
+
+    static Throwable unwrap(Throwable throwable) {
+
+        Throwable unwrapped, t = throwable;
+
+        do {
+            unwrapped = t;
+
+            if (unwrapped instanceof UnsupportedOperationException) {
+                break;
+            }
+
+            t = unwrapped.getCause();
+
+        } while (t != null);
+
+        return unwrapped;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.setUsageThreshold()
+ *     sets values correctly.
+ *     If the usage thresholds are supported in the pool, the test
+ *         1. sets two different values and expects that getUsageThreshold()
+ *            returns the latest one;
+ *         2. sets negative threshold and expects IllegalArgumentException;
+ *         3. sets threshold that has value greater than max value and expects
+ *            IllegalArgumentException.
+ *     If the usage thresholds are not supported, the test sets a threshold and
+ *     expects UnsupportedOperationException.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *     Fixed the bug:
+ *     5035038 Chain of JMX exceptions impact on monitoring tests
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryPoolMBean.setUsageThreshold.setthreshold001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.setUsageThreshold()
+ *     sets values correctly.
+ *     If the usage thresholds are supported in the pool, the test
+ *         1. sets two different values and expects that getUsageThreshold()
+ *            returns the latest one;
+ *         2. sets negative threshold and expects IllegalArgumentException;
+ *         3. sets threshold that has value greater than max value and expects
+ *            IllegalArgumentException.
+ *     If the usage thresholds are not supported, the test sets a threshold and
+ *     expects UnsupportedOperationException.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.setUsageThreshold.setthreshold001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.setUsageThreshold()
+ *     sets values correctly.
+ *     If the usage thresholds are supported in the pool, the test
+ *         1. sets two different values and expects that getUsageThreshold()
+ *            returns the latest one;
+ *         2. sets negative threshold and expects IllegalArgumentException;
+ *         3. sets threshold that has value greater than max value and expects
+ *            IllegalArgumentException.
+ *     If the usage thresholds are not supported, the test sets a threshold and
+ *     expects UnsupportedOperationException.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.setUsageThreshold.setthreshold001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.setUsageThreshold()
+ *     sets values correctly.
+ *     If the usage thresholds are supported in the pool, the test
+ *         1. sets two different values and expects that getUsageThreshold()
+ *            returns the latest one;
+ *         2. sets negative threshold and expects IllegalArgumentException;
+ *         3. sets threshold that has value greater than max value and expects
+ *            IllegalArgumentException.
+ *     If the usage thresholds are not supported, the test sets a threshold and
+ *     expects UnsupportedOperationException.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.setUsageThreshold.setthreshold001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryPoolMBean.setUsageThreshold()
+ *     sets values correctly.
+ *     If the usage thresholds are supported in the pool, the test
+ *         1. sets two different values and expects that getUsageThreshold()
+ *            returns the latest one;
+ *         2. sets negative threshold and expects IllegalArgumentException;
+ *         3. sets threshold that has value greater than max value and expects
+ *            IllegalArgumentException.
+ *     If the usage thresholds are not supported, the test sets a threshold and
+ *     expects UnsupportedOperationException.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.MemoryPoolMBean.setUsageThreshold.setthreshold001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryUsage/MemoryUsage/memoryusage001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryUsage.MemoryUsage;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+
+public class memoryusage001 {
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+
+        // Check all conditions for IllegalArgumentException
+
+        // 1.1. init is negative, but not -1
+        try {
+            new MemoryUsage(-2, 2, 3, 4);
+            out.println("Failure 1.1.");
+            out.println("new MemoryUsage(-2, 2, 3, 4) does not throw "
+                      + "IllegalArgumentException. init is negative, but not "
+                      + "-1.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+        }
+
+        // 1.2. max is negative, but not -1
+        try {
+            new MemoryUsage(1, 2, 3, -4);
+            out.println("Failure 1.2.");
+            out.println("new MemoryUsage(1, 2, 3, -4) does not throw "
+                      + "IllegalArgumentException. max is negative, but not "
+                      + "-1.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+        }
+
+        // 1.3. used is negative
+        try {
+            new MemoryUsage(1, -1, 3, 4);
+            out.println("Failure 1.3.");
+            out.println("new MemoryUsage(1, -1, 3, 4) does not throw "
+                      + "IllegalArgumentException. used is negative.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+        }
+
+        // 1.4. committed is negative
+        try {
+            new MemoryUsage(1, 2, -1, 4);
+            out.println("Failure 1.4.");
+            out.println("new MemoryUsage(1, 2, -1, 4) does not throw "
+                      + "IllegalArgumentException. committed is negative.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+        }
+
+        // 1.5. used is greater than committed
+        try {
+            new MemoryUsage(1, 2, 1, 4);
+            out.println("Failure 1.5.");
+            out.println("new MemoryUsage(1, 2, 1, 4) does not throw "
+                      + "IllegalArgumentException. used is greater than "
+                      + "committed.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+        }
+
+        // 1.6. used is greater than max, while max is not -1
+        try {
+            new MemoryUsage(1, 5, 6, 4);
+            out.println("Failure 1.6.");
+            out.println("new MemoryUsage(1, 5, 6, 4) does not throw "
+                      + "IllegalArgumentException. used is greater than max, "
+                      + "while max is not -1.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+        }
+
+        // Check different correct sets of values for MemoryUsage
+
+        // 2.1. init is -1
+        try {
+            new MemoryUsage(-1, 2, 3, 4);
+        } catch (IllegalArgumentException e) {
+            out.println("Failure 2.1.");
+            out.println("new MemoryUsage(-1, 2, 3, 4) throws " + e + ". init is"
+                      + " -1.");
+            testFailed = true;
+        }
+
+        // 2.2. max is -1
+        try {
+            new MemoryUsage(1, 2, 3, -1);
+        } catch (IllegalArgumentException e) {
+            out.println("Failure 2.2.");
+            out.println("new MemoryUsage(1, 2, 3, -1) throws " + e + ". max is "
+                      + "-1.");
+            testFailed = true;
+        }
+
+        // 2.3. used is equal to max
+        try {
+            new MemoryUsage(1, 2, 3, 2);
+
+            out.println("Failure 2.3.");
+            out.println("new MemoryUsage(1, 2, 3, 2) does not throw IllegalArgumentException. "
+                      + "used is equal to max.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+            // expected exception
+        }
+
+        // 2.4. used is less than max
+        try {
+            new MemoryUsage(1, 2, 3, 4);
+        } catch (IllegalArgumentException e) {
+            out.println("Failure 2.4.");
+            out.println("new MemoryUsage(1, 2, 3, 4) throws " + e + ". used is "
+                      + "less than max.");
+            testFailed = true;
+        }
+
+        // 2.5. committed is less than init
+        try {
+            new MemoryUsage(4, 2, 3, -1);
+        } catch (IllegalArgumentException e) {
+            out.println("Failure 2.5.");
+            out.println("new MemoryUsage(4, 2, 3, -1) throws " + e + ". "
+                      + "committed is less than init.");
+            testFailed = true;
+        }
+
+        // 2.6. max is less than committed
+        try {
+            new MemoryUsage(1, 2, 4, 3);
+            out.println("Failure 2.6.");
+            out.println("new MemoryUsage(1, 2, 4, 3) does not throw IllegalArgumentException. "
+                      + "max is less than committed.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+            // expected exception
+        }
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryUsage/MemoryUsage/memoryusage001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryUsage/MemoryUsage/memoryusage001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryUsage(long init, long used, long committed, long max)
+ *     correctly throws IllegalArgumentException, if:
+ *         1. init is negative, but not -1
+ *         2. max is negative, but not -1
+ *         3. used is negative
+ *         4. committed is negative
+ *         5. used is greater than committed
+ *         6. used is greater than max, while max is not -1
+ *     The method also checks that the constructor does not throw
+ *     IllegalArgumentException, if:
+ *         1. init is -1
+ *         2. max is -1
+ *         3. used is equal to max
+ *         4. used is less than max
+ *         5. committed is less than init
+ *         6. max is less than committed
+ * COMMENT
+ *     Fixed the bug:
+ *     5050603 memoryusage001 needs to be updated for MemoryUsage
+ *             spec change.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryUsage.MemoryUsage.memoryusage001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryUsage/from/from001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.MemoryUsage.from;
+
+import java.lang.management.*;
+import javax.management.*;
+import javax.management.openmbean.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class from001 {
+
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+
+        // 1. Check null CompositeData - null must be returned
+        MemoryUsage result = MemoryUsage.from(null);
+
+        if (result != null) {
+            log.complain("FAILURE 1.");
+            log.complain("MemoryUsage.from(null) returned " + result
+                      + ", expected: null.");
+            testFailed = true;
+        }
+
+        // 2. Check CompositeData that doest not represnt
+        // MemoryUsage - IllegalArgumentException must be thrown
+        Monitor.getThreadMonitor(log, argHandler);
+
+        Thread thread = Thread.currentThread();
+        long id = thread.getId();
+
+        Object[] params = {new Long(id), new Integer(Integer.MAX_VALUE)};
+        String[] signature = {"long", "int"};
+
+        ObjectName mbeanObjectName = null;
+        CompositeData cdata = null;
+        try {
+            mbeanObjectName = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME);
+            cdata = (CompositeData) Monitor.getMBeanServer().invoke(
+                                                mbeanObjectName,
+                                                "getThreadInfo", params, signature);
+        } catch (Exception e) {
+            log.complain("Unexpected exception " + e);
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+
+        try {
+            result = MemoryUsage.from(cdata);
+            log.complain("FAILURE 2.");
+            log.complain("MemoryUsage.from(CompositeData) returned " + result
+                      + ", expected: IllegalArgumentException.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+
+            // Expected: CompositeData doest not represnt MemoryUsage
+        }
+
+        // 3. Check correct CompositeData
+        CompositeData correctCD = null;
+        try {
+            mbeanObjectName = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
+            correctCD = (CompositeData) Monitor.getMBeanServer().getAttribute(
+                                                mbeanObjectName,
+                                                "HeapMemoryUsage");
+        } catch (Exception e) {
+            log.complain("Unexpected exception " + e);
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+
+        result = MemoryUsage.from(correctCD);
+        long init = result.getInit();
+        long used = result.getUsed();
+        long comm = result.getCommitted();
+        long max = result.getMax();
+
+        if (testFailed)
+            log.complain("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryUsage/from/from001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/MemoryUsage/from/from001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         MemoryUsage.from(CompositeData)
+ *     returns correct results:
+ *     1. null, if CompositeData is null;
+ *     2. trows IllegalArgumentException, if CompositeData doest not represnt
+ *        MemoryNotificationInfo;
+ *     3. correct MemoryUsage object, if CompositeData is correct (i.e all
+ *        attributes of the CompositeData must have correct values: init, used,
+ *        committed, max).
+ * COMMENT
+ *     Updated according to:
+ *     5014783 Move ThreadState class from java.lang.management to java.lang
+ *     5024531 Fix MBeans design flaw that restricts to use JMX CompositeData
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.MemoryUsage.from.from001 -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean001/RuntimeMXBean001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/RuntimeMXBean/RuntimeMXBean001.
+ * VM Testbase keywords: [quick, monitoring]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.RuntimeMXBean.RuntimeMXBean001.RuntimeMXBean001
+ *      -testMode=directly
+ */
+
+package nsk.monitoring.RuntimeMXBean.RuntimeMXBean001;
+
+import nsk.share.*;
+import nsk.share.test.*;
+import nsk.monitoring.share.*;
+import java.lang.management.*;
+
+/**
+ * Test functions of RuntimeMXBean.
+ *
+ *
+ * Checks that values returned by getStartTime() and getUptime()
+ * measure actual uptime well enough, i.e.
+ *  - start time does not change with time
+ *  - start time + uptime is approximately current time
+ */
+public class RuntimeMXBean001 extends MonitoringTestBase implements Initializable {
+        private static final long NANO_MS = 1000000;
+
+        private RuntimeMXBean runtime;
+        private int iterations = 10;
+        private long maxDiff = 5000;
+        private int fail_count = 0;
+
+        public void initialize() {
+                runtime = monitoringFactory.getRuntimeMXBean();
+        }
+
+        private static final long getMillis() {
+            return System.nanoTime() / NANO_MS;
+        }
+
+        private void checkTimes(long startTime, long upTime, String msg) {
+                if (startTime <= 0)
+                        throw new TestFailure("Invalid start time: " + startTime);
+                if (upTime <= 0)
+                        throw new TestFailure("Invalid uptime: " + upTime);
+        }
+
+        private void testUptimeOne(long sleepTime) {
+                long startTime1 = runtime.getStartTime();
+                long uptime1 = runtime.getUptime();
+                long time1 = getMillis();
+                log.info("startTime: " + startTime1 + ", uptime1: " + uptime1 + ", time1: " + time1);
+                checkTimes(startTime1, uptime1, "Before sleep");
+                try {
+                        Thread.sleep(sleepTime);
+                } catch (InterruptedException e) {
+                        throw new TestFailure("Sleep was interrupted", e);
+                }
+                long startTime2 = runtime.getStartTime();
+                long uptime2 = runtime.getUptime();
+                long time2 = getMillis();
+                checkTimes(startTime2, uptime2, "After sleep");
+
+                if (startTime1 != startTime2)
+                        throw new TestFailure("Start time before sleep: " + startTime1 + " start time after sleep: " + startTime2);
+                if (uptime2 < uptime1)
+                        throw new TestFailure("Uptime before sleep: " + uptime1 + " uptime after sleep: " + uptime2);
+
+                long utDiff = (uptime2 - uptime1);
+                long tDiff = (time2 - time1);
+                long flowDiff = Math.abs(utDiff -tDiff);
+                if (flowDiff > maxDiff) {
+                        throw new TestFailure("Difference between timeflow of uptime and current time is too big: " + flowDiff + ", expecting at most " + maxDiff);
+                }
+        }
+
+        private void testUptime() {
+                for (int i = 0; i < iterations; ++i) {
+                        log.info("Iteration: " + i);
+                        testUptimeOne(LocalRandom.randomPauseTime());
+                }
+        }
+
+        public void run() {
+                testUptime();
+        }
+
+        public static void main(String[] args) {
+                Monitoring.runTest(new RuntimeMXBean001(), args);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/RuntimeMXBean/RuntimeMXBean002.
+ * VM Testbase keywords: [quick, monitoring]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.RuntimeMXBean.RuntimeMXBean001.RuntimeMXBean001
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/RuntimeMXBean/RuntimeMXBean003.
+ * VM Testbase keywords: [quick, monitoring]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.RuntimeMXBean.RuntimeMXBean001.RuntimeMXBean001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/RuntimeMXBean/RuntimeMXBean004.
+ * VM Testbase keywords: [quick, monitoring]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.RuntimeMXBean.RuntimeMXBean001.RuntimeMXBean001
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/RuntimeMXBean/RuntimeMXBean005.
+ * VM Testbase keywords: [quick, monitoring]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.RuntimeMXBean.RuntimeMXBean001.RuntimeMXBean001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean006/RuntimeMXBean006.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/RuntimeMXBean/RuntimeMXBean006.
+ * VM Testbase keywords: [quick, monitoring, feature_jrockit_mxbeans_7u4]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         RuntimeMXBean.getName()
+ *     returns a name on the form <pid><at><hostname>.
+ *     The test accesses RuntimeMXBean directly.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.RuntimeMXBean.RuntimeMXBean006.RuntimeMXBean006
+ *      -testMode=directly
+ */
+
+package nsk.monitoring.RuntimeMXBean.RuntimeMXBean006;
+
+import java.lang.management.RuntimeMXBean;
+import java.util.regex.Pattern;
+
+import nsk.monitoring.share.Monitoring;
+import nsk.monitoring.share.MonitoringTestBase;
+import nsk.share.test.Initializable;
+
+public class RuntimeMXBean006 extends MonitoringTestBase implements Initializable {
+    private RuntimeMXBean runtime;
+    private Pattern namePattern;
+
+    public void initialize() {
+        runtime = monitoringFactory.getRuntimeMXBean();
+        /* Name should be on the format <pid>@<hostname>. */
+        namePattern = Pattern.compile("^[0-9]+@(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$");
+    }
+
+    private void testGetName() {
+        String name = runtime.getName();
+        log.debug(String.format("RuntimeMXBean.getName() returned \"%s\".", name));
+
+        if (namePattern.matcher(name).matches()) {
+            setFailed(false);
+        } else {
+            log.info(String.format("Test failure: name did not match format <pid>@<hostname>: \"%s\"", name));
+        }
+    }
+
+    public void run() {
+        setFailed(true);
+        testGetName();
+    }
+
+    public static void main(String[] args) {
+        Monitoring.runTest(new RuntimeMXBean006(), args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean007/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/RuntimeMXBean/RuntimeMXBean007.
+ * VM Testbase keywords: [quick, monitoring, feature_jrockit_mxbeans_7u4]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         RuntimeMXBean.getName()
+ *     returns a name on the form <pid><at><hostname>.
+ *     The test accesses RuntimeMXBean via default MBean server.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.RuntimeMXBean.RuntimeMXBean006.RuntimeMXBean006
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean008/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/RuntimeMXBean/RuntimeMXBean008.
+ * VM Testbase keywords: [quick, monitoring, feature_jrockit_mxbeans_7u4]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         RuntimeMXBean.getName()
+ *     returns a name on the form <pid><at><hostname>.
+ *     The test accesses RuntimeMXBean via custom MBean server.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.RuntimeMXBean.RuntimeMXBean006.RuntimeMXBean006
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean009/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/RuntimeMXBean/RuntimeMXBean009.
+ * VM Testbase keywords: [quick, monitoring, feature_jrockit_mxbeans_7u4]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         RuntimeMXBean.getName()
+ *     returns a name on the form <pid><at><hostname>.
+ *     The test accesses RuntimeMXBean via default MBean server proxy.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.RuntimeMXBean.RuntimeMXBean006.RuntimeMXBean006
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean010/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/RuntimeMXBean/RuntimeMXBean010.
+ * VM Testbase keywords: [quick, monitoring, feature_jrockit_mxbeans_7u4]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         RuntimeMXBean.getName()
+ *     returns a name on the form <pid><at><hostname>.
+ *     The test accesses RuntimeMXBean via custom MBean server proxy.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.RuntimeMXBean.RuntimeMXBean006.RuntimeMXBean006
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/from_c/from_c001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadInfo.from_c;
+
+import java.lang.management.*;
+import javax.management.*;
+import javax.management.openmbean.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class from_c001 {
+
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+
+        ThreadInfo result = null;
+
+        // 1. Check null CompositeData - null must be returned
+        result = ThreadInfo.from((CompositeData) null);
+
+        if (result != null) {
+            log.complain("FAILURE 1.");
+            log.complain("ThreadInfo.from(null) returned " + result
+                      + ", expected: null.");
+            testFailed = true;
+        }
+
+        MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+
+        ObjectName mbeanObjectName;
+        CompositeData cdata = null;
+
+        // 2. Check CompositeData that does not represent
+        // ThreadInfo - IllegalArgumentException must be thrown
+
+        try {
+            mbeanObjectName = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
+            cdata = (CompositeData )mbeanServer.getAttribute(mbeanObjectName,
+                                                                    "HeapMemoryUsage");
+        } catch (Exception e) {
+            log.complain("Unexpected exception " + e);
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+
+        try {
+            result = ThreadInfo.from(cdata);
+            log.complain("FAILURE 2.");
+            log.complain("ThreadInfo.from(CompositeData) returned " + result
+                      + ", expected: IllegalArgumentException.");
+            testFailed = true;
+        } catch (IllegalArgumentException e) {
+
+            // Expected: CompositeData doest not represnt ThreadInfo
+        }
+
+
+        Thread thread = Thread.currentThread();
+        long id = thread.getId();
+
+        Object[] params = {new Long(id), new Integer(Integer.MAX_VALUE)};
+        String[] signature = {"long", "int"};
+
+        cdata = null;
+        try {
+            mbeanObjectName = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME);
+            cdata = (CompositeData )mbeanServer.invoke(
+                                                mbeanObjectName,
+                                                "getThreadInfo", params, signature);
+        } catch (Exception e) {
+            log.complain("Unexpected exception " + e);
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+
+        try {
+            result = ThreadInfo.from(cdata);
+        } catch (Exception e) {
+            log.complain("FAILURE 3.");
+            log.complain("Unexpected " + e);
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+
+        long threadId = result.getThreadId();
+        Thread.State state = result.getThreadState();
+        boolean isInNative = result.isInNative();
+        boolean isSuspended = result.isSuspended();
+
+        // Thread ID, state, isInNative, isSuspended values must be correct
+        if (id != threadId) {
+            log.complain("FAILURE 3.1.");
+            log.complain("Wrong id value: " + threadId + ", expected: " + id);
+            testFailed = true;
+        }
+
+        if (state != Thread.State.RUNNABLE) {
+            log.complain("FAILURE 3.2.");
+            log.complain("Wrong id value: \"" + state + "\", expected: \""
+                      + Thread.State.RUNNABLE + "\"");
+            testFailed = true;
+        }
+
+        if (isInNative) {
+            log.complain("FAILURE 3.3.");
+            log.complain("Wrong isInNative value: true, expected: false");
+            testFailed = true;
+        }
+
+        if (isSuspended) {
+            log.complain("FAILURE 3.4.");
+            log.complain("Wrong isSuspended value: true, expected: false");
+            testFailed = true;
+        }
+
+        if (testFailed)
+            log.complain("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/from_c/from_c001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadInfo/from_c/from_c001.
+ * VM Testbase keywords: [quick, monitoring, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadInfo.from(CompositeData)
+ *     returns correct results:
+ *     1. null, if CompositeData is null;
+ *     2. trows IllegalArgumentException, if CompositeData doest not represnt
+ *        ThreadInfo;
+ *     3. correct ThreadInfo object, if CompositeData is correct (i.e attributes
+ *        of the CompositeData must have correct values: thread ID, state,
+ *        isInNative, isSuspended).
+ * COMMENT
+ *     Updated according to:
+ *     5014783 Move ThreadState class from java.lang.management to java.lang
+ *     5024531 Fix MBeans design flaw that restricts to use JMX CompositeData
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadInfo.from_c.from_c001 -testMode=server -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockName/getlockname001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadInfo.getLockName;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+
+public class getlockname001 {
+    private static Wicket mainEntrance = new Wicket();
+    private static Object backDoor = new Object();
+    private static String lock
+        = backDoor.getClass().getName() + "@"
+        + Integer.toHexString(System.identityHashCode(backDoor));
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
+        ThreadInfo info;
+        String name;
+
+        // Test MyThread that is going to be locked on "backDoor" object
+        MyThread myThread = new MyThread(out);
+        myThread.start();
+        long id = myThread.getId();
+
+        // Wait for MyThread to start
+        mainEntrance.waitFor();
+
+        synchronized(backDoor) {
+
+            // MyThread is about to be locked on "backDoor" right now
+            info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+            name = info.getLockName();
+            backDoor.notify();
+
+            if (!lock.equals(name)) {
+                out.println("Failure 1.");
+                out.println("ThreadInfo.getLockName() returned string \"" + name
+                          + "\" for a locked thread, but \"" + lock
+                          + "\" expected.");
+                testFailed = true;
+            }
+        }
+
+        // Test "main" that is not locked on any object
+        id = Thread.currentThread().getId();
+        info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+        name = info.getLockName();
+
+        if (name != null) {
+            out.println("Failure 2.");
+            out.println("ThreadInfo.getLockName() returned not-null \"" + name
+                      + "\" for a running thread.");
+            testFailed = true;
+        }
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    private static class MyThread extends Thread {
+        PrintStream out;
+
+        MyThread(PrintStream out) {
+            this.out = out;
+        }
+
+        public void run() {
+            synchronized(backDoor) {
+
+                // Notify "main" thread that "backDoor" is waiting for a signal
+                mainEntrance.unlock();
+
+                // The thread is locked on "backDoor" object
+                try {
+                    backDoor.wait();
+                } catch (InterruptedException e) {
+                    out.println("Unexpected exception.");
+                    e.printStackTrace(out);
+                    testFailed = true;
+                }
+            }
+        } // run()
+    } // MyThread
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockName/getlockname001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadInfo/getLockName/getlockname001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadInfo.getLockName()
+ *     returns correct string for a blocked thread and for a running thread.
+ *     The test starts an instance of MyThread, waits to be sure that it is blocked
+ *     on "backDoor" object and then calls getLockName() for it. Since the thread
+ *     is blocked, the expected string is:
+ *         backDoor.getClass().getName() + "<at>"
+ *         + Integer.toHexString(System.identityHashCode(backDoor))
+ *     After that current thread is checked. Since it is not blocked on any object,
+ *     getLockName() must return null.
+ *     Testing of the method does not depend on the way to access metrics, so
+ *     only one (direct access) is implemented in the test.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *     Updated according to:
+ *     5024531 Fix MBeans design flaw that restricts to use JMX CompositeData
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadInfo.getLockName.getlockname001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadInfo.getLockOwnerName;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+
+public class getlockownername001 {
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
+        long id = Thread.currentThread().getId();
+        ThreadInfo info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+        String name = info.getLockOwnerName();
+
+        if (name != null) {
+            out.println("TEST FAILED.");
+            out.println("ThreadInfo.getLockOwnerName() returned not-null \""
+                      + name + "\" for a running thread.");
+            return Consts.TEST_FAILED;
+        }
+        return Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadInfo.getLockOwnerName()
+ *     returns null string for a running thread.
+ *     The test examines the current thread that is not blocked on any object. So,
+ *     the method must return null.
+ *     Testing of the method does not depend on the way to access metrics, so
+ *     only one (direct access) is implemented in the test.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *     Updated according to:
+ *     5024531 Fix MBeans design flaw that restricts to use JMX CompositeData
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadInfo.getLockOwnerName.getlockownername001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/isInNative/isinnative001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadInfo.isInNative;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+
+public class isinnative001 {
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
+        Thread thread = Thread.currentThread();
+        long id = thread.getId();
+        ThreadInfo info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+        boolean isInNative = info.isInNative();
+
+        if (isInNative) {
+            out.println("TEST FAILED");
+            out.println("ThreadInfo.isInNative() returned true, in pure java "
+                      + "thread.");
+            return Consts.TEST_FAILED;
+        }
+        return Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/isInNative/isinnative001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadInfo/isInNative/isinnative001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadInfo.isInNative()
+ *     returns true for a pure java thread.
+ *     The test examines the current thread and expects the method to return true.
+ *     Testing of the method does not depend on the way to access metrics, so
+ *     only one (direct access) is implemented in the test.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *     Updated according to:
+ *     5024531 Fix MBeans design flaw that restricts to use JMX CompositeData
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadInfo.isInNative.isinnative001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadInfo.isSuspended;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+
+public class issuspended001 {
+    private static Wicket mainEntrance = new Wicket();
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
+        MyThread thread = new MyThread(out);
+        thread.start();
+
+        // Wait for MyThread to start
+        mainEntrance.waitFor();
+
+        long id = thread.getId();
+        ThreadInfo info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+        boolean isSuspended = info.isSuspended();
+        if (isSuspended) {
+            out.println("Failure 1.");
+            out.println("ThreadInfo.isSuspended() returned true, before "
+                      + "Thread.suspend() was invoked.");
+            testFailed = true;
+        }
+
+        thread.suspend();
+        info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+        isSuspended = info.isSuspended();
+        if (!isSuspended) {
+            out.println("Failure 2.");
+            out.println("ThreadInfo.isSuspended() returned false, after "
+                      + "Thread.suspend() was invoked.");
+            testFailed = true;
+        }
+
+        thread.resume();
+        info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+        isSuspended = info.isSuspended();
+        if (isSuspended) {
+            out.println("Failure 3.");
+            out.println("ThreadInfo.isSuspended() returned true, after "
+                      + "Thread.resume() was invoked.");
+            testFailed = true;
+        }
+
+        thread.die = true;
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    private static class MyThread extends Thread {
+        final static long WAIT_TIME = 500; // Milliseconds
+        Object object = new Object();
+        boolean die = false;
+        PrintStream out;
+
+        MyThread(PrintStream out) {
+            this.out = out;
+        }
+
+        public void run() {
+
+            // Notify "main" thread that MyThread has started
+            mainEntrance.unlock();
+
+            while (!die) {
+                synchronized(object) {
+                    try {
+                        object.wait(WAIT_TIME);
+                    } catch (InterruptedException e) {
+                        out.println("Unexpected exception.");
+                        e.printStackTrace(out);
+                        testFailed = true;
+                    }
+                } // synchronized
+            }
+        } // run()
+    } // MyThread
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadInfo/isSuspended/issuspended001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadInfo.isSuspended()
+ *     returns correct values for a thread in different states.
+ *     The test starts an instance of MyThread and checks that isSuspended()
+ *     returns false for it. Then it suspends the thread and expects the method
+ *     to return true. After that the MyThread is resumed and isSuspended() must
+ *     return false.
+ *     Testing of the method does not depend on the way to access metrics, so
+ *     only one (direct access) is implemented in the test.
+ * COMMENT
+ *     Fixed the bug
+ *     4989235 TEST: The spec is updated accoring to 4982289, 4985742
+ *     Updated according to:
+ *     5024531 Fix MBeans design flaw that restricts to use JMX CompositeData
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadInfo.isSuspended.issuspended001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended002.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadInfo.isSuspended;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+
+public class issuspended002 {
+    private static Wicket mainEntrance = new Wicket();
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
+        MyThread thread = new MyThread(out);
+        thread.start();
+
+        // Wait for MyThread to start
+        mainEntrance.waitFor();
+
+        long id = thread.getId();
+        ThreadInfo info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+        boolean isSuspended = info.isSuspended();
+        if (isSuspended) {
+            out.println("Failure 1.");
+            out.println("ThreadInfo.isSuspended() returned true, before "
+                      + "Thread.suspend() was invoked.");
+            testFailed = true;
+        }
+
+        thread.suspend();
+        info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+        isSuspended = info.isSuspended();
+        if (!isSuspended) {
+            out.println("Failure 2.");
+            out.println("ThreadInfo.isSuspended() returned false, after "
+                      + "Thread.suspend() was invoked.");
+            testFailed = true;
+        }
+
+        thread.resume();
+        info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+        isSuspended = info.isSuspended();
+        if (isSuspended) {
+            out.println("Failure 3.");
+            out.println("ThreadInfo.isSuspended() returned true, after "
+                      + "Thread.resume() was invoked.");
+            testFailed = true;
+        }
+
+        thread.die = true;
+
+        int count = 0;
+        while (true) {
+            info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+            if (info == null) {
+                // the thread has exited
+                break;
+            }
+            count++;
+            isSuspended = info.isSuspended();
+            if (isSuspended) {
+                out.println("Failure 4.");
+                out.println("ThreadInfo.isSuspended() returned true, after "
+                          + "thread.die was set to true.");
+                testFailed = true;
+                break;
+            }
+        }
+
+        out.println("INFO: made " + count + " late getThreadInfo() calls.");
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    private static class MyThread extends Thread {
+        final static long WAIT_TIME = 500; // Milliseconds
+        Object object = new Object();
+        volatile boolean die = false;
+        PrintStream out;
+
+        MyThread(PrintStream out) {
+            this.out = out;
+        }
+
+        public void run() {
+
+            // Notify "main" thread that MyThread has started
+            mainEntrance.unlock();
+
+            while (!die) {
+                synchronized(object) {
+                    try {
+                        object.wait(WAIT_TIME);
+                    } catch (InterruptedException e) {
+                        out.println("Unexpected exception.");
+                        e.printStackTrace(out);
+                        testFailed = true;
+                    }
+                } // synchronized
+            }
+        } // run()
+    } // MyThread
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadInfo/isSuspended/issuspended002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     Same test as issuspended001 with additional calls to
+ *     ThreadInfo.isSuspended() as the worker thread is exiting.
+ * COMMENT
+ *     Derived from nsk/monitoring/ThreadInfo/isSuspended/issuspended001.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm -Xlog:thread+smr=debug nsk.monitoring.ThreadInfo.isSuspended.issuspended002
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMBean/findMonitorDeadlockedThreads/find001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMBean.findMonitorDeadlockedThreads;
+
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class find001 {
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        ThreadMonitor monitor = Monitor.getThreadMonitor(log, argHandler);
+        long id = Thread.currentThread().getId();
+        long[] ids = monitor.findMonitorDeadlockedThreads();
+
+        if (ids == null) {
+            log.display("findCircularBlockedThread() returned null");
+            return Consts.TEST_PASSED;
+        }
+
+        if (ids.length == 0) {
+            log.display("findCircularBlockedThread() returned array of length "
+                      + "0");
+            return Consts.TEST_PASSED;
+        }
+
+        for (int i = 0; i < ids.length; i++) {
+            if (ids[i] == id) {
+                log.complain("TEST FAILED");
+                log.complain("findCircularBlockedThread() returned current "
+                           + "thread (id = " + id + ")");
+                return Consts.TEST_FAILED;
+            }
+        }
+        return Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMBean/isCurrentThreadCpuTimeSupported/curthcputime001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMBean.isCurrentThreadCpuTimeSupported;
+
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class curthcputime001 {
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        ThreadMonitor monitor = Monitor.getThreadMonitor(log, argHandler);
+
+        // Check the method is... for the specified way of access to MBeans
+        boolean isSupported = monitor.isCurrentThreadCpuTimeSupported();
+        if (isSupported) {
+            log.display("Current thread cpu time is supported.");
+        } else {
+            log.display("Current thread cpu time is not supported.");
+        }
+        return 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMBean/isThreadContentionMonitoringSupported/thcontmonitor001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMBean.isThreadContentionMonitoringSupported;
+
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class thcontmonitor001 {
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        ThreadMonitor monitor = Monitor.getThreadMonitor(log, argHandler);
+
+        // Check the method is... for the specified way of access to MBeans
+        if (!monitor.isThreadContentionMonitoringSupported()) {
+            log.complain("Thread contention monitoring is not supported.");
+            return 2;
+        }
+        return 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMBean/isThreadCpuTimeSupported/thcputime001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMBean.isThreadCpuTimeSupported;
+
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class thcputime001 {
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        ThreadMonitor monitor = Monitor.getThreadMonitor(log, argHandler);
+
+        // Check the method is... for the specified way of access to MBeans
+        boolean isSupported = monitor.isThreadCpuTimeSupported();
+        if (isSupported) {
+            log.display("Thread cpu time is supported.");
+        } else {
+            log.display("Thread cpu time is not supported.");
+        }
+        return 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMBean/resetPeakThreadCount/reset001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMBean.resetPeakThreadCount;
+
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class reset001 {
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        ThreadMonitor monitor = Monitor.getThreadMonitor(log, argHandler);
+
+        // Start a couple of threads and wait until they exit
+        Thread left = new Thread();
+        Thread right = new Thread();
+        left.start();
+        right.start();
+
+        try {
+            left.join();
+            right.join();
+        } catch (InterruptedException e) {
+            log.complain("Unexpected exception.");
+            e.printStackTrace(log.getOutStream());
+            testFailed = true;
+        }
+
+        // The test supposes that no threads are appered/disappeared between
+        // "getPeakThreadCount()" and "getThreadCount()" calls
+        monitor.resetPeakThreadCount();
+        int peak = monitor.getPeakThreadCount();
+        int live = monitor.getThreadCount();
+
+        if (peak != live) {
+            log.complain("getPeakThreadCount() returned " + peak + ", but "
+                      + "getThreadCount() returned " + live + " after "
+                      + "resetPeakThreadCount().");
+            testFailed = true;
+        }
+
+        if (testFailed)
+            out.println("TEST FAILED");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/BarrierHandler.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean;
+
+import java.util.concurrent.*;
+
+/**
+ * Provide synchronization between management thread and its
+ * managed threads.
+ */
+public class BarrierHandler {
+
+    /**
+     * CyclicBarries for internal synchronization
+     */
+    private CyclicBarrier monitoredThreadsBarrier, startActionBarrier,
+            finishActionBarrier;
+
+    /**
+     * Creates new BarrierHandler that will match specified Threads with
+     * management threads
+     *
+     * @param threads managed threads that are handled by BarrierHandler
+     */
+    public BarrierHandler(MXBeanTestThread... threads) {
+        startActionBarrier = new CyclicBarrier(2);
+        finishActionBarrier = new CyclicBarrier(2);
+        monitoredThreadsBarrier = new CyclicBarrier(threads.length, new ActionThread());
+    }
+
+    /**
+     * Waits when managed thread completes iteration and some action should
+     * be performed by management thread. Should be called within managed thread
+     * only.
+     *
+     */
+    public void ready() {
+        try {
+            monitoredThreadsBarrier.await();
+        } catch (Exception ignored) {}
+    }
+
+    /**
+     * Allows managed threads to proceed to next iteration. Should be called
+     * within management thread only.
+     */
+    public void proceed() {
+        try {
+            finishActionBarrier.await();
+            startActionBarrier.await();
+        } catch (Exception ignored) {}
+    }
+
+    /**
+     * Waits until all managed threads complete first iteration. Should be
+     * called within management thread only.
+     */
+    public void start() {
+        try {
+            startActionBarrier.await();
+        } catch (Exception ignored) {}
+    }
+
+    /**
+     * Allows managed threads to finish after last iteration. Should be called
+     * within management thread only.
+     */
+    public void finish() {
+        try {
+            finishActionBarrier.await();
+        } catch (Exception ignored) {}
+    }
+
+    /**
+     * Action performed on main barrier. Used for synchronization between
+     * management and managed threads
+     */
+    private class ActionThread extends Thread {
+        @Override
+        public void run() {
+            try {
+                startActionBarrier.await();
+                finishActionBarrier.await();
+            } catch (Exception ignored) {}
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/AllocatedMemorySupportedTest.README	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,42 @@
+Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute 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.
+
+DESCRIPTION
+    Tests isThreadAllocatedMemorySupported(), isThreadAllocatedMemoryEnabled()
+    and setThreadAllocatedMemoryEnabled(boolean enabled) functions
+    of com.sun.management.ThreadMXBean
+
+    - isThreadAllocatedMemorySupported() should return true
+    - isThreadAllocatedMemoryEnabled() should return true by default
+    - isThreadAllocatedMemoryEnabled() should return false after
+    setThreadAllocatedMemoryEnabled(false) call
+    - isThreadAllocatedMemoryEnabled() should return true again after
+    setThreadAllocatedMemoryEnabled(true) call
+
+    Test is executed in following configurations:
+    ThreadMXBean is accessed
+      - directly threw ManagementFactory.getThreadMXBean()
+      - threw default MBeanServer
+      - threw custom MBeanServer
+      - threw default Proxy
+      - threw custom Proxy
+
+COMMENTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/AllocatedMemorySupportedTest.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.ThreadMXBean.ThreadMXBeanTestBase;
+
+/**
+ * Tests isThreadAllocatedMemorySupported(), isThreadAllocatedMemoryEnabled()
+ * and setThreadAllocatedMemoryEnabled(boolean enabled) functions
+ * of com.sun.management.ThreadMXBean
+ * <p>
+ *  - isThreadAllocatedMemorySupported() should return true
+ * <br>
+ *  - isThreadAllocatedMemoryEnabled() should return true by default
+ * <br>
+ *  - isThreadAllocatedMemoryEnabled() should return false after
+ * setThreadAllocatedMemoryEnabled(false) call
+ * <br>
+ *  - isThreadAllocatedMemoryEnabled() should return true again after
+ * setThreadAllocatedMemoryEnabled(true) call
+ */
+public class AllocatedMemorySupportedTest extends ThreadMXBeanTestBase {
+
+    /**
+     * Actually runs the test
+     */
+    public void run() {
+        if (threadMXBean == null)
+            return;
+        // Check that isThreadAllocatedMemorySupported() returns true by default
+        if (! threadMXBean.isThreadAllocatedMemorySupported()) {
+            throw new TestFailure("Failure! isThreadAllocatedMemorySupported() "
+                   + "does not return true by default...");
+        }
+        // Check that isThreadAllocatedMemoryEnabled() returns true by default
+        if (! threadMXBean.isThreadAllocatedMemoryEnabled()) {
+            throw new TestFailure("Failure! isThreadAllocatedMemoryEnabled() "
+                    + "does not return true by default...");
+        }
+        // Call setThreadAllocatedMemoryEnabled(false)
+        threadMXBean.setThreadAllocatedMemoryEnabled(false);
+        // Check that isThreadAllocatedMemoryEnabled() now returns false
+        if (threadMXBean.isThreadAllocatedMemoryEnabled()) {
+            throw new TestFailure("Failure! setThreadAllocatedMemoryEnabled(false) "
+                    + "does not operate as expected...");
+        }
+        // Call setThreadAllocatedMemoryEnabled(true)
+        threadMXBean.setThreadAllocatedMemoryEnabled(true);
+        // Check that isThreadAllocatedMemoryEnabled() returns true again
+        if (! threadMXBean.isThreadAllocatedMemoryEnabled()) {
+            throw new TestFailure("Failure! setThreadAllocatedMemoryEnabled(true) "
+                    + "does not operate as expected...");
+        }
+        log.info("AllocatedMemorySupportedTest passed.");
+    }
+
+    /**
+     * Entry point for java program
+     * @param args sets the test configuration
+     */
+    public static void main(String[] args) {
+        Monitoring.runTest(new AllocatedMemorySupportedTest(), args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/BaseBehaviorTest.README	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,41 @@
+Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute 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.
+
+DESCRIPTION
+
+    Tests getThreadAllocatedBytes(long id) and  getThreadAllocatedBytes(long[] ids),
+    functions of com.sun.management.ThreadMXBean
+
+    All methods should
+    - return -1 if ThreadCpuTime allocation is not enabled
+    - return -1 for not started thread
+    - return > 0 value for any running thread
+    - return -1 for finished thread
+
+    Test is executed in following configurations:
+    ThreadMXBean is accessed
+      - directly threw ManagementFactory.getThreadMXBean()
+      - threw default MBeanServer
+      - threw custom MBeanServer
+      - threw default Proxy
+      - threw custom Proxy
+
+COMMENTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/BaseBehaviorTest.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.ThreadMXBean.*;
+
+/**
+ * Tests getThreadAllocatedBytes(long id) and  getThreadAllocatedBytes(long[] ids),
+ * functions of com.sun.management.ThreadMXBean
+ * <p>
+ * All methods should
+ * <br>
+ * -  return -1 if ThreadAllocatedMemory allocation is
+ * not enabled
+ *  <br>
+ * - return -1 for not started thread
+ *  <br>
+ * - return > 0 value for any running thread
+ *  <br>
+ * - return -1 for finished thread
+ */
+public class BaseBehaviorTest extends ThreadMXBeanTestBase {
+
+    /**
+     * Actually runs the test
+     */
+    public void run() {
+        if (threadMXBean == null)
+            return;
+        MXBeanTestThread thread = new MXBeanTestThread();
+        long id = thread.getId();
+        long[] idArr = new long[] { id };
+        long result;
+        long[] resultArr;
+        // Expect -1 for not started threads
+        result = threadMXBean.getThreadAllocatedBytes(id);
+        if (result != -1)
+            throw new TestFailure("Failure! getThreadAllocatedBytes(long id) should "
+                    + "return -1 for not started threads. Recieved : " + result);
+        resultArr = threadMXBean.getThreadAllocatedBytes(idArr);
+        if (resultArr[0] != -1)
+            throw new TestFailure("Failure! getThreadAllocatedBytes(long[] ids) should "
+                    + "return -1 for not started threads. Recieved : " + resultArr[0]);
+        BarrierHandler handler = startThreads(thread);
+        try {
+            handler.proceed();
+            // Expect -1 for running thread if ThreadAllocatedMemory (CpuTime) is disabled
+            threadMXBean.setThreadAllocatedMemoryEnabled(false);
+            result = threadMXBean.getThreadAllocatedBytes(id);
+            if (result != -1)
+                throw new TestFailure("Failure! getThreadAllocatedBytes(long id) should "
+                    + "return -1 if ThreadAllocatedMemoryEnabled is set to false. "
+                    + "Recieved : " + result);
+            resultArr = threadMXBean.getThreadAllocatedBytes(idArr);
+            if (resultArr[0] != -1)
+                throw new TestFailure("Failure! getThreadAllocatedBytes(long[] ids) should "
+                    + "return -1 if ThreadAllocatedMemoryEnabled is set to false. "
+                    + "Recieved : " + resultArr[0]);
+
+            threadMXBean.setThreadAllocatedMemoryEnabled(true);
+            // Expect > 0 value for running threads
+            result = threadMXBean.getThreadAllocatedBytes(id);
+            if (result < 0)
+            throw new TestFailure("Failure! getThreadAllocatedBytes(long id) should "
+                    + "return > 0 value for RUNNING thread. Recieved : " + result);
+            resultArr = threadMXBean.getThreadAllocatedBytes(idArr);
+            if (resultArr[0] < 0)
+                throw new TestFailure("Failure! getThreadAllocatedBytes(long[] ids) should "
+                    + "return > 0 value for RUNNING thread. Recieved : " + resultArr[0]);
+        } finally {
+            // Let thread finish
+            handler.finish();
+        }
+        try {
+            thread.join();
+        } catch (InterruptedException e) {}
+        // Expect -1 for finished thread
+        result = threadMXBean.getThreadAllocatedBytes(id);
+        if (result != -1)
+            throw new TestFailure("Failure! getThreadAllocatedBytes(long id) should "
+                    + "return -1 for finished threads. Recieved : " + result);
+        resultArr = threadMXBean.getThreadAllocatedBytes(idArr);
+        if (resultArr[0] != -1)
+            throw new TestFailure("Failure! getThreadAllocatedBytes(long[] ids) should "
+                    + "return -1 for finished threads. Recieved : " + resultArr[0]);
+        log.info("BaseBehaviorTest passed.");
+    }
+
+    /**
+     * Entry point for java program
+     * @param args sets the test configuration
+     */
+    public static void main(String[] args) {
+        ThreadMXBeanTestBase test = new BaseBehaviorTest();
+        Monitoring.runTest(test, test.setGarbageProducer(args));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/DoubleAllocationTest.README	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,43 @@
+Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute 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.
+
+DESCRIPTION
+
+    Tests getThreadAllocatedBytes(long id) function of com.sun.management.ThreadMXBean
+
+    - Test starts thread and allocates some amount of memory, then calculates this
+    allocation using getThreadAllocatedBytes() call (allocation1). Then this thread
+    allocates just the same amount of memory and calculates getThreadAllocatedBytes()
+    again (allocation2). It is assumed that allocation2/allocation1 ~ 2.
+
+    Test is executed in following configurations:
+    ThreadMXBean is accessed
+      - directly threw ManagementFactory.getThreadMXBean()
+      - threw default MBeanServer
+      - threw custom MBeanServer
+      - threw default Proxy
+      - threw custom Proxy
+    Allocated object types are
+      - primitive arrays
+      - Class instances
+      - interned String instances
+
+COMMENTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/DoubleAllocationTest.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.ThreadMXBean.ThreadMXBeanTestBase;
+import nsk.monitoring.ThreadMXBean.MXBeanTestThread;
+import nsk.monitoring.ThreadMXBean.BarrierHandler;
+
+/**
+ * Tests getThreadAllocatedBytes(long id) function of com.sun.management.ThreadMXBean
+ * <p>
+ *  - Test starts thread and allocates some amount of memory, then calculates this
+ * allocation using getThreadAllocatedBytes() call (allocation1). Then this thread
+ * allocates just the same amount of memory and calculates getThreadAllocatedBytes()
+ * again (allocation2). It is assumed that allocation2/allocation1 ~ 2.
+ */
+public class DoubleAllocationTest extends ThreadMXBeanTestBase {
+
+    /**
+     * Actually runs the test
+     */
+    public void run() {
+        if (threadMXBean == null)
+            return;
+        //TestThread tr = new DoubleAllocationTestThread();
+
+        // Double allocation TestThread thread.
+        // Run behavior : Allocates memory, waits for notify() call,
+        // allocates memory again and waits for notify() call again
+        MXBeanTestThread.warmUp(garbageProducerId);
+        MXBeanTestThread tr = new MXBeanTestThread(garbageProducerId) {
+            @Override
+            public void doWork() {
+                //threadStartBytes = threadMXBean.getThreadAllocatedBytes(Thread.currentThread().getId());
+                //allocate();
+                handler.ready();
+                allocate();
+                handler.ready();
+                allocate();
+                handler.ready();
+            }
+        };
+        BarrierHandler handler = startThreads(tr);
+        try {
+            long startBytes = threadMXBean.getThreadAllocatedBytes(tr.getId());
+            handler.proceed();
+            long value1 = threadMXBean.getThreadAllocatedBytes(tr.getId())
+                    - startBytes;
+            handler.proceed();
+            long value2 = threadMXBean.getThreadAllocatedBytes(tr.getId())
+                    - startBytes;
+            // Expect value1 and value2 differs not more then for 15%
+            if (Math.abs(((double) value2 / (double) value1) - 2) > (double)2*DELTA_PERCENT/100)
+            //if ( Math.abs(2*value1 - value2) > value1*DELTA_PERCENT/100)
+                throw new TestFailure("Failure! Expected getThreadAllocatedBytes() "
+                        + "measurement for some thread at one moment could not be "
+                        + "greater then similar measurement for the same thread "
+                        + "at later moment. Thread allocates same amount of memory "
+                        + "before each measurement. Excpected ~2 times difference. "
+                        + "Recieved: " + value1 + " and " + value2);
+            log.info("DoubleAllocationTest passed.");
+        } finally {
+            handler.finish();
+        }
+    }
+
+    /**
+     * Entry point for java program
+     * @param args sets the test configuration
+     */
+    public static void main(String[] args) {
+        ThreadMXBeanTestBase test = new DoubleAllocationTest();
+        Monitoring.runTest(test, test.setGarbageProducer(args));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/EqualThreadsTest.README	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,41 @@
+Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute 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.
+
+DESCRIPTION
+
+    Tests getThreadAllocatedBytes(long id) function of com.sun.management.ThreadMXBean
+
+    - Check that result of getThreadAllocatedBytes(long id) call for similar
+    threads are approximately equals.
+
+    Test is executed in following configurations:
+    ThreadMXBean is accessed
+      - directly threw ManagementFactory.getThreadMXBean()
+      - threw default MBeanServer
+      - threw custom MBeanServer
+      - threw default Proxy
+      - threw custom Proxy
+    Allocated object types are
+      - primitive arrays
+      - Class instances
+      - interned String instances
+
+COMMENTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/EqualThreadsTest.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.ThreadMXBean.ThreadMXBeanTestBase;
+import nsk.monitoring.ThreadMXBean.MXBeanTestThread;
+import nsk.monitoring.ThreadMXBean.BarrierHandler;
+
+/**
+ * Tests getThreadAllocatedBytes(long id) function of com.sun.management.ThreadMXBean
+ * <p>
+ *  - Check that result of getThreadAllocatedBytes(long id) call for similar
+ * threads are approximately equals.
+ */
+public class EqualThreadsTest extends ThreadMXBeanTestBase {
+
+    /**
+     * Actually runs the test
+     */
+    public void run() {
+        if (threadMXBean == null)
+            return;
+        MXBeanTestThread.warmUp(garbageProducerId);
+        MXBeanTestThread tr1 = new MXBeanTestThread(garbageProducerId);
+        MXBeanTestThread tr2 = new MXBeanTestThread(garbageProducerId);
+        BarrierHandler handler = startThreads(tr1, tr2);
+        try {
+            long startBytesTr1 = threadMXBean.getThreadAllocatedBytes(tr1.getId());
+            long startBytesTr2 = threadMXBean.getThreadAllocatedBytes(tr2.getId());
+            handler.proceed();
+            long value1 = threadMXBean.getThreadAllocatedBytes(tr1.getId())
+                - startBytesTr1;
+            long value2 = threadMXBean.getThreadAllocatedBytes(tr2.getId())
+                - startBytesTr2;
+            // Expect value1 and value2 differs not more then for 10%
+            if ( Math.abs(value1 - value2) > value1*DELTA_PERCENT/100)
+                throw new TestFailure("Failure! Let f(thread) = getThreadAllocatedBytes()."
+                    + " Expected if thread tr1 is similar to thread tr2"
+                    + " then f(tr1) and f(tr2) differs not more then for "
+                    + DELTA_PERCENT + " %. Recieved: f(tr1)=" + value1
+                    + " f(tr2)=" + value2);
+            log.info("EqualThreadsTest passed.");
+        } finally {
+            handler.finish();
+        }
+    }
+
+    /**
+     * Entry point for java program
+     * @param args sets the test configuration
+     */
+    public static void main(String[] args) {
+        ThreadMXBeanTestBase test = new EqualThreadsTest();
+        Monitoring.runTest(test, test.setGarbageProducer(args));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/IllegalArgumentsTest.README	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,43 @@
+Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute 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.
+
+DESCRIPTION
+
+    Tests getThreadAllocatedBytes(long id), getThreadAllocatedBytes(long[] ids)
+    and setThreadAllocatedMemoryEnabled(boolean enabled) functions of
+    com.sun.management.ThreadMXBean
+
+    - any method called with null argument should throw NullPointerException
+    for direct and proxy MBean delivery methods and RuntimeException for
+    server MBean delivery method (MBeanServer)
+    - any method called with zero (0 for long, { 0 } for long[]) argument
+    should throw IllegalArgumentException for direct and proxy MBean delivery
+    methods and RuntimeException for server MBean delivery method (MBeanServer)
+
+    Test is executed in following configurations:
+    ThreadMXBean is accessed
+      - directly threw ManagementFactory.getThreadMXBean()
+      - threw default MBeanServer
+      - threw custom MBeanServer
+      - threw default Proxy
+      - threw custom Proxy
+
+COMMENTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/IllegalArgumentsTest.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.ThreadMXBean.ThreadMXBeanTestBase;
+
+
+/**
+ * Tests getThreadAllocatedBytes(long id), getThreadAllocatedBytes(long[] ids)
+ * and setThreadAllocatedMemoryEnabled(boolean enabled) functions of
+ * com.sun.management.ThreadMXBean
+ * <p>
+ *  - any method called with null argument should throw NullPointerException
+ * for direct and proxy MBean delivery methods and RuntimeException for
+ * server MBean delivery method (MBeanServer)
+ *  <br>
+ *  - any method called with zero (0 for long, { 0 } for long[]) argument
+ * should throw IllegalArgumentException for direct and proxy MBean delivery
+ * methods and RuntimeException for server MBean delivery method (MBeanServer)
+ */
+public class IllegalArgumentsTest extends ThreadMXBeanTestBase {
+
+    /**
+     * Actually runs the test
+     */
+    public void run() {
+        if (threadMXBean == null)
+            return;
+        int exceptions = 0;
+        // getThreadAllocatedBytes with null argument
+        try {
+            threadMXBean.getThreadAllocatedBytes(null);
+        } catch (NullPointerException e) {
+            log.info("Caught expected NPE : " + e.getMessage());
+            exceptions++;
+        } catch (RuntimeException e1) {
+            log.info("Caught expected RuntimeException : "
+                    + e1.getMessage());
+            exceptions++;
+        }
+        // getThreadAllocatedBytes(long) with 0
+        try {
+            threadMXBean.getThreadAllocatedBytes(0);
+        } catch (IllegalArgumentException e) {
+            log.info("Caught expected IllegalArgumentException : " + e.getMessage());
+            exceptions++;
+        } catch (RuntimeException e1) {
+            log.info("Caught expected RuntimeException : " + e1.getMessage());
+            exceptions++;
+        }
+        // getThreadAllocatedBytes(long[]) with { 0 }
+        try {
+            threadMXBean.getThreadAllocatedBytes(new long[] { 0 });
+        } catch (IllegalArgumentException e) {
+            log.info("Caught expected IllegalArgumentException : " + e.getMessage());
+            exceptions++;
+        } catch (RuntimeException e1) {
+            log.info("Caught expected RuntimeException : " + e1.getMessage());
+            exceptions++;
+        }
+        // setThreadAllocatedMemoryEnabled(boolean) with null
+        Boolean b = null;
+        try {
+            threadMXBean.setThreadAllocatedMemoryEnabled(b);
+        } catch (NullPointerException e) {
+            log.info("Caught expected NPE : " + e.getMessage());
+            exceptions++;
+        }
+        // 4 exceptions should have been caught
+        if (exceptions != 4)
+            throw new TestFailure("Failure! Expected to catch 4 exceptions, "
+                    + "actually caught : " + exceptions);
+        log.info("IllegalArgumentsTest passed.");
+    }
+
+    /**
+     * Entry point for java program
+     * @param args sets the test configuration
+     */
+    public static void main(String[] args) {
+        Monitoring.runTest(new IllegalArgumentsTest(), args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/NoAllocationTest.README	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute 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.
+
+DESCRIPTION
+
+    Tests getThreadAllocatedBytes(long id) function of com.sun.management.ThreadMXBean
+
+    - Test starts thread that does not allocate any additional memory and stores
+    it's getThreadAllocatedBytes() result (value1)
+    Then it starts several other threads that does allocate memory and, after these
+    threads are finished, checks that getThreadAllocatedBytes() result (value2)
+    does not differ from value1
+
+    Test is executed in following configurations:
+    ThreadMXBean is accessed
+      - directly threw ManagementFactory.getThreadMXBean()
+      - threw default MBeanServer
+      - threw custom MBeanServer
+      - threw default Proxy
+      - threw custom Proxy
+
+COMMENTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/NoAllocationTest.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.ThreadMXBean.ThreadMXBeanTestBase;
+import nsk.monitoring.ThreadMXBean.MXBeanTestThread;
+import nsk.monitoring.ThreadMXBean.BarrierHandler;
+
+/**
+ * Tests getThreadAllocatedBytes(long id) function of com.sun.management.ThreadMXBean
+ * <p>
+ *  - Test starts thread that does not allocate any additional memory and stores
+ * it's getThreadAllocatedBytes() result (value1)
+ * Then it starts several other threads that does allocate memory and, after these
+ * threads are finished, checks that getThreadAllocatedBytes() result (value2)
+ * does not differ from value1
+ */
+public class NoAllocationTest extends ThreadMXBeanTestBase {
+    private volatile boolean start = false;
+    private volatile boolean stop = false;
+
+    /**
+     * Actually runs the test
+     */
+    public void run() {
+        if (threadMXBean == null)
+            return;
+        // No allocation TestThread thread.
+        // Run behavior : does nothing,  waits for notify() call
+        MXBeanTestThread tr = new MXBeanTestThread() {
+                @Override
+                public void doWork() {
+                    start = true;
+                    while (!stop) { /* empty */ }
+                }
+            };
+        tr.start();
+        MXBeanTestThread tr1 = new MXBeanTestThread();
+        MXBeanTestThread tr2 = new MXBeanTestThread();
+        BarrierHandler handler = startThreads(tr1, tr2);
+        while (!start) { /* empty */ }
+        long value1 = threadMXBean.getThreadAllocatedBytes(tr.getId());
+        handler.proceed();
+        long value2 = threadMXBean.getThreadAllocatedBytes(tr.getId());
+        if (value1 != value2) {
+            throw new TestFailure("Failure! It is expected that idle thread "
+                                  + "does not allocate any memory. getThreadAllocatedBytes() call "
+                                  + "for idle TestThread-" + tr.getName() + " returns different "
+                                  + "values. Recieved : " + value1 + " and " + value2);
+        }
+        log.info("NoAllocationTest passed.");
+        stop = true;
+        handler.finish();
+    }
+
+    /**
+     * Entry point for java program
+     * @param args sets the test configuration
+     */
+    public static void main(String[] args) {
+        ThreadMXBeanTestBase test = new NoAllocationTest();
+        Monitoring.runTest(test, test.setGarbageProducer(args));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/StressTest.README	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute 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.
+
+DESCRIPTION
+
+    Tests getThreadAllocatedBytes(long[] id) function of com.sun.management.ThreadMXBean
+
+    This test starts several threads (according test machine processor count). Each
+    thread allocates different size objects (from 8 bytes to 2 megabytes) during
+    defined Stresser time (default is 1 minute). After that for each thread allocated
+    memory is counted and compared to the result of getThreadAllocatedBytes() call.
+
+    Test is executed in following configurations:
+    ThreadMXBean is accessed
+      - directly threw ManagementFactory.getThreadMXBean()
+      - threw default MBeanServer
+      - threw custom MBeanServer
+      - threw default Proxy
+      - threw custom Proxy
+
+COMMENTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/StressTest.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.ThreadMXBean.*;
+import nsk.share.test.Stresser;
+
+/**
+ * Tests getThreadAllocatedBytes(long[] id) function of com.sun.management.ThreadMXBean
+ * <p>
+ * This test starts several threads (according test machine processor count). Each
+ * thread allocates different size objects (from 8 bytes to 2 megabytes) during
+ * defined Stresser time (default is 1 minute). After that for each thread allocated
+ * memory is counted and compared to the result of getThreadAllocatedBytes() call.
+ */
+public class StressTest extends ThreadMXBeanTestBase {
+
+    /**
+     * Stress allocation TestThread thread.
+     * Run behavior : Allocates memory for specified amount of time
+     * (default - 1 minute) and waits for notify() call
+     */
+    private class StressTestThread extends MXBeanTestThread {
+        private StressTestThread(Stresser stresser) {
+            super(stresser);
+        }
+
+        @Override
+        public void doWork() {
+            allocateStress();
+            handler.ready();
+        }
+    }
+
+    /**
+     * Actually runs the test
+     */
+    public void run() {
+        if (threadMXBean == null)
+            return;
+        int threadCount = Runtime.getRuntime().availableProcessors();
+        long memMax = Runtime.getRuntime().maxMemory();
+        long threadMemMax = Math.round((((double) memMax) * 0.6) / (double) threadCount);
+        MXBeanTestThread[] threadArr = new MXBeanTestThread[threadCount];
+        long[] idArr = new long[threadCount];
+        for (int i = 0; i < threadCount; i++) {
+            threadArr[i] = new StressTestThread(stresser);
+            threadArr[i].setMaxThreadMemory(threadMemMax);
+            idArr[i] = threadArr[i].getId();
+        }
+        stresser.start(0);
+        BarrierHandler handler = startThreads(threadArr);
+        try {
+            long[] actual = threadMXBean.getThreadAllocatedBytes(idArr);
+            long[] expected = this.getStressAllocatedBytes(threadArr);
+            for (int i = 0; i < threadCount; i++) {
+                if (expected[i] > MIN_STRESS_ALLOCATION_AMOUNT
+                        && Math.abs(actual[i] - expected[i]) >  expected[i]*DELTA_PERCENT/100)
+                {
+                    throw new TestFailure("Failure! Expected that Thread-"
+                        + threadArr[i].getName() + " allocate " + expected[i]
+                        + " bytes. getThreadAllocatedBytes() call returns "
+                        + actual[i]);
+                }
+            }
+            log.info("StressTest passed.");
+        } finally {
+            handler.finish();
+        }
+    }
+
+    /**
+     * Entry point for java program
+     * @param args sets the test configuration
+     */
+    public static void main(String[] args) {
+        ThreadMXBeanTestBase test = new StressTest();
+        test.setStresser(args);
+        Monitoring.runTest(test, test.setGarbageProducer(args));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_directly/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_directly.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes AllocatedMemorySupportedTest
+ *     For more info please refer to AllocatedMemorySupportedTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.AllocatedMemorySupportedTest
+ *      -testMode=directly
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_proxy_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_proxy_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes AllocatedMemorySupportedTest
+ *     For more info please refer to AllocatedMemorySupportedTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.AllocatedMemorySupportedTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_proxy_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_proxy_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes AllocatedMemorySupportedTest
+ *     For more info please refer to AllocatedMemorySupportedTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.AllocatedMemorySupportedTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_server_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_server_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes AllocatedMemorySupportedTest
+ *     For more info please refer to AllocatedMemorySupportedTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.AllocatedMemorySupportedTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_server_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_server_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes AllocatedMemorySupportedTest
+ *     For more info please refer to AllocatedMemorySupportedTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.AllocatedMemorySupportedTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_directly/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_directly.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes BaseBehaviorTest
+ *     For more info please refer to BaseBehaviorTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.BaseBehaviorTest
+ *      -testMode=directly
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_proxy_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_proxy_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes BaseBehaviorTest
+ *     For more info please refer to BaseBehaviorTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.BaseBehaviorTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_proxy_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_proxy_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes BaseBehaviorTest
+ *     For more info please refer to BaseBehaviorTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.BaseBehaviorTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_server_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_server_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes BaseBehaviorTest
+ *     For more info please refer to BaseBehaviorTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.BaseBehaviorTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_server_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_server_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes BaseBehaviorTest
+ *     For more info please refer to BaseBehaviorTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.BaseBehaviorTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_directly_array/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_directly_array.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes DoubleAllocationTest
+ *     For more info please refer to DoubleAllocationTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ *     Allocation objects are primitive arrays (IntArrayProducer GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.DoubleAllocationTest
+ *      -testMode=directly
+ *      -gp intArr
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_directly_string/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_directly_string.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes DoubleAllocationTest
+ *     For more info please refer to DoubleAllocationTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ *     Allocation objects are interned Strings (Interned(SimpleString) GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.DoubleAllocationTest
+ *      -testMode=directly
+ *      -gp interned(simpleString)
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_custom_array/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_custom_array.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes DoubleAllocationTest
+ *     For more info please refer to DoubleAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ *     Allocation objects are primitive arrays (IntArrayProducer GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.DoubleAllocationTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ *      -gp intArr
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_custom_string/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_custom_string.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes DoubleAllocationTest
+ *     For more info please refer to DoubleAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ *     Allocation objects are interned Strings (Interned(SimpleString) GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.DoubleAllocationTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ *      -gp interned(simpleString)
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_default_array/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_default_array.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes DoubleAllocationTest
+ *     For more info please refer to DoubleAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ *     Allocation objects are primitive arrays (IntArrayProducer GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.DoubleAllocationTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ *      -gp intArr
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_default_string/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_default_string.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes DoubleAllocationTest
+ *     For more info please refer to DoubleAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ *     Allocation objects are interned Strings (Interned(SimpleString) GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.DoubleAllocationTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ *      -gp interned(simpleString)
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_custom_array/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_custom_array.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes DoubleAllocationTest
+ *     For more info please refer to DoubleAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ *     Allocation objects are primitive arrays (IntArrayProducer GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.DoubleAllocationTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -gp intArr
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_custom_string/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_custom_string.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes DoubleAllocationTest
+ *     For more info please refer to DoubleAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ *     Allocation objects are interned Strings (Interned(SimpleString) GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.DoubleAllocationTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -gp interned(simpleString)
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_default_array/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_default_array.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes DoubleAllocationTest
+ *     For more info please refer to DoubleAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ *     Allocation objects are primitive arrays (IntArrayProducer GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.DoubleAllocationTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ *      -gp intArr
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_default_string/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_default_string.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes DoubleAllocationTest
+ *     For more info please refer to DoubleAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ *     Allocation objects are interned Strings (Interned(SimpleString) GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.DoubleAllocationTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ *      -gp interned(simpleString)
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_directly_array/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_directly_array.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes EqualThreadsTest
+ *     For more info please refer to EqualThreadsTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ *     Allocation objects are primitive arrays (IntArrayProducer GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.EqualThreadsTest
+ *      -testMode=directly
+ *      -gp intArr
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_directly_string/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_directly_string.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes EqualThreadsTest
+ *     For more info please refer to EqualThreadsTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ *     Allocation objects are interned Strings (Interned(SimpleString) GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.EqualThreadsTest
+ *      -testMode=directly
+ *      -gp interned(simpleString)
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_custom_array/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_custom_array.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes EqualThreadsTest
+ *     For more info please refer to EqualThreadsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ *     Allocation objects are primitive arrays (IntArrayProducer GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.EqualThreadsTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ *      -gp intArr
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_custom_string/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_custom_string.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes EqualThreadsTest
+ *     For more info please refer to EqualThreadsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ *     Allocation objects are interned Strings (Interned(SimpleString) GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.EqualThreadsTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ *      -gp interned(simpleString)
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_default_array/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_default_array.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes EqualThreadsTest
+ *     For more info please refer to EqualThreadsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ *     Allocation objects are primitive arrays (IntArrayProducer GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.EqualThreadsTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ *      -gp intArr
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_default_string/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_default_string.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes EqualThreadsTest
+ *     For more info please refer to EqualThreadsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ *     Allocation objects are interned Strings (Interned(SimpleString) GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.EqualThreadsTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ *      -gp interned(simpleString)
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_custom_array/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_custom_array.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes EqualThreadsTest
+ *     For more info please refer to EqualThreadsTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ *     Allocation objects are primitive arrays (IntArrayProducer GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.EqualThreadsTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -gp intArr
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_custom_string/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_custom_string.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes EqualThreadsTest
+ *     For more info please refer to EqualThreadsTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ *     Allocation objects are interned Strings (Interned(SimpleString) GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.EqualThreadsTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -gp interned(simpleString)
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_default_array/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_default_array.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes EqualThreadsTest
+ *     For more info please refer to EqualThreadsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ *     Allocation objects are primitive arrays (IntArrayProducer GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.EqualThreadsTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ *      -gp intArr
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_default_string/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_default_string.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes EqualThreadsTest
+ *     For more info please refer to EqualThreadsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ *     Allocation objects are interned Strings (Interned(SimpleString) GarbageProducer)
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.EqualThreadsTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ *      -gp interned(simpleString)
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_directly/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_directly.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes IllegalArgumentsTest
+ *     For more info please refer to IllegalArgumentsTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.IllegalArgumentsTest
+ *      -testMode=directly
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_proxy_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_proxy_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes IllegalArgumentsTest
+ *     For more info please refer to IllegalArgumentsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.IllegalArgumentsTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_proxy_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_proxy_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes IllegalArgumentsTest
+ *     For more info please refer to IllegalArgumentsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.IllegalArgumentsTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_server_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_server_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes IllegalArgumentsTest
+ *     For more info please refer to IllegalArgumentsTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.IllegalArgumentsTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_server_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_server_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes IllegalArgumentsTest
+ *     For more info please refer to IllegalArgumentsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.IllegalArgumentsTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_directly/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_directly.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes NoAllocationTest
+ *     For more info please refer to NoAllocationTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.NoAllocationTest
+ *      -testMode=directly
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_proxy_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_proxy_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes NoAllocationTest
+ *     For more info please refer to NoAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.NoAllocationTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_proxy_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_proxy_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes NoAllocationTest
+ *     For more info please refer to NoAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.NoAllocationTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_server_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_server_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes NoAllocationTest
+ *     For more info please refer to NoAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.NoAllocationTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_server_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_server_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes NoAllocationTest
+ *     For more info please refer to NoAllocationTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.NoAllocationTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_directly/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_directly/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_directly.
+ * VM Testbase keywords: [stress, monitoring, feature_memory_alloc, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes StressTest
+ *     For more info please refer to StressTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.StressTest
+ *      -testMode=directly
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_proxy_custom/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_proxy_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_proxy_custom.
+ * VM Testbase keywords: [stress, monitoring, feature_memory_alloc, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes StressTest
+ *     For more info please refer to StressTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.StressTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_proxy_default/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_proxy_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_proxy_default.
+ * VM Testbase keywords: [stress, monitoring, feature_memory_alloc, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes StressTest
+ *     For more info please refer to StressTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.StressTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_server_custom/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_server_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_server_custom.
+ * VM Testbase keywords: [stress, monitoring, feature_memory_alloc, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes StressTest
+ *     For more info please refer to StressTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.StressTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_server_default/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_server_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/stressTest_server_default.
+ * VM Testbase keywords: [stress, monitoring, feature_memory_alloc, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes StressTest
+ *     For more info please refer to StressTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.ThreadMXBean.GetThreadAllocatedBytes.StressTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/BaseBehaviorTest.README	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,41 @@
+Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute 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.
+
+DESCRIPTION
+
+    Tests getThreadCpuTime(long[] ids) and getThreadUserTime(long[] ids)
+    functions of com.sun.management.ThreadMXBean
+
+    All methods should
+    - return -1 if ThreadCpuTime allocation is not enabled
+    - return -1 for not started thread
+    - return > 0 value for any running thread
+    - return -1 for finished thread
+
+    Test is executed in following configurations:
+    ThreadMXBean is accessed
+      - directly threw ManagementFactory.getThreadMXBean()
+      - threw default MBeanServer
+      - threw custom MBeanServer
+      - threw default Proxy
+      - threw custom Proxy
+
+COMMENTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/BaseBehaviorTest.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean.GetThreadCpuTime;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.ThreadMXBean.*;
+
+/**
+ * Tests getThreadCpuTime(long[] ids) and getThreadUserTime(long[] ids)
+ * functions of com.sun.management.ThreadMXBean
+ * <p>
+ * All methods should
+ * <br>
+ * -  return -1 if ThreadCpuTime allocation is
+ * not enabled
+ * <br>
+ * - return -1 for not started thread
+ * <br>
+ * - return > 0 value for any running thread
+ * <br>
+ * - return -1 for finished thread
+ */
+public class BaseBehaviorTest extends ThreadMXBeanTestBase {
+
+    /**
+     * Actually runs the test
+     */
+    public void run() {
+        if (threadMXBean == null)
+            return;
+        MXBeanTestThread thread = new MXBeanTestThread();
+        long id = thread.getId();
+        long[] idArr = new long[] { id };
+        long[] resultArr;
+        // Expect -1 for not started threads
+        resultArr = threadMXBean.getThreadCpuTime(idArr);
+        if (resultArr[0] != -1)
+            throw new TestFailure("Failure! getThreadCpuTime(long[] ids) should "
+                    + "return -1 for not started threads. Recieved : " + resultArr[0]);
+        resultArr = threadMXBean.getThreadUserTime(idArr);
+        if (resultArr[0] != -1)
+            throw new TestFailure("Failure! getThreadUserTime(long[] ids) should "
+                    + "return -1 for not started threads. Recieved : " + resultArr[0]);
+        BarrierHandler handler = startThreads(thread);
+        try {
+            handler.proceed();
+            // Expect -1 for running thread if ThreadAllocatedMemory (CpuTime) is disabled
+            threadMXBean.setThreadCpuTimeEnabled(false);
+            resultArr = threadMXBean.getThreadCpuTime(idArr);
+            if (resultArr[0] != -1)
+                throw new TestFailure("Failure! getThreadCpuTime(long[] ids) should "
+                    + "return -1 if threadCpuTimeEnabled is set to false. "
+                    + "Recieved : " + resultArr[0]);
+            resultArr = threadMXBean.getThreadUserTime(idArr);
+            if (resultArr[0] != -1)
+                throw new TestFailure("Failure! getThreadUserTime(long[] ids) should "
+                    + "return -1 if threadCpuTimeEnabled is set to false. "
+                    + "Recieved : " + resultArr[0]);
+            threadMXBean.setThreadCpuTimeEnabled(true);
+            // Expect > 0 value for running threads
+            resultArr = threadMXBean.getThreadCpuTime(idArr);
+            if (resultArr[0] < 0)
+                throw new TestFailure("Failure! getThreadCpuTime(long[] ids) should "
+                    + "return > 0 value for RUNNING thread. Recieved : " + resultArr[0]);
+            resultArr = threadMXBean.getThreadUserTime(idArr);
+            if (resultArr[0] < 0)
+                throw new TestFailure("Failure! getThreadUserTime(long[] ids) should "
+                    + "return > 0 value for RUNNING thread. Recieved : " + resultArr[0]);
+        } finally {
+            // Let thread finish
+            handler.finish();
+        }
+        try {
+            thread.join();
+        } catch (InterruptedException e) {}
+        // Expect -1 for finished thread
+        resultArr = threadMXBean.getThreadCpuTime(idArr);
+        if (resultArr[0] != -1)
+            throw new TestFailure("Failure! getThreadCpuTime(long[] ids) should "
+                    + "return -1 for finished threads. Recieved : " + resultArr[0]);
+        resultArr = threadMXBean.getThreadUserTime(idArr);
+        if (resultArr[0] != -1)
+            throw new TestFailure("Failure! getThreadUserTime(long[] ids) should "
+                    + "return -1 for finished threads. Recieved : " + resultArr[0]);
+        log.info("BaseBehaviorTest passed.");
+    }
+
+    /**
+     * Entry point for java program
+     * @param args sets the test configuration
+     */
+    public static void main(String[] args) {
+        ThreadMXBeanTestBase test = new BaseBehaviorTest();
+        Monitoring.runTest(test, test.setGarbageProducer(args));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/IllegalArgumentsTest.README	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,42 @@
+Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute 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.
+
+DESCRIPTION
+
+    Tests  getThreadCpuTime(long[] ids) and getThreadUserTime(long[] ids)
+    functions of com.sun.management.ThreadMXBean
+
+    - any method called with null argument should throw NullPointerException
+    for direct and proxy MBean delivery methods and RuntimeException for
+    server MBean delivery method (MBeanServer)
+    - any method called with zero (0 for long, { 0 } for long[]) argument
+    should throw IllegalArgumentException for direct and proxy MBean delivery
+    methods and RuntimeException for server MBean delivery method (MBeanServer)
+
+    Test is executed in following configurations:
+    ThreadMXBean is accessed
+      - directly threw ManagementFactory.getThreadMXBean()
+      - threw default MBeanServer
+      - threw custom MBeanServer
+      - threw default Proxy
+      - threw custom Proxy
+
+COMMENTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/IllegalArgumentsTest.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean.GetThreadCpuTime;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.ThreadMXBean.ThreadMXBeanTestBase;
+
+
+/**
+ * Tests  getThreadCpuTime(long[] ids) and getThreadUserTime(long[] ids)
+ * functions of com.sun.management.ThreadMXBean
+ * <p>
+ *  - any method called with null argument should throw NullPointerException
+ * for direct and proxy MBean delivery methods and RuntimeException for
+ * server MBean delivery method (MBeanServer)
+ * <br>
+ *  - any method called with zero (0 for long, { 0 } for long[]) argument
+ * should throw IllegalArgumentException for direct and proxy MBean delivery
+ * methods and RuntimeException for server MBean delivery method (MBeanServer)
+ */
+public class IllegalArgumentsTest extends ThreadMXBeanTestBase {
+
+    /**
+     * Actually runs the test
+     */
+    public void run() {
+        if (threadMXBean == null)
+            return;
+        int exceptions = 0;
+        // getThreadCpuTime(long[]) with null
+        try {
+            threadMXBean.getThreadCpuTime(null);
+        } catch (NullPointerException e) {
+            log.info("Caught expected NPE : " + e.getMessage());
+            exceptions++;
+        } catch (RuntimeException e1) {
+            log.info("Caught expected RuntimeException : " + e1.getMessage());
+            exceptions++;
+        }
+        // getThreadCpuTime(long[]) with { 0 }
+        try {
+            threadMXBean.getThreadCpuTime(new long[] { 0 });
+        } catch (IllegalArgumentException e) {
+            log.info("Caught expected IllegalArgumentException : " + e.getMessage());
+            exceptions++;
+        } catch (RuntimeException e1) {
+            log.info("Caught expected RuntimeException : " + e1.getMessage());
+            exceptions++;
+        }
+        // getThreadUserTime(long[]) with null
+        try {
+            threadMXBean.getThreadUserTime(null);
+        } catch (NullPointerException e) {
+            log.info("Caught expected NPE : " + e.getMessage());
+            exceptions++;
+        } catch (RuntimeException e1) {
+            log.info("Caught expected RuntimeException : " + e1.getMessage());
+            exceptions++;
+        }
+        // getThreadCpuTime(long[]) with { 0 }
+        try {
+            threadMXBean.getThreadUserTime(new long[] { 0 });
+        } catch (IllegalArgumentException e) {
+            log.info("Caught expected IllegalArgumentException : " + e.getMessage());
+            exceptions++;
+        } catch (RuntimeException e1) {
+            log.info("Caught expected RuntimeException : " + e1.getMessage());
+            exceptions++;
+        }
+        // 4 exceptions should have been caught
+        if (exceptions != 4)
+            throw new TestFailure("Failure! Expected to catch 4 exceptions, "
+                    + "actually caught : " + exceptions);
+        log.info("IllegalArgumentsTest passed.");
+    }
+
+    /**
+     * Entry point for java program
+     * @param args sets the test configuration
+     */
+    public static void main(String[] args) {
+        Monitoring.runTest(new IllegalArgumentsTest(), args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_directly/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_directly.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes BaseBehaviorTest
+ *     For more info please refer to BaseBehaviorTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadCpuTime.BaseBehaviorTest
+ *      -testMode=directly
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_proxy_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_proxy_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes BaseBehaviorTest
+ *     For more info please refer to BaseBehaviorTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadCpuTime.BaseBehaviorTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_proxy_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_proxy_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes BaseBehaviorTest
+ *     For more info please refer to BaseBehaviorTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadCpuTime.BaseBehaviorTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_server_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_server_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes BaseBehaviorTest
+ *     For more info please refer to BaseBehaviorTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadCpuTime.BaseBehaviorTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_server_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_server_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes BaseBehaviorTest
+ *     For more info please refer to BaseBehaviorTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadCpuTime.BaseBehaviorTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_directly/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_directly.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes IllegalArgumentsTest
+ *     For more info please refer to IllegalArgumentsTest.README
+ *     Test configuration:
+ *     Direct access to management metrics
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadCpuTime.IllegalArgumentsTest
+ *      -testMode=directly
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_proxy_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_proxy_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes IllegalArgumentsTest
+ *     For more info please refer to IllegalArgumentsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadCpuTime.IllegalArgumentsTest
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_proxy_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_proxy_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes IllegalArgumentsTest
+ *     For more info please refer to IllegalArgumentsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server proxy
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadCpuTime.IllegalArgumentsTest
+ *      -testMode=proxy
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_server_custom/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_server_custom.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes IllegalArgumentsTest
+ *     For more info please refer to IllegalArgumentsTest.README
+ *     Test configuration:
+ *     Access to management metrics via custom MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadCpuTime.IllegalArgumentsTest
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_server_default/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_server_default.
+ * VM Testbase keywords: [quick, monitoring, feature_memory_alloc]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     This test executes IllegalArgumentsTest
+ *     For more info please refer to IllegalArgumentsTest.README
+ *     Test configuration:
+ *     Access to management metrics via default MBean server
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.GetThreadCpuTime.IllegalArgumentsTest
+ *      -testMode=server
+ *      -MBeanServer=default
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/MXBeanTestThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean;
+
+import java.util.ArrayList;
+import java.util.List;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.gp.GarbageUtils;
+import nsk.share.test.Stresser;
+
+
+public class MXBeanTestThread extends Thread {
+
+    /**
+     * BarrierHandler instance for synchronization with management thread
+     */
+    protected BarrierHandler handler;
+
+    /**
+     * List where allocated objects are stored
+     */
+    private List<Object> allocatedList;
+    /**
+     * Number of simultaneously running threads
+     */
+    private static int threadCount;
+    /**
+     * java.util.Random instance for stress test (allocateStress())
+     */
+    private java.util.Random random = new java.util.Random();
+    /**
+     * Expected amount of memory allocated during stress test
+     */
+    private long stressAllocatedBytes;
+    /**
+     * Maximum memory in bytes that one thread is allowed to use at once
+     */
+    private long maxThreadMemory = 0;
+    /**
+     * GarbageProducer for objects creation
+     */
+    private GarbageProducer gp;
+    /**
+     * Stresser instance for allocateStress()
+     */
+    private Stresser stresser;
+
+    public static void warmUp(String garbageProducerId) {
+        MXBeanTestThread warmUpThread = new MXBeanTestThread(garbageProducerId) {
+                @Override
+                public void doWork() {
+                    allocate();
+                }
+            };
+        warmUpThread.start();
+        do {
+            try {
+                warmUpThread.join();
+            } catch (InterruptedException ie) {}
+        } while(warmUpThread.isAlive());
+    }
+
+    /**
+     * Sets BarrierHandler for this thread
+     *
+     * @param handler BarrierHandler to synchronize with
+     */
+    public void setHandler(BarrierHandler handler) {
+        this.handler = handler;
+    }
+
+    /**
+     * Returns an instance of MXBeanTestThread with already defined
+     * allocatedList List and GarbageProducer
+     */
+    public MXBeanTestThread(String garbageProducerId) {
+        super(Integer.toString(++threadCount));
+        allocatedList = new ArrayList<Object>();
+        gp = GarbageUtils.getGarbageProducer(garbageProducerId);
+        maxThreadMemory = Runtime.getRuntime().maxMemory()/4;
+    }
+
+    /**
+     * Returns an instance of MXBeanTestThread with already defined
+     * allocatedList List and default GarbageProducer
+     */
+    public MXBeanTestThread() {
+        this("intArr");
+    }
+
+    /**
+     * Returns an instance of MXBeanTestThread with already defined
+     * allocatedList List and Stresser
+     */
+    public MXBeanTestThread(Stresser stresser) {
+        this("intArr");
+        this.stresser = stresser;
+    }
+
+    /**
+     * Sets maximum amount of memory that could be used at once for each
+     * TestThread in StressTest
+     */
+    public void setMaxThreadMemory (long memory) {
+        maxThreadMemory = memory;
+    }
+
+    /**
+     * Returns expected memory allocated by TestThread during StressTest
+     * @return expected memory amount
+     */
+    public long getStressAllocatedBytes() {
+        return stressAllocatedBytes;
+    }
+
+    @Override
+    public void run() {
+        doWork();
+    }
+
+    /**
+     * Implementation of TestThread behavior logic
+     */
+    public void doWork() {
+        handler.ready();
+        allocate();
+        handler.ready();
+    }
+
+    /**
+     * Allocates memory for amount of time specified in Stresser instance
+     */
+    protected void allocateStress() {
+        // Size of long[] array that allocates 2 Mb + 1 byte
+        int MAX_ARR_SIZE=262146;
+        // Anount of memory allocated by thread with existing links
+        // Which means that these objects can't be collected by GC
+        long actuallyAllocated = 0;
+        try {
+            while (stresser.continueExecution()) {
+                //int chunkSize = random.nextInt(MAX_OBJECT_SIZE);
+                //Object obj = gp.create(chunkSize);
+                int chunkSize = random.nextInt(MAX_ARR_SIZE);
+                Object obj = new long[chunkSize];
+                allocatedList.add(obj);
+                actuallyAllocated += chunkSize*8;
+                if (actuallyAllocated > maxThreadMemory) {
+                    // Allocated more then allowed to one thread
+                    // re-define allocatedList to allow GC to delete
+                    // created objects
+                    stressAllocatedBytes += actuallyAllocated;
+                    actuallyAllocated = 0;
+                    allocatedList = new ArrayList<Object>();
+                }
+            }
+        } catch (OutOfMemoryError e) {
+        } finally {
+            stressAllocatedBytes += actuallyAllocated;
+        }
+    }
+
+    /**
+     * Allocates memory once according test settings
+     */
+    protected void allocate() {
+        long actuallyAllocated = 0;
+        for (int i = 0; i < ThreadMXBeanTestBase.allocArr.length; i++) {
+            long size = ThreadMXBeanTestBase.allocArr[i];
+            if (actuallyAllocated + size > maxThreadMemory) {
+                break;
+            }
+            allocatedList.add(gp.create(size));
+            actuallyAllocated += size;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=blocked
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=blocked
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=blocked
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=blocked
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=blocked
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, quarantine]
+ * VM Testbase comments: JDK-8060733
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=javaDeadlock
+ *      -iterations=1
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=javaDeadlock
+ *      -testMode=server
+ *      -iterations=1
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=javaDeadlock
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -iterations=1
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=javaDeadlock
+ *      -testMode=proxy
+ *      -iterations=1
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=javaDeadlock
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ *      -iterations=1
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/MixedDeadlock001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/MixedDeadlock001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=mixedDeadlock
+ *      -iterations=1
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/NativeDeadlock001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/NativeDeadlock001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=nativeDeadlock
+ *      -iterations=1
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/SynchronizedMethodDeadlock001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/SynchronizedMethodDeadlock001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=synchronizedMethodDeadlock
+ *      -iterations=1
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/SynchronizerDeadlock001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/SynchronizerDeadlock001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=synchronizerDeadlock
+ *      -iterations=1
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=finished
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=finished
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=finished
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=finished
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=finished
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=lockingThreads
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=lockingThreads
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=lockingThreads
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=lockingThreads
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=lockingThreads
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi001/Multi001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi001.
+ * VM Testbase keywords: [monitoring, stress, stressopt, feature_136, nonconcurrent, vm6, quarantine]
+ * VM Testbase comments: JDK-7187073
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadMXBean.ThreadInfo.Multi.Multi001.Multi001
+ */
+
+package nsk.monitoring.ThreadMXBean.ThreadInfo.Multi.Multi001;
+
+import java.lang.management.*;
+import nsk.share.runner.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.share.thread.*;
+import nsk.share.TestFailure;
+import nsk.share.test.Stresser;
+
+/**
+ * This test starts huge number of scenarios of different types. Each
+ * thread is then brought into pre-defined state and ThreadInfo
+ * information obtained from ThreadMXBean is verified. This is repeated
+ * several times.
+ */
+public class Multi001 extends MonitoringTestBase implements RunParamsAware {
+        private RunParams runParams;
+        private ThreadMXBean thread;
+        private int scenarioCount;
+        private ThreadMonitoringScenarioFactory scenarioFactory;
+        private int iterations = 3;
+        private int maxDepth = 200;
+
+        private void runOne() {
+                ThreadMonitoringScenario scenario = new MultiScenario(scenarioFactory, scenarioCount);
+                try {
+                        log.info("Starting: " + scenario);
+                        scenario.begin();
+                        scenario.waitState();
+                        log.info("State reached");
+                        log.info("Checking: " + scenario);
+                        scenario.check(thread);
+                } finally {
+                        log.info("Finishing: " + scenario);
+                        scenarioFactory.finish();
+                        scenario.finish();
+                        log.info("Ending: " + scenario);
+                        scenario.end();
+                }
+        }
+
+        public void run() {
+                scenarioFactory = new StandardThreadMonitoringScenarioFactory(log, maxDepth, runParams.getMediumLoadThreadsCount());
+                thread = monitoringFactory.getThreadMXBean();
+                //scenarioCount = runParams.getHighLoadThreadsCount();
+                scenarioCount = scenarioFactory.getScenarioCount(runParams.getBasicLoadThreadsCount());
+                log.info("Scenario count: " + scenarioCount);
+                Stresser stresser = new Stresser(runParams.getStressOptions());
+                try {
+                        stresser.start(iterations);
+                        while (stresser.iteration());
+                                runOne();
+                } finally {
+                        stresser.finish();
+                }
+                log.info("TEST PASSED");
+        }
+
+        public void setRunParams(RunParams runParams) {
+                this.runParams = runParams;
+        }
+
+        public static void main(String[] args) {
+                Monitoring.runTest(new Multi001(), args);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi001/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi002/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi002.
+ * VM Testbase keywords: [monitoring, stress, stressopt, feature_136, nonconcurrent, vm6, quarantine]
+ * VM Testbase comments: JDK-7187073
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadMXBean.ThreadInfo.Multi.Multi001.Multi001 -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi003/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi003.
+ * VM Testbase keywords: [monitoring, stress, stressopt, feature_136, nonconcurrent, vm6, quarantine]
+ * VM Testbase comments: JDK-7187073
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.Multi.Multi001.Multi001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi004/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi004.
+ * VM Testbase keywords: [monitoring, stress, stressopt, feature_136, nonconcurrent, vm6, quarantine]
+ * VM Testbase comments: JDK-7187073
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadMXBean.ThreadInfo.Multi.Multi001.Multi001 -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi005/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/Multi/Multi005.
+ * VM Testbase keywords: [monitoring, stress, stressopt, feature_136, nonconcurrent, vm6, quarantine]
+ * VM Testbase comments: JDK-7187073
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.Multi.Multi001.Multi001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=nativeBlocked
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=nativeBlocked
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=nativeBlocked
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=nativeBlocked
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=nativeBlocked
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=new
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=new
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=new
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=new
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=new
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread001/RunningThread001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=running
+ */
+
+package nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001;
+
+import java.lang.management.*;
+import nsk.share.runner.*;
+import nsk.monitoring.share.*;
+import nsk.monitoring.share.thread.*;
+import nsk.share.TestFailure;
+
+/**
+ * This test starts huge number of threads of different types. Each
+ * thread is then brought into pre-defined state and ThreadInfo
+ * information obtained from ThreadMXBean is verified. This is repeated
+ * several times.
+ */
+public class RunningThread001 extends MonitoringTestBase implements RunParamsAware, ScenarioTypeAware {
+        private RunParams runParams;
+        private ThreadMXBean thread;
+        private int threadCount;
+        private ThreadMonitoringScenarioFactory scenarioFactory;
+        private String scenarioType;
+        private int iterations;
+        private int maxDepth = 200;
+
+        private void runOne() {
+                ThreadMonitoringScenario scenario = scenarioFactory.createScenario(scenarioType);
+                try {
+                        log.info("Starting: " + scenario);
+                        scenario.begin();
+                        scenario.waitState();
+                        log.info("State reached");
+                        log.info("Checking: " + scenario);
+                        scenario.check(thread);
+                } finally {
+                        log.info("Finishing: " + scenario);
+                        scenarioFactory.finish();
+                        scenario.finish();
+                        log.info("Ending: " + scenario);
+                        scenario.end();
+                }
+
+        }
+
+        public void run() {
+                thread = monitoringFactory.getThreadMXBean();
+                scenarioFactory = new StandardThreadMonitoringScenarioFactory(log, maxDepth, runParams.getMediumLoadThreadsCount());
+                iterations = argHandler.getIterations();
+                for (int i = 0; i < iterations; ++i)
+                        runOne();
+                log.info("TEST PASSED");
+        }
+
+        public void setRunParams(RunParams runParams) {
+                this.runParams = runParams;
+        }
+
+        public void setScenarioType(String scenarioType) {
+                this.scenarioType = scenarioType;
+        }
+
+        public static void main(String[] args) {
+                Monitoring.runTest(new RunningThread001(), args);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=running
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=running
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=running
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=running
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=sleeping
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=sleeping
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=sleeping
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=sleeping
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=sleeping
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=synchronizerLockingThreads
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=synchronizerLockingThreads
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=synchronizerLockingThreads
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=synchronizerLockingThreads
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=synchronizerLockingThreads
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=timedWaiting
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=timedWaiting
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=timedWaiting
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=timedWaiting
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=timedWaiting
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread001.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=waiting
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread002.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=waiting
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread003.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=waiting
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread004.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=waiting
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread005.
+ * VM Testbase keywords: [quick, monitoring, feature_136, vm6, jdk_desktop]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMXBean.ThreadInfo.RunningThread.RunningThread001.RunningThread001
+ *      -scenarioType=waiting
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/ThreadMXBeanTestBase.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean;
+
+import java.util.*;
+import nsk.share.test.*;
+import nsk.monitoring.share.*;
+import nsk.share.gc.Memory;
+
+public abstract class ThreadMXBeanTestBase extends MonitoringTestBase
+        implements Initializable {
+
+    /**
+     * Maximum allocation object size. about 2 Mb
+     */
+    private static final int MAX_OBJECT_SIZE = 2*1024*1024;
+    /**
+     * Allocations count for each MXBeanTestThread
+     */
+    private static final int ALLOCATIONS = 100;
+    /**
+     * Minimum size of allocated objects for a single thread stressing GC: 1Mb
+     */
+    protected static final int MIN_STRESS_ALLOCATION_AMOUNT = 1024*1024;
+    /**
+     * Percent of maximum difference of actual result from expected one
+     */
+    protected static final int DELTA_PERCENT = 15;
+    /**
+     * java.util.Random instance for allocArr filling
+     */
+    private final java.util.Random random = new java.util.Random();
+
+    /**
+     * Instance of com.sun.management.ThreadMXBean used by all tests
+     * Obtained in initialize() method
+     */
+    protected com.sun.management.ThreadMXBean threadMXBean;
+    /**
+     * Stresser class instance used in StressTest
+     */
+    protected Stresser stresser;
+    /**
+     * String indicating the GarbageProducer type used in test
+     */
+    protected String garbageProducerId;
+    /**
+     * Defined array with allocation objects sizes
+     */
+    protected static int[] allocArr = new int[ALLOCATIONS];
+
+    /**
+     * Obtains instance of com.sun.management.ThreadMXBean
+     * and stores it in threadMXBean field
+     * If com.sun.management.ThreadMXBean API is not available,
+     * threadMXBean is set to null and appropriate message is
+     * prompted
+     */
+    public void initialize() {
+        if (monitoringFactory.hasThreadMXBeanNew()) {
+            threadMXBean =
+                    (com.sun.management.ThreadMXBean) monitoringFactory.getThreadMXBeanNew();
+            for (int i = 0; i < ALLOCATIONS; i++) {
+                allocArr[i] = Memory.getArrayExtraSize() + Memory.getIntSize()
+                        + Memory.getReferenceSize() // don't be zero-length
+                        + random.nextInt(MAX_OBJECT_SIZE);
+            }
+        } else {
+            log.info("com.sun.management.ThreadMXBean API is not available!");
+        }
+    }
+
+    /**
+     * Obtains instance of Stresser and stores it in stresser field
+     * @param args Stresser arguments
+     */
+    public void setStresser(String[] args) {
+        if (stresser == null)
+            stresser = new Stresser(args);
+    }
+
+    /**
+     * Parses input String arrays searching for GarbageProducer
+     * settings. If found, sets garbageProducerID filed.
+     * @param args input arguments
+     * @return input arguments without GarbageProducer options
+     */
+    public String[] setGarbageProducer(String[] args) {
+        if (garbageProducerId == null) {
+            ArrayList<String> list = new ArrayList<String>();
+            for (int i = 0; i < args.length; i++) {
+                if (args[i].equals("-gp")) {
+                    garbageProducerId = args[++i];
+                } else {
+                    list.add(args[i]);
+                }
+            }
+            return list.toArray(new String[] {});
+        } else {
+            return args;
+        }
+    }
+
+    /**
+     * Starts all specified TestThread threads
+     * @param threads threads to start
+     */
+    public BarrierHandler startThreads(MXBeanTestThread... threads) {
+        BarrierHandler handler = new BarrierHandler(threads);
+        for (MXBeanTestThread thread : threads) {
+            thread.setHandler(handler);
+            thread.start();
+        }
+        handler.start();
+        return handler;
+    }
+
+    /**
+     * Returns expected memory size allocated by MXBeanTestThreads during
+     * stress test (allocateStress() method execution)
+     *
+     * @param array of MXBeanTestThreads
+     * @return expected amount of memory allocated by each StressTestThread
+     */
+    public long[] getStressAllocatedBytes(MXBeanTestThread... threads) {
+        long[] result = new long[threads.length];
+        int counter = 0;
+        for (MXBeanTestThread thread : threads) {
+            result[counter++] = thread.getStressAllocatedBytes();
+        }
+        return result;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.findMonitorDeadlockedThreads()
+ *     does not return the id of the currect thread, since it is not deadlocked.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadMBean.findMonitorDeadlockedThreads.find001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.findMonitorDeadlockedThreads()
+ *     does not return the id of the currect thread, since it is not deadlocked.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.findMonitorDeadlockedThreads.find001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.findMonitorDeadlockedThreads()
+ *     does not return the id of the currect thread, since it is not deadlocked.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.findMonitorDeadlockedThreads.find001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.findMonitorDeadlockedThreads()
+ *     does not return the id of the currect thread, since it is not deadlocked.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadMBean.findMonitorDeadlockedThreads.find001 -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.findMonitorDeadlockedThreads()
+ *     does not return the id of the currect thread, since it is not deadlocked.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.findMonitorDeadlockedThreads.find001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find006.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.ThreadMXBean.findMonitorDeadlockedThreads;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class find006 {
+    private static Wicket mainEntrance = new Wicket();
+    private static boolean testFailed = false;
+
+    public static void main(String[] argv) {
+        System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        ThreadMonitor monitor = Monitor.getThreadMonitor(log, argHandler);
+        long id = Thread.currentThread().getId();
+        long[] ids = monitor.findMonitorDeadlockedThreads();
+
+        if (ids == null) {
+            log.display("findCircularBlockedThread() returned null");
+        } else if (ids.length == 0) {
+            log.display("findCircularBlockedThread() returned array of length "
+                      + "0");
+        } else {
+            for (int i = 0; i < ids.length; i++) {
+                if (ids[i] == id) {
+                    log.complain("TEST FAILED");
+                    log.complain("findCircularBlockedThread() returned current "
+                               + "thread (id = " + id + ")");
+                    testFailed = true;
+                    break;
+                }
+            }
+        }
+
+        ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
+        MyThread thread = new MyThread(out);
+        thread.start();
+
+        // Wait for MyThread to start
+        mainEntrance.waitFor();
+        id = thread.getId();
+
+        thread.die = true;
+
+        int count = 0;
+        while (true) {
+            ids = monitor.findMonitorDeadlockedThreads();
+            count++;
+            ThreadInfo info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
+            if (info == null) {
+                // the thread has exited
+                break;
+            }
+        }
+
+        out.println("INFO: made " + count + " late findMonitorDeadlockedThreads() calls.");
+
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    private static class MyThread extends Thread {
+        final static long WAIT_TIME = 500; // Milliseconds
+        Object object = new Object();
+        volatile boolean die = false;
+        PrintStream out;
+
+        MyThread(PrintStream out) {
+            this.out = out;
+        }
+
+        public void run() {
+
+            // Notify "main" thread that MyThread has started
+            mainEntrance.unlock();
+
+            while (!die) {
+                synchronized(object) {
+                    try {
+                        object.wait(WAIT_TIME);
+                    } catch (InterruptedException e) {
+                        out.println("Unexpected exception.");
+                        e.printStackTrace(out);
+                        testFailed = true;
+                    }
+                } // synchronized
+            }
+        } // run()
+    } // MyThread
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find006/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find006.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     Same test as find001 with additional calls to
+ *     findMonitorDeadlockedThreads() while a thread is exiting.
+ * COMMENT
+ *     Derived from nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find001.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -Xlog:thread+smr=debug
+ *      nsk.monitoring.ThreadMXBean.findMonitorDeadlockedThreads.find006
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isCurrentThreadCpuTimeSupported()
+ *     method returns true. The test performs directly access to management
+ *     metrics within the same JVM.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *     Fixed the bug:
+ *     4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadMBean.isCurrentThreadCpuTimeSupported.curthcputime001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isCurrentThreadCpuTimeSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through default MBeanServer.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isCurrentThreadCpuTimeSupported.curthcputime001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isCurrentThreadCpuTimeSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through custom MBeanServer (developed and saved in
+ *     $TESTBASE/src/nsk/monitoring/share).
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isCurrentThreadCpuTimeSupported.curthcputime001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isCurrentThreadCpuTimeSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through default MBeanServer proxy.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isCurrentThreadCpuTimeSupported.curthcputime001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isCurrentThreadCpuTimeSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through custom MBeanServer proxy (developed and saved in
+ *     $TESTBASE/src/nsk/monitoring/share).
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isCurrentThreadCpuTimeSupported.curthcputime001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isThreadContentionMonitoringSupported()
+ *     method returns true. The test performs directly access to management
+ *     metrics within the same JVM.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *     Fixed the bug:
+ *     4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isThreadContentionMonitoringSupported.thcontmonitor001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isThreadContentionMonitoringSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through default MBeanServer.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isThreadContentionMonitoringSupported.thcontmonitor001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isThreadContentionMonitoringSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through custom MBeanServer (developed and saved in
+ *     $TESTBASE/src/nsk/monitoring/share).
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isThreadContentionMonitoringSupported.thcontmonitor001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isThreadContentionMonitoringSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through default MBeanServer proxy.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isThreadContentionMonitoringSupported.thcontmonitor001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isThreadContentionMonitoringSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through custom MBeanServer proxy (developed and saved in
+ *     $TESTBASE/src/nsk/monitoring/share).
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isThreadContentionMonitoringSupported.thcontmonitor001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isThreadCpuTimeSupported()
+ *     method returns true. The test performs directly access to management
+ *     metrics within the same JVM.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *     Fixed the bug:
+ *     4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadMBean.isThreadCpuTimeSupported.thcputime001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isThreadCpuTimeSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through default MBeanServer.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isThreadCpuTimeSupported.thcputime001
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isThreadCpuTimeSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through custom MBeanServer (developed and saved in
+ *     $TESTBASE/src/nsk/monitoring/share).
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isThreadCpuTimeSupported.thcputime001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isThreadCpuTimeSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through default MBeanServer proxy.
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isThreadCpuTimeSupported.thcputime001
+ *      -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.isThreadCpuTimeSupported()
+ *     method returns true. The test performs access to management metrics
+ *     through custom MBeanServer proxy (developed and saved in
+ *     $TESTBASE/src/nsk/monitoring/share).
+ *     Note, that the test is correct ONLY against Sun's Hotspot VM. This
+ *     feature is optional and the method may return either true, or false.
+ *     However, Sun's implementation must always return true.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.isThreadCpuTimeSupported.thcputime001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset001.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.resetPeakThreadCount()
+ *     returns correct result.
+ *     The test starts a couple of user threads and waits until they finish. After
+ *     that, resetPeakThreadCount() is invoked to reset the peak. Then
+ *     getPeakThreadCount() and getThreadCount() must return the same values. The
+ *     preposition is that no threads are appered/disappeared between
+ *     "getPeakThreadCount()" and getThreadCount()" calls.
+ *     The test implements direct access to the metrics.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadMBean.resetPeakThreadCount.reset001
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset002.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.resetPeakThreadCount()
+ *     returns correct result.
+ *     The test starts a couple of user threads and waits until they finish. After
+ *     that, resetPeakThreadCount() is invoked to reset the peak. Then
+ *     getPeakThreadCount() and getThreadCount() must return the same values. The
+ *     preposition is that no threads are appered/disappeared between
+ *     "getPeakThreadCount()" and getThreadCount()" calls.
+ *     The test implements access to the metrics via default MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadMBean.resetPeakThreadCount.reset001 -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset003.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.resetPeakThreadCount()
+ *     returns correct result.
+ *     The test starts a couple of user threads and waits until they finish. After
+ *     that, resetPeakThreadCount() is invoked to reset the peak. Then
+ *     getPeakThreadCount() and getThreadCount() must return the same values. The
+ *     preposition is that no threads are appered/disappeared between
+ *     "getPeakThreadCount()" and getThreadCount()" calls.
+ *     The test implements access to the metrics via custom MBean server.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.resetPeakThreadCount.reset001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset004.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.resetPeakThreadCount()
+ *     returns correct result.
+ *     The test starts a couple of user threads and waits until they finish. After
+ *     that, resetPeakThreadCount() is invoked to reset the peak. Then
+ *     getPeakThreadCount() and getThreadCount() must return the same values. The
+ *     preposition is that no threads are appered/disappeared between
+ *     "getPeakThreadCount()" and getThreadCount()" calls.
+ *     The test implements access to the metrics via default MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.ThreadMBean.resetPeakThreadCount.reset001 -testMode=proxy
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ *
+ * @summary converted from VM Testbase nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset005.
+ * VM Testbase keywords: [quick, monitoring]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that
+ *         ThreadMBean.resetPeakThreadCount()
+ *     returns correct result.
+ *     The test starts a couple of user threads and waits until they finish. After
+ *     that, resetPeakThreadCount() is invoked to reset the peak. Then
+ *     getPeakThreadCount() and getThreadCount() must return the same values. The
+ *     preposition is that no threads are appered/disappeared between
+ *     "getPeakThreadCount()" and getThreadCount()" calls.
+ *     The test implements access to the metrics via custom MBean server proxy.
+ * COMMENT
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.ThreadMBean.resetPeakThreadCount.reset001
+ *      -testMode=proxy
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ArgumentHandler.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,507 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import nsk.share.log.Log;
+import nsk.share.TestBug;
+import nsk.share.ArgumentParser;
+import java.lang.management.*;
+
+/**
+ * Parser for JSR-174 test's arguments.
+ * <p>
+ * <code>ArgumentHandler</code> handles specific command line arguments
+ * related to way of execution of a test in addition to general arguments
+ * recognized by {@link ArgumentParser <code>ArgumentParser</code>}.
+ * <p>
+ * Following is the list of specific options for <code>ArgumentHandler</code>:
+ * <ul>
+ * <li><code>-testMode="<i>value</i>"</code>, where <i>value</i> may take
+ *      one of the following values: <code>directly</code> -- to call methods in
+ *      the MBean directly within the same JVM, <code>server</code> -- to call
+ *      methods through MBeanServer, <code>proxy</code> -- to call methods
+ *      through MBean proxy (not yet implemented).
+ * <li><code>-MBeanServer="<i>value</i>"</code>, where <i>value</i> may take
+ *      one of the following values: <code>default</code> -- to execute test for
+ *      default JMX implementation of MBeanServer or <code>custom</code> -- for
+ *      implementation provided by NSK J2SE SQE Team.
+ * <li><code>-loadableClassCount=<i>value</i></code>, where <i>value</i> defines
+ *      amount of loadable classes. Default values is <code>100</code>.
+ * <li><code>-loadersCount=<i>value</i></code>, where <i>value</i> defines
+ *      amount of class loaders. Default values is <code>100</code>.
+ * <li><code>-singleClassloaderClass</code> specifies whether class loaders are
+ *      instances of the same class.
+ * <li><code>-memory="<i>value</i>"</code>, where <i>value</i> may take
+ *      one of the following values: <code>heap</code> -- to test heap memory,
+ *      <code>nonheap</code> to test nonheap memory, <code>mixed</code> -- to
+ *      test both heap and nonheap memory.
+ * <li><code>-invocationType="<i>value</i>"</code>, where <i>value</i> may take
+ *      one of the following values: <code>java</code> -- to start java threads,
+ *      <code>native</code> -- to start native threads, <code>mixed</code> -- to
+ *      both java and native threads.
+ * <li><code>-monitoring="<i>value</i>"</code>, where <i>value</i> may take
+ *      one of the following values: <code>polling</code> -- to start polling
+ *      mechanism of monitoring, <code>notification</code> -- to start
+ *      notification mechanism of monitoring.
+ * <li><code>-threshold="<i>value</i>"</code>, where <i>value</i> may take
+ *      one of the following values: <code>usage</code> -- to test usage
+ *      thresholds, <code>collection</code> -- to test collection usage
+ *      thresholds.
+ * <li><code>-depth=<i>value</i></code>, where <i>value</i> defines
+ *      depth of recursion. Default values is <code>1</code>.
+ * <li><code>-threadCount=<i>value</i></code>, where <i>value</i> defines
+ *      number of threads to start. Default values is <code>1</code>.
+ * <li><code>-timeout=<i>value</i></code>, where <i>value</i> defines
+ *      number of minutes to run the test.
+ * </ul>
+ * <p>
+ * See also list of basic options recognized by <code>ArgumentParser</code>.
+ * <p>
+ * See also comments to <code>ArgumentParser</code> how to work with
+ * command line arguments and options.
+ *
+ * @see ArgumentParser
+ */
+public class ArgumentHandler extends ArgumentParser {
+    static final String TEST_MODE = "testMode";
+    static final String DIRECTLY_MODE = "directly";
+    static final String SERVER_MODE = "server";
+    static final String PROXY_MODE = "proxy";
+
+    static final String SERVER_TYPE = "MBeanServer";
+    static final String DEFAULT_TYPE = "default";
+    static final String CUSTOM_TYPE = "custom";
+
+    static final String LOADABLE_CLASSES_COUNT = "loadableClassCount";
+    static final String LOADERS_COUNT = "loadersCount";
+    static final String SINGLE_CLASSLOADER_CLASS = "singleClassloaderClass";
+
+    static final String MEMORY_TYPE = "memory";
+    static final String MT_HEAP = "heap";
+    static final String MT_NONHEAP = "nonheap";
+    static final String MT_MIXED = "mixed";
+
+    static final String INVOCATION_TYPE = "invocationType";
+    static final String JAVA_TYPE = "java";
+    static final String NATIVE_TYPE = "native";
+    static final String MIXED_TYPE = "mixed";
+
+    static final String MONITORING = "monitoring";
+    static final String MON_POLLING = "polling";
+    static final String MON_NOTIF = "notification";
+
+    static final String THRESHOLD = "threshold";
+    static final String TH_USAGE = "usage";
+    static final String TH_COLLECTION = "collection";
+
+    static final String THREAD_DEPTH = "depth";
+    static final String THREAD_COUNT = "threadCount";
+    static final String TIMEOUT = "timeout";
+
+    static final String SCENARIO_TYPE = "scenarioType";
+
+    static final String ITERATIONS = "iterations";
+
+    /**
+     * Keep a copy of raw command-line arguments and parse them;
+     * but throw an exception on parsing error.
+     *
+     * @param  args  Array of the raw command-line arguments.
+     *
+     * @throws  BadOption  If unknown option or illegal
+     *                     option value found
+     *
+     * @see ArgumentParser
+     */
+    public ArgumentHandler(String args[]) {
+        super(args);
+    }
+
+    /**
+     * Returns the test mode.
+     * <p>
+     * To access the metrics directly, <code>testMode</code> option should
+     * be defined in command line <code>-testMode="directly"</code>.
+     * To access the metrics via MBeanServer, <code>"server"</code> should be
+     * assigned to <code>-testMode="directly"</code>.
+     * <p>
+     * If <code>testMode</code> is not defined by command line, a test is
+     * executed in <code>directly</code> mode.
+     *
+     * @return name of test mode.
+     *
+     */
+    public String getTestMode() {
+        return options.getProperty(TEST_MODE, DIRECTLY_MODE);
+    }
+
+    /**
+     * Returns a type of MBean server if any.
+     * Two kinds of MBean servers are allowed: default and custom servers.
+     * Default server is an implementation of {@link
+     * javax.management.MBeanServer <tt>javax.management.MBeanServer</tt>}
+     * interface provided by JMX. Custom server is an implementation provided
+     * by NSK J2SE SQE Team. Server type is defined by <tt>MBeanServer</tt>
+     * key in command line <code>-MBeanServer="default"</code> or
+     * <code>-MBeanServer="custom"</code>
+     *
+     * @return <i>MBeanServer</i> server type.
+     *
+     */
+    public String getServerType() {
+        return options.getProperty(SERVER_TYPE, DEFAULT_TYPE);
+    }
+
+    /**
+     * Returns <i>true</i> if default implementation is used.
+     *
+     * @return <i>true</i> if default implementation is used.
+     *
+     * @see #getServerType()
+     */
+    public boolean isDefaultServer() {
+        return getServerType().equals(DEFAULT_TYPE);
+    }
+
+    /**
+     * Returns amount of class loaders.
+     *
+     * @return <i>loadersCount</i> as an integer value
+     */
+    public int getLoadersCount() {
+        String val = options.getProperty(LOADERS_COUNT, "100");
+        int number;
+        try {
+            number = Integer.parseInt(val);
+        } catch (NumberFormatException e) {
+            throw new TestBug("Not integer value of \"" + LOADERS_COUNT
+                                    + "\" argument: " + val);
+        }
+        return number;
+    }
+
+    /**
+     * Returns <i>true</i> if class loaders, which perform class loading, are
+     * instances of the same class. If <code>-singleClassloaderClass</code> key
+     * is not set in command line options, then <i>false</i> is returned.
+     *
+     * @return if class loaders are instances of the same class.
+     *
+     */
+    public boolean singleClassloaderClass() {
+        return options.getProperty(SINGLE_CLASSLOADER_CLASS) != null;
+    }
+
+    /**
+     * Returns amount of loadable classes. If <code>-loadableClassesCount</code>
+     * key is not set with command line, <code>100</code> is returned.
+     *
+     * @return <i>loadableClassesCount</i> as an integer value
+     *
+     * @throws TestBug <i>loadableClassesCount</i> is non-numeric value.
+     *
+     */
+    public int getLoadableClassesCount() {
+        String val = options.getProperty(LOADABLE_CLASSES_COUNT, "1");
+        int number;
+        try {
+            number = Integer.parseInt(val);
+        } catch (NumberFormatException e) {
+            throw new TestBug("Not integer value of \"" + LOADABLE_CLASSES_COUNT
+                                    + "\" argument: " + val);
+        }
+        return number;
+    }
+
+    /**
+     * Returns invocation type.
+     *
+     * @return <i>invocationType</i> value
+     *
+     */
+    public String getInvocationType() {
+        return options.getProperty(INVOCATION_TYPE, JAVA_TYPE);
+    }
+
+    /**
+     * Returns tested memory type.
+     *
+     * @return <i>memory</i> value
+     *
+     */
+    public String getTestedMemory() {
+        return options.getProperty(MEMORY_TYPE, MT_HEAP);
+    }
+
+    /**
+     * Returns timeout.
+     *
+     * @return <i>timeout</i> value
+     *
+     */
+    public int getTimeout() {
+        String value = options.getProperty(TIMEOUT, "30");
+
+        try {
+            return Integer.parseInt(value);
+        } catch (NumberFormatException e) {
+            throw new TestBug("Not integer value of \"" + TIMEOUT
+                            + "\" argument: " + value);
+        }
+    }
+
+    /**
+     * Returns recursion depth.
+     *
+     * @return <i>depth</i> value
+     *
+     */
+    public int getThreadDepth() {
+        String value = options.getProperty(THREAD_DEPTH, "1");
+
+        try {
+            return Integer.parseInt(value);
+        } catch (NumberFormatException e) {
+            throw new TestBug("Not integer value of \"" + THREAD_DEPTH
+                            + "\" argument: " + value);
+        }
+    }
+
+    /**
+     * Returns number of threads.
+     *
+     * @return <i>threadCount</i> value
+     *
+     */
+    public int getThreadCount() {
+        String value = options.getProperty(THREAD_COUNT, "1");
+
+        try {
+            return Integer.parseInt(value);
+        } catch (NumberFormatException e) {
+            throw new TestBug("Not integer value of \"" + THREAD_COUNT
+                            + "\" argument: " + value);
+        }
+    }
+
+    /**
+     * Returns type of monitoring.
+     *
+     * @return <i>monitoring</i> value
+     *
+     */
+    public String getMonitoring() {
+        return options.getProperty(MONITORING, MON_NOTIF);
+    }
+
+    /**
+     * Returns type of threshold.
+     *
+     * @return <i>threshold</i> value
+     *
+     */
+    public String getThreshold() {
+        return options.getProperty(THRESHOLD, TH_USAGE);
+    }
+
+    /**
+     * Returns thread type to create.
+     */
+    public String getScenarioType() {
+            return options.getProperty(SCENARIO_TYPE, "running");
+    }
+
+    public int getIterations() {
+            return Integer.parseInt(options.getProperty(ITERATIONS, "3"));
+    }
+
+    /**
+     * Checks if an option is allowed and has proper value.
+     * This method is invoked by <code>parseArguments()</code>
+     *
+     * @param option option name
+     * @param value string representation of value
+     *                      (could be an empty string too)
+     *              null if this option has no value
+     * @return <i>true</i> if option is allowed and has proper value
+     *         <i>false</i> if otion is not admissible
+     *
+     * @throws <i>BadOption</i> if option has an illegal value
+     *
+     * @see nsk.share.ArgumentParser#parseArguments
+     */
+    protected boolean checkOption(String option, String value) {
+
+        // defines directly, server or proxytest mode
+        if (option.equals(TEST_MODE)) {
+            if ( (!value.equals(DIRECTLY_MODE)) &&
+                 (!value.equals(SERVER_MODE)) &&
+                 (!value.equals(PROXY_MODE))
+               ) {
+                throw new BadOption(option + ": must be one of: "
+                                  + "\"" + DIRECTLY_MODE + "\", "
+                                  + "\"" + SERVER_MODE   + "\", "
+                                  + "\"" + PROXY_MODE    + "\"");
+            }
+            return true;
+        }
+
+        // defines invocation type for stack filling
+        if (option.equals(INVOCATION_TYPE)) {
+            if ( (!value.equals(JAVA_TYPE)) &&
+                 (!value.equals(NATIVE_TYPE)) &&
+                 (!value.equals(MIXED_TYPE))
+               ) {
+                throw new BadOption(option + ": must be one of: "
+                                  + "\"" + JAVA_TYPE + "\", "
+                                  + "\"" + NATIVE_TYPE + "\", "
+                                  + "\"" + MIXED_TYPE + "\"");
+            }
+            return true;
+        }
+
+        // defines default or custom MBean server
+        if (option.equals(SERVER_TYPE)) {
+            if ((!value.equals(DEFAULT_TYPE))
+                && (!value.equals(CUSTOM_TYPE))) {
+                throw new BadOption(option + ": must be one of: \""
+                                           + DEFAULT_TYPE + "\", \""
+                                           + CUSTOM_TYPE + "\"");
+            }
+
+            return true;
+        }
+
+        // defines loadable classes and loaders counts
+        if (option.equals(LOADABLE_CLASSES_COUNT) ||
+                option.equals(LOADERS_COUNT) ||
+                option.equals(THREAD_DEPTH) || option.equals(THREAD_COUNT)) {
+            try {
+                int number = Integer.parseInt(value);
+                if (number < 0) {
+                    throw new BadOption(option + ": value must be a positive "
+                                      + "integer");
+                }
+            } catch (NumberFormatException e) {
+                throw new BadOption(option + ": value must be an integer");
+            }
+            return true;
+        }
+
+        // defines timeout
+        if (option.equals(TIMEOUT)) {
+            try {
+                int number = Integer.parseInt(value);
+
+                if (number < 0)
+                    throw new BadOption(option + ": value must be a positive "
+                                      + "integer");
+            } catch (NumberFormatException e) {
+                throw new BadOption(option + ": value must be an integer");
+            }
+            return true;
+        }
+
+        // defines if classloader class is single
+        if (option.equals(SINGLE_CLASSLOADER_CLASS)) {
+            if (!(value == null || value.length() <= 0)) {
+                throw new BadOption(option + ": no value must be specified");
+            }
+            return true;
+        }
+
+        // defines memory types
+        if (option.equals(MEMORY_TYPE)) {
+            if ( (!value.equals(MT_HEAP)) &&
+                 (!value.equals(MT_NONHEAP)) &&
+                 (!value.equals(MT_MIXED))
+               )
+                throw new BadOption(option + ": must be one of: "
+                                  + "\"" + MT_HEAP + "\", "
+                                  + "\"" + MT_NONHEAP + "\", "
+                                  + "\"" + MT_MIXED + "\"");
+            return true;
+        }
+
+        // defines type of monitoring
+        if (option.equals(MONITORING)) {
+            if ( (!value.equals(MON_POLLING)) &&
+                 (!value.equals(MON_NOTIF))
+               )
+                throw new BadOption(option + ": must be one of: "
+                                  + "\"" + MON_POLLING + "\", "
+                                  + "\"" + MON_NOTIF + "\"");
+            return true;
+        }
+
+        // defines threshold
+        if (option.equals(THRESHOLD)) {
+            if ( (!value.equals(TH_USAGE)) &&
+                 (!value.equals(TH_COLLECTION))
+               )
+                throw new BadOption(option + ": must be one of: "
+                                  + "\"" + TH_USAGE + "\", "
+                                  + "\"" + TH_COLLECTION + "\"");
+            return true;
+        }
+
+        if (option.equals(SCENARIO_TYPE)) {
+                return true;
+        }
+        if (option.equals(ITERATIONS)) {
+            try {
+                int number = Integer.parseInt(value);
+
+                if (number < 0)
+                    throw new BadOption(option + ": value must be a positive "
+                                      + "integer");
+                return true;
+            } catch (NumberFormatException e) {
+                throw new BadOption(option + ": value must be an integer");
+            }
+
+        }
+        return super.checkOption(option, value);
+    }
+
+    /**
+     * Check if the values of all options are consistent.
+     * This method is invoked by <code>parseArguments()</code>
+     *
+     * @throws <i>BadOption</i> if options have inconsistent values
+     *
+     * @see nsk.share.ArgumentParser#parseArguments
+     */
+    protected void checkOptions() {
+        super.checkOptions();
+    }
+
+    public void dump(Log log) {
+            log.info("Test mode: " + getTestMode());
+            log.info("Server type: " + getServerType());
+            log.info("loadableClassesCount: " + getLoadableClassesCount());
+            log.info("loadersCount: " + getLoadersCount());
+            log.info("singleClassloaderClass: " + singleClassloaderClass());
+    }
+} // ArgumentHandler
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ArgumentHandlerAware.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+public interface ArgumentHandlerAware {
+        public void setArgumentHandler(ArgumentHandler argHandler);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ClassLoadingController.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,291 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.util.*;
+import nsk.share.log.Log;
+import nsk.share.ClassUnloader;
+import nsk.share.CustomClassLoader;
+import nsk.share.test.Stresser;
+
+/**
+ * The <code>ClassLoadingController</code> class allows to operate class
+ * loading/unloading process.
+ */
+public class ClassLoadingController extends StateControllerBase {
+        // Path and name of the classes to load
+        private static final String CLASSNAME_PATTERN = "nsk.monitoring.share.newclass.LoadableClass";
+
+        private int loadedClassCount = 100;
+        private int loaderCount = 1;
+        private boolean singleClass = true;
+        private String classDir;
+        private Hashtable<String, String[]> classesTable = new Hashtable<String, String[]>();
+        private ClassUnloader[] unloaders;
+
+        private Stresser stresser;
+
+        /**
+         * Constructs a new <code>ClassLoadingController</code> with defined
+         * arguments.
+         *
+         * @param log <code>Log</code> to print log info to.
+         * @param loadedClassCount number of classes to load.
+         * @param loaderCount number of loaders to use.
+         * @param singleClass if class loaders are instances of the same class.
+         * @param classDir directory to load classes from.
+         */
+        public ClassLoadingController(
+                Log log,
+                int loadedClassCount,
+                int loaderCount,
+                boolean singleClass,
+                String classDir,
+                Stresser stresser
+        ) {
+                super(log);
+                setLoadedClassCount(loadedClassCount);
+                setLoaderCount(loaderCount);
+                setClassDir(classDir);
+                singleClassLoaderClass(singleClass);
+                dump();
+                preloadAllClasses();
+                setStresser(stresser);
+        }
+
+    private void setStresser(Stresser stresser) {
+        this.stresser = stresser;
+    }
+
+    public ClassLoadingController(Log log, ArgumentHandler argHandler, Stresser stresser) {
+                this(
+                        log,
+                        argHandler.getLoadableClassesCount(),
+//                        argHandler.getLoadersCount(),
+                        (int)stresser.getMaxIterations(),
+                        argHandler.singleClassloaderClass(),
+                        argHandler.getRawArgument(0),
+                        stresser
+                );
+        }
+
+        public void dump() {
+                log.debug("classes to be loaded:\t" + loadedClassCount);
+                log.debug("classloader instances:\t" + loaderCount);
+                if (singleClass)
+                        log.debug("classloader class:\tsingle");
+                else
+                        log.debug("classloader class:\ttwo");
+                log.debug("Class dir" + classDir);
+
+        }
+
+        private void setLoadedClassCount(int loadedClassCount) {
+                this.loadedClassCount = loadedClassCount;
+        }
+
+        // Set loaderCount value
+        private void setLoaderCount(int loaderCount) {
+                this.loaderCount = loaderCount;
+        }
+
+        // Set singleClass value
+        private void singleClassLoaderClass(boolean singleClass) {
+                this.singleClass = singleClass;
+        }
+
+        // Set classDir value
+        private void setClassDir(String classDir) {
+                this.classDir = classDir;
+        }
+
+        // Load classes
+        private void preloadAllClasses() {
+                log.debug("preloading all classes...");
+                if (singleClass)
+                        createUnloaders(1);
+                else
+                        createUnloaders(2);
+
+                for (int i = 0; i < unloaders.length; i++) {
+                        loadClasses(unloaders[i], 1, false);
+                        unloaders[i].unloadClass();
+                }
+        }
+
+        // Load classes
+        private boolean loadClasses(ClassUnloader unloader, int classCount, boolean doKeep) {
+                String newClassName;
+                String[] classNames = new String[classCount + 1];
+                classNames[0] = unloader.getClassLoader().getClass().getName()
+                        + "@"
+                        + Integer.toHexString(
+                                        unloader.getClassLoader().hashCode()
+                                        );
+
+
+                for (int i = 1; i <= classCount; i++) {
+                        newClassName = CLASSNAME_PATTERN + int2Str(i);
+                        classNames[i] = newClassName;
+                        try {
+                                unloader.loadClass(newClassName);
+                        } catch (ClassNotFoundException e) {
+                                log.error(e.toString());
+                                e.printStackTrace();
+                                return false;
+                        }
+                }
+                if (doKeep)
+                        classesTable.put(String.valueOf(unloader.hashCode()), classNames);
+                return true;
+        } // loadClasses()
+
+        /**
+         * Loads all classes.
+         *
+         * @see ClassLoadingController#ClassLoadingController
+         */
+        public int loadClasses() {
+                CustomClassLoader loader;
+                boolean res = true;
+                String loaderName;
+
+                createUnloaders(loaderCount);
+
+                int count = 0;
+                for (int i = 0; i < unloaders.length; i++) {
+                        loaderName = unloaders[i].getClassLoader().getClass().getName()
+                                + "@"
+                                + Integer.toHexString(
+                                                unloaders[i].getClassLoader().hashCode()
+                                                );
+                        if (loadClasses(unloaders[i], loadedClassCount, true)) {
+                                String[] values = (String[])
+                                        classesTable.get(String.valueOf(unloaders[i].hashCode()));
+                                int length = values.length - 1;
+                                log.debug(loaderName + "(" + i + ")>>> " + length
+                                                + " classes have been loaded");
+                                count += length;
+                        }
+                }
+                log.info("Total: loading is performed " + count + " times");
+
+                return count;
+        }
+
+        // Unload classes
+        public int unloadClasses() {
+                String loaderName;
+                int count = 0;
+                long timeLeft = 0;
+
+                for (int i = 0; i < loaderCount && (timeLeft = stresser.getTimeLeft()/1000) > 0; i++) {
+                        loaderName = unloaders[i].getClassLoader().getClass().getName()
+                                + "@"
+                                + Integer.toHexString(
+                                                unloaders[i].getClassLoader().hashCode()
+                                                );
+                        String hashCode = String.valueOf(unloaders[i].hashCode());
+                        String[] values = (String[]) classesTable.get(hashCode);
+
+                        if (unloaders[i].unloadClass()) {
+                                int length = values.length - 1;
+                                count += length;
+                                log.debug(loaderName + "(" + i + ")>>> " + length
+                                                + " classes have been unloaded (time left: "+timeLeft+" s)");
+                                classesTable.remove(hashCode);
+                        } else {
+                                log.debug(loaderName + "(" + i + ")>>> "
+                                                + "classes couldn't be unloaded (time left: "+timeLeft+" s)");
+                        }
+                }
+
+                log.info("Total: unloading is performed " + count + " times");
+
+                return count;
+        }
+
+        private void createUnloaders(int count) {
+                CustomClassLoader loader;
+                unloaders = new ClassUnloader[count];
+
+                for (int i = 0; i < count; i++) {
+                        unloaders[i] = new ClassUnloader();
+                        if (singleClass) {
+                                loader = unloaders[i].createClassLoader();
+                        } else {
+                                if (i%2 == 0)
+                                        loader = new ClassLoaderA();
+                                else
+                                        loader = new ClassLoaderB();
+                                unloaders[i].setClassLoader(loader);
+                        }
+                        loader.setClassPath(classDir);
+                } // for
+        }
+
+        /**
+         * Brings out VM into defined state. The method loads all classes via
+         * {@link ClassLoadingController#loadClasses}.
+         *
+         * @see ClassLoadingController#loadClasses
+         */
+        public void run() {
+                loadClasses();
+        }
+
+        /**
+         * Tries to reclaim VM into initial state. The method tries to load all
+         * classes via {@link ClassLoadingController#unloadClasses}.
+         *
+         * @see ClassLoadingController#unloadClasses
+         */
+        public void reset() {
+                unloadClasses();
+        }
+
+        // The class extends CustomClassLoader with specific implementation of
+        // toString() method
+        class ClassLoaderA extends CustomClassLoader {
+                public ClassLoaderA() {
+                        super();
+                }
+
+                public String toString() {
+                        return "ClassLoaderA";
+                }
+        } // ClassLoaderA
+
+        // The class extends CustomClassLoader with specific implementation of
+        // toString() method
+        class ClassLoaderB extends CustomClassLoader {
+                public ClassLoaderB() {
+                        super();
+                }
+
+                public String toString() {
+                        return "ClassLoaderB";
+                }
+        } // ClassLoaderB
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ClassLoadingMonitor.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.lang.management.*;
+import javax.management.*;
+import java.util.*;
+import nsk.share.*;
+
+/**
+ * <code>ClassLoadingMonitor</code> class is a wrapper of
+ * <code>ClassLoadingMXBean</code>. Depending on command line arguments, an
+ * instance of this class redirects invocations to the
+ * <code>ClassLoadingMXBean</code> interface. If
+ * <code>-testMode="directly"</code> option is set, this instance directly
+ * invokes corresponding method of the <tt>ClassLoadingMXBean</tt> interface. If
+ * <code>-testMode="server"</code> option is set, it makes invokations via
+ * MBeanServer. If <code>-testMode="proxy"</code> option is set it will make
+ * invocations via MBeanServer proxy.
+ *
+ * @see ArgumentHandler
+ */
+public class ClassLoadingMonitor extends Monitor {
+
+    // Names of the attributes of ClassLoadingMXBean
+    private static final String LOADED_CLASSES = "LoadedClassCount";
+    private static final String TOTAL_CLASSES = "TotalLoadedClassCount";
+    private static final String UNLOADED_CLASSES = "UnloadedClassCount";
+
+    // Internal trace level
+    private static final int TRACE_LEVEL = 10;
+
+    // An instance of ClassLoadingMXBean
+    private static ClassLoadingMXBean mbean
+        = ManagementFactory.getClassLoadingMXBean();
+
+    private ClassLoadingMXBean proxyInstance;
+
+    static {
+        Monitor.logPrefix = "ClassLoadingMonitor> ";
+    }
+
+    /**
+     * Creates a new <code>ClassLoadingMonitor</code> object.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     */
+    public ClassLoadingMonitor(Log log, ArgumentHandler argumentHandler) {
+        super(log, argumentHandler);
+    }
+
+    /**
+     *
+     * Return a proxy instance for a platform
+     * {@link java.lang.management.ClassLoadingMXBean
+     * <code>ClassLoadingMXBean</code>} interface.
+     *
+     */
+    synchronized ClassLoadingMXBean getProxy() {
+        if (proxyInstance == null) {
+            // create proxy instance
+            try {
+                proxyInstance = (ClassLoadingMXBean)
+                ManagementFactory.newPlatformMXBeanProxy(
+                    getMBeanServer(),
+                    ManagementFactory.CLASS_LOADING_MXBEAN_NAME,
+                    ClassLoadingMXBean.class
+                );
+            } catch (java.io.IOException e) {
+                throw new Failure(e);
+            }
+        }
+        return proxyInstance;
+    }
+
+    /**
+     * Redirects the invocation to
+     * {@link java.lang.management.ClassLoadingMXBean#getLoadedClassCount()
+     * <code>ClassLoadingMXBean.getLoadedClassCount()</code>}.
+     *
+     * @return the number of currently loaded classes.
+     */
+    public int getLoadedClassCount() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            logger.trace(TRACE_LEVEL,"[getLoadedClassCount] "
+                       + "getLoadedClassCount() directly invoked");
+            return mbean.getLoadedClassCount();
+
+        case SERVER_MODE:
+            logger.trace(TRACE_LEVEL,"[getLoadedClassCount] "
+                       + "getLoadedClassCount() invoked through MBeanServer");
+            return getIntAttribute(mbeanObjectName, LOADED_CLASSES);
+
+        case PROXY_MODE:
+            logger.trace(TRACE_LEVEL,"[getLoadedClassCount] "
+                       + "getLoadedClassCount() invoked through proxy");
+            return getProxy().getLoadedClassCount();
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ClassLoadingMXBean#getTotalLoadedClassCount()
+     * <code>ClassLoadingMXBean.getTotalLoadedClassCount()</code>}.
+     *
+     * @return the total number of classes loaded.
+     */
+    public long getTotalLoadedClassCount() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            logger.trace(TRACE_LEVEL,"[getTotalLoadedClassCount] "
+                       + "getTotalLoadedClassCount() directly invoked");
+            return mbean.getTotalLoadedClassCount();
+
+        case SERVER_MODE:
+            logger.trace(TRACE_LEVEL,"[getTotalLoadedClassCount] "
+                      + "getTotalLoadedClassCount() invoked through "
+                      + "MBeanServer");
+            return getLongAttribute(mbeanObjectName, TOTAL_CLASSES);
+
+        case PROXY_MODE:
+            logger.trace(TRACE_LEVEL,"[getTotalLoadedClassCount] "
+                       + "getTotalLoadedClassCount() invoked through proxy");
+            return getProxy().getTotalLoadedClassCount();
+        }
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+    /**
+     * Redirects the invocation to
+     * {@link java.lang.management.ClassLoadingMXBean#getUnloadedClassCount()
+     * <code>ClassLoadingMXBean.getUnloadedClassCount()</code>}.
+     *
+     * @return the number of unloaded classes.
+     */
+    public long getUnloadedClassCount() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            logger.trace(TRACE_LEVEL,"[getUnloadedClassCount] "
+                       + "getUnloadedClassCount() directly invoked");
+            return mbean.getUnloadedClassCount();
+
+        case SERVER_MODE:
+            logger.trace(TRACE_LEVEL,"[getUnloadedClassCount] "
+                       + "getUnloadedClassCount() invoked through MBeanServer");
+            return getLongAttribute(mbeanObjectName, UNLOADED_CLASSES);
+
+        case PROXY_MODE:
+            logger.trace(TRACE_LEVEL,"[getUnloadedClassCount] "
+                       + "getUnloadedClassCount() invoked through proxy");
+            return getProxy().getUnloadedClassCount();
+
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+} // ClassLoadingMonitor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/CompilationMonitor.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.lang.management.*;
+import javax.management.*;
+import nsk.share.*;
+
+/**
+ * <code>CompilationMonitor</code> class is a wrapper of
+ * <tt>CompilationMXBean</tt>. Depending on command line arguments, an instance
+ * of this class redirects invocations to the <tt>CompilationMXBean</tt>
+ * interface. If <code>-testMode="directly"</code> option is set, this instance
+ * directly invokes corresponding method of the <tt>CompilationMXBean</tt>
+ * interface. If <code>-testMode="server"</code> option is set it will make
+ * invocations via MBeanServer. If <code>-testMode="proxy"</code> option is set
+ * it will make invocations via MBeanServer proxy.
+ *
+ * @see ArgumentHandler
+ */
+public class CompilationMonitor extends Monitor {
+
+    // An instance of CompilationMXBean
+    private static CompilationMXBean mbean
+        = ManagementFactory.getCompilationMXBean();
+
+    private CompilationMXBean proxyInstance;
+
+    // An attribute of CompilationMXBean
+    private static final String IS_COMP = "CompilationTimeMonitoringSupported";
+
+    static {
+        Monitor.logPrefix = "CompilationMonitor> ";
+    }
+
+    /**
+     * Creates a new <code>CompilationMonitor</code> object.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     */
+    public CompilationMonitor(Log log, ArgumentHandler argumentHandler) {
+        super(log, argumentHandler);
+
+    }
+
+    /**
+     *
+     * Return a proxy instance for a platform
+     * {@link java.lang.management.CompilationMXBean
+     * <code>CompilationMXBean</code>} interface.
+     *
+     */
+    synchronized CompilationMXBean getProxy() {
+        if (proxyInstance == null) {
+            // create proxy instance
+            try {
+                proxyInstance = (CompilationMXBean)
+                ManagementFactory.newPlatformMXBeanProxy(
+                    getMBeanServer(),
+                    ManagementFactory.COMPILATION_MXBEAN_NAME,
+                    CompilationMXBean.class
+                );
+            } catch (java.io.IOException e) {
+                throw new Failure(e);
+            }
+        }
+        return proxyInstance;
+    }
+
+    /**
+     * Detects if the JVM has compilation system.
+     *
+     * @return <code>true</code>, if the JVM has compilation system,
+     *         <code>false</code> otherwise.
+     */
+    public boolean isCompilationSystem() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            return (mbean != null);
+
+        case SERVER_MODE:
+        case PROXY_MODE:
+            try {
+                return getMBeanServer().isRegistered(mbeanObjectName);
+            } catch (RuntimeOperationsException e) {
+                complain("Unexpected exception");
+                e.printStackTrace(logger.getOutStream());
+                throw new Failure(e);
+            }
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    } // isCompilationSystem()
+
+    /**
+     * Redirects the invocation to
+     * {@link CompilationMXBean#isCompilationTimeMonitoringSupported()
+     * <code>CompilationMXBean.isCompilationTimeMonitoringSupported()</code>}.
+     *
+     * @return <code>true</code>, if the monitoring of compilation time is
+     *         supported, <code>false</code> otherwise.
+     */
+    public boolean isCompilationTimeMonitoringSupported() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            return mbean.isCompilationTimeMonitoringSupported();
+
+        case SERVER_MODE:
+            return getBooleanAttribute(mbeanObjectName, IS_COMP);
+
+        case PROXY_MODE:
+            return getProxy().isCompilationTimeMonitoringSupported();
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    } // isCompilationTimeMonitoringSupported()
+} // CompilationMonitor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/CustomMBeanRegistration.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import javax.management.*;
+
+/**
+ * <code>CustomMBeanRegistration</code> class is a dummy implementation of
+ * <code>MBeanRegistration</code> interface.
+ *
+ * @see javax.management.MBeanRegistration
+ */
+class CustomMBeanRegistration implements MBeanRegistration {
+    public void postDeregister() {}
+
+    public void postRegister(Boolean registrationDone) {}
+
+    public void preDeregister() {}
+
+    public ObjectName preRegister(MBeanServer server, ObjectName name) {
+        return name;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/CustomMBeanServer.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,843 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.util.*;
+import java.io.*;
+import java.lang.reflect.*;
+import java.lang.management.*;
+import javax.management.*;
+import javax.management.loading.*;
+import nsk.share.*;
+
+/**
+ * The <code>CustomMBeanServer</code> implemenets the
+ * {@link javax.management.MBeanServer MBeanServer} interface to provide
+ * minimal funcionality for JSR-174 testing.
+ * <p>Insignificant methods that are not used just throw {@link TestBug TestBug}
+ * with "not implemented" message. If this exception is caught during test
+ * execution, the corresponding method must be implemented.
+ */
+
+public class CustomMBeanServer implements MBeanServer {
+
+        // Name of the system property, which specifies class name of MBean server
+        final static String SERVER_BUILDER_PROPERTY
+                = "javax.management.builder.initial";
+
+        // Class name of MBeanServer builder that creates CustomMBeanServer
+        final static String CUSTOM_SERVER_BUILDER
+                = CustomMBeanServerBuilder.class.getCanonicalName();
+
+        // Default MBeanServer builder
+        final static String DEFAULT_SERVER_BUILDER = "";
+
+        // Internal trace level
+        private final static int TRACE_ALL = 10;
+
+        // Prefix to print while logging
+        private final static String LOG_PREFIX = "CustomMBeanServer> ";
+
+        private final static String BROADCASTER_ITNF_NAME =
+                "javax.management.NotificationBroadcaster";
+
+        private final static String DYNAMICMBEAN_ITNF_NAME =
+                "javax.management.DynamicMBean";
+
+        // Private variables
+        private String defaultDomain;
+        private CustomMBeanRegistration register = new CustomMBeanRegistration();
+        private Log.Logger log;
+        private Hashtable<ObjectName, ObjectKeeper> registeredMBeans = new Hashtable<ObjectName, ObjectKeeper>();
+        // StandardMBean view of registered MBeans
+        private Map<ObjectName, DynamicMBean> registeredMBeansStd = new HashMap<ObjectName, DynamicMBean>();
+
+        // Inner class to connect ObjectInstance and Object
+        class ObjectKeeper {
+                ObjectInstance instance;
+                Object object;
+
+                ObjectKeeper(ObjectInstance instance, Object object) {
+                        this.instance = instance;
+                        this.object = object;
+                }
+        }
+
+        /**
+         * Creates a new <code>CustomMBeanServer</code> object.
+         *
+         * @param defaultDomain default domain of the new MBeanServer
+         */
+        public CustomMBeanServer(String defaultDomain) {
+                this.defaultDomain = defaultDomain;
+        }
+
+        /**
+         * Instantiates and registers an MBean in the MBean server.
+         *
+         * @see javax.management.MBeanServer#createMBean(String, ObjectName)
+         */
+        public ObjectInstance createMBean(String className, ObjectName name)
+                throws ReflectionException,
+                       InstanceAlreadyExistsException,
+                       MBeanRegistrationException,
+                       MBeanException,
+                       NotCompliantMBeanException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Instantiates and registers an MBean in the MBean server.
+         *
+         * @see javax.management.MBeanServer#createMBean(String, ObjectName,
+         *      Object[], String[])
+         */
+        public ObjectInstance createMBean(String className, ObjectName name,
+                        Object[] params, String[] signature)
+                throws ReflectionException,
+                       InstanceAlreadyExistsException,
+                       MBeanRegistrationException,
+                       MBeanException,
+                       NotCompliantMBeanException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Instantiates and registers an MBean in the MBean server.
+         *
+         * @see javax.management.MBeanServer#createMBean(String, ObjectName,
+         *      ObjectName)
+         */
+        public ObjectInstance createMBean(String className, ObjectName name,
+                        ObjectName loaderName)
+                throws ReflectionException,
+                       InstanceAlreadyExistsException,
+                       MBeanRegistrationException,
+                       MBeanException,
+                       NotCompliantMBeanException,
+                       InstanceNotFoundException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Instantiates and registers an MBean in the MBean server.
+         *
+         * @see javax.management.MBeanServer#createMBean(String, ObjectName,
+         *      ObjectName, Object[], String[])
+         */
+        public ObjectInstance createMBean(String className, ObjectName name,
+                        ObjectName loaderName, Object[] params,
+                        String[] signature)
+                throws ReflectionException,
+                       InstanceAlreadyExistsException,
+                       MBeanRegistrationException,
+                       MBeanException,
+                       NotCompliantMBeanException,
+                       InstanceNotFoundException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Registers a pre-existing object as an MBean with the MBean server
+         *
+         * @see javax.management.MBeanServer#registerMBean(Object, ObjectName)
+         */
+        public ObjectInstance registerMBean(Object object, ObjectName name)
+                throws InstanceAlreadyExistsException,
+                       MBeanRegistrationException,
+                       NotCompliantMBeanException {
+                               ObjectName newName = null;
+
+                               try {
+                                       newName = register.preRegister(this, name);
+                               } catch (Exception e) {
+                                       register.postRegister(new Boolean(false));
+                                       throw new MBeanRegistrationException(e);
+                               }
+
+                               // The log object may not be initialized by that time, so try
+                               // to check it
+                               if (log != null)
+                                       log.trace(TRACE_ALL, "[registerMBean] " + newName);
+
+                               if  (isRegistered(newName)) {
+                                       register.postRegister(new Boolean(false));
+                                       throw new InstanceAlreadyExistsException("already registered");
+                               }
+
+                               ObjectInstance instance = null;
+                               try {
+                                       instance = new ObjectInstance(newName, object.getClass().getName());
+                               } catch (IllegalArgumentException e) {
+                                       throw new RuntimeOperationsException(e);
+                               }
+                               registeredMBeans.put(newName, new ObjectKeeper(instance, object));
+                               register.postRegister(new Boolean(true));
+                               return instance;
+                       }
+
+        /**
+         * Unregisters an MBean from the MBean server.
+         *
+         * @see javax.management.MBeanServer#unregisterMBean(ObjectName)
+         */
+        public void unregisterMBean(ObjectName name)
+                throws InstanceNotFoundException,
+                       MBeanRegistrationException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Gets the <code>ObjectInstance</code> for a given MBean registered with
+         * the MBean server.
+         *
+         * @see javax.management.MBeanServer#getObjectInstance(ObjectName)
+         */
+        public ObjectInstance getObjectInstance(ObjectName name)
+                throws InstanceNotFoundException {
+                        throw new TestBug("not implemented");
+                }
+
+        /**
+         * Gets MBeans controlled by the MBean server.
+         *
+         * @see javax.management.MBeanServer#queryMBeans(ObjectName, QueryExp)
+         */
+        public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
+                if ( (name != null) || (query != null) )
+                        throw new TestBug("not implemented");
+
+                HashSet<ObjectInstance> result = new HashSet<ObjectInstance>();
+                Enumeration enumeration = registeredMBeans.elements();
+                while (enumeration.hasMoreElements()) {
+                        ObjectKeeper keeper = (ObjectKeeper) enumeration.nextElement();
+                        result.add(keeper.instance);
+                }
+                return result;
+        }
+
+        /**
+         * Gets the names of MBeans controlled by the MBean server.
+         *
+         * @see javax.management.MBeanServer#queryNames(ObjectName, QueryExp)
+         */
+        public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
+                if (query != null)
+                        throw new TestBug("not implemented");
+
+                HashSet<ObjectName> result = new HashSet<ObjectName>();
+                Enumeration enumeration = registeredMBeans.elements();
+                while (enumeration.hasMoreElements()) {
+                        ObjectKeeper keeper = (ObjectKeeper) enumeration.nextElement();
+                        ObjectName obj = keeper.instance.getObjectName();
+                        if ((name == null) || (name.apply(obj))) {
+                            result.add(obj);
+                        }
+                }
+                return result;
+        }
+
+        /**
+         * Checks whether an MBean, identified by its object name, is
+         * already registered with the MBean server.
+         *
+         * @see javax.management.MBeanServer#isRegistered(ObjectName)
+         */
+        public boolean isRegistered(ObjectName name) {
+                return registeredMBeans.containsKey(name);
+        }
+
+        /**
+         * Returns the number of MBeans registered in the MBean server.
+         *
+         * @see javax.management.MBeanServer#getMBeanCount()
+         */
+        public Integer getMBeanCount() {
+                throw new TestBug("not implemented");
+        }
+
+        /**
+         * Gets the value of a specific attribute of a named MBean.
+         *
+         * @see javax.management.MBeanServer#getAttribute(ObjectName, String)
+         */
+        public Object getAttribute(ObjectName name, String attribute)
+                throws MBeanException,
+                       AttributeNotFoundException,
+                       InstanceNotFoundException,
+                       ReflectionException {
+
+                               if (log != null)
+                                       log.trace(TRACE_ALL, "[getAttribute] " + name + "> " + attribute);
+
+                               DynamicMBean mbean = getObject(name);
+                               Object result = mbean.getAttribute(attribute);
+                               if (result instanceof List) {
+                                       List list = (List) result;
+                                       Object[] arr = new Object[list.size()];
+                                       int i = 0;
+                                       for (Object o : list)
+                                               arr[i++] = o;
+                                       return arr;
+                               }
+                               return result;
+                       }
+
+        /**
+         * Gets the values of several attributes of a named MBean.
+         *
+         * @see javax.management.MBeanServer#getAttributes(ObjectName, String[])
+         */
+        public AttributeList getAttributes(ObjectName name, String[] attributes)
+                throws InstanceNotFoundException,
+                       ReflectionException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Sets the value of a specific attribute of a named MBean.
+         *
+         * @see javax.management.MBeanServer#setAttribute(ObjectName, Attribute)
+         */
+        public void setAttribute(ObjectName name, Attribute attribute)
+                throws InstanceNotFoundException,
+                       AttributeNotFoundException,
+                       InvalidAttributeValueException,
+                       MBeanException,
+                       ReflectionException {
+
+                               if (log != null)
+                                       log.trace(TRACE_ALL, "[setAttribute] " + name + "> " + attribute);
+
+                               DynamicMBean mbean = getObject(name);
+                               mbean.setAttribute(attribute);
+                       }
+
+        /**
+         * Sets the values of several attributes of a named MBean.
+         *
+         * @see javax.management.MBeanServer#setAttributes(ObjectName,
+         *      AttributeList)
+         */
+        public AttributeList setAttributes(ObjectName name,
+                        AttributeList attributes)
+                throws InstanceNotFoundException,
+                       ReflectionException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Invokes an operation on an MBean.
+         *
+         * @see javax.management.MBeanServer#invoke(ObjectName, String,
+         *      Object[], String[])
+         */
+        public Object invoke(ObjectName name, String operationName,
+                        Object[] params, String[] signature)
+                throws InstanceNotFoundException,
+                       MBeanException,
+                       ReflectionException {
+
+                               if (log != null)
+                                       log.trace(TRACE_ALL, "[invoke] " + name + "> "
+                                                       + operationName);
+                               return invokeObjectMethod(name, operationName, params, signature);
+                       }
+
+        /**
+         * Returns the default domain used for naming the MBean.
+         *
+         * @see javax.management.MBeanServer#getDefaultDomain()
+         */
+        public String getDefaultDomain() {
+                throw new TestBug("not implemented");
+        }
+
+        /**
+         * Returns the list of domains in which any MBean is currently
+         * registered.
+         *
+         * @see javax.management.MBeanServer#getDomains()
+         */
+        public String[] getDomains() {
+                throw new TestBug("not implemented");
+        }
+
+        /**
+         * Adds a listener to a registered MBean.
+         *
+         * @see javax.management.MBeanServer#addNotificationListener(ObjectName,
+         *      NotificationListener, NotificationFilter, Object)
+         */
+        public void addNotificationListener(ObjectName name,
+                        NotificationListener listener,
+                        NotificationFilter filter,
+                        Object handback) throws InstanceNotFoundException {
+                getNotificationBroadcaster(name).addNotificationListener(listener, filter, handback);
+        }
+
+        /**
+         * Adds a listener to a registered MBean.
+         *
+         * @see javax.management.MBeanServer#addNotificationListener(ObjectName,
+         *      ObjectName, NotificationFilter, Object)
+         */
+        public void addNotificationListener(ObjectName name, ObjectName listener,
+                        NotificationFilter filter,
+                        Object handback)
+                throws InstanceNotFoundException {
+                        throw new TestBug("not implemented");
+                }
+
+        /**
+         * Removes a listener from a registered MBean.
+         *
+         * @see javax.management.MBeanServer#removeNotificationListener(ObjectName,
+         *      ObjectName)
+         */
+        public void removeNotificationListener(ObjectName name, ObjectName listener)
+                throws InstanceNotFoundException, ListenerNotFoundException {
+                        throw new TestBug("not implemented");
+                }
+
+        /**
+         * Removes a listener from a registered MBean.
+         *
+         * @see javax.management.MBeanServer#removeNotificationListener(ObjectName,
+         *      ObjectName, NotificationFilter, Object)
+         */
+        public void removeNotificationListener(ObjectName name,
+                        ObjectName listener,
+                        NotificationFilter filter,
+                        Object handback)
+                throws InstanceNotFoundException,
+                       ListenerNotFoundException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Removes a listener from a registered MBean.
+         *
+         * @see javax.management.MBeanServer#removeNotificationListener(ObjectName,
+         *      NotificationListener)
+         */
+        public void removeNotificationListener(ObjectName name,
+                        NotificationListener listener)
+                throws InstanceNotFoundException,
+                       ListenerNotFoundException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Removes a listener from a registered MBean.
+         *
+         * @see javax.management.MBeanServer#removeNotificationListener(ObjectName,
+         *      NotificationListener, NotificationFilter, Object)
+         */
+        public void removeNotificationListener(ObjectName name,
+                        NotificationListener listener,
+                        NotificationFilter filter,
+                        Object handback)
+                throws InstanceNotFoundException,
+                       ListenerNotFoundException {
+                       }
+
+        /**
+         * This method discovers the attributes and operations that an
+         * MBean exposes for management.
+         *
+         * @see javax.management.MBeanServer#getMBeanInfo(ObjectName)
+         */
+        public MBeanInfo getMBeanInfo(ObjectName name)
+                throws InstanceNotFoundException,
+                       IntrospectionException,
+                       ReflectionException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Returns true if the MBean specified is an instance of the
+         * specified class, false otherwise.
+         *
+         * @see javax.management.MBeanServer#isInstanceOf(ObjectName, String)
+         */
+        public boolean isInstanceOf(ObjectName name, String className)
+                throws InstanceNotFoundException {
+                        //        DynamicMBean mbean = getObject(name);
+                        //        MBeanInfo info = mbean.getMBeanInfo();
+                        //        return info.getClassName().compareTo(className) == 0;
+
+                        DynamicMBean mbean = getObject(name);
+                        MBeanInfo info = mbean.getMBeanInfo();
+                        String infoClassName = info.getClassName();
+
+                        if (log != null) {
+                                log.trace(TRACE_ALL, "[isInstanceOf] name=" + name);
+                                log.trace(TRACE_ALL, "[isInstanceOf] className=" + className);
+                        }
+
+                        if (infoClassName.equals(className)) {
+                                if (log != null)
+                                        log.trace(TRACE_ALL, "[isInstanceOf] infoClassName is equal className. return true");
+                                return true;
+                        }
+
+                        try {
+                                ClassLoader cl = mbean.getClass().getClassLoader();
+                                Class<?> classNameClass = loadClass(className,cl);
+                                if (classNameClass == null) {
+                                        if (log != null)
+                                                log.trace(TRACE_ALL, "[isInstanceOf] classNameClass is null. return false");
+                                        return false;
+                                }
+
+                                if (classNameClass.isInstance(mbean)) {
+                                        if (log != null)
+                                                log.trace(TRACE_ALL, "[isInstanceOf] mbean is instance of classNameClass. return true");
+                                        return true;
+                                }
+
+                                Class<?> instanceClass = loadClass(infoClassName,cl);
+                                if (instanceClass == null) {
+                                        if (log != null)
+                                                log.trace(TRACE_ALL, "[isInstanceOf] instanceClass is null. return false");
+                                        return false;
+                                }
+
+                                boolean isAssignable = classNameClass.isAssignableFrom(instanceClass);
+                                if (log != null)
+                                        log.trace(TRACE_ALL, "[isInstanceOf] classNameClass is assignable="+isAssignable);
+                                return isAssignable;
+                        } catch (ReflectionException e) {
+                                if (log != null) {
+                                        log.trace(TRACE_ALL, "[isInstanceOf] "+e.getMessage());
+                                        e.printStackTrace(log.getOutStream());
+                                }
+                                return false;
+                        } catch (Exception e) {
+                                /* Could be SecurityException or ClassNotFoundException */
+                                if (log != null) {
+                                        log.trace(TRACE_ALL, "[isInstanceOf] "+e.getMessage());
+                                        e.printStackTrace(log.getOutStream());
+                                }
+                                return false;
+                        }
+
+                }
+
+        /**
+         * Load a class with the specified loader, or with this object
+         * class loader if the specified loader is null.
+         **/
+        static Class loadClass(String className, ClassLoader loader)
+                throws ReflectionException {
+
+                        Class theClass = null;
+                        if (className == null) {
+                                throw new RuntimeOperationsException(new
+                                                IllegalArgumentException("The class name cannot be null"),
+                                                "Exception occured during object instantiation");
+                        }
+                        try {
+                                if (loader == null)
+                                        loader = CustomMBeanServer.class.getClassLoader();
+                                if (loader != null) {
+                                        theClass = Class.forName(className, false, loader);
+                                } else {
+                                        theClass = Class.forName(className);
+                                }
+                        } catch (ClassNotFoundException e) {
+                                throw new ReflectionException(e,
+                                                "The MBean class could not be loaded by the context classloader");
+                        }
+                        return theClass;
+                }
+
+
+        /**
+         * Instantiates an object using the list of all class loaders
+         * registered in the MBean server's.
+         *
+         * @see javax.management.MBeanServer#instantiate(String)
+         */
+        public Object instantiate(String className)
+                throws ReflectionException,
+                       MBeanException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Instantiates an object using the list of all class loaders
+         * registered in the MBean server's.
+         *
+         * @see javax.management.MBeanServer#instantiate(String, ObjectName)
+         */
+        public Object instantiate(String className, ObjectName loaderName)
+                throws ReflectionException,
+                       MBeanException,
+                       InstanceNotFoundException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Instantiates an object using the list of all class loaders
+         * registered in the MBean server's.
+         *
+         * @see javax.management.MBeanServer#instantiate(String, Object[],
+         *      String[])
+         */
+        public Object instantiate(String className, Object[] params,
+                        String[] signature)
+                throws ReflectionException,
+                       MBeanException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Instantiates an object using the list of all class loaders
+         * registered in the MBean server's.
+         *
+         * @see javax.management.MBeanServer#instantiate(String, ObjectName,
+         *      Object[], String[])
+         */
+        public Object instantiate(String className, ObjectName loaderName,
+                        Object[] params, String[] signature)
+                throws ReflectionException,
+                       MBeanException,
+                       InstanceNotFoundException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * De-serializes a byte array in the context of the class loader
+         * of an MBean.
+         *
+         * @see javax.management.MBeanServer#deserialize(ObjectName, byte[])
+         */
+        public ObjectInputStream deserialize(ObjectName name, byte[] data)
+                throws InstanceNotFoundException,
+                       OperationsException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * De-serializes a byte array in the context of the class loader
+         * of an MBean.
+         *
+         * @see javax.management.MBeanServer#deserialize(String, byte[])
+         */
+        public ObjectInputStream deserialize(String className, byte[] data)
+                throws OperationsException,
+                       ReflectionException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * De-serializes a byte array in the context of the class loader
+         * of an MBean.
+         *
+         * @see javax.management.MBeanServer#deserialize(String, ObjectName, byte[])
+         */
+        public ObjectInputStream deserialize(String className,
+                        ObjectName loaderName,
+                        byte[] data)
+                throws InstanceNotFoundException,
+                       OperationsException,
+                       ReflectionException {
+                               throw new TestBug("not implemented");
+                       }
+
+        /**
+         * Return the {@link java.lang.ClassLoader} that was used for
+         * loading the class of the named MBean.
+         *
+         * @see javax.management.MBeanServer#getClassLoaderFor(ObjectName)
+         */
+        public ClassLoader getClassLoaderFor(ObjectName mbeanName)
+                throws InstanceNotFoundException {
+                        throw new TestBug("not implemented");
+                }
+
+        /**
+         * Return the named {@link java.lang.ClassLoader}.
+         *
+         * @see javax.management.MBeanServer#getClassLoader(ObjectName)
+         */
+        public ClassLoader getClassLoader(ObjectName loaderName)
+                throws InstanceNotFoundException {
+                        throw new TestBug("not implemented");
+                }
+
+        /**
+         * Return the named {@link java.lang.ClassLoader}.
+         *
+         * @see javax.management.MBeanServer#getClassLoader(ObjectName)
+         */
+        public ClassLoaderRepository getClassLoaderRepository() {
+                throw new TestBug("not implemented");
+        }
+
+        /**
+         * Initializes {@link Log <code>Log</code>} object.
+         *
+         * @param log a new <code>Log</code> object.
+         */
+        public void setLog(Log log) {
+                this.log = new Log.Logger(log, LOG_PREFIX + "> ");
+        }
+
+        // **********************************************************************
+        //
+        // Private methods
+        //
+        // **********************************************************************
+
+        /**
+         * Gets the object reference for a given MBean registered with the MBean
+         * server.
+         *
+         * @param name The object name of the MBean.
+         *
+         * @return The MBean object, specified by <code>name</code>.
+         *
+         * @throws InstanceNotFoundException The MBean specified is not registered
+         *         in the MBean server.
+         */
+        private DynamicMBean getObject(ObjectName name) throws InstanceNotFoundException {
+                DynamicMBean mbean = registeredMBeansStd.get(name);
+                if (mbean == null) {
+                        ObjectKeeper objKeeper = registeredMBeans.get(name);
+                        if (objKeeper == null)
+                                throw new InstanceNotFoundException();
+                        Object object = objKeeper.object;
+                        if (object instanceof DynamicMBean)
+                                mbean = (DynamicMBean) object;
+                        else
+                                mbean = new StandardMBean(object, getMBeanInterface(object), true);
+                        registeredMBeansStd.put(name, mbean);
+                }
+                return mbean;
+                /*
+                   ObjectKeeper objKeeper = (ObjectKeeper) registeredMBeans.get(name);
+
+                   if (objKeeper == null)
+                   throw new InstanceNotFoundException();
+
+                   Class superOfMBeans = null;
+                   try {
+                   superOfMBeans = Class.forName(DYNAMICMBEAN_ITNF_NAME);
+                   } catch (ClassNotFoundException e) {
+                   throw new InstanceNotFoundException();
+                   }
+
+                   if (superOfMBeans.isAssignableFrom(objKeeper.object.getClass())) {
+                   return (DynamicMBean )objKeeper.object;
+                   }
+
+                   return null;
+                   */
+        }
+
+        /**
+         * Obtain NotificationBroadcaster for given MBean registered with the MBean
+         * server.
+         *
+         * @param name The object name of the MBean.
+         *
+         * @return The MBean object, specified by <code>name</code>.
+         *
+         * @throws InstanceNotFoundException if MBean specified is not registered
+         *         in the MBean server.
+         */
+        private NotificationBroadcaster getNotificationBroadcaster(ObjectName name) throws InstanceNotFoundException {
+                ObjectKeeper objKeeper = (ObjectKeeper) registeredMBeans.get(name);
+                if (objKeeper == null)
+                        throw new InstanceNotFoundException();
+                Object mbean = objKeeper.object;
+                if (mbean instanceof NotificationBroadcaster)
+                        return (NotificationBroadcaster) mbean;
+                throw new InstanceNotFoundException();
+        }
+
+        /**
+         * Invoke the method
+         */
+        private Object invokeObjectMethod(ObjectName name, String methodName,
+                        Object[] params, String[] signature) throws InstanceNotFoundException,
+                MBeanException,
+                ReflectionException {
+
+                        if (log != null)
+                                log.trace(TRACE_ALL, "[invokeObjectMethod] " + name + "> "
+                                                + methodName);
+
+                        DynamicMBean mbean = getObject(name);
+                        return mbean.invoke(methodName, params, signature);
+                }
+
+        private Class getInterface(Class cl, String prefix) {
+                Class[] interfaces = cl.getInterfaces();
+                if (interfaces == null || interfaces.length == 0)
+                        return null;
+                for (Class c : interfaces) {
+                        if (c.getName().startsWith(prefix))
+                                return c;
+                        c = getInterface(c, prefix);
+                        if (c != null)
+                                return c;
+                }
+                return null;
+        }
+
+        /**
+         * Discover MBean interface of the bean.
+         *
+         * Note: this is very specialized for java.lang.management
+         * and java.util.logging tests.
+         * It is generally not correct for any MBean.
+         *
+         * @param object the bean
+         * @return interface class
+         */
+        private Class getMBeanInterface(Object object) throws InstanceNotFoundException {
+                String className = object.getClass().getName();
+                Class<?> iface = null;
+                if (className.startsWith("java.lang.management"))
+                        iface = getInterface(object.getClass(), "java.lang.management");
+                else if (className.startsWith("java.util.logging"))
+                        iface = getInterface(object.getClass(), "java.util.logging");
+                else if (className.startsWith("sun.management"))
+                        iface = getInterface(object.getClass(), "java.lang.management");
+                if (iface != null)
+                        return iface;
+                Class<?>[] interfaces = object.getClass().getInterfaces();
+                System.out.println(object);
+                System.out.println(object.getClass());
+                System.out.println(interfaces.length);
+                for (Class<?> c : interfaces) {
+                        System.out.println(c.getName());
+                }
+                throw new TestBug("No suitable implemented interface found for: " + object + " class: " + object.getClass());
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/CustomMBeanServerBuilder.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import javax.management.*;
+
+/**
+ * The <code>CustomMBeanServerBuilder</code> class represents a builder that
+ * creates {@link CustomMBeanServer <tt>CustomMBeanServer</tt>} which is
+ * implemeted by NSK J2SE SQE Team to test Monitoring and Management API
+ * (JSR-174).
+ *
+ * <p>To instantiate <tt>CustomMBeanServer</tt>, the
+ * <b>javax.management.builder.initial</b> system property must contain
+ * <code>"nsk.monitoring.share.CustomMBeanServerBuilder"</code> string.
+ */
+public class CustomMBeanServerBuilder extends MBeanServerBuilder {
+
+    // NSK default domain
+    private static final String DEFAULT_DOMAIN = "nsk.defaultDomain";
+
+    /**
+     * Public default constructor.
+     */
+    public CustomMBeanServerBuilder() {
+        super();
+    }
+
+    /**
+     * Creates a new <code>CustomMBeanServer</code> object.
+     *
+     * @param defaultDomain Default domain of the new MBean server.
+     * @param outer A pointer to the MBean server object that must be passed
+     *        to the MBeans when invoking their
+     *        {@link javax.management.MBeanRegistration
+     *        <code>MBeanRegistration</code>} interface.
+     * @param delegate A pointer to the MBeanServerDelegate associated with
+     *        the new MBeanServer. The new MBeanServer must register this
+     *        MBean in its MBean repository.
+     *
+     * @return A new <code>CustomMBeanServer</code> instance.
+     *
+     * @see javax.management.MBeanServerBuilder#newMBeanServer
+     */
+    public MBeanServer newMBeanServer(String defaultDomain,
+                                  MBeanServer outer,
+                                  MBeanServerDelegate delegate) {
+        if (defaultDomain == null || defaultDomain.length() == 0)
+            return new CustomMBeanServer(DEFAULT_DOMAIN);
+        else
+            return new CustomMBeanServer(defaultDomain);
+    }
+
+    /**
+     * Creates an instance of the {@link javax.management.MBeanServerDelegate
+     * <code>MBeanServerDelegate</code>} class.
+     *
+     * @return A new <code>MBeanServerDelegate</code> object.
+     *
+     * @see javax.management.MBeanServerBuilder#newMBeanServerDelegate
+     */
+    public MBeanServerDelegate newMBeanServerDelegate() {
+        return new MBeanServerDelegate();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/GarbageCollectorMonitor.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.lang.management.*;
+import javax.management.*;
+import java.io.IOException;
+import java.util.*;
+
+import nsk.share.*;
+
+/**
+ * <code>GarbageCollectorMonitor</code> class is a wrapper of
+ * <code>GarbageCollectorMXBean</code>.
+ * Depending on command line arguments, an instance of this class redirects
+ * invocations to the <code>GarbageCollectorMXBean</code> interface. If
+ * <code>-testMode="directly"</code> option is set, this instance directly
+ * invokes corresponding method of the <code>GarbageCollectorMXBean</code>
+ * interface. If <code>-testMode="server"</code> option is set it will make
+ * invocations via MBeanServer. If <code>-testMode="proxy"</code> option
+ * is set it will make invocations via MBeanServer proxy.
+ *
+ * @see ArgumentHandler
+ */
+
+public class GarbageCollectorMonitor extends Monitor {
+
+    public static final String GARBAGECOLLECTOR_MXBEAN_NAME =
+        ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE;
+
+    private static List<GarbageCollectorMXBean> mbeans
+        = ManagementFactory.getGarbageCollectorMXBeans();
+
+    // Internal trace level
+    private static final int TRACE_LEVEL = 10;
+
+    // Names of the attributes of ClassLoadingMXBean
+    private static final String COLLECTION_COUNT = "CollectionCount";
+    private static final String COLLECTION_TIME = "CollectionTime";
+
+    static {
+        Monitor.logPrefix = "GarbageCollectorMonitor> ";
+    }
+
+    /**
+     * Creates a new <code>GarbageCollectorMonitor</code> object.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     */
+    public GarbageCollectorMonitor(Log log, ArgumentHandler argumentHandler) {
+
+        super(log, argumentHandler);
+    }
+
+    public ObjectName getMBeanObjectName() {
+
+        return mbeanObjectName;
+    }
+
+    public Object[] getGarbageCollectorMXBeans() {
+
+        List<Object> list = new ArrayList<Object>();
+        int mode = getTestMode();
+
+        switch (mode) {
+            case DIRECTLY_MODE:
+                list.addAll(mbeans);
+                break;
+            case SERVER_MODE:
+                try {
+                    Set query = getMBeanServer().queryNames(null, null);
+                    Iterator it = query.iterator();
+                    while (it.hasNext()) {
+                        ObjectName oname = (ObjectName)it.next();
+                        if (oname.toString().startsWith(
+                            GARBAGECOLLECTOR_MXBEAN_NAME + ",")) {
+                            list.add(oname);
+                        }
+                    }
+                } catch (Exception e) {
+                    throw new Failure(e);
+                }
+                break;
+            case PROXY_MODE:
+                try {
+                    Set query = getMBeanServer().queryNames(null, null);
+                    Iterator it = query.iterator();
+                    while (it.hasNext()) {
+                        ObjectName oname = (ObjectName)it.next();
+                        if (oname.toString().startsWith(
+                            GARBAGECOLLECTOR_MXBEAN_NAME + ",")) {
+                            list.add(getProxy(oname));
+                        }
+                    }
+                } catch (Exception e) {
+                    throw new Failure(e);
+                }
+                break;
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+
+        return list.toArray();
+    }
+
+    private GarbageCollectorMXBean getProxy(ObjectName gcMXBean) {
+
+        try {
+            GarbageCollectorMXBean proxy = (GarbageCollectorMXBean)
+            ManagementFactory.newPlatformMXBeanProxy(
+                getMBeanServer(),
+                gcMXBean.toString(),
+                GarbageCollectorMXBean.class
+            );
+
+            return proxy;
+        } catch (Exception e) {
+            throw new Failure(e);
+        }
+    }
+
+    /**
+     * Redirects the invocation to
+     * {@link java.lang.management.GarbageCollectorMXBean#getCollectionCount()
+     * <code>GarbageCollectorMXBean.getCollectionCount()</code>}.
+     *
+     * @return the total number of collections that have occurred.
+     *
+     * @see java.lang.management.GarbageCollectorMXBean#getCollectionCount()
+     */
+    public long getCollectionCount(Object gcMXBean) {
+
+        int mode = getTestMode();
+
+        switch (mode) {
+            case DIRECTLY_MODE:
+                return ((GarbageCollectorMXBean)gcMXBean).getCollectionCount();
+            case SERVER_MODE:
+                return getLongAttribute((ObjectName)gcMXBean,
+                    COLLECTION_COUNT);
+            case PROXY_MODE:
+                return ((GarbageCollectorMXBean)gcMXBean).getCollectionCount();
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    }
+
+    /**
+     * Redirects the invocation to
+     * {@link java.lang.management.GarbageCollectorMXBean#getCollectionTime()
+     * <code>GarbageCollectorMXBean.getCollectionTime()</code>}.
+     *
+     * @return the approximate accumulated collection elapsed time
+     * in milliseconds.
+     *
+     * @see java.lang.management.GarbageCollectorMXBean#getCollectionTime()
+     */
+    public long getCollectionTime(Object gcMXBean) {
+
+        int mode = getTestMode();
+
+        switch (mode) {
+            case DIRECTLY_MODE:
+                return ((GarbageCollectorMXBean)gcMXBean).getCollectionTime();
+            case SERVER_MODE:
+                return getLongAttribute(((ObjectName)gcMXBean),
+                    COLLECTION_TIME);
+            case PROXY_MODE:
+                return ((GarbageCollectorMXBean)gcMXBean).getCollectionTime();
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    }
+
+} // GarbageCollectorMonitor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/Generator.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.util.*;
+import java.io.*;
+import java.util.ArrayList;
+
+public class Generator {
+        private String patternFileName;
+        private String outDir;
+        private List<String> lines = new ArrayList<>();
+        private String prefix = "LoadableClass";
+
+        public Generator(String patternFileName, String outDir) {
+                this.patternFileName = patternFileName;
+                this.outDir = outDir;
+        }
+
+        private void load() throws IOException {
+                BufferedReader rd = null;
+                try {
+                        rd = new BufferedReader(new FileReader(patternFileName));
+                        String s = rd.readLine();
+                        while (s != null) {
+                                lines.add(s);
+                                s = rd.readLine();
+                        }
+                } finally {
+                        if (rd != null) {
+                                rd.close();
+                        }
+                }
+        }
+
+        private void generate(int n) throws IOException {
+                PrintStream out = null;
+                String tokens = Integer.toString(n);
+                if (tokens.length() == 1)
+                        tokens = "00" + tokens;
+                else if (tokens.length() == 2)
+                        tokens = "0" + tokens;
+                try {
+                        out = new PrintStream(new FileOutputStream(new File(outDir, prefix + tokens + ".java")));
+                        for (int i = 0; i < lines.size(); ++i) {
+                                String line = lines.get(i);
+                                out.println(line.replaceAll("XYZ", tokens));
+                        }
+                } finally {
+                        if (out != null) {
+                                out.close();
+                        }
+                }
+        }
+
+        public void run() throws IOException {
+                load();
+                for (int i = 1; i < 101; ++i)
+                        generate(i);
+        }
+
+        private static void usage() {
+                System.out.println("Usage: nsk.monitoring.share.Generator <pattern file> <output directory>");
+        }
+
+        public static void main(String[] args) throws Exception {
+                if (args.length != 2) {
+                        usage();
+                        throw new IllegalArgumentException("Need exactly two arguments.");
+                }
+                new Generator(args[0], args[1]).run();
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/LoadableClass.pattern	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.newclass;
+
+public class LoadableClassXYZ {
+    public Object dummyField;
+
+    public void dummyMethod() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/LoggingMonitor.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,331 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.lang.management.*;
+import java.util.logging.*;
+import javax.management.*;
+import java.io.IOException;
+import java.util.List;
+
+import nsk.share.*;
+
+/**
+ * <code>LoggingMonitor</code> class is a wrapper of <code>LoggingMXBean</code>.
+ * Depending on command line arguments, an instance of this class redirects
+ * invocations to the <code>LoggingMXBean</code> interface. If
+ * <code>-testMode="directly"</code> option is set, this instance directly
+ * invokes corresponding method of the <code>LoggingMXBean</code> interface. If
+ * <code>-testMode="server"</code> option is set it will make invocations via
+ * MBeanServer. If <code>-testMode="proxy"</code> option is set it will make
+ * invocations via MBeanServer proxy.
+ *
+ * @see ArgumentHandler
+ */
+
+public class LoggingMonitor extends Monitor {
+
+    public static final String LOGGING_MXBEAN_NAME =
+        LogManager.LOGGING_MXBEAN_NAME;
+
+    private static LoggingMXBean mbean = LogManager.getLoggingMXBean();
+    private LoggingMXBean proxyInstance = null;
+
+    // Internal trace level
+    private static final int TRACE_LEVEL = 10;
+
+    // Names of the attributes of ClassLoadingMXBean
+    private static final String GET_LOGGER_LEVEL = "getLoggerLevel";
+    private static final String SET_LOGGER_LEVEL = "setLoggerLevel";
+    private static final String GET_PARENT_LOGGER_NAME = "getParentLoggerName";
+    private static final String LOGGER_NAMES = "LoggerNames";
+
+    static {
+        Monitor.logPrefix = "LoggingMonitor> ";
+    }
+
+    /**
+     * Creates a new <code>LoggingMonitor</code> object.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     */
+    public LoggingMonitor(Log log, ArgumentHandler argumentHandler) {
+
+        super(log, argumentHandler);
+    }
+
+    public ObjectName getMBeanObjectName() {
+
+        return mbeanObjectName;
+    }
+
+    /**
+     *
+     * Return a proxy instance for a platform
+     * {@link java.lang.management.LoggingMXBean
+     * <code>LoggingMXBean</code>} interface.
+     *
+     */
+    LoggingMXBean getProxy() {
+        if (proxyInstance == null) {
+            // create proxy instance
+            try {
+                proxyInstance = (LoggingMXBean)
+                ManagementFactory.newPlatformMXBeanProxy(
+                    getMBeanServer(),
+                    LOGGING_MXBEAN_NAME,
+                    LoggingMXBean.class
+                );
+            } catch (Exception e) {
+                throw new Failure(e);
+            }
+        }
+        return proxyInstance;
+    }
+
+    /**
+     * Redirects the invocation to
+     * {@link java.util.logging.LoggingMXBean#getLoggerLevel(String)
+     * <code>LoggingMXBean.getLoggerLevel(String loggerName)</code>}.
+     *
+     * @param loggerName The name of the <tt>Logger</tt> to be retrieved.
+     *
+     * @return The name of the log level of the specified logger; or
+     *         an empty string if the log level of the specified logger
+     *         is <tt>null</tt>.  If the specified logger does not
+     *         exist, <tt>null</tt> is returned.
+     *
+     * @see java.util.logging.LoggingMXBean#getLoggerLevel(String)
+     */
+     public String getLoggerLevel(String loggerName) {
+
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            logger.trace(TRACE_LEVEL,"[getLoggerLevel] "
+                       + "getLoggerLevel() directly invoked");
+            return mbean.getLoggerLevel(loggerName);
+
+        case SERVER_MODE:
+            logger.trace(TRACE_LEVEL,"[getLoggerLevel] "
+                       + "getLoggerLevel() invoked through MBeanServer");
+
+            try {
+
+                Object[] params = { loggerName };
+                String[] signature = { String.class.getName() };
+
+                String res = (String) getMBeanServer().invoke(
+                    mbeanObjectName,
+                    GET_LOGGER_LEVEL,
+                    params,
+                    signature );
+                return res;
+
+            } catch (Exception e) {
+
+                throw new Failure(e);
+            }
+        case PROXY_MODE:
+            logger.trace(TRACE_LEVEL,"[getLoggerLevel] "
+                       + "getLoggerLevel() invoked through MBeanServer proxy");
+            return getProxy().getLoggerLevel(loggerName);
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+
+    /**
+     * Redirects the invocation to
+     * {@link java.util.logging.LoggingMXBean#getLoggerNames()
+     * <code>LoggingMXBean.getLoggerNames()</code>}.
+     *
+     * @return A list of <tt>String</tt> each of which is a
+     *         currently registered <tt>Logger</tt> name.
+     *
+     * @see java.util.logging.LoggingMXBean#getLoggerNames()
+     */
+    public List<String> getLoggerNames() {
+
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            logger.trace(TRACE_LEVEL,"[getLoggerNames] "
+                       + "getLoggerNames() directly invoked");
+            return mbean.getLoggerNames();
+
+        case SERVER_MODE:
+            logger.trace(TRACE_LEVEL,"[getLoggerNames] "
+                       + "getLoggerNames() invoked through MBeanServer");
+
+            try {
+
+                    Object value = getMBeanServer().getAttribute(
+                        mbeanObjectName, LOGGER_NAMES);
+                    if (value instanceof List)
+                            return (List<String>) value;
+                    else if (value instanceof Object[]) {
+                            Object[] names = (Object[]) value;
+                            List<String> res = new java.util.ArrayList<String>(names.length);
+                            for (int i=0; i < names.length; i++)
+                                    res.add(names[i].toString());
+
+                            return res;
+                    } else {
+                            String[] names = (String[]) getMBeanServer().getAttribute(
+                                            mbeanObjectName, LOGGER_NAMES);
+
+                            List<String> res = new java.util.ArrayList<String>(names.length);
+                            for (int i=0; i<names.length; i++)
+                                    res.add(names[i]);
+
+                            return res;
+                    }
+                    } catch (Exception e) {
+                            throw new Failure(e);
+                    }
+        case PROXY_MODE:
+            logger.trace(TRACE_LEVEL,"[getLoggerNames] "
+                       + "getLoggerNames() invoked through MBeanServer proxy");
+            return getProxy().getLoggerNames();
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+
+    /**
+     * Redirects the invocation to
+     * {@link java.util.logging.LoggingMXBean#getParentLoggerName(String)
+     * <code>LoggingMXBean.getParentLoggerName(String loggerName)</code>}.
+     *
+     * @param loggerName The name of a <tt>Logger</tt>.
+     *
+     * @return the name of the nearest existing parent logger;
+     *         an empty string if the specified logger is the root logger.
+     *         If the specified logger does not exist, <tt>null</tt>
+     *         is returned.
+     *
+     * @see java.util.logging.LoggingMXBean#getParentLoggerName(String)
+     */
+    public String getParentLoggerName(String loggerName) {
+
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            logger.trace(TRACE_LEVEL,"[getParentLoggerName] "
+                       + "getParentLoggerName() directly invoked");
+            return mbean.getParentLoggerName(loggerName);
+
+        case SERVER_MODE:
+            logger.trace(TRACE_LEVEL,"[getParentLoggerName] "
+                       + "getParentLoggerName() invoked through MBeanServer");
+
+            try {
+
+                Object[] params = { loggerName };
+                String[] signature = { String.class.getName() };
+
+                String res = (String) getMBeanServer().invoke(
+                    mbeanObjectName,
+                    GET_PARENT_LOGGER_NAME,
+                    params,
+                    signature );
+                return res;
+
+            } catch (Exception e) {
+
+                throw new Failure(e);
+            }
+        case PROXY_MODE:
+            logger.trace(TRACE_LEVEL,"[getParentLoggerName] "
+                       + "getParentLoggerName() invoked through MBeanServer proxy");
+            return getProxy().getParentLoggerName(loggerName);
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+
+    /**
+     * Redirects the invocation to
+     * {@link java.util.logging.LoggingMXBean#setLoggerLevel(String,String)
+     * <code>LoggingMXBean.setLoggerLevel(String loggerName, String levelName)</code>}.
+     *
+     * @param loggerName The name of the <tt>Logger</tt> to be set.
+     *                   Must be non-null.
+     * @param levelName The name of the level to set the specified logger to,
+     *                 or <tt>null</tt> if to set the level to inherit
+     *                 from its nearest ancestor.
+     *
+     * @see java.util.logging.LoggingMXBean#setLoggerLevel(String,String)
+     */
+    public void setLoggerLevel(String loggerName, String levelName) {
+
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            logger.trace(TRACE_LEVEL,"[setLoggerLevel] "
+                       + "setLoggerLevel() directly invoked");
+            mbean.setLoggerLevel(loggerName, levelName);
+            break;
+        case SERVER_MODE:
+            logger.trace(TRACE_LEVEL,"[setLoggerLevel] "
+                       + "setLoggerLevel() invoked through MBeanServer");
+
+            try {
+
+                Object[] params = { loggerName, levelName };
+                String[] signature = { String.class.getName(), String.class.getName() };
+
+                getMBeanServer().invoke(
+                    mbeanObjectName,
+                    SET_LOGGER_LEVEL,
+                    params,
+                    signature );
+
+            } catch (Exception e) {
+
+                throw new Failure(e);
+            }
+            break;
+        case PROXY_MODE:
+            logger.trace(TRACE_LEVEL,"[setLoggerLevel] "
+                       + "setLoggerLevel() invoked through MBeanServer proxy");
+            getProxy().setLoggerLevel(loggerName, levelName);
+            break;
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+} // LoggingMonitor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/MemoryMonitor.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,1611 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.lang.management.*;
+import javax.management.*;
+import javax.management.openmbean.*;
+import java.util.*;
+
+import nsk.share.*;
+
+/**
+ * <code>MemoryMonitor</code> class is a wrapper of <code>MemoryMXBean</code> and
+ * <code>MemoryPoolMXBean</code> interfaces. Depending on command line arguments,
+ * an instance of this class redirects invocations to the
+ * <code>MemoryMXBean</code> (or <code>MemoryPoolMXBean</code>) interface. If
+ * <code>-testMode="directly"</code> option is set, this instance directly
+ * invokes corresponding method of the <code>MemoryMXBean</code> (or
+ * <code>MemoryPoolMXBean</code>) interface. If <code>-testMode="server"</code>
+ * option is set it will make invocations via MBeanServer.
+ *
+ * @see ArgumentHandler
+ */
+public class MemoryMonitor extends Monitor implements NotificationListener,
+        NotificationFilter {
+
+    // Constants to define type of memory that will be allocated in
+    // MemoryMonitor. For heap memory objects will be allocated; for nonheap
+    // type classes will be loaded; for mixed type -- both (objects will be
+    // allocated and classes will be loaded).
+    public final static String HEAP_TYPE = "heap";
+    public final static String NONHEAP_TYPE = "nonheap";
+    public final static String MIXED_TYPE = "mixed";
+    // Names of the attributes of MemoryMXBean
+    private final static String POOL_TYPE = "Type";
+    private final static String POOL_RESET_PEAK = "resetPeakUsage";
+    private final static String POOL_PEAK = "PeakUsage";
+    private final static String POOL_VALID = "Valid";
+    private final static String POOL_U = "Usage";
+    private final static String UT = "UsageThreshold";
+    private final static String UT_COUNT = "UsageThresholdCount";
+    private final static String UT_SUPPORT = "UsageThresholdSupported";
+    private final static String UT_EXCEEDED = "UsageThresholdExceeded";
+    private final static String POOL_CU = "CollectionUsage";
+    private final static String CT = "CollectionUsageThreshold";
+    private final static String CT_COUNT = "CollectionUsageThresholdCount";
+    private final static String CT_SUPPORT = "CollectionUsageThresholdSupported";
+    private final static String CT_EXCEEDED = "CollectionUsageThresholdExceeded";
+    // Varibales to store options that are passed to the test
+    private static String memory;
+    private static int mode;
+    private static boolean isNotification;
+    private static boolean isUsageThreshold;
+    private static volatile boolean passed = true;
+    private Polling polling = new Polling();
+
+    static {
+        Monitor.logPrefix = "MemoryMonitor   > ";
+    }
+
+    /**
+     * Creates a new <code>MemoryMonitor</code> object.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param handler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     */
+    public MemoryMonitor(Log log, ArgumentHandler handler) {
+        super(log, handler);
+
+        memory = handler.getTestedMemory();
+        mode = getTestMode();
+        isNotification = (handler.MON_NOTIF.equals(handler.getMonitoring()));
+        isUsageThreshold = (handler.TH_USAGE.equals(handler.getThreshold()));
+
+        String s = "\t(This setting is used in lowmem* tests only)";
+
+        display("Memory:\t" + handler.getTestedMemory() + s);
+        display("Monitoring:\t" + handler.getMonitoring() + s);
+        display("Threshold:\t" + handler.getThreshold() + s);
+        display("Timeout:\t" + handler.getTimeout() + s);
+    }
+
+    /**
+     * Returns <code>true</code> if no failures were revealed during the test,
+     * <code>false</code> otherwise.
+     *
+     * @return <code>true</code> if no failures were revealed during the test,
+     * <code>false</code> otherwise.
+     *
+     */
+    public boolean getPassedStatus() {
+        return passed;
+    }
+
+    /**
+     * Enables memory monitoring.
+     * <p>
+     * If notification type of monitoring is chosen, the method adds {@link
+     * javax.management.NotificationListener
+     * <code>javax.management.NotificationListener</code>} to enables low
+     * memory detection support. If monitoring type is polling, a new thread
+     * that manages the low memory detection is started.
+     *
+     * @throws InstanceNotFoundException The MemoryMXBean is not registered on
+     *                                   the server.
+     */
+    public void enableMonitoring() throws InstanceNotFoundException {
+        if (isNotification) {
+            switch (mode) {
+                case DIRECTLY_MODE:
+                    MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
+                    NotificationEmitter emitter = (NotificationEmitter) mbean;
+                    emitter.addNotificationListener(this, this, null);
+                    break;
+
+                case SERVER_MODE:
+                case PROXY_MODE:
+                    getMBeanServer().addNotificationListener(mbeanObjectName,
+                            this, this, null);
+                    break;
+
+                default:
+                    throw new TestBug("Unknown testMode " + mode);
+            }
+        } else {
+
+            // Polling
+            // Start a thread that will manage all test modes
+            polling.start();
+
+        }
+    } // enableMonitoring()
+
+    /**
+     * Disables memory monitoring.
+     * <p>
+     * If monitoring type is polling, the thread that manages the low memory
+     * detection is stopped.
+     */
+    public void disableMonitoring() {
+        if (!isNotification) {
+
+            // Stop polling thread
+            polling.goOn = false;
+        }
+    } // disableMonitoring()
+
+    /**
+     * Updates thresholds. Thresholds values for all pools will be greater
+     * than <code>used</code> value.
+     * <p>
+     * If <code>usage</code> thresholds are chosen, the method updates just
+     * pools that support usage thresholds. If <code>collection</code>
+     * thresholds are chosen, the method updates memory pools that support
+     * collection usage thresholds.
+     *
+     * This method is synchronized because it may be invoked from
+     * <code>handleNotification</code> which is potentially done from
+     * multiple threads.
+     */
+    public synchronized void updateThresholds() {
+        if (isUsageThreshold) {
+            updateUsageThresholds();
+        } else {
+            updateCollectionThresholds();
+        }
+    }
+
+    /**
+     * Reset thresholds. Thresholds values for all pools will be 1.
+     * If <code>usage</code> thresholds are chosen, the method updates just
+     * pools that support usage thresholds. If <code>collection</code>
+     * thresholds are chosen, the method updates memory pools that support
+     * collection usage thresholds.
+     *
+     * This method is synchronized because it may be invoked from
+     * multiple threads.
+     */
+    public synchronized void resetThresholds(MemoryType type) {
+        List pools = getMemoryPoolMBeans();
+        for (int i = 0; i < pools.size(); i++) {
+            Object pool = pools.get(i);
+            if (isUsageThresholdSupported(pool)) {
+                if (getType(pool).equals(type)) {
+                    setUsageThreshold(pool, 1);
+                }
+            }
+        }
+    }
+
+    /**
+     * The method is invoked before sending the notification to the listener.
+     *
+     * @param notification The notification to be sent.
+     * @return <i>true</i> if the notification has to be sent to the listener;
+     *         <i>false</i> otherwise.
+     *
+     * @see javax.management.NotificationFilter
+     */
+    public boolean isNotificationEnabled(Notification notification) {
+        String type = notification.getType();
+        String usage = MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED;
+        String collection = MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED;
+
+        if (isUsageThreshold) {
+            return type.equals(usage);
+        } else {
+            return type.equals(collection);
+        }
+    } // isNotificationEnabled()
+
+    /**
+     * The method is invoked when a JMX notification occurs.
+     *
+     * @param notification The notification to be sent.
+     * @param handback An opaque object which helps the listener to associate
+     *        information regarding the MBean emitter.
+     * @see javax.management.NotificationListener
+     */
+    public void handleNotification(Notification notification, Object handback) {
+        CompositeData data = (CompositeData) notification.getUserData();
+        MemoryNotificationInfo mn = MemoryNotificationInfo.from(data);
+
+        display(mn.getCount() + " notification \"" + notification.getMessage()
+                + "\" is caught on " + (new Date(notification.getTimeStamp()))
+                + " by " + mn.getPoolName() + " (" + mn.getUsage() + ")");
+        updateThresholds();
+    } // handleNotification()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#resetPeakUsage
+     * <code>MemoryPoolMXBean.resetPeakUsage()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     */
+    public void resetPeakUsage(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                directPool.resetPeakUsage();
+                break;
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+
+                try {
+                    getMBeanServer().invoke(serverPool, POOL_RESET_PEAK,
+                            null, null);
+                } catch (Exception e) {
+                    e.printStackTrace(logger.getOutStream());
+                    throw new Failure(e);
+                }
+                break;
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                proxyPool.resetPeakUsage();
+                break;
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // resetPeakUsage()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#getPeakUsage
+     * <code>MemoryPoolMXBean.getPeakUsage()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return a <code>MemoryUsage</code> object representing the peak memory
+     *         usage; <code>null</code> otherwise.
+     */
+    public MemoryUsage getPeakUsage(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.getPeakUsage();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return getMemoryUsageAttribute(serverPool, POOL_PEAK);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.getPeakUsage();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // getPeakUsage()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#getUsage
+     * <code>MemoryPoolMXBean.getUsage()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return a <code>MemoryUsage</code> object; or <code>null</code> if this
+     *         pool not valid.
+     */
+    public MemoryUsage getUsage(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.getUsage();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return getUsageOnServer(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.getUsage();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // getUsage()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#getCollectionUsage
+     * <code>MemoryPoolMXBean.getCollectionUsage()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return a <code>MemoryUsage</code> object; or <code>null</code> if this
+     *         method is not supported.
+     */
+    public MemoryUsage getCollectionUsage(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.getCollectionUsage();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return getCollectionUsageOnServer(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.getCollectionUsage();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // getCollectionUsage()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#isValid
+     * <code>MemoryPoolMXBean.isValid()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return a <code>true</code> if the memory pool is valid in the running
+     *         JVM; <code>null</code> otherwise.
+     */
+    public boolean isValid(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.isValid();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return getBooleanAttribute(serverPool, POOL_VALID);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.isValid();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // isValid()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#isUsageThresholdSupported
+     * <code>MemoryPoolMXBean.isUsageThresholdSupported()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return a <code>true</code> if the memory pool supports usage threshold;
+     *         <code>null</code> otherwise.
+     */
+    public boolean isUsageThresholdSupported(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.isUsageThresholdSupported();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return isUsageThresholdSupportedOnServer(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.isUsageThresholdSupported();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // isUsageThresholdSupported()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#isCollectionUsageThresholdSupported
+     * <code>MemoryPoolMXBean.isCollectionUsageThresholdSupported()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return a <code>true</code> if the memory pool supports collection
+     *         usage threshold; <code>null</code> otherwise.
+     */
+    public boolean isCollectionThresholdSupported(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.isCollectionUsageThresholdSupported();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return isCollectionThresholdSupportedOnServer(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.isCollectionUsageThresholdSupported();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // isCollectionThresholdSupported()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#isUsageThresholdExceeded
+     * <code>MemoryPoolMXBean.isUsageThresholdExceeded()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return a <code>true</code> if the memory usage of this pool reaches or
+     *         exceeds the threshold value; <code>null</code> otherwise.
+     */
+    public boolean isUsageThresholdExceeded(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.isUsageThresholdExceeded();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return isUsageThresholdExceededOnServer(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.isUsageThresholdExceeded();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // isUsageThresholdExceeded()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#isCollectionUsageThresholdExceeded
+     * <code>MemoryPoolMXBean.isCollectionUsageThresholdExceeded()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return a <code>true</code> if the memory usage of this pool reaches or
+     *         exceeds the collection usage threshold value in the most recent
+     *         collection; <code>null</code> otherwise.
+     */
+    public boolean isCollectionThresholdExceeded(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.isCollectionUsageThresholdExceeded();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return isCollectionThresholdExceededOnServer(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.isCollectionUsageThresholdExceeded();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // isCollectionThresholdExceeded()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#getUsageThreshold
+     * <code>MemoryPoolMXBean.getUsageThreshold()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return the usage threshold value of this memory pool in bytes.
+     */
+    public long getUsageThreshold(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.getUsageThreshold();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return getUsageThresholdOnServer(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.getUsageThreshold();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // getUsageThreshold()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#getCollectionUsageThreshold
+     * <code>MemoryPoolMXBean.getCollectionUsageThreshold()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return the collection usage threshold value of this memory pool in
+     *         bytes.
+     */
+    public long getCollectionThreshold(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.getCollectionUsageThreshold();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return getCollectionThresholdOnServer(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.getCollectionUsageThreshold();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // getCollectionThreshold()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#getUsageThresholdCount
+     * <code>MemoryPoolMXBean.getUsageThresholdCount()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return number of times that the memory usage has crossed its usage
+     *         threshold value.
+     */
+    public long getUsageThresholdCount(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.getUsageThresholdCount();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return getUsageThresholdCountOnServer(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.getUsageThresholdCount();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // getUsageThresholdCount()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#getCollectionUsageThresholdCount
+     * <code>MemoryPoolMXBean.getCollectionUsageThresholdCount()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return number of times that the memory usage has crossed its collection
+     *         usage threshold value.
+     */
+    public long getCollectionThresholdCount(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.getCollectionUsageThresholdCount();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return getCollectionThresholdCountOnServer(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.getCollectionUsageThresholdCount();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // getCollectionThresholdCount()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#setUsageThreshold
+     * <code>MemoryPoolMXBean.setUsageThreshold()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @param threshold the new threshold value.
+     */
+    public void setUsageThreshold(Object poolObject, long threshold) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                directPool.setUsageThreshold(threshold);
+                break;
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                setUsageThresholdOnServer(serverPool, threshold);
+                break;
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                proxyPool.setUsageThreshold(threshold);
+                break;
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // setUsageThreshold()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#setCollectionUsageThreshold
+     * <code>MemoryPoolMXBean.setCollectionUsageThreshold()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @param threshold the new collection usage threshold value.
+     */
+    public void setCollectionThreshold(Object poolObject, long threshold) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                directPool.setCollectionUsageThreshold(threshold);
+                break;
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                setCollectionThresholdOnServer(serverPool, threshold);
+                break;
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                proxyPool.setCollectionUsageThreshold(threshold);
+                break;
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // setCollectionThreshold()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#getName
+     * <code>MemoryPoolMXBean.getName()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return the name of the memory pool.
+     */
+    public String getName(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.getName();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return serverPool.toString();
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.getName();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // getName()
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.MemoryPoolMXBean#getType
+     * <code>MemoryPoolMXBean.getType()</code>}.
+     *
+     * @param poolObject reference to the pool. The pool may be specified
+     *        either by <code>ObjectName</code>, or
+     *        <code>MemoryPoolMXBean</code>.
+     * @return the name of the memory pool.
+     */
+    public MemoryType getType(Object poolObject) {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                MemoryPoolMXBean directPool = (MemoryPoolMXBean) poolObject;
+                return directPool.getType();
+
+            case SERVER_MODE:
+                ObjectName serverPool = (ObjectName) poolObject;
+                return getType(serverPool);
+
+            case PROXY_MODE:
+                MemoryPoolMXBean proxyPool = (MemoryPoolMXBean) poolObject;
+                return proxyPool.getType();
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ManagementFactory#getMemoryPoolMXBeans
+     * <code>ManagementFactory.getMemoryPoolMXBeans()</code>}.
+     *
+     * @return a list of <code>MemoryPoolMXBean</code> objects.
+     */
+    public List<? extends Object> getMemoryPoolMBeans() {
+        switch (mode) {
+            case DIRECTLY_MODE:
+                return ManagementFactory.getMemoryPoolMXBeans();
+
+            case SERVER_MODE: {
+                ObjectName[] names = getMemoryPoolMXBeansOnServer();
+                ArrayList<ObjectName> list = new ArrayList<ObjectName>();
+
+                for (int i = 0; i < names.length; i++) {
+                    list.add(names[i]);
+                }
+                return list;
+            }
+
+            case PROXY_MODE: {
+                ObjectName[] names = getMemoryPoolMXBeansOnServer();
+                ArrayList<MemoryPoolMXBean> list = new ArrayList<MemoryPoolMXBean>();
+
+                for (int i = 0; i < names.length; i++) {
+                    list.add(getProxy(names[i]));
+                }
+                return list;
+            }
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // getMemoryPoolMXBeans()
+
+    // **********************************************************************
+    //
+    // Private methods
+    //
+    // **********************************************************************
+    private MemoryPoolMXBean getProxy(ObjectName objectName) {
+        try {
+            MemoryPoolMXBean proxy = (MemoryPoolMXBean) ManagementFactory.newPlatformMXBeanProxy(
+                    getMBeanServer(),
+                    objectName.toString(),
+                    MemoryPoolMXBean.class);
+            return proxy;
+        } catch (Exception e) {
+            throw new Failure(e);
+        }
+    }
+
+    // Sets new usage threasholds in all pools that match the tested memory and
+    // support low memory detetion. A new value will be greater than used value
+    // for the pool.
+    private void updateUsageThresholds() {
+        switch (mode) {
+            case DIRECTLY_MODE:
+            // we can use the same code here for direct and proxy modes
+            case PROXY_MODE:
+                List poolsMBean = ManagementFactory.getMemoryPoolMXBeans();
+
+                for (int i = 0; i < poolsMBean.size(); i++) {
+                    MemoryPoolMXBean pool = (MemoryPoolMXBean) poolsMBean.get(i);
+                    if (!pool.isUsageThresholdSupported()) {
+                        continue;
+                    }
+
+                    MemoryType mt = pool.getType();
+                    if ((!mt.equals(MemoryType.HEAP)
+                            || !memory.equals(HEAP_TYPE))
+                            && (!mt.equals(MemoryType.NON_HEAP)
+                            || !memory.equals(NONHEAP_TYPE))
+                            && !memory.equals(MIXED_TYPE)) {
+                        continue;
+                    }
+
+                    // Yes! We got the pool that
+                    // 1. supports usage threshold
+                    // 2. has type that match tested type
+                    // So, update the pool with new threshold
+                    long oldT = pool.getUsageThreshold();
+                    MemoryUsage usage = pool.getUsage();
+                    long newT = newThreshold(usage, oldT, pool.getName());
+
+                    try {
+                        pool.setUsageThreshold(newT);
+                    } catch (IllegalArgumentException e) {
+                        /*
+                         * Max value might have changed since the call to newThreshold()
+                         * above. If it has fallen below the value of newT, which is certainly
+                         * possible, an exception like this one will be thrown from
+                         * sun.management.MemoryPoolImpl.setUsageThreshold():
+                         *
+                         * java.lang.IllegalArgumentException: Invalid threshold: 48332800 > max (47251456).
+                         *
+                         * We don't know the max value at the time of the failed call, and it
+                         * might have changed since the call once more. So there is no point
+                         * trying to detect whether the IllegalArgumentException had been
+                         * justified, we cannot know it at this point.
+                         *
+                         * The best we can do is log the fact and continue.
+                         */
+                        displayInfo("setUsageThreshold() failed with " + e + ", ignoring... ",
+                                pool,
+                                "current usage after the call to setUsageThreshold(): ", getUsage(pool),
+                                "threshold: ", newT);
+                        continue;
+                    }
+                    displayInfo("Usage threshold is set", pool, "usage: ", pool.getUsage(), "threshold: ", pool.getUsageThreshold());
+                    if (pool.getUsageThreshold() != newT) {
+                        complain("Cannot reset usage threshold from " + oldT
+                                + " to " + newT + " in pool " + pool.getName() + " "
+                                + pool.getUsageThreshold());
+                        passed = false;
+                    }
+                } // for i
+                break;
+
+            case SERVER_MODE:
+                ObjectName[] pools = getMemoryPoolMXBeansOnServer();
+
+                for (int i = 0; i < pools.length; i++) {
+                    if (!isUsageThresholdSupportedOnServer(pools[i])) {
+                        continue;
+                    }
+
+                    MemoryType mt = getType(pools[i]);
+                    if ((!mt.equals(MemoryType.HEAP)
+                            || !memory.equals(HEAP_TYPE))
+                            && (!mt.equals(MemoryType.NON_HEAP)
+                            || !memory.equals(NONHEAP_TYPE))
+                            && !memory.equals(MIXED_TYPE)) {
+                        continue;
+                    }
+
+                    // Yes! We got the pool that
+                    // 1. supports usage threshold
+                    // 2. has type that match tested type
+                    // So, update the pool with new threshold
+                    long oldT = getUsageThreshold(pools[i]);
+                    long newT = newThreshold(getUsageOnServer(pools[i]), oldT,
+                            pools[i].toString());
+                    try {
+                        setUsageThresholdOnServer(pools[i], newT);
+                    } catch (Failure e) {
+                        /*
+                         * Max value might have changed since the call to newThreshold()
+                         * above. If it has fallen below the value of newT, which is certainly
+                         * possible, an exception like this one will be thrown from
+                         * sun.management.MemoryPoolImpl.setUsageThreshold():
+                         *
+                         * java.lang.IllegalArgumentException: Invalid threshold: 48332800 > max (47251456).
+                         *
+                         * and we'll catch Failure here as a result (it'll be thrown by
+                         * Monitor.setLongAttribute).
+                         *
+                         * We don't know the max value at the time of the failed call, and it
+                         * might have changed since the call once more. So there is no point
+                         * trying to detect whether the IllegalArgumentException had been
+                         * justified, we cannot know it at this point.
+                         *
+                         * The best we can do is log the fact and continue.
+                         */
+                        displayInfo("setUsageThresholdOnServer() failed with " + e + ", ignoring... ",
+                                pools[i],
+                                "current usage after the call to setUsageThresholdOnServer(): ", getUsageOnServer(pools[i]),
+                                "threshold: ", newT);
+                        continue;
+                    }
+                    displayInfo("Usage threshold is set", null, "pool: ", pools[i], "usage:", getUsageOnServer(pools[i]));
+                    if (getUsageThreshold(pools[i]) != newT) {
+                        complain("Cannot reset usage threshold from " + oldT + " to "
+                                + newT + " in pool " + pools[i].toString());
+                        passed = false;
+                    }
+                } // for i
+                break;
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // updateUsageThresholds()
+
+    // Sets new collection usage threasholds in all pools that match the tested
+    // memory and support low memory detetion. A new value will be greater than
+    // used value for the pool.
+    private void updateCollectionThresholds() {
+        switch (mode) {
+            case DIRECTLY_MODE:
+            // we can use the same code here for direct and proxy modes
+            case PROXY_MODE:
+                List poolsMBean = ManagementFactory.getMemoryPoolMXBeans();
+
+                for (int i = 0; i < poolsMBean.size(); i++) {
+                    MemoryPoolMXBean pool = (MemoryPoolMXBean) poolsMBean.get(i);
+                    if (!pool.isCollectionUsageThresholdSupported()) {
+                        continue;
+                    }
+
+                    MemoryType mt = pool.getType();
+                    if ((!mt.equals(MemoryType.HEAP)
+                            || !memory.equals(HEAP_TYPE))
+                            && (!mt.equals(MemoryType.NON_HEAP)
+                            || !memory.equals(NONHEAP_TYPE))
+                            && !memory.equals(MIXED_TYPE)) {
+                        continue;
+                    }
+
+                    // Yes! We got the pool that
+                    // 1. supports collection threshold
+                    // 2. has type that match tested type
+                    // So, update the pool with new threshold
+                    long oldT = pool.getCollectionUsageThreshold();
+                    MemoryUsage usage = pool.getUsage();
+                    long newT = newThreshold(usage, oldT, pool.getName());
+
+                    try {
+                        pool.setCollectionUsageThreshold(newT);
+                    } catch (IllegalArgumentException e) {
+
+                        /*
+                         * Max value might have changed since the call to newThreshold()
+                         * above. If it has fallen below the value of newT, which is certainly
+                         * possible, an exception like this one will be thrown from
+                         * sun.management.MemoryPoolImpl.setCollectionUsageThreshold():
+                         *
+                         * java.lang.IllegalArgumentException: Invalid threshold: 48332800 > max (47251456).
+                         *
+                         * We don't know the max value at the time of the failed call, and it
+                         * might have changed since the call once more. So there is no point
+                         * trying to detect whether the IllegalArgumentException had been
+                         * justified, we cannot know it at this point.
+                         *
+                         * The best we can do is log the fact and continue.
+                         */
+                        displayInfo("setCollectionUsageThreshold() failed with " + e + ", ignoring... ",
+                                pool,
+                                "current usage after the call to setCollectionUsageThreshold(): ", getUsage(pool),
+                                "threshold: ", newT);
+                        continue;
+                    }
+                    displayInfo("Collection threshold is set", pool, "usage: ", getUsage(pool), "threshold: ", newT);
+                    if (pool.getCollectionUsageThreshold() != newT) {
+                        complain("Cannot reset collection threshold from " + oldT
+                                + " to " + newT + " in pool " + pool.getName() + " "
+                                + pool.getCollectionUsageThreshold());
+                        passed = false;
+                    }
+                } // for i
+                break;
+
+            case SERVER_MODE:
+                ObjectName[] pools = getMemoryPoolMXBeansOnServer();
+
+                for (int i = 0; i < pools.length; i++) {
+                    if (!isCollectionThresholdSupportedOnServer(pools[i])) {
+                        continue;
+                    }
+
+                    MemoryType mt = getType(pools[i]);
+                    if ((!mt.equals(MemoryType.HEAP)
+                            || !memory.equals(HEAP_TYPE))
+                            && (!mt.equals(MemoryType.NON_HEAP)
+                            || !memory.equals(NONHEAP_TYPE))
+                            && !memory.equals(MIXED_TYPE)) {
+                        continue;
+                    }
+
+                    // Yes! We got the pool that
+                    // 1. supports usage threshold
+                    // 2. has type that match tested type
+                    // So, update the pool with new threshold
+                    long oldT = getCollectionThresholdOnServer(pools[i]);
+                    long newT = newThreshold(getUsageOnServer(pools[i]), oldT,
+                            pools[i].toString());
+                    try {
+                        setCollectionThresholdOnServer(pools[i], newT);
+                    } catch (Failure e) {
+                        /*
+                         * Max value might have changed since the call to newThreshold()
+                         * above. If it has fallen below the value of newT, which is certainly
+                         * possible, an exception like this one will be thrown from
+                         * sun.management.MemoryPoolImpl.setCollectionUsageThreshold():
+                         *
+                         * java.lang.IllegalArgumentException: Invalid threshold: 48332800 > max (47251456).
+                         *
+                         * and we'll catch Failure here as a result (it'll be thrown by
+                         * Monitor.setLongAttribute).
+                         *
+                         * We don't know the max value at the time of the failed call, and it
+                         * might have changed since the call once more. So there is no point
+                         * trying to detect whether the IllegalArgumentException had been
+                         * justified, we cannot know it at this point.
+                         *
+                         * The best we can do is log the fact and continue.
+                         */
+                        displayInfo("setCollectionThresholdOnServer() failed with " + e + ", ignoring... ",
+                                pools[i],
+                                "current usage after the call to setCollectionThresholdOnServer(): ", getUsageOnServer(pools[i]),
+                                "threshold: ", newT);
+                        continue;
+                    }
+                    displayInfo("Collection threshold is set", pools[i], "usage: ", getUsageOnServer(pools[i]), "threshold: ", newT);
+                    if (getCollectionThresholdOnServer(pools[i]) != newT) {
+                        complain("Cannot reset collaction threshold from " + oldT
+                                + " to " + newT + " in pool " + pools[i].toString());
+                        passed = false;
+                    }
+                } // for i
+                break;
+
+            default:
+                throw new TestBug("Unknown testMode " + mode);
+        }
+    } // updateCollectionThresholds()
+
+    // Calculates a new value of threshold based on MemoryUsage and old value of
+    // the threshold. New one will be not less than previous one.
+    private long newThreshold(MemoryUsage mu, long oldT, String poolName) {
+        long newT = mu.getCommitted() / 2 + mu.getUsed() / 2;
+        long max = mu.getMax();
+
+        if (newT < oldT) {
+            newT = mu.getCommitted() / 2 + oldT / 2;
+        }
+        if ((max > -1) && (newT > max)) {
+            newT = max;
+        }
+        displayInfo("Changing threshold", poolName, null, null, "new threshold: ", newT);
+        return newT;
+    }
+
+    // **********************************************************************
+    //
+    // Methods to work with MBean server in SERVER_MODE
+    //
+    // **********************************************************************
+    // Returns usage threshold value of the pool MBean that is accessed via
+    // MBeanServer
+    private long getUsageThresholdOnServer(ObjectName pool) {
+        return getLongAttribute(pool, UT);
+    }
+
+    // Returns collection threshold value of the pool MBean that is accessed via
+    // MBeanServer
+    private long getCollectionThresholdOnServer(ObjectName pool) {
+        return getLongAttribute(pool, CT);
+    }
+
+    // Sets new usage threshold value for the pool MBean that is accessed via
+    // MBeanServer
+    private void setUsageThresholdOnServer(ObjectName pool, long value) {
+        setLongAttribute(pool, UT, value);
+    }
+
+    // Sets new collection threshold value for the pool MBean that is accessed
+    // via MBeanServer
+    private void setCollectionThresholdOnServer(ObjectName pool, long value) {
+        setLongAttribute(pool, CT, value);
+    }
+
+    // Returns MemoryType of the pool MBean that is accessed via MBeanServer.
+    private MemoryType getType(ObjectName pool) {
+        try {
+            Object value = getMBeanServer().getAttribute(pool, POOL_TYPE);
+            if (value instanceof MemoryType) {
+                return (MemoryType) value;
+            } else if (value instanceof String) {
+                String name = (String) value;
+                return MemoryType.valueOf(name);
+            } else {
+                return null;
+            }
+        } catch (Exception e) {
+            e.printStackTrace(logger.getOutStream());
+            throw new Failure(e);
+        }
+    }
+
+    // Returns MemoryUsage of the pool MBean that is accessed via MBeanServer
+    private MemoryUsage getUsageOnServer(ObjectName pool) {
+        return getMemoryUsageAttribute(pool, POOL_U);
+    }
+
+    // Returns collection usage of the pool MBean that is accessed via
+    // MBeanServer
+    private MemoryUsage getCollectionUsageOnServer(ObjectName pool) {
+        return getMemoryUsageAttribute(pool, POOL_CU);
+    }
+
+    // Returns if usage threshold is supported in the pool
+    private boolean isUsageThresholdSupportedOnServer(ObjectName pool) {
+        return getBooleanAttribute(pool, UT_SUPPORT);
+    }
+
+    // Returns if collection threshold is supported in the pool
+    private boolean isCollectionThresholdSupportedOnServer(ObjectName pool) {
+        return getBooleanAttribute(pool, CT_SUPPORT);
+    }
+
+    // Returns if usage threshold is exceeded in the pool
+    private boolean isUsageThresholdExceededOnServer(ObjectName pool) {
+        return getBooleanAttribute(pool, UT_EXCEEDED);
+    }
+
+    // Returns if collection threshold is exceeded in the pool
+    private boolean isCollectionThresholdExceededOnServer(ObjectName pool) {
+        return getBooleanAttribute(pool, CT_EXCEEDED);
+    }
+
+    // Returns the usage threshold count of the pool
+    private long getUsageThresholdCountOnServer(ObjectName pool) {
+        return getLongAttribute(pool, UT_COUNT);
+    }
+
+    // Returns the collection threshold count of the pool.
+    private long getCollectionThresholdCountOnServer(ObjectName pool) {
+        return getLongAttribute(pool, CT_COUNT);
+    }
+    private final StringBuffer buffer = new StringBuffer(1000);
+
+    /**
+     * Display information about execution ignoring OOM.
+     */
+    private void displayInfo(String message, Object pool, String message1, Object n1, String message2, long n2) {
+        try {
+            buffer.delete(0, buffer.length());
+            buffer.append(message);
+            if (pool != null) {
+                buffer.append(", pool: ");
+                buffer.append(pool.toString());
+            }
+            buffer.append(", ");
+            buffer.append(message1);
+            buffer.append(n1);
+            if (message2 != null) {
+                buffer.append(", ");
+                buffer.append(message2);
+                buffer.append(n2);
+            }
+            display(buffer.toString());
+        } catch (OutOfMemoryError e) {
+            // Ignore.
+        }
+    }
+
+    /**
+     * Display information about execution ignoring OOM.
+     */
+    private void displayInfo(String message, MemoryPoolMXBean pool, String message1, Object n1, String message2, Object n2) {
+        try {
+            buffer.delete(0, buffer.length());
+            buffer.append(message);
+            if (pool != null) {
+                buffer.append(", pool: ");
+                buffer.append(pool.getName());
+            }
+            buffer.append(", ");
+            buffer.append(message1);
+            buffer.append(n1);
+            if (message2 != null) {
+                buffer.append(", ");
+                buffer.append(message2);
+                buffer.append(n2);
+            }
+            display(buffer.toString());
+        } catch (OutOfMemoryError e) {
+            // Ignore.
+        }
+    }
+
+    // Returns all MemoryPoolMXBeans that are registered on the MBeanServer
+    private ObjectName[] getMemoryPoolMXBeansOnServer() {
+
+        // Get all registered MBeans on the server
+        ObjectName filterName = null;
+        try {
+            filterName = new ObjectName(
+                 ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE + ",*");
+
+            Set<ObjectName> filteredSet = getMBeanServer().queryNames(filterName, null);
+            return filteredSet.toArray(new ObjectName[0]);
+        } catch(Exception e) {
+            return new ObjectName[0];
+        }
+
+    } // getMemoryPoolMXBeansOnServer()
+
+    // **********************************************************************
+    //
+    // Class to implement polling mechanism of monitoring
+    //
+    // **********************************************************************
+    class Polling extends Thread {
+
+        final static long WAIT_TIME = 100; // Milliseconds
+        Object object = new Object();
+        long[] thresholdCounts;
+        boolean goOn = true;
+
+        public void run() {
+            try {
+                if (isUsageThreshold) {
+                    pollUsageThresholds();
+                } else {
+                    pollCollectionThresholds();
+                }
+            } catch (Failure e) {
+                complain("Unexpected " + e + " in Polling thread");
+                e.printStackTrace(logger.getOutStream());
+                passed = false;
+            }
+        } // run()
+
+        private void pollUsageThresholds() {
+            switch (mode) {
+                case DIRECTLY_MODE:
+                // we can use the same code here for direct and proxy modes
+                case PROXY_MODE:
+                    List poolsMBean = ManagementFactory.getMemoryPoolMXBeans();
+
+                    // Create an array to store all threshold values
+                    thresholdCounts = new long[poolsMBean.size()];
+                    for (int i = 0; i < thresholdCounts.length; i++) {
+                        thresholdCounts[i] = 0;
+                    }
+
+                    while (goOn) {
+                        synchronized (object) {
+                            try {
+                                object.wait(WAIT_TIME);
+                            } catch (InterruptedException e) {
+
+                                // Stop the thread
+                                return;
+                            }
+                        } // synchronized
+
+                        for (int i = 0; i < poolsMBean.size(); i++) {
+                            MemoryPoolMXBean pool = (MemoryPoolMXBean) poolsMBean.get(i);
+                            MemoryType mt = pool.getType();
+
+                            if (!pool.isUsageThresholdSupported()) {
+                                continue;
+                            }
+
+                            if ((!mt.equals(MemoryType.HEAP)
+                                    || !memory.equals(HEAP_TYPE))
+                                    && (!mt.equals(MemoryType.NON_HEAP)
+                                    || !memory.equals(NONHEAP_TYPE))
+                                    && !memory.equals(MIXED_TYPE)) {
+                                continue;
+                            }
+
+                            boolean exceeded;
+
+                            // The exception is not documented, but it may be
+                            // erroneously thrown
+                            try {
+                                exceeded = pool.isUsageThresholdExceeded();
+                            } catch (IllegalArgumentException e) {
+                                complain("Unexpected exception while retrieving "
+                                        + "isUsageThresholdExceeded() for pool "
+                                        + pool.getName());
+                                e.printStackTrace(logger.getOutStream());
+                                passed = false;
+                                continue;
+                            }
+
+                            if (!exceeded
+                                    || pool.getUsageThresholdCount() == thresholdCounts[i]) {
+                                continue;
+                            }
+
+                            // Yes! We got the pool that
+                            // 1. supports usage threshold
+                            // 2. has type that match tested type
+                            // 3. its threshold is exceeded
+                            // So, update all thresholds
+                            long c = pool.getUsageThresholdCount();
+                            if (c <= thresholdCounts[i]) {
+                                complain("Usage threshold count is not greater "
+                                        + "than previous one: " + c + " < "
+                                        + thresholdCounts[i] + " in pool "
+                                        + pool.getName());
+                                passed = false;
+                            }
+                            thresholdCounts[i] = c;
+                            displayInfo("Crossing is noticed", pool, "usage: ", pool.getUsage(), "count: ", c);
+                            updateThresholds();
+                        } // for i
+                    } // while
+                    break;
+
+                case SERVER_MODE:
+                    ObjectName[] pools = getMemoryPoolMXBeansOnServer();
+
+                    // Create an array to store all threshold values
+                    thresholdCounts = new long[pools.length];
+                    for (int i = 0; i < thresholdCounts.length; i++) {
+                        thresholdCounts[i] = 0;
+                    }
+
+                    while (goOn) {
+                        synchronized (object) {
+                            try {
+                                object.wait(WAIT_TIME);
+                            } catch (InterruptedException e) {
+
+                                // Stop the thread
+                                return;
+                            }
+                        } // synchronized
+
+                        for (int i = 0; i < pools.length; i++) {
+                            MemoryType mt = getType(pools[i]);
+
+                            if (!isUsageThresholdSupportedOnServer(pools[i])) {
+                                continue;
+                            }
+
+                            if ((!mt.equals(MemoryType.HEAP)
+                                    || !memory.equals(HEAP_TYPE))
+                                    && (!mt.equals(MemoryType.NON_HEAP)
+                                    || !memory.equals(NONHEAP_TYPE))
+                                    && !memory.equals(MIXED_TYPE)) {
+                                continue;
+                            }
+
+                            boolean exceeded;
+
+                            // The exception is not documented, but it may be
+                            // erroneously thrown
+                            try {
+                                exceeded = isUsageThresholdExceededOnServer(pools[i]);
+                            } catch (Failure e) {
+                                complain("Unexpected exception while retrieving "
+                                        + "isUsageThresholdExceeded() for pool "
+                                        + pools[i].toString());
+                                e.printStackTrace(logger.getOutStream());
+                                passed = false;
+                                continue;
+                            }
+
+                            if (!exceeded
+                                    || getUsageThresholdCount(pools[i]) == thresholdCounts[i]) {
+                                continue;
+                            }
+
+                            // Yes! We got the pool that
+                            // 1. supports usage threshold
+                            // 2. has type that match tested type
+                            // 3. its threshold is exceeded
+                            // So, update all thresholds
+                            long c = getUsageThresholdCount(pools[i]);
+                            if (c <= thresholdCounts[i]) {
+                                complain("Usage threshold count is not greater "
+                                        + "than previous one: " + c + " < "
+                                        + thresholdCounts[i] + " in pool "
+                                        + pools[i].toString());
+                                passed = false;
+                            }
+                            thresholdCounts[i] = c;
+                            displayInfo("Crossing is noticed", null, "pool: ", pools[i], "usage: ", getUsageOnServer(pools[i]));
+                            updateThresholds();
+                        } // for i
+                    } // while
+                    break;
+
+                default:
+                    throw new TestBug("Unknown testMode " + mode);
+            } // switch
+        } // pollUsageThresholds()
+
+        private void pollCollectionThresholds() {
+            switch (mode) {
+                case DIRECTLY_MODE:
+                // we can use the same code here for direct and proxy modes
+                case PROXY_MODE:
+                    List poolsMBean = ManagementFactory.getMemoryPoolMXBeans();
+
+                    // Create an array to store all threshold values
+                    thresholdCounts = new long[poolsMBean.size()];
+                    for (int i = 0; i < thresholdCounts.length; i++) {
+                        thresholdCounts[i] = 0;
+                    }
+
+                    while (goOn) {
+                        synchronized (object) {
+                            try {
+                                object.wait(WAIT_TIME);
+                            } catch (InterruptedException e) {
+
+                                // Stop the thread
+                                return;
+                            }
+                        } // synchronized
+
+                        for (int i = 0; i < poolsMBean.size(); i++) {
+                            MemoryPoolMXBean pool = (MemoryPoolMXBean) poolsMBean.get(i);
+                            MemoryType mt = pool.getType();
+
+                            if (!pool.isCollectionUsageThresholdSupported()) {
+                                continue;
+                            }
+
+                            if ((!mt.equals(MemoryType.HEAP)
+                                    || !memory.equals(HEAP_TYPE))
+                                    && (!mt.equals(MemoryType.NON_HEAP)
+                                    || !memory.equals(NONHEAP_TYPE))
+                                    && !memory.equals(MIXED_TYPE)) {
+                                continue;
+                            }
+
+                            boolean exceeded;
+
+                            // The exception is not documented, but it may be
+                            // erroneously thrown
+                            try {
+                                exceeded = pool.isCollectionUsageThresholdExceeded();
+                            } catch (IllegalArgumentException e) {
+                                complain("Unexpected exception while retrieving "
+                                        + "isCollectionUsageThresholdExceeded()"
+                                        + " for pool " + pool.getName());
+                                e.printStackTrace(logger.getOutStream());
+                                passed = false;
+                                continue;
+                            }
+
+                            if (!exceeded
+                                    || pool.getCollectionUsageThresholdCount()
+                                    == thresholdCounts[i]) {
+                                continue;
+                            }
+
+                            // Yes! We got thet pool that
+                            // 1. supports collection usage threshold
+                            // 2. has type that match tested type
+                            // 3. its threshold is exceeded
+                            // So, update all thresholds
+                            long c = pool.getCollectionUsageThresholdCount();
+                            if (c <= thresholdCounts[i]) {
+                                complain("Collection usage threshold count is "
+                                        + "not greater than previous one: " + c
+                                        + " < " + thresholdCounts[i] + " in pool "
+                                        + pool.getName());
+                                passed = false;
+                            }
+                            thresholdCounts[i] = c;
+                            displayInfo("Crossing is noticed", pool, "usage: ", pool.getUsage(), "count: ", c);
+                            updateThresholds();
+                        } // for i
+                    } // while
+                    break;
+
+                case SERVER_MODE:
+                    ObjectName[] pools = getMemoryPoolMXBeansOnServer();
+
+                    // Create an array to store all threshold values
+                    thresholdCounts = new long[pools.length];
+                    for (int i = 0; i < thresholdCounts.length; i++) {
+                        thresholdCounts[i] = 0;
+                    }
+
+                    while (goOn) {
+                        synchronized (object) {
+                            try {
+                                object.wait(WAIT_TIME);
+                            } catch (InterruptedException e) {
+
+                                // Stop the thread
+                                return;
+                            }
+                        } // synchronized
+
+                        for (int i = 0; i < pools.length; i++) {
+                            MemoryType mt = getType(pools[i]);
+
+                            if (!isCollectionThresholdSupportedOnServer(pools[i])) {
+                                continue;
+                            }
+
+                            if ((!mt.equals(MemoryType.HEAP)
+                                    || !memory.equals(HEAP_TYPE))
+                                    && (!mt.equals(MemoryType.NON_HEAP)
+                                    || !memory.equals(NONHEAP_TYPE))
+                                    && !memory.equals(MIXED_TYPE)) {
+                                continue;
+                            }
+
+                            boolean exceeded;
+
+                            // The exception is not documented, but it may be
+                            // erroneously thrown
+                            try {
+                                exceeded = isCollectionThresholdExceededOnServer(pools[i]);
+                            } catch (Failure e) {
+                                complain("Unexpected exception while retrieving "
+                                        + "isCollectionUsageThresholdExceeded() "
+                                        + "for pool " + pools[i].toString());
+                                e.printStackTrace(logger.getOutStream());
+                                passed = false;
+                                continue;
+                            }
+
+                            if (!exceeded
+                                    || getCollectionThresholdCountOnServer(pools[i])
+                                    == thresholdCounts[i]) {
+                                continue;
+                            }
+
+                            // Yes! We got thet pool that
+                            // 1. supports collection usage threshold
+                            // 2. has type that match tested type
+                            // 3. its threshold is exceeded
+                            // So, update all thresholds
+                            long c = getCollectionThresholdCountOnServer(pools[i]);
+                            if (c <= thresholdCounts[i]) {
+                                complain("Collection usage threshold count is "
+                                        + "not greater than previous one: " + c
+                                        + " < " + thresholdCounts[i] + " in pool "
+                                        + pools[i].toString());
+                                passed = false;
+                            }
+                            thresholdCounts[i] = c;
+                            displayInfo("Crossing is noticed", pools[i], "usage: ", getUsageOnServer(pools[i]), "count: ", c);
+                            updateThresholds();
+                        } // for i
+                    } // while
+                    break;
+
+                default:
+                    throw new TestBug("Unknown testMode " + mode);
+            } // switch
+        } // pollCollectionThresholds()
+    } // class Polling
+} // MemoryMonitor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/Monitor.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,465 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.lang.management.*;
+import javax.management.*;
+import javax.management.openmbean.*;
+import nsk.share.*;
+
+/**
+ * <code>Monitor</code> is a factory class for getting wrappers for monitoring
+ * interfaces.
+ * <p>This class consists of static methods that return an instance of a
+ * wapper. Depending on command line arguments, a wrapper redirects invocations
+ * interfaces directly, or accesses MBeans through MBeanServer</p>
+ *
+ * <p>At the same time <code>Monitor</code> is a base class for such wrappers.
+ * Each wrapper must override {@link #Monitor
+ * <code>Monitor(Log, ArgumentHandler)</code>} constructor, that receives
+ * command line options and creates a proper MBean server based on that options.
+ */
+public class Monitor {
+
+    /**
+     * <code>Directly</code> mode -- the MBeans' methods are accessed directly
+     * within the same JVM.
+     */
+    public static final int DIRECTLY_MODE = 0;
+
+    /**
+     * <code>Server</code> mode -- the MBeans' methods are accessed through
+     * default MBeanServer.
+     */
+    public static final int SERVER_MODE = 1;
+
+    /**
+     * <code>Server</code> mode -- the MBeans' methods are accessed through
+     * MBean proxy.
+     */
+    public static final int PROXY_MODE = 2;
+
+    /**
+     * Prefix string to print while logging.
+     */
+    protected static String logPrefix;
+
+    /**
+     * <code>Logger</code> object to print info in.
+     */
+    protected Log.Logger logger;
+
+    /**
+     * An <code>ObjectName</code> object to represent somespecific MBean.
+     */
+    protected ObjectName mbeanObjectName;
+
+    // Some private variables
+    private static int testMode;
+    private static MBeanServer mbeanServer = null;
+
+    /**
+     * Creates a new <code>Monitor</code> object. The arguments that are passed
+     * to the test are parsed.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     */
+    protected Monitor(Log log, ArgumentHandler argumentHandler) {
+        if (log != null)
+            logger = new Log.Logger(log, logPrefix);
+        readArguments(argumentHandler);
+    }
+
+    /**
+     * Returns the test mode code.
+     *
+     * @return the test mode code.
+     *
+     * @see Monitor#DIRECTLY_MODE
+     * @see Monitor#SERVER_MODE
+     * @see Monitor#PROXY_MODE
+     *
+     */
+    public static int getTestMode() {
+        return testMode;
+    }
+
+    /**
+     * Returns MBean server if <code>"server"</code> is assigned to
+     * <code>-testMode</code>, i.e. the metrics are accessed through default
+     * or custom MBeanServer.
+     *
+     * @return MBean server
+     */
+    public static MBeanServer getMBeanServer() {
+        return mbeanServer;
+    }
+
+    // Parse the arguments passed to the test
+    private void readArguments(ArgumentHandler argumentHandler) {
+        String tmp = argumentHandler.getTestMode();
+        String tmp1 = "Test mode:\t";
+
+        if (tmp.equals(ArgumentHandler.DIRECTLY_MODE)) {
+            testMode = DIRECTLY_MODE;
+            display(tmp1 + "DIRECTLY access to MBean");
+        } else if (tmp.equals(ArgumentHandler.SERVER_MODE)) {
+            testMode = SERVER_MODE;
+            display(tmp1 + "access to MBean through MBeanServer");
+        } else if (tmp.equals(ArgumentHandler.PROXY_MODE)) {
+            testMode = PROXY_MODE;
+            display(tmp1 + "access to MBean through proxy");
+        } else {
+            throw new Failure("UNKNOWN test mode.");
+        }
+
+        if (testMode == SERVER_MODE || testMode == PROXY_MODE)
+            createMBeanServer(argumentHandler.isDefaultServer());
+    }
+
+    // Create a new either default, or custom MBeanServer
+    private void createMBeanServer(boolean defaultServer) {
+        String tmp = "MBeanServer:\t";
+        if (defaultServer) {
+            System.setProperty(CustomMBeanServer.SERVER_BUILDER_PROPERTY,
+                               CustomMBeanServer.DEFAULT_SERVER_BUILDER);
+            display(tmp + "DEFAULT");
+        } else {
+            System.setProperty(CustomMBeanServer.SERVER_BUILDER_PROPERTY,
+                               CustomMBeanServer.CUSTOM_SERVER_BUILDER);
+            display(tmp + "CUSTOM");
+        }
+
+        mbeanServer = ManagementFactory.getPlatformMBeanServer();
+        if (!defaultServer)
+            ((CustomMBeanServer) mbeanServer).setLog(logger.getLog());
+    }
+
+    /**
+     * Creates an instance of the <code>ClassLoadingMonitor</code> class to
+     * provide class loading/unloading monitoring.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     * @return New <code>ClassLoadingMonitor</code> instance.
+     *
+     * @see ArgumentHandler
+     */
+    public static ClassLoadingMonitor getClassLoadingMonitor(Log log,
+                                              ArgumentHandler argumentHandler) {
+
+        ClassLoadingMonitor monitor
+            = new ClassLoadingMonitor(log, argumentHandler);
+        createMBean(monitor, ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
+        return monitor;
+    }
+
+    /**
+     * Creates an instance of the <code>MemoryMonitor</code> class to
+     * provide control on heap and non-heap memory.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     * @return New <code>MemoryMonitor</code> instance.
+     *
+     * @see ArgumentHandler
+     */
+    public static MemoryMonitor getMemoryMonitor(Log log,
+                                              ArgumentHandler argumentHandler) {
+
+        MemoryMonitor monitor = new MemoryMonitor(log, argumentHandler);
+        createMBean(monitor, ManagementFactory.MEMORY_MXBEAN_NAME);
+        return monitor;
+    }
+
+    /**
+     * Creates an instance of the <code>ThreadMonitor</code> class to
+     * provide control on threads.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     * @return New <code>ThreadMonitor</code> instance.
+     *
+     * @see ArgumentHandler
+     */
+    public static ThreadMonitor getThreadMonitor(Log log,
+                                              ArgumentHandler argumentHandler) {
+
+        ThreadMonitor monitor = new ThreadMonitor(log, argumentHandler);
+        createMBean(monitor, ManagementFactory.THREAD_MXBEAN_NAME);
+        return monitor;
+    }
+
+    /**
+     * Creates an instance of the <code>RuntimeMonitor</code> class to
+     * provide control on runtime enviroment.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     * @return New <code>RuntimeMonitor</code> instance.
+     *
+     * @see ArgumentHandler
+     */
+    public static RuntimeMonitor getRuntimeMonitor(Log log,
+                                              ArgumentHandler argumentHandler) {
+
+        RuntimeMonitor monitor = new RuntimeMonitor(log, argumentHandler);
+        createMBean(monitor, ManagementFactory.RUNTIME_MXBEAN_NAME);
+        return monitor;
+    }
+
+    /**
+     * Creates an instance of the <code>CompilationMonitor</code> class to
+     * provide control on compilation system.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     * @return New <code>CompilationMonitor</code> instance.
+     *
+     * @see ArgumentHandler
+     */
+    public static CompilationMonitor getCompilationMonitor(Log log,
+                                              ArgumentHandler argumentHandler) {
+
+        CompilationMonitor monitor
+            = new CompilationMonitor(log, argumentHandler);
+        createMBean(monitor, ManagementFactory.COMPILATION_MXBEAN_NAME);
+        return monitor;
+    }
+
+    /**
+     * Creates an instance of the <code>LoggingMonitor</code> class to
+     * provide control on logging system.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     * @return New <code>LoggingMonitor</code> instance.
+     *
+     * @see ArgumentHandler
+     */
+    public static LoggingMonitor getLoggingMonitor(Log log,
+                                              ArgumentHandler argumentHandler) {
+
+        LoggingMonitor monitor
+            = new LoggingMonitor(log, argumentHandler);
+        createMBean(monitor, LoggingMonitor.LOGGING_MXBEAN_NAME);
+        return monitor;
+    }
+
+    /**
+     * Creates an instance of the <code>GarbageCollectorMonitor</code> class to
+     * provide control on logging system.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     * @return New <code>GarbageCollectorMonitor</code> instance.
+     *
+     * @see ArgumentHandler
+     */
+    public static GarbageCollectorMonitor getGarbageCollectorMonitor(Log log,
+                                              ArgumentHandler argumentHandler) {
+
+        GarbageCollectorMonitor monitor
+            = new GarbageCollectorMonitor(log, argumentHandler);
+        createMBean(monitor,
+            GarbageCollectorMonitor.GARBAGECOLLECTOR_MXBEAN_NAME);
+        return monitor;
+    }
+
+    /**
+     * Displays <code>message</code> using <code>Log.Logger</code> object.
+     */
+    protected void display(String message) {
+        if (logger != null)
+            logger.display(message);
+    }
+
+    /**
+     * Displays an error <code>message</code> using <code>Log.Logger</code>
+     * object.
+     */
+    protected void complain(String message) {
+        if (logger != null)
+            logger.complain(message);
+    }
+
+    /**
+     * Retrieves the <code>boolean</code> value of the specified attribute
+     * from MBeanServer.
+     *
+     * @param object MBean's <code>ObjectName</code>
+     * @param name name of the attribute.
+     *
+     * @return value of the attribute.
+     */
+    protected boolean getBooleanAttribute(ObjectName object, String name) {
+        try {
+            Boolean b = (Boolean) getMBeanServer().getAttribute(object, name);
+            return b.booleanValue();
+        } catch (Exception e) {
+            throw new Failure(e);
+        }
+    } // getBooleanAttribute()
+
+    /**
+     * Retrieves the <code>int</code> value of the specified attribute
+     * from MBeanServer.
+     *
+     * @param object MBean's <code>ObjectName</code>
+     * @param name name of the attribute.
+     *
+     * @return value of the attribute.
+     */
+    protected int getIntAttribute(ObjectName object, String name) {
+        try {
+            Integer i = (Integer) getMBeanServer().getAttribute(object, name);
+            return i.intValue();
+        } catch (Exception e) {
+            throw new Failure(e);
+        }
+    } // getIntAttribute()
+
+    /**
+     * Retrieves the <code>long</code> value of the specified attribute
+     * from MBeanServer.
+     *
+     * @param object MBean's <code>ObjectName</code>
+     * @param name name of the attribute.
+     *
+     * @return value of the attribute.
+     */
+    protected long getLongAttribute(ObjectName object, String name) {
+        try {
+            Long l = (Long) getMBeanServer().getAttribute(object, name);
+            return l.longValue();
+        } catch (Exception e) {
+            throw new Failure(e);
+        }
+    } // getLongAttribute()
+
+    /**
+     * Retrieves the array of <code>long</code> -- value of the specified
+     * attribute from MBeanServer.
+     *
+     * @param object MBean's <code>ObjectName</code>
+     * @param name name of the attribute.
+     *
+     * @return value of the attribute.
+     */
+    protected long[] getLongArrayAttribute(ObjectName object, String name) {
+        try {
+            Object o = (Object) getMBeanServer().getAttribute(object, name);
+            return (long[]) o;
+        } catch (Exception e) {
+            throw new Failure(e);
+        }
+    } // getLongArrayAttribute()
+
+    /**
+     * Retrieves the <code>MemoryUsage</code> value of the specified attribute
+     * from MBeanServer.
+     *
+     * @param object MBean's <code>ObjectName</code>
+     * @param name name of the attribute.
+     *
+     * @return value of the attribute.
+     */
+    protected MemoryUsage getMemoryUsageAttribute(ObjectName object,
+                                                                   String name) {
+        try {
+                Object data = getMBeanServer().getAttribute(object, name);
+                if (data instanceof MemoryUsage)
+                        return (MemoryUsage) data;
+                return MemoryUsage.from((CompositeData) data);
+        } catch (Exception e) {
+            throw new Failure(e);
+        }
+    } // getMemoryUsageAttribute()
+
+    /**
+     * Sets the <code>long</code> value to the specified attribute from
+     * MBeanServer.
+     *
+     * @param object MBean's <code>ObjectName</code>
+     * @param name name of the attribute.
+     * @param value value of the attribute.
+     */
+    protected void setLongAttribute(ObjectName object, String name,
+                                                                   long value) {
+        Attribute attribute = new Attribute(name, new Long(value));
+
+        try {
+            getMBeanServer().setAttribute(object, attribute);
+        } catch (Exception e) {
+            throw new Failure(e);
+        }
+    } // setLongAttribute()
+
+    /**
+     * Sets the <code>boolean</code> value to the specified attribute from
+     * MBeanServer.
+     *
+     * @param object MBean's <code>ObjectName</code>
+     * @param name name of the attribute.
+     * @param value value of the attribute.
+     */
+    protected void setBooleanAttribute(ObjectName object, String name,
+                                                                boolean value) {
+        Attribute attribute = new Attribute(name, new Boolean(value));
+
+        try {
+            getMBeanServer().setAttribute(object, attribute);
+        } catch (Exception e) {
+            throw new Failure(e);
+        }
+    } // setBooleanAttribute()
+
+    // Create a new MBean with specified object name
+    private static void createMBean(Monitor monitor, String name) {
+
+        if (testMode == SERVER_MODE || testMode == PROXY_MODE) {
+            try {
+                monitor.mbeanObjectName = new ObjectName(name);
+            } catch (MalformedObjectNameException e) {
+                throw new Failure(e);
+            }
+        }
+    }
+} // Monitor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/Monitoring.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import nsk.share.test.*;
+import nsk.share.runner.*;
+import nsk.share.log.Log;
+import java.lang.management.*;
+import javax.management.*;
+import nsk.monitoring.share.thread.RunningThread;
+import nsk.monitoring.share.thread.SleepingThread;
+import nsk.monitoring.share.thread.WaitingThread;
+import nsk.monitoring.share.thread.BlockedThread;
+import nsk.monitoring.share.thread.*;
+import nsk.monitoring.share.direct.DirectMonitoringFactory;
+import nsk.monitoring.share.server.ServerMonitoringFactory;
+import nsk.monitoring.share.proxy.ProxyMonitoringFactory;
+import nsk.share.TestBug;
+import nsk.share.Failure;
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+
+public class Monitoring extends nsk.share.test.Tests {
+        private Monitoring() {
+        }
+
+        /**
+         * Convert monitoring exception.
+         *
+         * @param e exception
+         * @return converted exception
+         */
+        public static RuntimeException convertException(Throwable e) {
+                //e.printStackTrace(logger.getOutStream());
+                return new Failure(e);
+        }
+
+        protected static class MonitoringTestRunner extends TestRunner {
+                private ArgumentHandler argHandler;
+
+                public MonitoringTestRunner(Test test, String[] args) {
+                        super(test, args);
+                }
+
+                public synchronized ArgumentHandler getArgumentHandler(String[] args) {
+                        if (argHandler == null)
+                                argHandler = new ArgumentHandler(args);
+                        return argHandler;
+                }
+
+                public synchronized MonitoringFactory getMonitoringFactory(String testMode, String serverType) {
+                        if (testMode.equals(ArgumentHandler.DIRECTLY_MODE))
+                                return new DirectMonitoringFactory();
+                        else if (testMode.equals(ArgumentHandler.SERVER_MODE))
+                                return new ServerMonitoringFactory(getMBeanServer(serverType));
+                        else if (testMode.equals(ArgumentHandler.PROXY_MODE))
+                                return new ProxyMonitoringFactory(getMBeanServer(serverType));
+                        else
+                                throw new TestBug("Unknown test mode" + testMode);
+                }
+
+                public synchronized MBeanServer getMBeanServer(String serverType) {
+                        if (serverType.equals(ArgumentHandler.DEFAULT_TYPE))
+                                return ManagementFactory.getPlatformMBeanServer();
+                        else {
+                                System.setProperty(CustomMBeanServer.SERVER_BUILDER_PROPERTY, CustomMBeanServer.CUSTOM_SERVER_BUILDER);
+                                return ManagementFactory.getPlatformMBeanServer();
+                        }
+                }
+
+
+                public void configure(Object o) {
+                        super.configure(o);
+                        if (o instanceof ArgumentHandlerAware)
+                                ((ArgumentHandlerAware) o).setArgumentHandler(getArgumentHandler(args));
+                        if (o instanceof MonitoringFactoryAware) {
+                                ArgumentHandler argHandler = getArgumentHandler(args);
+                                MonitoringFactory mfactory = getMonitoringFactory(argHandler.getTestMode(), argHandler.getServerType());
+                                ((MonitoringFactoryAware) o).setMonitoringFactory(mfactory);
+                        }
+                        if (o instanceof ScenarioTypeAware) {
+                                ArgumentHandler argHandler = getArgumentHandler(args);
+                                ((ScenarioTypeAware) o).setScenarioType(argHandler.getScenarioType());
+                        }
+                }
+        }
+
+        public static void runTest(Test test, String[] args) {
+                new MonitoringTestRunner(test, args).run();
+        }
+
+        public static Collection<ObjectName> queryNamesByStart(MBeanServer mbeanServer, String name) {
+                try {
+                        ObjectName pattern = ObjectName.getInstance(name + "*");
+                        Set<ObjectName> query = mbeanServer.queryNames(pattern, null);
+                        List<ObjectName> list = new ArrayList<ObjectName>(query.size());
+                        for (ObjectName oname : query) {
+                            list.add(oname);
+                        }
+                        return list;
+                } catch (Exception e) {
+                        throw convertException(e);
+                }
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/MonitoringFactory.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.util.List;
+import java.lang.management.*;
+import javax.management.*;
+
+/**
+ * This factory encapsulates a way to obtain VM monitoring beans.
+ *
+ * There are currently three implementations.
+ * {@link nsk.monitoring.share.direct.DirectMonitoringFactory} obtains
+ * them directly through {@link java.lang.management.MonitoringFactory}.
+ * {@link nsk.monitoring.share.proxy.ProxyMonitoringFactory} obtains
+ * proxies for a given MBeanServer.
+ * {@link nsk.monitoring.share.server.ServerMonitoringFactory} obtains
+ * MXBeans that use MBeanServer property methods to do it's work.
+ *
+ * @see nsk.monitoring.share.direct.DirectMonitoringFactory
+ * @see nsk.monitoring.share.proxy.ProxyMonitoringFactory
+ * @see nsk.monitoring.share.server.ServerMonitoringFactory
+ */
+public interface MonitoringFactory {
+        /**
+         * Obtain ClassLoadingMXBean.
+         */
+        public ClassLoadingMXBean getClassLoadingMXBean();
+
+        /**
+         * Check if CompilationMXBean is available.
+         *
+         * It may be unavailable if VM does not have a compilation
+         * system, for example when -Xint option is used.
+         *
+         * @return true if CompilationMXBean is available, false
+         * otherwise
+         */
+        public boolean hasCompilationMXBean();
+
+        /**
+         * Obtain CompilationMXBean
+         */
+        public CompilationMXBean getCompilationMXBean();
+
+        /**
+         * Obtain GarbageCollectorMXBean's.
+         */
+        public List<GarbageCollectorMXBean> getGarbageCollectorMXBeans();
+
+        /**
+         * Obtain RuntimeMXBean.
+         */
+        public RuntimeMXBean getRuntimeMXBean();
+
+        /**
+         * Obtain MemoryMXBean.
+         */
+        public MemoryMXBean getMemoryMXBean();
+
+        /**
+         * Obtain NotificationEmitter for MemoryMXBean.
+         */
+        public NotificationEmitter getMemoryMXBeanNotificationEmitter();
+
+        /**
+         * Obtain MemoryPoolMXBean's.
+         */
+        public List<MemoryPoolMXBean> getMemoryPoolMXBeans();
+
+        /**
+         * Obtain ThreadMXBean.
+         */
+        public ThreadMXBean getThreadMXBean();
+
+         /**
+         * Check if com.sun.managementThreadMXBean is available.
+         *
+         * It may be unavailable if corresponding API is not integrated
+         * into JDK under test and ThreadImpl does not inherit c.s.m.ThreadMXBean
+         *
+         * @return true if c.s.m.ThreadMXBean is available, false
+         * otherwise
+         */
+        public boolean hasThreadMXBeanNew();
+
+         /**
+         * Obtain com.sun.management.ThreadMXBean.
+         */
+        public ThreadMXBean getThreadMXBeanNew();
+
+        /*
+        public OperatingSystemMXBean getOperatingSystemMXBean();
+        */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/MonitoringFactoryAware.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+/**
+ * Marker interface that signifies that MonitoringFactory is needed.
+ *
+ * @see nsk.monitoring.share.MonitoringFactory
+ */
+public interface MonitoringFactoryAware {
+        public void setMonitoringFactory(MonitoringFactory mfactory);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/MonitoringTestBase.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import nsk.share.test.*;
+
+public abstract class MonitoringTestBase extends TestBase implements MonitoringFactoryAware, ArgumentHandlerAware {
+        protected MonitoringFactory monitoringFactory;
+        protected ArgumentHandler argHandler;
+
+        public final void setMonitoringFactory(MonitoringFactory monitoringFactory) {
+                this.monitoringFactory = monitoringFactory;
+        }
+
+        public final void setArgumentHandler(ArgumentHandler argHandler) {
+                this.argHandler = argHandler;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/RuntimeMonitor.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.lang.management.*;
+import javax.management.*;
+import nsk.share.*;
+
+/**
+ * <code>RuntimeMonitor</code> class is a wrapper of <code>RuntimeMXBean</code>.
+ * Depending on command line arguments, an instance of this class redirects
+ * invocations to the <code>RuntimeMXBean</code> interface. If
+ * <code>-testMode="directly"</code> option is set, this instance directly
+ * invokes corresponding method of the <code>RuntimeMXBean</code> interface. If
+ * <code>-testMode="server"</code> option is set it will make invocations via
+ * MBeanServer. If <code>-testMode="proxy"</code> option is set it will make
+ * invocations via MBeanServer proxy.
+ *
+ * @see ArgumentHandler
+ */
+public class RuntimeMonitor extends Monitor {
+    // An instance of ClassLoadingMBean
+    private final static RuntimeMXBean mbean
+        = ManagementFactory.getRuntimeMXBean();
+
+    // Name of an attribute of RuntimeMonitor
+    private static final String IS_BOOT = "BootClassPathSupported";
+
+    private RuntimeMXBean proxyInstance;
+
+    static {
+        Monitor.logPrefix = "RuntimeMonitor> ";
+    }
+
+    /**
+     * Creates a new <code>RuntimeMonitor</code> object.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     */
+    public RuntimeMonitor(Log log, ArgumentHandler argumentHandler) {
+        super(log, argumentHandler);
+    }
+
+    /**
+     *
+     * Return a proxy instance for a platform
+     * {@link java.lang.management.RuntimeMXBean
+     * <code>RuntimeMXBean</code>} interface.
+     *
+     */
+    RuntimeMXBean getProxy() {
+        if (proxyInstance == null) {
+            // create proxy instance
+            try {
+                proxyInstance = (RuntimeMXBean)
+                ManagementFactory.newPlatformMXBeanProxy(
+                    getMBeanServer(),
+                    ManagementFactory.RUNTIME_MXBEAN_NAME,
+                    RuntimeMXBean.class
+                );
+            } catch (java.io.IOException e) {
+                throw new Failure(e);
+            }
+        }
+        return proxyInstance;
+    }
+
+    /**
+     * Redirects the invocation to
+     * {@link java.lang.management.RuntimeMXBean#isBootClassPathSupported()
+     * <code>RuntimeMXBean.isBootClassPathSupported()</code>}.
+     *
+     * @return <code>true</code>, if the JVM supports the class path mechanism;
+     *         <code>flase</code> otherwise.
+     */
+    public boolean isBootClassPathSupported() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            return mbean.isBootClassPathSupported();
+
+        case SERVER_MODE:
+            return getBooleanAttribute(mbeanObjectName, IS_BOOT);
+
+        case PROXY_MODE:
+            return getProxy().isBootClassPathSupported();
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+} // RuntimeMonitor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ServerNotificationEmitter.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import javax.management.*;
+
+/**
+ * NotificationEmitter that delegates functionality to MBeanServer.
+ */
+public class ServerNotificationEmitter implements NotificationEmitter {
+        private MBeanServer mbeanServer;
+        private ObjectName name;
+
+        public ServerNotificationEmitter(MBeanServer mbeanServer, ObjectName name) {
+                this.mbeanServer = mbeanServer;
+                this.name = name;
+        }
+
+        public ServerNotificationEmitter(MBeanServer mbeanServer, String name) {
+                try {
+                        this.mbeanServer = mbeanServer;
+                        this.name = new ObjectName(name);
+                } catch (MalformedObjectNameException e) {
+                        throw Monitoring.convertException(e);
+                }
+        }
+
+        public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)  {
+                try {
+                        mbeanServer.addNotificationListener(name, listener, filter, handback);
+                } catch (InstanceNotFoundException e) {
+                        throw Monitoring.convertException(e);
+                }
+        }
+
+        public MBeanNotificationInfo[] getNotificationInfo() {
+                throw new TestBug("ServerNotificationEmitter.getNotificationInfo() not implemented.");
+        }
+
+        public void removeNotificationListener(NotificationListener listener)
+                throws ListenerNotFoundException {
+                try {
+                        mbeanServer.removeNotificationListener(name, listener);
+                } catch (InstanceNotFoundException e) {
+                        throw Monitoring.convertException(e);
+                }
+        }
+
+        public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
+                throws ListenerNotFoundException {
+                try {
+                        mbeanServer.removeNotificationListener(name, listener, filter, handback);
+                } catch (InstanceNotFoundException e) {
+                        throw Monitoring.convertException(e);
+                }
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/StackTraceController.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+#include <stdio.h>
+#include "jni_tools.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GET_OBJECT_CLASS(_class, _obj)\
+    if (!NSK_JNI_VERIFY(env, (_class = \
+            NSK_CPP_STUB2(GetObjectClass, env, _obj)) != NULL))\
+        return 2
+
+#define CALL_STATIC_VOID_NOPARAM(_class, _methodName)\
+    GET_STATIC_METHOD_ID(method, _class, _methodName, "()V");\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB3(CallStaticVoidMethod, env,\
+                            _class, method)))\
+        return 2
+
+#define GET_STATIC_METHOD_ID(_methodID, _class, _methodName, _sig)\
+    if (!NSK_JNI_VERIFY(env, (_methodID = \
+            NSK_CPP_STUB4(GetStaticMethodID, env, _class,\
+                _methodName, _sig)) != NULL))\
+        return 2
+
+#define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\
+    if (!NSK_JNI_VERIFY(env, (_methodID = \
+            NSK_CPP_STUB4(GetMethodID, env, _class,\
+                _methodName, _sig)) != NULL))\
+        return 2
+
+#define CALL_VOID_NOPARAM(_obj, _class, _methodName)\
+    GET_METHOD_ID(method, _class, _methodName, "()V");\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB3(CallVoidMethod, env, _obj,\
+                                                    method)))\
+        return 2
+
+JNIEXPORT jint JNICALL
+Java_nsk_monitoring_stress_thread_RunningThread_recursionNative(JNIEnv *env,
+         jobject obj, jint maxDepth, jint currentDepth, jboolean returnToJava) {
+    jmethodID method;
+    jclass threadClass;
+
+    GET_OBJECT_CLASS(threadClass, obj);
+    currentDepth++;
+
+    if (maxDepth > currentDepth) {
+        CALL_STATIC_VOID_NOPARAM(threadClass, "yield");
+
+        if (returnToJava) {
+            GET_METHOD_ID(method, threadClass, "recursionJava", "(II)V");
+            if (!NSK_JNI_VERIFY_VOID(env,
+                                     NSK_CPP_STUB5(CallIntMethod, env, obj,
+                                                   method, maxDepth,
+                                                   currentDepth))) {
+                return 1;
+            }
+        } else {
+            GET_METHOD_ID(method, threadClass, "recursionNative", "(IIZ)I");
+            if (!NSK_JNI_VERIFY_VOID(env,
+                                     NSK_CPP_STUB6(CallIntMethod, env, obj,
+                                                   method, maxDepth,
+                                                   currentDepth,
+                                                   returnToJava))) {
+                return 1;
+            }
+        }
+    }
+    CALL_VOID_NOPARAM(obj, threadClass, "waitForSign");
+    return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/StateController.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import nsk.share.*;
+
+/**
+ * An abstract base class for operating VM state. The follow methods must
+ * be implemented by its subclasses:
+ * <ul>
+ *      <li><code>run()</code> -- brings VM into defined state.
+ *      <li><code>reset()</code> -- tries to reclaim VM into initial state.
+ * </ul>
+ */
+public abstract class StateController implements Runnable {
+
+    /**
+     * Public default constructor.
+     */
+    public StateController() {
+        super();
+    }
+
+    /**
+     * A string that is printed before each string when {@link Log#complain
+     * <code>Log.complain()</code>}, and {@link Log#display
+     * <code>Log.display()</code>} are invoked.
+     */
+    protected String logPrefix;
+
+    /**
+     * A variable to save reference to {@link Log <code>Log.Logger</code>}
+     * class.
+     */
+    protected Log.Logger logger;
+
+    /**
+     * Brings VM into defined state.
+     */
+    public abstract void run();
+
+    /**
+     * Tries to reclaim VM into initial state
+     */
+    public abstract void reset();
+
+    /**
+     * Outputs <code>message</code> using {@link Log <code>Log.Logger</code>}
+     * object.
+     */
+    protected void display(String message) {
+        if (logger != null)
+            logger.display(message);
+    }
+
+    /**
+     * Outputs <code>message</code> using {@link Log <code>Log.Logger</code>}
+     * object.
+     */
+    protected void complain(String message) {
+        if (logger != null)
+            logger.complain(message);
+    }
+
+    /**
+     * Defines {@link Log <code>Log.Logger</code>} object.
+     */
+    public void setLog(Log log) {
+        logger = new Log.Logger(log, logPrefix);
+    }
+
+    /**
+     * Converts an integer to string.
+     *
+     * @param i an integer to convert.
+     * @return a string that represents the int value.
+     */
+    public String int2Str(int i) {
+        String tmp = "";
+
+        if (i < 10) {
+            tmp = "00";
+        } else if (i >= 10 && i < 100) {
+            tmp = "0";
+        }
+        return tmp + String.valueOf(i);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/StateControllerBase.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import nsk.share.log.*;
+
+/**
+ * An abstract base class for operating VM state. The follow methods must
+ * be implemented by its subclasses:
+ * <ul>
+ *      <li><code>run()</code> -- brings VM into defined state.
+ *      <li><code>reset()</code> -- tries to reclaim VM into initial state.
+ * </ul>
+ */
+public abstract class StateControllerBase implements LogAware {
+        protected Log log;
+
+        public StateControllerBase(Log log) {
+                this.log = log;
+        }
+
+        /**
+         * Brings VM into defined state.
+         */
+        public abstract void run();
+
+        /**
+         * Tries to reclaim VM into initial state
+         */
+        public abstract void reset();
+
+        /**
+         * Defines {@link Log <code>Log.Logger</code>} object.
+         */
+        public final void setLog(Log log) {
+                this.log = log;
+        }
+
+        /**
+         * Converts an integer to string.
+         *
+         * @param i an integer to convert.
+         * @return a string that represents the int value.
+         */
+        protected String int2Str(int i) {
+                String tmp = "";
+
+                if (i < 10) {
+                        tmp = "00";
+                } else if (i >= 10 && i < 100) {
+                        tmp = "0";
+                }
+                return tmp + String.valueOf(i);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,531 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <assert.h>
+#include <jni.h>
+#include <jvmti.h>
+#include <stdio.h>
+#include "jni_tools.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define FIND_CLASS(_class, _className)\
+    if (!NSK_JNI_VERIFY(env, (_class = \
+            NSK_CPP_STUB2(FindClass, env, _className)) != NULL))\
+        return
+
+#define GET_OBJECT_CLASS(_class, _obj)\
+    if (!NSK_JNI_VERIFY(env, (_class = \
+            NSK_CPP_STUB2(GetObjectClass, env, _obj)) != NULL))\
+        return
+
+#define GET_STATIC_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\
+    if (!NSK_JNI_VERIFY(env, (_fieldID = \
+            NSK_CPP_STUB4(GetStaticFieldID, env, _class,\
+                _fieldName, _fieldSig)) != NULL))\
+        return
+
+#define GET_STATIC_OBJ_FIELD(_value, _class, _fieldName, _fieldSig)\
+    GET_STATIC_FIELD_ID(field, _class, _fieldName, _fieldSig);\
+    _value = NSK_CPP_STUB3(GetStaticObjectField, env, _class, \
+                                field)
+
+#define GET_STATIC_BOOL_FIELD(_value, _class, _fieldName)\
+    GET_STATIC_FIELD_ID(field, _class, _fieldName, "Z");\
+    _value = NSK_CPP_STUB3(GetStaticBooleanField, env, _class, field)
+
+#define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\
+    if (!NSK_JNI_VERIFY(env, (_fieldID = \
+            NSK_CPP_STUB4(GetFieldID, env, _class,\
+                _fieldName, _fieldSig)) != NULL))\
+        return
+
+#define GET_INT_FIELD(_value, _obj, _class, _fieldName)\
+    GET_FIELD_ID(field, _class, _fieldName, "I");\
+    _value = NSK_CPP_STUB3(GetIntField, env, _obj, field)
+
+#define GET_BOOL_FIELD(_value, _obj, _class, _fieldName)\
+    GET_FIELD_ID(field, _class, _fieldName, "Z");\
+    _value = NSK_CPP_STUB3(GetBooleanField, env, _obj, field)
+
+#define GET_LONG_FIELD(_value, _obj, _class, _fieldName)\
+    GET_FIELD_ID(field, _class, _fieldName, "J");\
+    _value = NSK_CPP_STUB3(GetLongField, env, _obj, field)
+
+#define GET_STATIC_INT_FIELD(_value, _class, _fieldName)\
+    GET_STATIC_FIELD_ID(field, _class, _fieldName, "I");\
+    _value = NSK_CPP_STUB3(GetStaticIntField, env, _class, field)
+
+#define SET_INT_FIELD(_obj, _class, _fieldName, _newValue)\
+    GET_FIELD_ID(field, _class, _fieldName, "I");\
+    NSK_CPP_STUB4(SetIntField, env, _obj, field, _newValue)
+
+#define GET_OBJ_FIELD(_value, _obj, _class, _fieldName, _fieldSig)\
+    GET_FIELD_ID(field, _class, _fieldName, _fieldSig);\
+    _value = NSK_CPP_STUB3(GetObjectField, env, _obj, field)
+
+
+#define GET_ARR_ELEMENT(_arr, _index)\
+    NSK_CPP_STUB3(GetObjectArrayElement, env, _arr, _index)
+
+#define SET_ARR_ELEMENT(_arr, _index, _newValue)\
+    NSK_CPP_STUB4(SetObjectArrayElement, env, _arr, _index, _newValue)
+
+#define GET_STATIC_METHOD_ID(_methodID, _class, _methodName, _sig)\
+    if (!NSK_JNI_VERIFY(env, (_methodID = \
+            NSK_CPP_STUB4(GetStaticMethodID, env, _class,\
+                _methodName, _sig)) != NULL))\
+        return
+
+#define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\
+    if (!NSK_JNI_VERIFY(env, (_methodID = \
+            NSK_CPP_STUB4(GetMethodID, env, _class,\
+                _methodName, _sig)) != NULL))\
+        return
+
+#define CALL_STATIC_VOID_NOPARAM(_class, _methodName)\
+    GET_STATIC_METHOD_ID(method, _class, _methodName, "()V");\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB3(CallStaticVoidMethod, env,\
+                            _class, method)))\
+        return
+
+#define CALL_STATIC_VOID(_class, _methodName, _sig, _param)\
+    GET_STATIC_METHOD_ID(method, _class, _methodName, _sig);\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB4(CallStaticVoidMethod, env,\
+                                                    _class, method, _param)))\
+        return
+
+#define CALL_STATIC_OBJ(_value, _class, _methodName, _sig, _param)\
+    GET_STATIC_METHOD_ID(method, _class, _methodName, _sig);\
+    _value = NSK_CPP_STUB4(CallStaticObjectMethod, env, _class, method, _param)
+
+#define CALL_VOID_NOPARAM(_obj, _class, _methodName)\
+    GET_METHOD_ID(method, _class, _methodName, "()V");\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB3(CallVoidMethod, env, _obj,\
+                                                    method)))\
+        return
+
+#define CALL_VOID(_obj, _class, _methodName, _sig, _param)\
+    GET_METHOD_ID(method, _class, _methodName, "()V");\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB4(CallVoidMethod, env, _obj,\
+                                                    method, _param)))\
+        return
+
+#define CALL_VOID2(_obj, _class, _methodName, _sig, _param1, _param2)\
+    GET_METHOD_ID(method, _class, _methodName, _sig);\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB5(CallVoidMethod, env, _obj, \
+                                                    method, _param1, _param2)))\
+        return
+
+#define CALL_INT_NOPARAM(_value, _obj, _class, _methodName)\
+    GET_METHOD_ID(method, _class, _methodName, "()I");\
+    _value = NSK_CPP_STUB3(CallIntMethod, env, _obj, method)
+
+#define NEW_OBJ(_obj, _class, _constructorName, _sig, _params)\
+    GET_METHOD_ID(method, _class, _constructorName, _sig);\
+    if (!NSK_JNI_VERIFY(env, (_obj = \
+            NSK_CPP_STUB4(NewObject, env, _class, method, _params)) != NULL))\
+        return
+
+#define MONITOR_ENTER(x) \
+    NSK_JNI_VERIFY(env, NSK_CPP_STUB2(MonitorEnter, env, x) == 0)
+
+#define MONITOR_EXIT(x) \
+    NSK_JNI_VERIFY(env, NSK_CPP_STUB2(MonitorExit, env, x) == 0)
+
+#define TRACE(msg)\
+   GET_OBJ_FIELD(logger, obj, threadClass, "logger", "Lnsk/share/Log$Logger;");\
+   jmsg = NSK_CPP_STUB2(NewStringUTF, env, msg);\
+   CALL_VOID2(logger, loggerClass, "trace",\
+                           "(ILjava/lang/String;)V", 50, jmsg)
+
+    static const char *SctrlClassName="nsk/monitoring/share/ThreadController";
+    static const char *SthreadControllerSig
+    = "Lnsk/monitoring/share/ThreadController;";
+
+    static const char *SThreadsGroupLocksSig
+    ="Lnsk/monitoring/share/ThreadsGroupLocks;";
+    static const char *SThreadsGroupLocksClassName
+    ="nsk/monitoring/share/ThreadsGroupLocks";
+
+
+    static const char *SbringState_mn="bringState";
+    static const char *SnativeBringState_mn="nativeBringState";
+    static const char *SrecursiveMethod_mn="recursiveMethod";
+    static const char *SnativeRecursiveMethod_mn="nativeRecursiveMethod";
+    static const char *SloggerClassName = "nsk/share/Log$Logger";
+
+    static const char *Snoparams="()V";
+    static const char *Slongparam="(J)V";
+
+    /*
+     * Class:     nsk_monitoring_share_BaseThread
+     * Method:    nativeRecursiveMethod
+     * Signature: ()V
+     */
+    JNIEXPORT void JNICALL
+    Java_nsk_monitoring_share_BaseThread_nativeRecursiveMethod(JNIEnv *env,
+            jobject obj) {
+        jint currDepth, maxDepth;
+        jobject logger;
+        jstring jmsg;
+        jfieldID field;
+        jmethodID method;
+
+        jobject controller;
+        jclass threadClass, ctrlClass, loggerClass;
+
+        int invocationType;
+
+        GET_OBJECT_CLASS(threadClass, obj);
+        FIND_CLASS(ctrlClass, SctrlClassName);
+        FIND_CLASS(loggerClass, SloggerClassName);
+
+
+        /* currDepth++ */
+        GET_INT_FIELD(currDepth, obj, threadClass, "currentDepth");
+        currDepth++;
+        SET_INT_FIELD(obj, threadClass, "currentDepth", currDepth);
+
+        GET_OBJ_FIELD(controller, obj, threadClass, "controller",
+                      SthreadControllerSig);
+        GET_INT_FIELD(maxDepth, controller, ctrlClass, "maxDepth");
+
+        GET_STATIC_INT_FIELD(invocationType, ctrlClass, "invocationType");
+
+        if (maxDepth - currDepth > 0)
+        {
+            CALL_STATIC_VOID_NOPARAM(threadClass, "yield");
+
+            if (invocationType == 2/*MIXED_TYPE*/)
+            {
+                CALL_VOID_NOPARAM(obj, threadClass, SrecursiveMethod_mn);
+            }
+            else
+            {
+                CALL_VOID_NOPARAM(obj, threadClass, SnativeRecursiveMethod_mn);
+            }
+        }
+        else
+        {
+            TRACE("state has been reached");
+            if (invocationType == 2/*MIXED_TYPE*/)
+            {
+                CALL_VOID_NOPARAM(obj, threadClass, SbringState_mn);
+            }
+            else
+            {
+                CALL_VOID_NOPARAM(obj, threadClass, SnativeBringState_mn);
+            }
+        }
+
+        currDepth--;
+        GET_OBJECT_CLASS(threadClass, obj);
+        SET_INT_FIELD(obj, threadClass, "currentDepth", currDepth);
+    }
+
+    /*
+     * Class:     nsk_monitoring_share_BlockedThread
+     * Method:    nativeBringState
+     * Signature: ()V
+     */
+    JNIEXPORT void JNICALL
+    Java_nsk_monitoring_share_BlockedThread_nativeBringState(JNIEnv *env,
+            jobject obj) {
+        jobject logger;
+        jstring jmsg;
+        jfieldID field;
+        jmethodID method;
+
+        jclass threadClass, loggerClass;
+
+        jobject STATE;
+
+        //ThreadsGroupLocks:
+        jclass ThreadsGroupLocks;
+        jobject  threadsGroupLocks;
+        jmethodID getBarrier;
+
+
+        //CountDownLatch
+        jobject barrier;
+        jclass CountDownLatch;
+
+        //Blocker
+        jobject blocker;
+        jclass Blocker;
+
+        GET_OBJECT_CLASS(threadClass, obj);
+
+        FIND_CLASS(loggerClass, SloggerClassName);
+        FIND_CLASS(ThreadsGroupLocks, SThreadsGroupLocksClassName);
+        FIND_CLASS(Blocker, "Lnsk/monitoring/share/ThreadsGroupLocks$Blocker;");
+        FIND_CLASS(CountDownLatch, "nsk/monitoring/share/ThreadsGroupLocks$PlainCountDownLatch");
+
+        GET_OBJ_FIELD(threadsGroupLocks, obj, threadClass, "threadsGroupLocks", SThreadsGroupLocksSig);
+        GET_STATIC_OBJ_FIELD(STATE, threadClass, "STATE", "Ljava/lang/Thread$State;");
+        GET_OBJ_FIELD(blocker, threadsGroupLocks, ThreadsGroupLocks, "blocker", "Lnsk/monitoring/share/ThreadsGroupLocks$Blocker;");
+
+        getBarrier = (*env)->GetMethodID(env, ThreadsGroupLocks, "getBarrier",
+            "(Ljava/lang/Thread$State;)Lnsk/monitoring/share/ThreadsGroupLocks$PlainCountDownLatch;");
+        barrier = (*env)->CallObjectMethod(env, threadsGroupLocks, getBarrier, STATE);
+
+
+        TRACE("entering to monitor");
+
+        CALL_VOID_NOPARAM(barrier, CountDownLatch, "countDown");
+        CALL_VOID_NOPARAM(blocker, Blocker, "block");
+        TRACE("exiting from monitor");
+
+    }
+
+    /*
+     * Class:     nsk_monitoring_share_WaitingThread
+     * Method:    nativeBringState
+     * Signature: ()V
+     */
+    JNIEXPORT void JNICALL
+    Java_nsk_monitoring_share_WaitingThread_nativeBringState(JNIEnv *env,
+            jobject obj) {
+        jobject logger;
+        jstring jmsg;
+        jfieldID field;
+        jmethodID method;
+
+        jclass threadClass, loggerClass;
+
+        //STATE
+        jobject STATE;
+
+        //ThreadsGroupLocks:
+        jclass ThreadsGroupLocks;
+        jobject  threadsGroupLocks;
+        jmethodID getBarrier;
+
+        //CountDownLatch
+        jobject barrier;
+        jclass CountDownLatch;
+
+        GET_OBJECT_CLASS(threadClass, obj);
+
+        FIND_CLASS(loggerClass, SloggerClassName);
+        FIND_CLASS(ThreadsGroupLocks, "nsk/monitoring/share/ThreadsGroupLocks");
+        FIND_CLASS(CountDownLatch, "nsk/monitoring/share/ThreadsGroupLocks$PlainCountDownLatch");
+
+        GET_STATIC_OBJ_FIELD(STATE, threadClass, "STATE", "Ljava/lang/Thread$State;");
+        GET_OBJ_FIELD(threadsGroupLocks, obj, threadClass, "threadsGroupLocks", "Lnsk/monitoring/share/ThreadsGroupLocks;");
+
+        getBarrier = (*env)->GetMethodID(env, ThreadsGroupLocks, "getBarrier",
+            "(Ljava/lang/Thread$State;)Lnsk/monitoring/share/ThreadsGroupLocks$PlainCountDownLatch;");
+        barrier = (*env)->CallObjectMethod(env, threadsGroupLocks, getBarrier, STATE);
+        CALL_VOID_NOPARAM(barrier, CountDownLatch, "countDown");
+
+        TRACE("waiting on a monitor");
+        CALL_VOID_NOPARAM(barrier, CountDownLatch, "await");
+    }
+
+    /*
+     * Class:     nsk_monitoring_share_SleepingThread
+     * Method:    nativeBringState
+     * Signature: ()V
+     */
+    JNIEXPORT void JNICALL
+    Java_nsk_monitoring_share_SleepingThread_nativeBringState(JNIEnv *env,
+            jobject obj) {
+        jfieldID field;
+        jmethodID method;
+
+        jclass threadClass, loggerClass;
+
+        //STATE
+        jobject STATE;
+
+        //ThreadsGroupLocks:
+        jclass ThreadsGroupLocks;
+        jobject  threadsGroupLocks;
+        jmethodID getBarrier;
+
+        //CountDownLatch
+        jobject barrier;
+        jclass CountDownLatch;
+
+        //Thread
+        jclass Thread;
+
+        jlong sleepTime = 20 * 60 * 1000;
+
+
+        GET_OBJECT_CLASS(threadClass, obj);
+
+        FIND_CLASS(loggerClass, SloggerClassName);
+        FIND_CLASS(ThreadsGroupLocks, "nsk/monitoring/share/ThreadsGroupLocks");
+        FIND_CLASS(CountDownLatch, "nsk/monitoring/share/ThreadsGroupLocks$PlainCountDownLatch");
+
+        GET_STATIC_OBJ_FIELD(STATE, threadClass, "STATE", "Ljava/lang/Thread$State;");
+        GET_OBJ_FIELD(threadsGroupLocks, obj, threadClass, "threadsGroupLocks", "Lnsk/monitoring/share/ThreadsGroupLocks;");
+
+        // Thread.sleep(3600 * 1000);
+        FIND_CLASS(Thread, "java/lang/Thread");
+
+        getBarrier = (*env)->GetMethodID(env, ThreadsGroupLocks, "getBarrier",
+            "(Ljava/lang/Thread$State;)Lnsk/monitoring/share/ThreadsGroupLocks$PlainCountDownLatch;");
+        barrier = (*env)->CallObjectMethod(env, threadsGroupLocks, getBarrier, STATE);
+        CALL_VOID_NOPARAM(barrier, CountDownLatch, "countDown");
+
+        CALL_STATIC_VOID(Thread, "sleep", "(J)V", sleepTime);
+    }
+
+    /*
+     * Class:     nsk_monitoring_share_RunningThread
+     * Method:    nativeBringState
+     * Signature: ()V
+     */
+    JNIEXPORT void JNICALL
+    Java_nsk_monitoring_share_RunningThread_nativeBringState(JNIEnv *env,
+            jobject obj) {
+        jobject logger;
+        jstring jmsg;
+        jfieldID field;
+        jmethodID method;
+
+        jclass threadClass, loggerClass;
+
+        //STATE
+        jobject STATE;
+
+        //ThreadsGroupLocks:
+        jclass ThreadsGroupLocks;
+        jobject  threadsGroupLocks;
+        jmethodID getBarrier;
+
+        //CountDownLatch
+        jobject barrier;
+        jclass CountDownLatch;
+
+        //Thread
+        jclass Thread;
+
+        //runnableCanExit
+        jboolean flag = JNI_FALSE;
+
+        GET_OBJECT_CLASS(threadClass, obj);
+
+        FIND_CLASS(loggerClass, SloggerClassName);
+        FIND_CLASS(ThreadsGroupLocks, "nsk/monitoring/share/ThreadsGroupLocks");
+        FIND_CLASS(CountDownLatch, "nsk/monitoring/share/ThreadsGroupLocks$PlainCountDownLatch");
+
+        GET_STATIC_OBJ_FIELD(STATE, threadClass, "STATE", "Ljava/lang/Thread$State;");
+        GET_OBJ_FIELD(threadsGroupLocks, obj, threadClass, "threadsGroupLocks", "Lnsk/monitoring/share/ThreadsGroupLocks;");
+
+        // Thread.sleep(3600 * 1000);
+        FIND_CLASS(Thread, "java/lang/Thread");
+
+        getBarrier = (*env)->GetMethodID(env, ThreadsGroupLocks, "getBarrier",
+            "(Ljava/lang/Thread$State;)Lnsk/monitoring/share/ThreadsGroupLocks$PlainCountDownLatch;");
+
+        TRACE("running loop");
+
+        barrier = (*env)->CallObjectMethod(env, threadsGroupLocks, getBarrier, STATE);
+        CALL_VOID_NOPARAM(barrier, CountDownLatch, "countDown");
+
+        // while (!threadsGroupLocks.runnableCanExit.get()) {
+        //        Thread.yield();
+        //    }
+        while(flag==JNI_FALSE)
+        {
+            GET_BOOL_FIELD(flag, threadsGroupLocks, ThreadsGroupLocks, "runnableCanExit");
+            CALL_STATIC_VOID_NOPARAM(Thread, "yield");
+        }
+
+    }
+
+    jstring getStateName(JNIEnv *env, jint state) {
+        switch (state & JVMTI_JAVA_LANG_THREAD_STATE_MASK) {
+            case JVMTI_JAVA_LANG_THREAD_STATE_NEW:
+                return (*env)->NewStringUTF(env,"NEW");
+            case JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED:
+                return (*env)->NewStringUTF(env,"TERMINATED");
+            case JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE:
+                return (*env)->NewStringUTF(env,"RUNNABLE");
+            case JVMTI_JAVA_LANG_THREAD_STATE_BLOCKED:
+                return (*env)->NewStringUTF(env,"BLOCKED");
+            case JVMTI_JAVA_LANG_THREAD_STATE_WAITING:
+                return (*env)->NewStringUTF(env, "WAITING");
+            case JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING:
+                return (*env)->NewStringUTF(env,"TIMED_WAITING");
+            }
+        // should never reach
+        assert(0);
+        return 0;
+    }
+
+    /*
+     * Class:     nsk_monitoring_share_ThreadController
+     * Method:    getThreadState
+     * Signature: (Ljava/lang/Thread;)Ljava/lang/Thread/State;
+     */
+    JNIEXPORT jobject JNICALL
+    Java_nsk_monitoring_share_ThreadController_getThreadState(JNIEnv *env,
+            jobject obj, jobject thread){
+
+        JavaVM *vm;
+        jvmtiEnv *jvmti;
+        jclass ThreadState;
+        jmethodID method;
+        jobject threadState;
+        jstring stateName;
+        jint state;
+
+        if(!NSK_VERIFY(
+             NSK_CPP_STUB2(GetJavaVM, env, &vm) == 0)) {
+            return NULL;
+        }
+
+        if(!NSK_VERIFY(
+             NSK_CPP_STUB3(GetEnv, vm, (void **)&jvmti, JVMTI_VERSION_1)
+                    == JNI_OK)) {
+            return NULL;
+        }
+
+        if(!NSK_VERIFY(
+             NSK_CPP_STUB3(GetThreadState, jvmti, (jthread)thread, &state)
+             == JVMTI_ERROR_NONE)) {
+            return NULL;
+        }
+
+        stateName = getStateName(env, state);
+        if (!NSK_JNI_VERIFY(env, (ThreadState = NSK_CPP_STUB2(FindClass, env, "java/lang/Thread$State")) != NULL))
+            return NULL;
+
+        if (!NSK_JNI_VERIFY(env, (method = NSK_CPP_STUB4(GetStaticMethodID, env, ThreadState, "valueOf", "(Ljava/lang/String;)Ljava/lang/Thread$State;")) != NULL))
+            return NULL;
+        threadState = NSK_CPP_STUB4(CallStaticObjectMethod, env, ThreadState, method, stateName);
+
+        return threadState;
+    }
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,889 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.lang.management.*;
+import java.util.*;
+
+import nsk.share.*;
+
+/**
+ * The <code>ThreadController</code> class allows to operate with threads.
+ */
+public class ThreadController extends StateController {
+
+    /**
+     * Type of threads: pure java.
+     */
+    static public final int JAVA_TYPE = 0;
+
+    /**
+     * Type of threads: native.
+     */
+    static public final int NATIVE_TYPE = 1;
+
+    /**
+     * Type of threads: both java and native.
+     */
+    static public final int MIXED_TYPE = 2;
+
+    /**
+     * Result code: no errors.
+     */
+    static public final int NO_ERROR = 0;
+
+    /**
+     * Result code: wrong state of the thread.
+     */
+    static public final int ERR_STATE = 1;
+
+    /**
+     * Result code: error in stack trace.
+     */
+    static public final int ERR_STACKTRACE = 2;
+
+    /**
+     * Result code: thread not found.
+     */
+    static public final int ERR_THREAD_NOTFOUND = 3;
+
+
+    // Prefix to print while logging
+    static final String LOG_PREFIX = "ThreadController> ";
+
+    // Internal trace levels
+    static final int THREAD_TRACE_LEVEL = 50;
+
+    /**
+     * Suffix of all started threads.
+     */
+    static final String THREAD_SUFFIX = "_ThreadMM";
+
+    // Number of tested kinds of threads
+    public static final int THREAD_KIND_COUNT = 4;
+
+    /**
+     * Index of blocked threads.
+     */
+    static public final int BLOCKED_IDX = 0;
+
+    /**
+     * Index of waiting threads.
+     */
+    static public final int WAITING_IDX = 1;
+
+    /**
+     * Index of sleeping threads.
+     */
+    static public final int SLEEPING_IDX = 2;
+
+    /**
+     * Index of running threads.
+     */
+    static public final int RUNNING_IDX = 3;
+
+    public static final String[] THREAD_KIND_NAMES =  {"BLOCKED","WAITING","SLEEPING","RUNNABLE"};
+    public static final Thread.State[] THREAD_KINDS = {Thread.State.BLOCKED, Thread.State.WAITING, Thread.State.TIMED_WAITING, Thread.State.RUNNABLE};
+
+    private Map<Thread.State, Integer> threadsCount = new HashMap<Thread.State, Integer>();
+    private Map<Thread.State, List<BaseThread>> threadsClusters = new HashMap<Thread.State, List<BaseThread>>();
+
+    private ThreadsGroupLocks threadsGroupLocks;
+
+
+    int maxDepth;
+    static int invocationType;
+
+    static {
+        try {
+            System.loadLibrary("ThreadController");
+        } catch (UnsatisfiedLinkError e) {
+            System.err.println("Could not load \"ThreadController\" "
+                    + "library");
+            System.err.println("java.library.path:"
+                    + System.getProperty("java.library.path"));
+            throw e;
+        }
+    }
+
+    /**
+     * Creates a new <code>ThreadController</code> object with defined
+     * arguments..
+     *
+     * @param log            <code>Log</code> object to print info to.
+     * @param threadCount    number of threads to start.
+     * @param maxDepth       depth of recursion.
+     * @param invocationType type of threads to start (java, native, or mixed).
+     */
+    public ThreadController(Log log, int threadCount, int maxDepth,
+                            String invocationType) {
+        logPrefix = LOG_PREFIX;
+        setLog(log);
+        setThreadCount(threadCount);
+        setDepth(maxDepth);
+        setInvocationType(invocationType);
+    }
+
+
+    // Calculate how many threads of each kind to start
+    private void setThreadCount(int threadCount) {
+        int total = 0;
+        int kinds = THREAD_KIND_COUNT;
+        int tmp = threadCount / kinds;
+        int rest = threadCount % kinds;
+        int increased = kinds - rest;
+        for (int i = 0; i < kinds; i++) {
+            if (i >= increased) {
+                threadsCount.put(THREAD_KINDS[i], tmp + 1);
+            } else {
+                threadsCount.put(THREAD_KINDS[i], tmp);
+            }
+        }
+        display("number of created threads:\t" + threadCount);
+    }
+
+    // Print thread count
+    private void printThreadCount() {
+        for (Thread.State state : THREAD_KINDS) {
+            display("\t" + state + " threads ("
+                    + threadsCount.get(state) + ")");
+        }
+    }
+
+    // Set recursion depth
+    private void setDepth(int depth) {
+        maxDepth = depth;
+        display("depth for all threads:\t" + maxDepth);
+    }
+
+    // Set invocation type
+    private void setInvocationType(String value) {
+        display("invocation type:\t" + value);
+        if (value.equals(ArgumentHandler.JAVA_TYPE)) {
+            invocationType = JAVA_TYPE;
+        } else if (value.equals(ArgumentHandler.NATIVE_TYPE)) {
+            invocationType = NATIVE_TYPE;
+        } else if (value.equals(ArgumentHandler.MIXED_TYPE)) {
+            invocationType = MIXED_TYPE;
+        } else {
+            throw new Failure("UNKNOWN invocation type");
+        }
+    }
+
+    /**
+     * Returns invocation type.
+     *
+     * @return invocation type.
+     */
+    public int getInvocationType() {
+        return invocationType;
+    }
+
+    /**
+     * Returns thread count.
+     *
+     * @param state kind of thread state
+     * @return thread count.
+     */
+    public int getThreadCount(Thread.State state) {
+        return threadsCount.get(state);
+    }
+
+      /**
+     * Returns thread count.
+     *
+     * @param kindIndex of thread state
+     * @return thread count.
+     */
+    public int getThreadCount(int kindIndex) {
+        return threadsCount.get(THREAD_KINDS[kindIndex]);
+    }
+
+    public int getThreadKindCount() {
+        return THREAD_KINDS.length;
+    }
+
+
+    /**
+     * Brings out VM into defined state.
+     * <p/>
+     * The method starts all threads.
+     */
+    public void run() {
+        long startTime = System.currentTimeMillis() / 1000;
+        startThreads();
+        display("locking threads");
+        waitForThreads();
+    }
+
+    /**
+     * Tries to return VM into initial state
+     * <p/>
+     * The method interrupts all threads.
+     */
+    public void reset() {
+        for (Thread.State state : THREAD_KINDS) {
+            threadsGroupLocks.releaseGroup(state);
+        }
+    }
+
+    // Get thread state via JVMTI
+    private native Thread.State getThreadState(Thread thread);
+
+    // Start all threads
+    private void startThreads() throws Failure {
+
+        String tmp_name;
+        BaseThread thread = null;
+
+        threadsGroupLocks = new ThreadsGroupLocks(threadsCount, logger);
+        for (Thread.State state : THREAD_KINDS) {
+            threadsClusters.put(state, new ArrayList<BaseThread>());
+            for (int j = 0; j < threadsCount.get(state); j++) {
+                tmp_name = state + THREAD_SUFFIX + int2Str(j);
+                switch (state) {
+                    case BLOCKED:
+                        thread = new BlockedThread(this, tmp_name, logger.getLog(), threadsGroupLocks);
+                        break;
+                    case WAITING:
+                        thread = new WaitingThread(this, tmp_name, logger.getLog(), threadsGroupLocks);
+                        break;
+                    case TIMED_WAITING:
+                        thread = new SleepingThread(this, tmp_name, logger.getLog(), threadsGroupLocks);
+                        break;
+                    case RUNNABLE:
+                        thread = new RunningThread(this, tmp_name, logger.getLog(), threadsGroupLocks);
+                        break;
+                    default:
+                        throw new TestBug("Unknow thread kind");
+                }
+                threadsClusters.get(state).add(thread);
+                thread.start();
+            }
+        }
+        waitForThreads();
+    }
+
+    private boolean checkState(Thread.State expectedState) {
+        for (Thread thread : threadsClusters.get(expectedState)) {
+            if (getThreadState(thread) != expectedState) {
+
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private void waitForThreads() {
+        for (Thread.State state : THREAD_KINDS) {
+            threadsGroupLocks.waitForGroup(state);
+            while (!checkState(state)) {
+                Thread.yield();
+            }
+        }
+    }
+
+
+    /**
+     * Finds a thread with defined id.
+     *
+     * @param id ID of the thread.
+     * @return a thread with defined id.
+     */
+    public BaseThread findThread(long id) {
+        for(Thread.State state:THREAD_KINDS){
+            for(BaseThread thread:threadsClusters.get(state)){
+                 if (id==thread.getId()) {
+                     return thread;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Finds a thread by name.
+     *
+     * @param name name of the thread.
+     * @return a thread with defined name.
+     */
+    public BaseThread findThread(String name) {
+        for(Thread.State state:THREAD_KINDS){
+            for(BaseThread thread:threadsClusters.get(state)){
+                 if (name.equals(thread.getName())) {
+                     return thread;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Checks the thread's <code>ThreadInfo</code>.
+     *
+     * @param info <code>ThreadInfo</code> object to test.
+     * @return result code.
+     * @see #NO_ERROR
+     * @see #ERR_THREAD_NOTFOUND
+     * @see #ERR_STATE
+     * @see #ERR_STACKTRACE
+     */
+    public int checkThreadInfo(ThreadInfo info) {
+        String name = info.getThreadName();
+
+        if (name.indexOf(THREAD_SUFFIX) == -1) {
+            return NO_ERROR;
+        }
+
+        long id = info.getThreadId();
+        Thread.State state = info.getThreadState();
+        StackTraceElement[] stackTrace = info.getStackTrace();
+
+        BaseThread thrd = findThread(id);
+        if (thrd == null) {
+            return ERR_THREAD_NOTFOUND;
+        }
+
+        if (!thrd.checkState(state))
+            return ERR_STATE;
+
+        if (!thrd.checkStackTrace(stackTrace))
+            return ERR_STACKTRACE;
+
+        return NO_ERROR;
+    }
+}
+
+abstract class BaseThread extends Thread {
+
+    private int currentDepth = 0;
+    private String logPrefix;
+    protected Log.Logger logger;
+
+    protected ThreadController controller;
+
+    protected List<String> expectedMethods = new ArrayList<String>();
+    protected int expectedLength;
+
+    protected ThreadsGroupLocks threadsGroupLocks;
+
+    static {
+        if (ThreadController.invocationType == ThreadController.NATIVE_TYPE ||
+                ThreadController.invocationType == ThreadController.MIXED_TYPE) {
+            try {
+                System.loadLibrary("ThreadController");
+            } catch (UnsatisfiedLinkError e) {
+                System.err.println("Could not load \"ThreadController\" "
+                        + "library");
+                System.err.println("java.library.path:"
+                        + System.getProperty("java.library.path"));
+                throw e;
+            }
+        }
+    }
+
+    public BaseThread(ThreadController controller, String name, Log log, ThreadsGroupLocks threadsGroupLocks) {
+        super(name);
+        this.controller = controller;
+        int pos = controller.LOG_PREFIX.indexOf('>');
+        logPrefix = controller.LOG_PREFIX.substring(0, pos) + "::"
+                + name + "> ";
+        setLog(log);
+        this.threadsGroupLocks = threadsGroupLocks;
+
+        expectedLength = 1 + controller.maxDepth + 1;
+        if(controller.invocationType == ThreadController.MIXED_TYPE) {
+             //nativeRecursiveMethod
+             expectedLength ++;
+        }
+
+        expectedMethods.add(BaseThread.class.getName() + ".run");
+
+        switch (controller.invocationType) {
+            case ThreadController.JAVA_TYPE:
+                expectedMethods.add(BaseThread.class.getName() + ".recursiveMethod");
+                break;
+            case ThreadController.NATIVE_TYPE:
+                expectedMethods.add(BaseThread.class.getName() + ".nativeRecursiveMethod");
+                break;
+            case ThreadController.MIXED_TYPE:
+                expectedMethods.add(BaseThread.class.getName() + ".recursiveMethod");
+                expectedMethods.add(BaseThread.class.getName() + ".nativeRecursiveMethod");
+        }
+
+        expectedMethods.add(ThreadsGroupLocks.PlainCountDownLatch.class.getName() + ".countDown");
+    }
+
+    public void run() {
+        try {
+            switch (controller.invocationType) {
+                case ThreadController.JAVA_TYPE:
+                case ThreadController.MIXED_TYPE:
+                    recursiveMethod();
+                    break;
+                case ThreadController.NATIVE_TYPE:
+                    nativeRecursiveMethod();
+                    break;
+                default:
+                    throw new Failure("unknown invocationType:"
+                            + controller.invocationType);
+            }
+        } catch (StackOverflowError e) {
+            logger.complain(e.toString());
+            throw new RuntimeException(e);
+        }
+        logger.trace(controller.THREAD_TRACE_LEVEL, "thread finished");
+    }
+
+    protected abstract void bringState();
+
+    public abstract State getState();
+
+    protected abstract void nativeBringState();
+
+    public abstract boolean checkState(Thread.State state);
+
+    public boolean checkStackTrace(StackTraceElement[] elements) {
+        boolean res = true;
+
+        logger.trace(controller.THREAD_TRACE_LEVEL, "trace elements: "
+                + elements.length);
+
+        if (elements.length > expectedLength) {
+            res = false;
+            logger.complain("Contains " + elements.length + ", more then "
+                    + expectedLength + " elements");
+        }
+
+        for (int j = 0; j < elements.length; j++) {
+            if (!checkElement(elements[j])) {
+                logger.complain("Unexpected method name: "
+                                + elements[j].getMethodName()
+                                + " at " + j + " position");
+                if (elements[j].isNativeMethod()) {
+                    logger.complain("\tline number: (native method)");
+                    logger.complain("\tclass name: " + elements[j].getClassName());
+                } else {
+                    logger.complain("\tline number: " + elements[j].getLineNumber());
+                    logger.complain("\tclass name: " + elements[j].getClassName());
+                    logger.complain("\tfile name: " + elements[j].getFileName());
+                }
+                res = false;
+            }
+        }
+        return res;
+    }
+
+    protected boolean checkElement(StackTraceElement element) {
+        String name = element.getClassName() + "." + element.getMethodName();
+        if (expectedMethods.contains(name)) {
+            return true;
+        }
+
+        logger.trace(controller.THREAD_TRACE_LEVEL, "\"" + name + "\""
+                + " is not expected method name");
+        return false;
+    }
+
+    protected void recursiveMethod() {
+        currentDepth++;
+
+        if (controller.maxDepth - currentDepth > 0) {
+
+            Thread.yield();
+            try {
+                if (ThreadController.invocationType
+                        == ThreadController.MIXED_TYPE) {
+                    nativeRecursiveMethod();
+                } else {
+                    recursiveMethod();
+                }
+
+            } catch (StackOverflowError e) {
+                logger.display(getName() + "> " + e);
+            }
+
+        } else if (controller.maxDepth == currentDepth) {
+            logger.trace(controller.THREAD_TRACE_LEVEL, "state has been "
+                    + "reached");
+            bringState();
+        }
+        currentDepth--;
+    }
+
+    protected native void nativeRecursiveMethod();
+
+    /**
+     * Defines <code>Log.Logger</code> object
+     */
+    public void setLog(Log log) {
+        logger = new Log.Logger(log, logPrefix);
+    }
+}
+
+class BlockedThread extends BaseThread {
+
+    private static final Thread.State STATE = Thread.State.BLOCKED;
+
+    public State getState() {
+        return STATE;
+    }
+
+    public BlockedThread(ThreadController controller, String name, Log log, ThreadsGroupLocks threadsGroupLocks) {
+        super(controller, name, log, threadsGroupLocks);
+
+        this.threadsGroupLocks = threadsGroupLocks;
+
+        expectedLength += 2;
+
+        expectedMethods.add(ThreadsGroupLocks.Blocker.class.getName() + ".block");
+
+        switch (controller.invocationType) {
+            case ThreadController.JAVA_TYPE:
+                expectedMethods.add(BlockedThread.class.getName() + ".bringState");
+                break;
+            case ThreadController.NATIVE_TYPE:
+                expectedMethods.add(BlockedThread.class.getName() + ".nativeBringState");
+                break;
+            case ThreadController.MIXED_TYPE:
+                expectedMethods.add(BlockedThread.class.getName() + ".bringState");
+
+        }
+    }
+
+    protected void bringState() {
+        logger.trace(controller.THREAD_TRACE_LEVEL, "entering to monitor");
+        threadsGroupLocks.getBarrier(getState()).countDown();
+        threadsGroupLocks.blocker.block();
+        logger.trace(controller.THREAD_TRACE_LEVEL, "exiting from monitor");
+    }
+
+    protected native void nativeBringState();
+
+    public boolean checkState(Thread.State state) {
+        return state == Thread.State.BLOCKED;
+    }
+}
+
+class WaitingThread extends BaseThread {
+
+    private static final Thread.State STATE = Thread.State.WAITING;
+    public State getState() {
+        return STATE;
+    }
+
+    private ThreadsGroupLocks threadsGroupLocks;
+
+    public WaitingThread(ThreadController controller, String name, Log log, ThreadsGroupLocks threadsGroupLocks) {
+        super(controller, name, log, threadsGroupLocks);
+
+        this.threadsGroupLocks = threadsGroupLocks;
+
+        expectedLength += 4;
+
+        expectedMethods.add(ThreadsGroupLocks.PlainCountDownLatch.class.getName() + ".await");
+        expectedMethods.add(Object.class.getName() + ".wait");
+
+        switch (controller.invocationType) {
+            case ThreadController.JAVA_TYPE:
+                expectedMethods.add(WaitingThread.class.getName() + ".bringState");
+                break;
+            case ThreadController.NATIVE_TYPE:
+                expectedMethods.add(WaitingThread.class.getName() + ".nativeBringState");
+                break;
+            case ThreadController.MIXED_TYPE:
+                expectedMethods.add(WaitingThread.class.getName() + ".bringState");
+
+        }
+    }
+
+
+    protected void bringState() {
+        ThreadsGroupLocks.PlainCountDownLatch barrier = threadsGroupLocks.getBarrier(STATE);
+        try {
+            logger.trace(controller.THREAD_TRACE_LEVEL, "waiting on a monitor");
+            threadsGroupLocks.getBarrier(getState()).countDown();
+            barrier.await();
+        } catch (InterruptedException e) {
+            logger.display(e.toString());
+        }
+    }
+
+    protected native void nativeBringState();
+
+    public boolean checkState(Thread.State state) {
+        return state == STATE;
+    }
+
+}
+
+class SleepingThread extends BaseThread {
+    private static final Thread.State STATE = State.TIMED_WAITING;
+
+    public State getState() {
+        return STATE;
+    }
+
+    private ThreadsGroupLocks threadsGroupLocks;
+
+    public SleepingThread(ThreadController controller, String name, Log log, ThreadsGroupLocks threadsGroupLocks) {
+        super(controller, name, log, threadsGroupLocks);
+
+        this.threadsGroupLocks = threadsGroupLocks;
+
+        expectedLength += 3;
+
+        expectedMethods.add(Thread.class.getName() + ".sleep");
+        expectedMethods.add(SleepingThread.class.getName() + ".run");
+
+        switch (controller.invocationType) {
+            case ThreadController.JAVA_TYPE:
+                expectedMethods.add(SleepingThread.class.getName() + ".bringState");
+                break;
+            case ThreadController.NATIVE_TYPE:
+                 expectedMethods.add(SleepingThread.class.getName() + ".nativeBringState");
+                break;
+            case ThreadController.MIXED_TYPE:
+                 expectedMethods.add(SleepingThread.class.getName() + ".bringState");
+        }
+
+    }
+
+    protected void bringState() {
+        try {
+            threadsGroupLocks.getBarrier(getState()).countDown();
+            Thread.sleep(3600 * 1000);
+        } catch (InterruptedException e) {
+            logger.display(e.toString());
+        }
+    }
+
+    protected native void nativeBringState();
+
+    public boolean checkState(Thread.State state) {
+        return state == Thread.State.TIMED_WAITING;
+    }
+
+    public void run() {
+        try {
+            switch (controller.invocationType) {
+                case ThreadController.JAVA_TYPE:
+                case ThreadController.MIXED_TYPE:
+                    recursiveMethod();
+                    break;
+                case ThreadController.NATIVE_TYPE:
+                    nativeRecursiveMethod();
+                    break;
+                default:
+                    throw new Failure("unknown invocationType:"
+                            + controller.invocationType);
+            }
+            logger.trace(controller.THREAD_TRACE_LEVEL, "thread finished");
+        } catch (StackOverflowError e) {
+            logger.complain(e.toString());
+            throw new RuntimeException(e);
+        }
+    }
+}
+
+class RunningThread extends BaseThread {
+    public State getState() {
+        return STATE;
+    }
+
+    private static final Thread.State STATE = Thread.State.RUNNABLE;
+    private ThreadsGroupLocks threadsGroupLocks;
+
+    public RunningThread(ThreadController controller, String name, Log log, ThreadsGroupLocks threadsGroupLocks) {
+        super(controller, name, log, threadsGroupLocks);
+        this.threadsGroupLocks = threadsGroupLocks;
+
+        expectedLength += 2;
+
+        expectedMethods.add(Thread.class.getName() + ".yield");
+
+        switch (controller.invocationType) {
+            case ThreadController.JAVA_TYPE:
+                expectedMethods.add(RunningThread.class.getName() + ".bringState");
+                break;
+            case ThreadController.NATIVE_TYPE:
+                expectedMethods.add(RunningThread.class.getName() + ".nativeBringState");
+                break;
+            case ThreadController.MIXED_TYPE:
+                expectedMethods.add(RunningThread.class.getName() + ".bringState");
+        }
+    }
+
+    protected void bringState() {
+        logger.trace(controller.THREAD_TRACE_LEVEL, "running loop");
+        threadsGroupLocks.getBarrier(getState()).countDown();
+        while (!threadsGroupLocks.runnableCanExit) {
+            Thread.yield();
+        }
+    }
+
+    protected native void nativeBringState();
+
+    public boolean checkState(Thread.State state) {
+        return state == Thread.State.RUNNABLE;
+    }
+}
+
+
+class ThreadsGroupLocks {
+
+    private Log.Logger logger;
+
+    //for all
+    private Map<Thread.State, PlainCountDownLatch> barriers = new HashMap<Thread.State, PlainCountDownLatch>();
+
+    //for Blocked
+    public final Blocker blocker = new Blocker();
+
+    //for Runnable
+    public volatile boolean runnableCanExit = false;
+
+    public ThreadsGroupLocks(Map<Thread.State, Integer> threadsCount, Log.Logger logger) {
+        this.logger = logger;
+        for (Thread.State state : threadsCount.keySet()) {
+            if (state == Thread.State.WAITING) {
+                barriers.put(state, new PlainCountDownLatch(threadsCount.get(state) + 1));
+            } else {
+                barriers.put(state, new PlainCountDownLatch(threadsCount.get(state)));
+            }
+        }
+        blocker.startBlocker();
+    }
+
+    public PlainCountDownLatch getBarrier(Thread.State state) {
+        return barriers.get(state);
+    }
+
+    public void waitForGroup(Thread.State stateGroup) {
+        switch (stateGroup) {
+            case BLOCKED:
+            case RUNNABLE:
+            case TIMED_WAITING:
+                try {
+                    barriers.get(stateGroup).await();
+                } catch (InterruptedException e) {
+                    logger.display(e.toString());
+                }
+                break;
+
+            case WAITING:
+                while (barriers.get(stateGroup).getCount() != 1) {
+                    Thread.yield();
+                }
+                break;
+        }
+    }
+
+    public void releaseGroup(Thread.State stateGroup) {
+        switch (stateGroup) {
+            case BLOCKED:
+                blocker.unBlock();
+                break;
+            case RUNNABLE:
+                runnableCanExit = true;
+                break;
+            case TIMED_WAITING:
+            case WAITING:
+                barriers.get(stateGroup).countDown();
+                break;
+        }
+    }
+
+    public class Blocker {
+
+        private Object monitor = new Object();
+        private PlainCountDownLatch blockerCanExit = new PlainCountDownLatch(1);
+        private PlainCountDownLatch blockerStart = new PlainCountDownLatch(1);
+
+        private Runnable blockerThread = new Runnable() {
+            public void run() {
+                synchronized (monitor) {
+                    blockerStart.countDown();
+                    try {
+                        blockerCanExit.await();
+                    } catch (InterruptedException e) {
+                        logger.display(e.toString());
+                    }
+
+                }
+            }
+        };
+
+        public void startBlocker() {
+            new Thread(blockerThread, "Blocker").start();
+        }
+
+        public void block() {
+            try {
+                blockerStart.await();
+            } catch (InterruptedException e) {
+                logger.complain(e.toString());
+            }
+            synchronized (monitor) {
+            }
+        }
+
+        public void unBlock() {
+            blockerCanExit.countDown();
+        }
+    }
+
+     public static class PlainCountDownLatch {
+        private volatile int counter;
+        private Object counterMonitor = new Object();
+
+        public PlainCountDownLatch(int counter){
+            this.counter = counter;
+        }
+
+        public void countDown(){
+            synchronized (counterMonitor) {
+                counter--;
+                if(counter==0) {
+                    counterMonitor.notifyAll();
+                }
+            }
+        }
+
+        public void await() throws InterruptedException{
+            synchronized (counterMonitor){
+                while(counter != 0){
+                    counterMonitor.wait();
+                }
+            }
+        }
+
+         public int getCount(){
+             synchronized (counterMonitor) {
+                 return counter;
+             }
+         }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadMonitor.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,442 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share;
+
+import java.lang.management.*;
+import javax.management.*;
+import javax.management.openmbean.*;
+import java.util.*;
+import nsk.share.*;
+
+/**
+ * <code>ThreadMonitor</code> class is a wrapper of <code>ThreadMXBean</code>.
+ * Depending on command line arguments, an instance of this class redirects
+ * invocations to the <code>ThreadMXBean</code> interface. If
+ * <code>-testMode="directly"</code> option is set, this instance directly
+ * invokes corresponding method of the <code>ThreadMXBean</code> interface.
+ * If <code>-testMode="server"</code> option is set it will make invocations
+ * via MBeanServer. If <code>-testMode="proxy"</code> option is set it will
+ * make invocations via MBeanServer proxy.
+ *
+ * @see ArgumentHandler
+ */
+public class ThreadMonitor extends Monitor {
+
+    // Names of the attributes of ThreadMXBean
+    private static final String GET_THREAD_INFO = "getThreadInfo";
+    private static final String GET_THREAD_CPU_TIME = "ThreadCpuTime";
+    private static final String ALL_THREAD_IDS = "AllThreadIds";
+    private static final String RESET_PEAK = "resetPeakThreadCount";
+    private static final String GET_PEAK_COUNT = "PeakThreadCount";
+    private static final String THREAD_COUNT = "ThreadCount";
+    private static final String FIND_THREADS = "findMonitorDeadlockedThreads";
+    private static final String IS_CURRENT = "CurrentThreadCpuTimeSupported";
+    private static final String IS_CPUTIME = "ThreadCpuTimeSupported";
+    private static final String IS_CONT_SUPP
+        = "ThreadContentionMonitoringSupported";
+    private static final String IS_CONT_ENAB
+        = "ThreadContentionMonitoringEnabled";
+
+    // An instance of ThreadMXBean
+    private static ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
+
+    // proxy instance
+    private ThreadMXBean proxyInstance;
+
+    // Internal trace level
+    private static final int TRACE_LEVEL = 10;
+
+    static {
+        Monitor.logPrefix = "ThreadMonitor> ";
+    }
+
+    /**
+     * Creates a new <code>ThreadMonitor</code> object.
+     *
+     * @param log <code>Log</code> object to print info to.
+     * @param argumentHandler <code>ArgumentHandler</code> object that saves
+     *        all info about test's arguments.
+     *
+     */
+    public ThreadMonitor(Log log, ArgumentHandler argumentHandler) {
+        super(log, argumentHandler);
+    }
+
+    /**
+     *
+     * Return a proxy instance for a platform
+     * {@link java.lang.management.ThreadMXBean
+     * <code>ThreadMXBean</code>} interface.
+     *
+     */
+    synchronized ThreadMXBean getProxy() {
+        if (proxyInstance == null) {
+            // create proxy instance
+            try {
+                proxyInstance = (ThreadMXBean)
+                ManagementFactory.newPlatformMXBeanProxy(
+                    getMBeanServer(),
+                    ManagementFactory.THREAD_MXBEAN_NAME,
+                    ThreadMXBean.class
+                );
+            } catch (Exception e) {
+                throw new Failure(e);
+            }
+        }
+        return proxyInstance;
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#getAllThreadIds()
+     * <code>ThreadMXBean.getAllThreadIds()</code>}.
+     *
+     * @return an array of <code>long</code>, each is a thread ID.
+     */
+    public long[] getAllThreadIds() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            logger.trace(TRACE_LEVEL,"[getAllThreadIds] getAllThreadIds()"
+                            + " directly invoked");
+            return mbean.getAllThreadIds();
+
+        case SERVER_MODE:
+            logger.trace(TRACE_LEVEL,"[getAllThreadIds] getAllThreadIds()"
+                       + " invoked through MBeanServer");
+            return getLongArrayAttribute(mbeanObjectName, ALL_THREAD_IDS);
+
+        case PROXY_MODE:
+            logger.trace(TRACE_LEVEL,"[getAllThreadIds] getAllThreadIds()"
+                            + " invoked through MBeanServer proxy");
+            return getProxy().getAllThreadIds();
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#getThreadInfo
+     * <code>ThreadMXBean.getThreadInfo()</code>}.
+     *
+     * @param id the thread ID of the thread.
+     * @param maxDepth the maximum number of entries in the stack trace to
+     *        be dumped. <code>Integer.MAX_VALUE</code> could be used to request
+     *        entire stack to be dumped.
+     *
+     * @return A <code>ThreadInfo</code> of the thread of the given ID.
+     *          <code>null</code> if the thread of the given ID is not alive
+     *          or it does not exist
+     */
+    public ThreadInfo getThreadInfo(long id, int maxDepth) {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            logger.trace(TRACE_LEVEL, "[getThreadInfo] getThreadInfo(long, "
+                       + "int) directly invoked");
+            return mbean.getThreadInfo(id, maxDepth);
+
+        case SERVER_MODE:
+            Object[] params = {new Long(id), new Integer(maxDepth)};
+            String[] signature = {"long", "int"};
+
+            try {
+                logger.trace(TRACE_LEVEL, "[getThreadInfo] getThreadInfo(long, "
+                           + "int) invoked through MBeanServer");
+                Object value = getMBeanServer().invoke(mbeanObjectName,
+                                                             GET_THREAD_INFO,
+                                                             params, signature);
+                if (value instanceof ThreadInfo)
+                        return (ThreadInfo) value;
+                else {
+                        CompositeData data = (CompositeData) value;
+                        return ThreadInfo.from(data);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new Failure(e);
+            }
+        case PROXY_MODE:
+            logger.trace(TRACE_LEVEL, "[getThreadInfo] getThreadInfo(long, "
+                       + "int) invoked through MBeanServer proxy");
+            return getProxy().getThreadInfo(id, maxDepth);
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#isCurrentThreadCpuTimeSupported()
+     * <code>ThreadMXBean.isCurrentThreadCpuTimeSupported()</code>}.
+     *
+     * @return <code>true</code>, if the JVM supports CPU time measurement for
+     *         current thread, <code>false</code> otherwise.
+     */
+    public boolean isCurrentThreadCpuTimeSupported() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            return mbean.isCurrentThreadCpuTimeSupported();
+
+        case SERVER_MODE:
+            return getBooleanAttribute(mbeanObjectName, IS_CURRENT);
+
+        case PROXY_MODE:
+            return getProxy().isCurrentThreadCpuTimeSupported();
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#isThreadCpuTimeSupported()
+     * <code>ThreadMXBean.isThreadCpuTimeSupported()</code>}.
+     *
+     * @return <code>true</code>, if the JVM supports CPU time measurement for
+     *         any threads, <code>false</code> otherwise.
+     */
+    public boolean isThreadCpuTimeSupported() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            return mbean.isThreadCpuTimeSupported();
+
+        case SERVER_MODE:
+            return getBooleanAttribute(mbeanObjectName, IS_CPUTIME);
+
+        case PROXY_MODE:
+            return getProxy().isThreadCpuTimeSupported();
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#isThreadContentionMonitoringSupported()
+     * <code>ThreadMXBean.isThreadContentionMonitoringSupported()</code>}.
+     *
+     * @return <code>true</code>, if the JVM supports thread contantion
+     *         monitoring, <code>false</code> otherwise.
+     */
+    public boolean isThreadContentionMonitoringSupported() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            return mbean.isThreadContentionMonitoringSupported();
+
+        case SERVER_MODE:
+            return getBooleanAttribute(mbeanObjectName, IS_CONT_SUPP);
+
+        case PROXY_MODE:
+            return getProxy().isThreadContentionMonitoringSupported();
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#setThreadContentionMonitoringEnabled
+     * <code>ThreadMXBean.setThreadContentionMonitoringEnabled()</code>}.
+     *
+     * @param enable <code>true</code> to enable, <code>false</code> to disable.
+     */
+    public void setThreadContentionMonitoringEnabled(boolean enable) {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            mbean.setThreadContentionMonitoringEnabled(enable);
+            break;
+
+        case SERVER_MODE:
+            setBooleanAttribute(mbeanObjectName, IS_CONT_ENAB, enable);
+            break;
+
+        case PROXY_MODE:
+            getProxy().setThreadContentionMonitoringEnabled(enable);
+            break;
+
+        default:
+            throw new TestBug("Unknown testMode " + mode);
+        }
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#getThreadCpuTime
+     * <code>ThreadMXBean.getThreadCpuTime()</code>}.
+     *
+     * @param id the id of a thread
+     *
+     * @return the CPU time for a thread of the specified ID, if the thread
+     *         existsand is alive and CPU time measurement is enabled, -1
+     *         otherwise.
+     */
+    public long getThreadCpuTime(long id) {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            return mbean.getThreadCpuTime(id);
+
+        case SERVER_MODE:
+            Object[] params = {new Long(id)};
+            String[] signature = {"long"};
+
+            try {
+                Long l = (Long) getMBeanServer().invoke(mbeanObjectName,
+                                                            GET_THREAD_CPU_TIME,
+                                                             params, signature);
+                return l.longValue();
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new Failure(e);
+            }
+
+        case PROXY_MODE:
+            return getProxy().getThreadCpuTime(id);
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#getThreadCount()
+     * <code>ThreadMXBean.getThreadCount()</code>}.
+     *
+     * @return the current number of live threads.
+     */
+    public int getThreadCount() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            return mbean.getThreadCount();
+
+        case SERVER_MODE:
+            return getIntAttribute(mbeanObjectName, THREAD_COUNT);
+
+        case PROXY_MODE:
+            return getProxy().getThreadCount();
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#getPeakThreadCount()
+     * <code>ThreadMXBean.getPeakThreadCount()</code>}.
+     *
+     * @return the peak live thrad count.
+     */
+    public int getPeakThreadCount() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            return mbean.getPeakThreadCount();
+
+        case SERVER_MODE:
+            return getIntAttribute(mbeanObjectName, GET_PEAK_COUNT);
+
+        case PROXY_MODE:
+            return getProxy().getPeakThreadCount();
+        }
+
+        throw new TestBug("Unknown testMode " + mode);
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#resetPeakThreadCount()
+     * <code>ThreadMXBean.resetPeakThreadCount()</code>}.
+     */
+    public void resetPeakThreadCount() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            mbean.resetPeakThreadCount();
+            break;
+
+        case SERVER_MODE:
+            try {
+               getMBeanServer().invoke(mbeanObjectName, RESET_PEAK, null, null);
+            } catch (Exception e) {
+                e.printStackTrace(logger.getOutStream());
+                throw new Failure(e);
+            }
+            break;
+        case PROXY_MODE:
+            getProxy().resetPeakThreadCount();
+            break;
+
+        default:
+            throw new TestBug("Unknown testMode " + mode);
+        }
+
+    }
+
+    /**
+     * Redirects the invocation to {@link
+     * java.lang.management.ThreadMXBean#findMonitorDeadlockedThreads
+     * <code>ThreadMXBean.findMonitorDeadlockedThreads()</code>}.
+     *
+     * @return an array of IDs of the reads that are monitor deadlocked, if any;
+     *         <code>null</code> otherwise.
+     */
+    public long[] findMonitorDeadlockedThreads() {
+        int mode = getTestMode();
+
+        switch (mode) {
+        case DIRECTLY_MODE:
+            return mbean.findMonitorDeadlockedThreads();
+
+        case SERVER_MODE:
+            try {
+                Object o = (Object) getMBeanServer().invoke(mbeanObjectName,
+                                                      FIND_THREADS, null, null);
+                return (long[]) o;
+            } catch (Exception e) {
+                e.printStackTrace(logger.getOutStream());
+                throw new Failure(e);
+            }
+        case PROXY_MODE:
+            return getProxy().findMonitorDeadlockedThreads();
+        }
+        throw new TestBug("Unknown testMode " + mode);
+    }
+} // ThreadMonitor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/direct/DirectMonitoringFactory.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.direct;
+
+import java.lang.management.*;
+import javax.management.*;
+import nsk.monitoring.share.*;
+import java.util.List;
+import java.lang.reflect.Method;
+
+/**
+ * This is MonitoringFactory implementation, which obtains
+ * MXBeans directly from ManagementFactory.
+ *
+ * @see nsk.monitoring.share.MonitoringFactory
+ */
+public class DirectMonitoringFactory implements MonitoringFactory {
+        public ClassLoadingMXBean getClassLoadingMXBean() {
+                return ManagementFactory.getClassLoadingMXBean();
+        }
+
+        public boolean hasCompilationMXBean() {
+                return ManagementFactory.getCompilationMXBean() != null;
+        }
+
+        public CompilationMXBean getCompilationMXBean() {
+                return ManagementFactory.getCompilationMXBean();
+        }
+
+        public List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
+                return ManagementFactory.getGarbageCollectorMXBeans();
+        }
+
+        public RuntimeMXBean getRuntimeMXBean() {
+                return ManagementFactory.getRuntimeMXBean();
+        }
+
+        public MemoryMXBean getMemoryMXBean() {
+                return ManagementFactory.getMemoryMXBean();
+        }
+
+        public NotificationEmitter getMemoryMXBeanNotificationEmitter() {
+                return (NotificationEmitter) ManagementFactory.getMemoryMXBean();
+        }
+
+        public List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
+                return ManagementFactory.getMemoryPoolMXBeans();
+        }
+
+        public ThreadMXBean getThreadMXBean() {
+                return ManagementFactory.getThreadMXBean();
+        }
+
+        public boolean hasThreadMXBeanNew() {
+            boolean supported = false;
+            Class cl = ManagementFactory.getThreadMXBean().getClass();
+            Method[] methods = cl.getDeclaredMethods();
+            for (int i = 0; i < methods.length; i++ ) {
+                if (methods[i].getName().equals("isThreadAllocatedMemorySupported")) {
+                    supported = true;
+                    break;
+                }
+            }
+            return supported;
+        }
+
+        public ThreadMXBean getThreadMXBeanNew() {
+            return getThreadMXBean();
+        }
+        /*
+        public OperatingSystemMXBean getOperatingSystemMXBean() {
+                return ManagementFactory.getOperatingSystemMXBean();
+        }
+
+        */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/libStackTraceController.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "StackTraceController.c"
+#include "jni_tools.c"
+#include "nsk_tools.c"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/libThreadController.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "ThreadController.c"
+#include "jni_tools.c"
+#include "nsk_tools.c"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/proxy/ProxyMonitoringFactory.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.proxy;
+
+import javax.management.MBeanServer;
+import java.lang.management.*;
+import javax.management.*;
+import nsk.monitoring.share.*;
+import java.util.*;
+import java.lang.reflect.Method;
+
+public class ProxyMonitoringFactory implements MonitoringFactory {
+        private MBeanServer mbeanServer;
+        private ClassLoadingMXBean classLoadingMXBean;
+        private CompilationMXBean compilationMXBean;
+        private List<GarbageCollectorMXBean> garbageCollectorMXBeans;
+        private RuntimeMXBean runtimeMXBean;
+        private MemoryMXBean memoryMXBean;
+        private List<MemoryPoolMXBean> memoryPoolMXBeans;
+        private ThreadMXBean threadMXBean;
+        private com.sun.management.ThreadMXBean threadMXBeanNew;
+
+        public ProxyMonitoringFactory(MBeanServer mbeanServer) {
+                this.mbeanServer = mbeanServer;
+        }
+
+        protected <T> T getProxy(String name, Class<T> cl) {
+                try {
+                        return (T) ManagementFactory.newPlatformMXBeanProxy(
+                                mbeanServer,
+                                name,
+                                cl
+                        );
+                } catch (Exception e) {
+                        throw Monitoring.convertException(e);
+                }
+        }
+
+        protected <T> T getProxy(ObjectName name, Class<T> cl) {
+                return getProxy(name.toString(), cl);
+        }
+
+        protected <T> List<T> getProxies(String prefix, Class<T> cl) {
+                Collection<ObjectName> coll = Monitoring.queryNamesByStart(mbeanServer, prefix + ",");
+                List<T> list = new ArrayList<T>(coll.size());
+                for (ObjectName name : coll) {
+                        list.add(getProxy(name, cl));
+                }
+                return list;
+        }
+
+        public synchronized ClassLoadingMXBean getClassLoadingMXBean() {
+                if (classLoadingMXBean == null)
+                        classLoadingMXBean = getProxy(
+                                ManagementFactory.CLASS_LOADING_MXBEAN_NAME,
+                                ClassLoadingMXBean.class
+                        );
+                return classLoadingMXBean;
+        }
+
+        public boolean hasCompilationMXBean() {
+                try {
+                        return mbeanServer.isRegistered(new ObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME));
+                } catch (MalformedObjectNameException e) {
+                        throw Monitoring.convertException(e);
+                }
+        }
+
+        public synchronized CompilationMXBean getCompilationMXBean() {
+                if (compilationMXBean == null)
+                        compilationMXBean = getProxy(
+                                ManagementFactory.COMPILATION_MXBEAN_NAME,
+                                CompilationMXBean.class
+                        );
+                return compilationMXBean;
+        }
+
+        public synchronized List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
+                if (garbageCollectorMXBeans == null) {
+                        Collection<ObjectName> coll = Monitoring.queryNamesByStart(mbeanServer, ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",");
+                        garbageCollectorMXBeans = new ArrayList<GarbageCollectorMXBean>(coll.size());
+                        for (ObjectName name : coll) {
+                                garbageCollectorMXBeans.add(getProxy(
+                                        name,
+                                        GarbageCollectorMXBean.class
+                                ));
+                        }
+                }
+                return garbageCollectorMXBeans;
+        }
+
+        public synchronized RuntimeMXBean getRuntimeMXBean() {
+                if (runtimeMXBean == null) {
+                        runtimeMXBean = getProxy(
+                                ManagementFactory.RUNTIME_MXBEAN_NAME,
+                                RuntimeMXBean.class
+                        );
+                }
+                return runtimeMXBean;
+        }
+
+        public synchronized MemoryMXBean getMemoryMXBean() {
+                if (memoryMXBean == null) {
+                        memoryMXBean = getProxy(
+                                ManagementFactory.MEMORY_MXBEAN_NAME,
+                                MemoryMXBean.class
+                        );
+                }
+                return memoryMXBean;
+        }
+
+        public synchronized NotificationEmitter getMemoryMXBeanNotificationEmitter() {
+                return new ServerNotificationEmitter(mbeanServer, ManagementFactory.MEMORY_MXBEAN_NAME);
+        }
+
+        public synchronized List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
+                if (memoryPoolMXBeans == null)
+                        memoryPoolMXBeans = getProxies(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE, MemoryPoolMXBean.class);
+                return memoryPoolMXBeans;
+        }
+
+        public synchronized ThreadMXBean getThreadMXBean() {
+                if (threadMXBean == null)
+                        threadMXBean = getProxy(
+                                ManagementFactory.THREAD_MXBEAN_NAME,
+                                ThreadMXBean.class
+                        );
+                return threadMXBean;
+        }
+
+        public boolean hasThreadMXBeanNew() {
+            boolean supported = false;
+            Class cl = ManagementFactory.getThreadMXBean().getClass();
+            Method[] methods = cl.getDeclaredMethods();
+            for (int i = 0; i < methods.length; i++ ) {
+                if (methods[i].getName().equals("isThreadAllocatedMemorySupported")) {
+                    supported = true;
+                    break;
+                }
+            }
+            return supported;
+        }
+
+        public ThreadMXBean getThreadMXBeanNew() {
+            if (threadMXBeanNew == null) {
+                threadMXBeanNew = getProxy(
+                    ManagementFactory.THREAD_MXBEAN_NAME,
+                    com.sun.management.ThreadMXBean.class
+                );
+            }
+            return (ThreadMXBean) threadMXBeanNew;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerClassLoadingMXBean.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import javax.management.MBeanServer;
+import java.lang.management.*;
+
+public class ServerClassLoadingMXBean extends ServerMXBean implements ClassLoadingMXBean {
+        private static final String LOADED_CLASSES = "LoadedClassCount";
+        private static final String TOTAL_CLASSES = "TotalLoadedClassCount";
+        private static final String UNLOADED_CLASSES = "UnloadedClassCount";
+        private static final String VERBOSE = "Verbose";
+
+        public ServerClassLoadingMXBean(MBeanServer mbeanServer) {
+                super(mbeanServer, ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
+        }
+
+        public int getLoadedClassCount() {
+                return getIntAttribute(LOADED_CLASSES);
+        }
+
+        public long getTotalLoadedClassCount() {
+                return getLongAttribute(TOTAL_CLASSES);
+        }
+
+        public long getUnloadedClassCount() {
+                return getLongAttribute(UNLOADED_CLASSES);
+        }
+
+        public boolean isVerbose() {
+                return getBooleanAttribute(VERBOSE);
+        }
+
+        public void setVerbose(boolean verbose) {
+                setBooleanAttribute(VERBOSE, verbose);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerCompilationMXBean.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import javax.management.MBeanServer;
+import java.lang.management.*;
+
+public class ServerCompilationMXBean extends ServerMXBean implements CompilationMXBean {
+        private static final String NAME = "Name";
+        private static final String TOTAL_COMPILATION_TIME = "TotalCompilationTime";
+        private static final String IS_COMP = "CompilationTimeMonitoringSupported";
+
+        public ServerCompilationMXBean(MBeanServer mbeanServer) {
+                super(mbeanServer, ManagementFactory.COMPILATION_MXBEAN_NAME);
+        }
+
+        public String getName() {
+                return getStringAttribute(NAME);
+        }
+
+        public long getTotalCompilationTime() {
+                return getLongAttribute(TOTAL_COMPILATION_TIME);
+        }
+
+        public boolean isCompilationTimeMonitoringSupported() {
+                return getBooleanAttribute(IS_COMP);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerGarbageCollectorMXBean.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import javax.management.*;
+import java.lang.management.*;
+
+public class ServerGarbageCollectorMXBean extends ServerMemoryManagerMXBean implements GarbageCollectorMXBean {
+        private static final String COLLECTION_COUNT = "CollectionCount";
+        private static final String COLLECTION_TIME = "CollectionTime";
+
+        public ServerGarbageCollectorMXBean(MBeanServer mbeanServer, String name) {
+                super(mbeanServer, name);
+        }
+
+        public ServerGarbageCollectorMXBean(MBeanServer mbeanServer, ObjectName name) {
+                super(mbeanServer, name);
+        }
+
+        public long getCollectionCount() {
+                return getLongAttribute(COLLECTION_COUNT);
+        }
+
+        public long getCollectionTime() {
+                return getLongAttribute(COLLECTION_TIME);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerMXBean.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import javax.management.*;
+import javax.management.openmbean.CompositeData;
+import java.lang.management.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+import java.lang.reflect.Method;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+
+public class ServerMXBean {
+        protected MBeanServer mbeanServer;
+        protected ObjectName objectName;
+
+        public ServerMXBean(MBeanServer mbeanServer, String name) {
+                this.mbeanServer = mbeanServer;
+                try {
+                        this.objectName = new ObjectName(name);
+                } catch (Exception e) {
+                        throw Monitoring.convertException(e);
+                }
+        }
+
+        public ServerMXBean(MBeanServer mbeanServer, ObjectName objectName) {
+                this.mbeanServer = mbeanServer;
+                this.objectName = objectName;
+        }
+
+        protected RuntimeException convertException(Exception e) {
+                //e.printStackTrace(logger.getOutStream());
+                return new Failure(e);
+        }
+
+        /**
+         * Retrieves the <code>int</code> value of the specified attribute
+         * from MBeanServer.
+         *
+         * @param object MBean's <code>ObjectName</code>
+         * @param name name of the attribute.
+         *
+         * @return value of the attribute.
+         */
+        protected int getIntAttribute(String name) {
+                try {
+                        Integer i = (Integer) mbeanServer.getAttribute(objectName, name);
+                        return i.intValue();
+                } catch (Exception e) {
+                        throw convertException(e);
+                }
+        }
+
+        /**
+         * Retrieves the <code>long</code> value of the specified attribute
+         * from MBeanServer.
+         *
+         * @param object MBean's <code>ObjectName</code>
+         * @param name name of the attribute.
+         *
+         * @return value of the attribute.
+         */
+        protected long getLongAttribute(String name) {
+                try {
+                        Long l = (Long) mbeanServer.getAttribute(objectName, name);
+                        return l.longValue();
+                } catch (Exception e) {
+                        throw convertException(e);
+                }
+        }
+
+        /**
+         * Sets the value of the specified <code>long</code> attribute
+         * from MBeanServer.
+         *
+         * @param object MBean's <code>ObjectName</code>
+         * @param name name of the attribute.
+         *
+         * @return value of the attribute.
+         */
+        protected void setLongAttribute(String name, long value) {
+                Attribute attribute = new Attribute(name, new Long(value));
+                try {
+                        mbeanServer.setAttribute(objectName, attribute);
+                } catch (Exception e) {
+                        throw convertException(e);
+                }
+        }
+
+
+        /**
+         * Sets the <code>boolean</code> value to the specified attribute from
+         * MBeanServer.
+         *
+         * @param object MBean's <code>ObjectName</code>
+         * @param name name of the attribute.
+         * @param value value of the attribute.
+         */
+        protected void setBooleanAttribute(String name, boolean value) {
+                Attribute attribute = new Attribute(name, new Boolean(value));
+                try {
+                        mbeanServer.setAttribute(objectName, attribute);
+                } catch (Exception e) {
+                        throw convertException(e);
+                }
+        }
+
+        /**
+         * Retrieves the <code>boolean</code> value of the specified attribute
+         * from MBeanServer.
+         *
+         * @param object MBean's <code>ObjectName</code>
+         * @param name name of the attribute.
+         *
+         * @return value of the attribute.
+         */
+        protected boolean getBooleanAttribute(String name) {
+                try {
+                        Boolean b = (Boolean) mbeanServer.getAttribute(objectName, name);
+                        return b.booleanValue();
+                } catch (Exception e) {
+                        throw convertException(e);
+                }
+        }
+
+        /**
+         * Retrieves the <code>String</code> value of the specified attribute
+         * from MBeanServer.
+         *
+         * @param object MBean's <code>ObjectName</code>
+         * @param name name of the attribute.
+         *
+         * @return value of the attribute.
+         */
+        protected String getStringAttribute(String name) {
+                try {
+                        String s = (String) mbeanServer.getAttribute(objectName, name);
+                        return s;
+                } catch (Exception e) {
+                        throw convertException(e);
+                }
+        }
+
+        /**
+         * Retrieves the <code>String</code> value of the specified attribute
+         * from MBeanServer.
+         *
+         * @param object MBean's <code>ObjectName</code>
+         * @param name name of the attribute.
+         *
+         * @return value of the attribute.
+         */
+        protected String[] getStringArrayAttribute(String name) {
+                try {
+                        String[] s = (String[]) mbeanServer.getAttribute(objectName, name);
+                        return s;
+                } catch (Exception e) {
+                        throw convertException(e);
+                }
+        }
+
+        /**
+         * Retrieves the <code>MemoryUsage</code> value of the specified attribute
+         * from MBeanServer.
+         *
+         * @param object MBean's <code>ObjectName</code>
+         * @param name name of the attribute.
+         *
+         * @return value of the attribute.
+         */
+        protected MemoryUsage getMemoryUsageAttribute(String name) {
+                try {
+                        Object data = mbeanServer.getAttribute(objectName, name);
+                        if (data instanceof MemoryUsage)
+                                return (MemoryUsage) data;
+                        return MemoryUsage.from((CompositeData) data);
+                } catch (Exception e) {
+                        throw convertException(e);
+                }
+        }
+
+        /**
+         * Retrieves the <code>MemoryType</code> value of the specified attribute
+         * from MBeanServer.
+         *
+         * @param object MBean's <code>ObjectName</code>
+         * @param name name of the attribute.
+         *
+         * @return value of the attribute.
+         */
+        protected MemoryType getMemoryTypeAttribute(String name) {
+                try {
+                        Object data = mbeanServer.getAttribute(objectName, name);
+                        return (MemoryType) data;
+                } catch (Exception e) {
+                        throw convertException(e);
+                }
+        }
+
+        protected<T> T[] convertArray(Object o, Class<T[]> cl) {
+                if (cl.isInstance(o))
+                        return (T[]) o;
+                else {
+                        CompositeData[] data = (CompositeData[]) o;
+                        Class<?> ccl = cl.getComponentType();
+                        T[] t = (T[]) Array.newInstance(ccl, data.length);
+                        for (int i = 0; i < t.length; ++i)
+                                t[i] = (T) convertObject(data[i], ccl);
+                        return t;
+                }
+        }
+
+        protected<T> T convertObject(Object o, Class<T> cl) {
+                if (cl.isInstance(o))
+                        return (T) o;
+                else {
+                        try {
+                                Method method = cl.getMethod("from", CompositeData.class);
+                                return (T) method.invoke(null, o);
+                        } catch (NoSuchMethodException e) {
+                                throw Monitoring.convertException(e);
+                        } catch (IllegalAccessException e) {
+                                throw Monitoring.convertException(e);
+                        } catch (InvocationTargetException e) {
+                                throw Monitoring.convertException(e);
+                        }
+                }
+        }
+
+        protected void invokeVoidMethod(String name) {
+                invokeMethod(name, new Object[0], null);
+        }
+
+        protected Object invokeMethod(String name, Object[] params, String[] signature) {
+                try {
+                        return mbeanServer.invoke(objectName, name, params, signature);
+                } catch (InstanceNotFoundException e) {
+                        throw Monitoring.convertException(e);
+                } catch (MBeanException e) {
+                        throw Monitoring.convertException(e);
+                } catch (ReflectionException e) {
+                        throw Monitoring.convertException(e);
+                }
+        }
+
+        public ObjectName getObjectName() {
+                return null;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerMemoryMXBean.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import java.util.*;
+import nsk.monitoring.share.*;
+import javax.management.*;
+import java.lang.management.*;
+
+/**
+ * MemoryMXBean implementation that delegates functionality to MBeanServer.
+ */
+public class ServerMemoryMXBean extends ServerMXBean implements MemoryMXBean {
+        private static final String GC = "gc";
+        private static final String HEAP_MEMORY_USAGE = "MemoryUsage";
+        private static final String NONHEAP_MEMORY_USAGE = "MemoryUsage";
+        private static final String OBJECT_PENDING_FINALIZATION_COUNT = "ObjectsPendingFinalizationCount";
+        private static final String VERBOSE = "Verbose";
+
+        public ServerMemoryMXBean(MBeanServer mbeanServer) {
+                super(mbeanServer, ManagementFactory.MEMORY_MXBEAN_NAME);
+        }
+
+        public void gc() {
+                invokeVoidMethod(GC);
+        }
+
+        public MemoryUsage getHeapMemoryUsage() {
+                return getMemoryUsageAttribute(HEAP_MEMORY_USAGE);
+        }
+
+        public MemoryUsage getNonHeapMemoryUsage() {
+                return getMemoryUsageAttribute(NONHEAP_MEMORY_USAGE);
+        }
+
+        public int getObjectPendingFinalizationCount() {
+                return getIntAttribute(OBJECT_PENDING_FINALIZATION_COUNT);
+        }
+
+        public boolean isVerbose() {
+                return getBooleanAttribute(VERBOSE);
+        }
+
+        public void setVerbose(boolean verbose) {
+                setBooleanAttribute(VERBOSE, verbose);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerMemoryManagerMXBean.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import javax.management.*;
+import java.lang.management.*;
+
+public class ServerMemoryManagerMXBean extends ServerMXBean implements MemoryManagerMXBean {
+        private static final String MEMORY_POOL_NAMES = "MemoryPoolNames";
+        private static final String NAME = "Name";
+        private static final String VALID = "Valid";
+
+        public ServerMemoryManagerMXBean(MBeanServer mbeanServer, String name) {
+                super(mbeanServer, name);
+        }
+
+        public ServerMemoryManagerMXBean(MBeanServer mbeanServer, ObjectName name) {
+                super(mbeanServer, name);
+        }
+
+        public String[] getMemoryPoolNames() {
+                throw new UnsupportedOperationException("TODO");
+        }
+
+        public String getName() {
+                return getStringAttribute(NAME);
+        }
+
+        public boolean isValid() {
+                return getBooleanAttribute(VALID);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerMemoryPoolMXBean.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import java.util.*;
+import nsk.monitoring.share.*;
+import javax.management.*;
+import java.lang.management.*;
+
+/**
+ * MemoryPoolMXBean implementation that delegates functionality to MBeanServer.
+ */
+public class ServerMemoryPoolMXBean extends ServerMXBean implements MemoryPoolMXBean {
+        public ServerMemoryPoolMXBean(MBeanServer mbeanServer, String name) {
+                super(mbeanServer, name);
+        }
+
+        public ServerMemoryPoolMXBean(MBeanServer mbeanServer, ObjectName name) {
+                super(mbeanServer, name);
+        }
+
+        public MemoryUsage getCollectionUsage() {
+                return getMemoryUsageAttribute("CollectionUsage");
+        }
+
+        public long getCollectionUsageThreshold() {
+                return getLongAttribute("CollectionUsageThreshold");
+        }
+
+        public long getCollectionUsageThresholdCount() {
+                return getLongAttribute("CollectionUsageThresholdCount");
+        }
+
+        public String[] getMemoryManagerNames() {
+                return getStringArrayAttribute("MemoryManagerNames");
+        }
+
+        public String getName() {
+                return getStringAttribute("Name");
+        }
+
+        public MemoryUsage getPeakUsage() {
+                return getMemoryUsageAttribute("PeakUsage");
+        }
+
+        public MemoryType getType() {
+                return getMemoryTypeAttribute("MemoryType");
+        }
+
+        public MemoryUsage getUsage() {
+                return getMemoryUsageAttribute("Usage");
+        }
+
+        public long getUsageThreshold() {
+                return getLongAttribute("UsageThreshhold");
+        }
+
+        public long getUsageThresholdCount() {
+                return getLongAttribute("UsageThreshholdCount");
+        }
+
+        public boolean isCollectionUsageThresholdExceeded() {
+                return getBooleanAttribute("CollectionUsageThresholdExceeded");
+        }
+
+        public boolean isCollectionUsageThresholdSupported() {
+                return getBooleanAttribute("CollectionUsageThresholdSupported");
+        }
+
+        public boolean isUsageThresholdExceeded() {
+                return getBooleanAttribute("UsageThresholdExceeded");
+        }
+
+        public boolean isUsageThresholdSupported() {
+                return getBooleanAttribute("UsageThresholdSupported");
+        }
+
+        public boolean isValid() {
+                return getBooleanAttribute("Valid");
+        }
+
+        public void resetPeakUsage() {
+                invokeVoidMethod("resetPeakUsage");
+        }
+
+        public void setCollectionUsageThreshold(long threshold) {
+                setLongAttribute("CollectionUsageThreshold", threshold);
+        }
+
+        public void setUsageThreshold(long threshold) {
+                setLongAttribute("UsageThreshold", threshold);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerMonitoringFactory.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import javax.management.*;
+import java.lang.management.*;
+import nsk.monitoring.share.*;
+import java.util.*;
+import java.lang.reflect.Method;
+
+public class ServerMonitoringFactory implements MonitoringFactory {
+        private MBeanServer mbeanServer;
+        private List<GarbageCollectorMXBean> garbageCollectorMXBeans;
+        private List<MemoryPoolMXBean> memoryPoolMXBeans;
+        private ThreadMXBean threadMXBean;
+
+        public ServerMonitoringFactory(MBeanServer mbeanServer) {
+                this.mbeanServer = mbeanServer;
+        }
+
+        public ClassLoadingMXBean getClassLoadingMXBean() {
+                return new ServerClassLoadingMXBean(mbeanServer);
+        }
+
+        public boolean hasCompilationMXBean() {
+                try {
+                        return mbeanServer.isRegistered(new ObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME));
+                } catch (MalformedObjectNameException e) {
+                        throw Monitoring.convertException(e);
+                }
+        }
+
+        public CompilationMXBean getCompilationMXBean() {
+                return new ServerCompilationMXBean(mbeanServer);
+        }
+
+        public synchronized List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
+                if (garbageCollectorMXBeans == null) {
+                        Collection<ObjectName> coll = Monitoring.queryNamesByStart(mbeanServer, ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",");
+                        garbageCollectorMXBeans = new ArrayList<GarbageCollectorMXBean>(coll.size());
+                        int i = 0;
+                        for (ObjectName name : coll)
+                                garbageCollectorMXBeans.add(new ServerGarbageCollectorMXBean(mbeanServer, name));
+                }
+                return garbageCollectorMXBeans;
+        }
+
+        public RuntimeMXBean getRuntimeMXBean() {
+                return new ServerRuntimeMXBean(mbeanServer);
+        }
+
+        public MemoryMXBean getMemoryMXBean() {
+                return new ServerMemoryMXBean(mbeanServer);
+        }
+
+        public NotificationEmitter getMemoryMXBeanNotificationEmitter() {
+                return new ServerNotificationEmitter(mbeanServer, ManagementFactory.MEMORY_MXBEAN_NAME);
+        }
+
+        public List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
+                if (memoryPoolMXBeans == null) {
+                        Collection<ObjectName> coll = Monitoring.queryNamesByStart(mbeanServer, ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE + ",");
+                        memoryPoolMXBeans = new ArrayList<MemoryPoolMXBean>(coll.size());
+                        int i = 0;
+                        for (ObjectName name : coll)
+                                memoryPoolMXBeans.add(new ServerMemoryPoolMXBean(mbeanServer, name));
+                }
+                return memoryPoolMXBeans;
+        }
+
+        public ThreadMXBean getThreadMXBean() {
+                if (threadMXBean == null)
+                        threadMXBean = new ServerThreadMXBean(mbeanServer);
+                return threadMXBean;
+        }
+
+        public boolean hasThreadMXBeanNew() {
+            boolean supported = false;
+            Class cl = ManagementFactory.getThreadMXBean().getClass();
+            Method[] methods = cl.getDeclaredMethods();
+            for (int i = 0; i < methods.length; i++ ) {
+                if (methods[i].getName().equals("isThreadAllocatedMemorySupported")) {
+                    supported = true;
+                    break;
+                }
+            }
+            return supported;
+        }
+
+        public ThreadMXBean getThreadMXBeanNew () {
+            return new ServerThreadMXBeanNew(mbeanServer);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerRuntimeMXBean.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import java.util.*;
+import javax.management.MBeanServer;
+import java.lang.management.*;
+
+public class ServerRuntimeMXBean extends ServerMXBean implements RuntimeMXBean {
+        private static final String BOOT_CLASSPATH= "BootClassPath";
+        private static final String CLASSPATH= "ClassPath";
+        private static final String INPUT_ARGUMENTS = "InputArguments";
+        private static final String LIBRARY_PATH = "LibraryPath";
+        private static final String MANAGEMENT_SPEC_VERSION = "ManagementSpecVersion";
+        private static final String NAME = "Name";
+        private static final String SPEC_NAME = "SpecName";
+        private static final String SPEC_VENDOR = "SpecVendor";
+        private static final String SPEC_VERSION = "SpecVersion";
+        private static final String START_TIME = "StartTime";
+        private static final String UPTIME = "Uptime";
+        private static final String VM_NAME = "VmName";
+        private static final String VM_VENDOR = "VmVendor";
+        private static final String VM_VERSION = "VmVersion";
+        private static final String BOOT_CLASSPATH_SUPPORTED = "BootClassPathSupported";
+
+        public ServerRuntimeMXBean(MBeanServer mbeanServer) {
+                super(mbeanServer, ManagementFactory.RUNTIME_MXBEAN_NAME);
+        }
+
+        public String getBootClassPath() {
+                return getStringAttribute(BOOT_CLASSPATH);
+        }
+
+        public String getClassPath() {
+                return getStringAttribute(CLASSPATH);
+        }
+
+        public List<String> getInputArguments() {
+                throw new UnsupportedOperationException("TODO");
+        }
+
+        public String getLibraryPath() {
+                return getStringAttribute(LIBRARY_PATH);
+        }
+
+        public String getManagementSpecVersion() {
+                return getStringAttribute(MANAGEMENT_SPEC_VERSION);
+        }
+
+        public String getName() {
+                return getStringAttribute(NAME);
+        }
+
+        public String getSpecName() {
+                return getStringAttribute(SPEC_NAME);
+        }
+
+        public String getSpecVendor() {
+                return getStringAttribute(SPEC_VENDOR);
+        }
+
+        public String getSpecVersion() {
+                return getStringAttribute(SPEC_VERSION);
+        }
+
+        public long getStartTime() {
+                return getLongAttribute(START_TIME);
+        }
+
+        public Map<String, String> getSystemProperties() {
+                throw new UnsupportedOperationException("TODO");
+        }
+
+        public long getUptime() {
+                return getLongAttribute(UPTIME);
+        }
+
+        public String getVmName() {
+                return getStringAttribute(VM_NAME);
+        }
+
+        public String getVmVendor() {
+                return getStringAttribute(VM_VENDOR);
+        }
+
+        public String getVmVersion() {
+                return getStringAttribute(VM_VERSION);
+        }
+
+        public boolean isBootClassPathSupported() {
+                return getBooleanAttribute(BOOT_CLASSPATH_SUPPORTED);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerThreadMXBean.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import java.util.*;
+import nsk.monitoring.share.*;
+import javax.management.*;
+import java.lang.management.*;
+import javax.management.openmbean.*;
+
+/**
+ * ThreadMXBean implementation that delegates functionality to MBeanServer.
+ */
+public class ServerThreadMXBean extends ServerMXBean implements ThreadMXBean {
+        public ServerThreadMXBean(MBeanServer mbeanServer) {
+                super(mbeanServer, ManagementFactory.THREAD_MXBEAN_NAME);
+        }
+
+        public ThreadInfo[] dumpAllThreads(boolean lockedMonitors, boolean lockedSynchronizers) {
+                return getThreadInfoArr(invokeMethod("dumpAllThreads", new Object[] { lockedMonitors, lockedSynchronizers },
+                        new String[] { boolean.class.getName(), boolean.class.getName() }));
+        }
+
+        public ThreadInfo[] dumpAllThreads(boolean lockedMonitors, boolean lockedSynchronizers, int maxDepth) {
+                return getThreadInfoArr(invokeMethod("dumpAllThreads", new Object[] { lockedMonitors, lockedSynchronizers, maxDepth },
+                        new String[] { boolean.class.getName(), boolean.class.getName(), int.class.getName() }));
+        }
+
+        public long[] findDeadlockedThreads() {
+                return (long[]) invokeMethod("findDeadlockedThreads", null, null);
+        }
+
+        public long[] findMonitorDeadlockedThreads() {
+                return (long[]) invokeMethod("findMonitorDeadlockedThreads", null, null);
+        }
+
+        public long[] getAllThreadIds() {
+                return (long[]) invokeMethod("getAllThreadIds", null, null);
+        }
+
+        public long getCurrentThreadCpuTime() {
+                return getLongAttribute("CurrentThreadCpuTime");
+        }
+
+        public long getCurrentThreadUserTime() {
+                return getLongAttribute("CurrentThreadUserTime");
+        }
+
+        public int getDaemonThreadCount() {
+                return getIntAttribute("DaemonThreadCount");
+        }
+
+        public int getPeakThreadCount() {
+                return getIntAttribute("PeakThreadCount");
+        }
+
+        public int getThreadCount() {
+                return getIntAttribute("ThreadCount");
+        }
+
+        public long getThreadCpuTime(long id) {
+                throw new UnsupportedOperationException("This method is not supported");
+        }
+
+        public ThreadInfo getThreadInfo(long id) {
+                return getThreadInfo(invokeMethod("getThreadInfo", new Object[] { id }, new String[] { long.class.getName() }));
+        }
+
+        public ThreadInfo[] getThreadInfo(long[] ids) {
+                return getThreadInfoArr(invokeMethod("getThreadInfo", new Object[] { ids },
+                        new String[] { long[].class.getName() }));
+        }
+
+        public ThreadInfo[] getThreadInfo(long[] ids, boolean lockedMonitors, boolean lockedSynchronizers) {
+                return getThreadInfoArr(invokeMethod("getThreadInfo", new Object[] { ids, lockedMonitors, lockedSynchronizers },
+                        new String[] { long[].class.getName(), boolean.class.getName(), boolean.class.getName() }));
+        }
+
+        public ThreadInfo[] getThreadInfo(long[] ids, boolean lockedMonitors, boolean lockedSynchronizers, int maxDepth) {
+                return getThreadInfoArr(invokeMethod("getThreadInfo", new Object[] { ids, lockedMonitors, lockedSynchronizers, maxDepth },
+                        new String[] { long[].class.getName(), boolean.class.getName(), boolean.class.getName(), int.class.getName() }));
+        }
+
+        public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth) {
+                return getThreadInfoArr(invokeMethod("getThreadInfo", new Object[] { ids, maxDepth }, new String[] { long[].class.getName(), int.class.getName() }));
+        }
+
+        public ThreadInfo getThreadInfo(long id, int maxDepth) {
+                return getThreadInfo(invokeMethod("getThreadInfo", new Object[] { id, maxDepth }, new String[] { long.class.getName(), int.class.getName() }));
+        }
+
+        public long getThreadUserTime(long id) {
+                throw new UnsupportedOperationException("This method is not supported");
+        }
+
+        public long getTotalStartedThreadCount() {
+                return getLongAttribute("TotalStartedThreadCount");
+        }
+
+        public boolean isCurrentThreadCpuTimeSupported() {
+                return getBooleanAttribute("CurrentThreadCpuTimeSupported");
+        }
+
+        public boolean isObjectMonitorUsageSupported() {
+                return getBooleanAttribute("ObjectMonitorUsageSupported");
+        }
+
+        public boolean isSynchronizerUsageSupported() {
+                return getBooleanAttribute("SynchronizerUsageSupported");
+        }
+
+        public boolean isThreadContentionMonitoringEnabled() {
+                return getBooleanAttribute("ThreadContentionMonitoringEnabled");
+        }
+
+        public boolean isThreadContentionMonitoringSupported() {
+                return getBooleanAttribute("ThreadContentionMonitoringSupported");
+        }
+
+        public boolean isThreadCpuTimeEnabled() {
+                return getBooleanAttribute("ThreadCpuTimeEnabled");
+        }
+
+        public boolean isThreadCpuTimeSupported() {
+                return getBooleanAttribute("ThreadCpuTimeSupported");
+        }
+
+        public void resetPeakThreadCount() {
+                invokeVoidMethod("resetPeakThreadCount");
+        }
+
+        public void setThreadContentionMonitoringEnabled(boolean enable) {
+                setBooleanAttribute("ThreadContentionMonitorinEnabled", enable);
+        }
+
+        public void setThreadCpuTimeEnabled(boolean enable) {
+                setBooleanAttribute("ThreadCpuTimeEnabled", enable);
+        }
+
+        protected ThreadInfo getThreadInfo(Object o) {
+                return convertObject(o, ThreadInfo.class);
+        }
+
+        protected ThreadInfo[] getThreadInfoArr(Object o) {
+                return convertArray(o, ThreadInfo[].class);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/server/ServerThreadMXBeanNew.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.server;
+
+import javax.management.*;
+import com.sun.management.*;
+
+/**
+ * com.sun.management.ThreadMXBean implementation that delegates functionality to MBeanServer.
+ */
+public class ServerThreadMXBeanNew extends ServerThreadMXBean implements ThreadMXBean{
+
+    public ServerThreadMXBeanNew(MBeanServer mbeanServer) {
+        super(mbeanServer);
+    }
+
+    public long[] getThreadUserTime(long[] ids) {
+        return (long[]) invokeMethod("getThreadUserTime",
+                new Object[] { ids },
+                new String[] { long[].class.getName() });
+    }
+
+    public long[] getThreadCpuTime(long[] ids) {
+        return (long[]) invokeMethod("getThreadCpuTime",
+                new Object[] { ids },
+                new String[] { long[].class.getName() });
+    }
+
+    public long[] getThreadAllocatedBytes(long[] ids) {
+        return (long[]) invokeMethod("getThreadAllocatedBytes",
+                new Object[] { ids },
+                new String[] { long[].class.getName() });
+    }
+
+    public long getThreadAllocatedBytes(long id) {
+        return (Long) invokeMethod("getThreadAllocatedBytes",
+            new Object[] { id },
+            new String[] { long.class.getName() });
+    }
+
+    public void setThreadAllocatedMemoryEnabled(boolean enabled) {
+        setBooleanAttribute("ThreadAllocatedMemoryEnabled", enabled);
+    }
+
+    public boolean isThreadAllocatedMemorySupported() {
+        return getBooleanAttribute("ThreadAllocatedMemorySupported");
+    }
+
+    public boolean isThreadAllocatedMemoryEnabled() {
+        return getBooleanAttribute("ThreadAllocatedMemoryEnabled");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/BlockedThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.log.Log;
+import java.lang.management.ThreadInfo;
+import java.lang.management.MonitorInfo;
+import java.lang.management.LockInfo;
+import nsk.share.TestBug;
+import nsk.share.test.LocalRandom;
+import nsk.monitoring.share.Monitoring;
+
+/**
+ * BlockedThread is RecursiveMonitoringThread that blocks on entering
+ * synchronized section.
+ */
+public class BlockedThread extends RecursiveMonitoringThread {
+        private LockerThread lockerThread;
+        protected Object lock;
+        protected Object readyLock = new Object();
+        protected volatile boolean ready = false;
+        private static final String[] expectedMethods = {
+                "nsk.monitoring.share.thread.BlockedThread.runInside"
+        };
+
+        public BlockedThread(Log log, RunType recursionType, int maxDepth, LockerThread lockerThread) {
+                super(log, recursionType, maxDepth);
+                this.lockerThread = lockerThread;
+                this.lock = lockerThread.getLock();
+        }
+
+        public void checkThreadInfo(ThreadInfo info) {
+                super.checkThreadInfo(info);
+                verify(info.getThreadState() == Thread.State.BLOCKED, "ThreadInfo.getThreadState() = " + info.getThreadState() + " != " + Thread.State.BLOCKED);
+                verify(info.getBlockedTime() == 0 || info.getBlockedTime() == -1, "ThreadInfo.getBlockedTime() == " + info.getBlockedTime());
+                verify(info.getBlockedCount() >= 1, "ThreadInfo.getBlockedCount() = " + info.getBlockedCount() + " != " + 1);
+                verify(info.getWaitedTime() == 0 || info.getWaitedTime() == -1, "ThreadInfo.getWaitedTime() == " + info.getWaitedTime());
+                verify(info.getWaitedCount() == 0, "ThreadInfo.getWaitedCount() = " + info.getWaitedCount() + " != " + 0);
+                checkLockInfo(info.getLockInfo(), lock);
+                verify(info.getLockName().equals(info.getLockInfo().toString()), "ThreadInfo.getLockName() = " + info.getLockName() + " != lock.toString() = " + lock.toString());
+                verify(info.getLockOwnerId() == lockerThread.getId(), "ThreadInfo.getLockOwnerId() = " + info.getLockOwnerId() + " != this.getId() = " + this.getId());
+                verify(info.getLockOwnerName().equals(lockerThread.getName()), "ThreadInfo.getLockOwnerName() = " + info.getLockOwnerName() + " != lockerThread.getName() = " + lockerThread.getName());
+                checkMonitorInfo(info.getLockedMonitors(), null);
+                checkSynchronizers(info.getLockedSynchronizers(), null);
+        }
+
+        private void checkStackTrace(MonitorInfo[] minfo, StackTraceElement[] elements) {
+                verify(minfo.length == 1, "ThreadInfo.getLockedMonitors() is of length " + minfo.length);
+                MonitorInfo minfo1 = minfo[0];
+                verify(minfo1.getLockedStackDepth() == elements.length, "MonitorInfo.getLockedStackDepth() = " + minfo1.getLockedStackDepth() + " != elements.length = " + elements.length);
+                verify(minfo1.getLockedStackFrame().equals(elements[elements.length - 1]), "MonitorInfo.getLockedStackFrame() = " + minfo1.getLockedStackFrame() + " is different from last element " + elements[elements.length - 1]);
+                checkLockInfo(minfo1, lock);
+        }
+
+        public void waitState() {
+                synchronized (readyLock) {
+                        while (!ready) {
+                                try {
+                                        readyLock.wait();
+                                } catch (InterruptedException e) {
+                                        log.warn(e);
+                                }
+                        }
+                }
+                waitThreadState(Thread.State.BLOCKED);
+        }
+
+        public void finish() {
+                ready = false;
+                synchronized (lock) {
+                        lock.notify();
+                }
+        }
+
+        protected void runInside() {
+                synchronized (readyLock) {
+                        ready = true;
+                        readyLock.notifyAll();
+                }
+                do {
+                        synchronized (lock) {
+                                System.out.println("BlockedThread acquired lock");
+
+                                // Actually, this thread will reach here after LockerThread.finish() is called,
+                                // but before finish() is called. But it does not matter, because check(ThreadInfo)
+                                // was already called.
+                        }
+
+                        System.out.println("BlockedThread relinquished lock");
+
+                } while (ready);
+        }
+
+        protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                return super.isStackTraceElementExpected(element) || checkStackTraceElement(element, expectedMethods);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/Deadlock.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+#include <jni.h>
+#include "jni_tools.h"
+
+#define FIND_CLASS(_class, _className)\
+        if (!NSK_JNI_VERIFY(env, (_class = \
+             NSK_CPP_STUB2(FindClass, env, _className)) != NULL))\
+                return
+
+#define GET_OBJECT_CLASS(_class, _obj)\
+        if (!NSK_JNI_VERIFY(env, (_class = \
+             NSK_CPP_STUB2(GetObjectClass, env, _obj)) != NULL))\
+                return
+
+#define GET_OBJ_FIELD(_value, _obj, _class, _fieldName, _fieldSig)\
+        GET_FIELD_ID(field, _class, _fieldName, _fieldSig);\
+        _value = NSK_CPP_STUB3(GetObjectField, env, _obj, field)
+
+#define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\
+        if (!NSK_JNI_VERIFY(env, (_fieldID = \
+             NSK_CPP_STUB4(GetFieldID, env, _class,\
+             _fieldName, _fieldSig)) != NULL))\
+                return
+
+#define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\
+        if (!NSK_JNI_VERIFY(env, (_methodID = \
+             NSK_CPP_STUB4(GetMethodID, env, _class,\
+             _methodName, _sig)) != NULL)) \
+                return
+
+#define CALL_VOID_NOPARAM(_obj, _class, _methodName)\
+            GET_METHOD_ID(method, _class, _methodName, "()V");\
+        if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB3(CallVoidMethod, env, _obj,\
+             method))) \
+                return
+
+/*
+ * Class:     nsk_monitoring_share_thread_MonitorDeadlock_DeadlockThread
+ * Method:    nativeLock2
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_nsk_monitoring_share_thread_Deadlock_00024NativeLocker_lock
+(JNIEnv *env, jobject this) {
+        jclass testBugClass, nativeLockerClass, lockerClass, wicketClass;
+        jobject lock, inner, step1, step2, step3;
+        jfieldID field;
+        jmethodID method;
+
+        GET_OBJECT_CLASS(nativeLockerClass, this);
+        FIND_CLASS(lockerClass, "nsk/monitoring/share/thread/Deadlock$Locker");
+        FIND_CLASS(wicketClass, "nsk/share/Wicket");
+        FIND_CLASS(testBugClass, "nsk/share/TestBug");
+        GET_OBJ_FIELD(lock, this, nativeLockerClass, "lock", "Ljava/lang/Object;");
+        GET_OBJ_FIELD(step1, this, nativeLockerClass, "step1", "Lnsk/share/Wicket;");
+        if (step1 == NULL) {
+                (*env)->ThrowNew(env, testBugClass, "step1 field is null");
+                return;
+        }
+        GET_OBJ_FIELD(step2, this, nativeLockerClass, "step2", "Lnsk/share/Wicket;");
+        if (step2 == NULL) {
+                (*env)->ThrowNew(env, testBugClass, "step2 field is null");
+                return;
+        }
+        GET_OBJ_FIELD(step3, this, nativeLockerClass, "step3", "Lnsk/share/Wicket;");
+        if (step3 == NULL) {
+                (*env)->ThrowNew(env, testBugClass, "step3 field is null");
+                return;
+        }
+        GET_OBJ_FIELD(inner, this, lockerClass, "inner", "Lnsk/monitoring/share/thread/Deadlock$Locker;");
+        if ((*env)->MonitorEnter(env, lock) == JNI_OK) {
+                if (inner == NULL) {
+                        (*env)->ThrowNew(env, testBugClass, "Should not reach here");
+                } else {
+                        CALL_VOID_NOPARAM(step1, wicketClass, "unlock");
+                        CALL_VOID_NOPARAM(step2, wicketClass, "waitFor");
+                        CALL_VOID_NOPARAM(step3, wicketClass, "unlock");
+                        CALL_VOID_NOPARAM(inner, lockerClass, "lock");
+                }
+                (*env)->MonitorExit(env, lock);
+        } else {
+                (*env)->ThrowNew(env, testBugClass, "MonitorEnter(lock) call failed");
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/Deadlock.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,595 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import java.lang.management.*;
+import nsk.share.log.*;
+import nsk.share.TestBug;
+import nsk.share.TestFailure;
+import nsk.share.Wicket;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Scenario that starts threads that use different scenarios to deadlock.
+ * Several types of deadlocks are implemented:
+ * Deadlock.Type.JAVA - several threads use synchronized blocks on java objects
+ * Deadlock.Type.NATIVE - several threads use JNI MonitorEnter on java objects
+ * Deadlock.Type.SYNCHRONIZED_METHOD - several threads use synchronized method
+ * Deadlock.Type.SYNCHRONIZER - several threads use java.util.concurrent.locks locks
+ * Deadlock.Type.MIXED - a mix of all above, each thread uses different combination
+ * of lock types
+ *
+ * Note: this scenario is not reusable in sense that it cannot be run and successfully
+ * checked several times, because there is no way to finish deadlocked threads.
+ */
+public class Deadlock extends ThreadMonitoringScenarioBase {
+        public static enum Type {
+                JAVA,
+                NATIVE,
+                SYNCHRONIZED_METHOD,
+                SYNCHRONIZER,
+                MIXED
+        };
+
+        private static final String[] expectedMethods = {
+                "nsk.monitoring.share.thread.Deadlock$DeadlockThread.runInside",
+                "nsk.monitoring.share.thread.Deadlock$DeadlockThread.javaLock",
+                "nsk.monitoring.share.thread.Deadlock$DeadlockThread.nativeLock",
+                "nsk.monitoring.share.thread.Deadlock$DeadlockThread.mixedLock",
+                "nsk.monitoring.share.thread.Deadlock$DeadlockThread.nativeLock2"
+        };
+        private Type deadlockType;
+        private RunType recursionType;
+        private int maxDepth;
+        private Wicket step1;
+        private Wicket step2;
+        private Wicket step3;
+        private Object[] locks;
+        private Locker[] lockers;
+        private DeadlockThread[] threads;
+        private long[] threadIds;
+        private ThreadInfo[] threadInfo;
+        private Deadlocker deadlocker;
+
+        static {
+                System.loadLibrary("Deadlock");
+        }
+
+        public Deadlock(Log log, RunType recursionType, int maxDepth, Type deadlockType) {
+                this(log, recursionType, maxDepth, deadlockType, 3);
+        }
+
+        public Deadlock(Log log, RunType recursionType, int maxDepth, Type deadlockType, int threadCount) {
+                super(log);
+                this.recursionType = recursionType;
+                this.maxDepth = maxDepth;
+                threads = new DeadlockThread[threadCount];
+                lockers = new Locker[threadCount];
+                locks = new Object[threadCount];
+                this.deadlockType = deadlockType;
+        }
+
+        public abstract class Locker {
+                protected Locker inner;
+
+                public Locker(Locker inner) {
+                        this.inner = inner;
+                }
+
+                public abstract String getTypeName();
+                public abstract void lock();
+                public abstract void check(ThreadInfo info);
+                public abstract Thread.State getExpectedThreadState();
+        }
+
+        private class JavaLocker extends Locker {
+                private Object lock;
+                private Map<String, Object[]> lockMap = new HashMap<String, Object[]>();
+
+                public JavaLocker(Object lock, Locker inner) {
+                        super(inner);
+                        this.lock = lock;
+                        lockMap.put("lock", new Object[] { lock });
+                }
+
+                public String getTypeName() {
+                        return "synchronized block";
+                }
+
+                public void lock() {
+                        synchronized (lock) {
+                                if (inner != null) {
+                                        step1.unlock();
+                                        step2.waitFor();
+                                        step3.unlock();
+                                        inner.lock();
+                                } else
+                                        throw new TestBug("Should not reach here");
+                        }
+                }
+
+                public void check(ThreadInfo info) {
+                        if (inner == null) {
+                                verify(info.getThreadState() == Thread.State.BLOCKED, "ThreadInfo.getThreadState() = " + info.getThreadState() + " != " + Thread.State.BLOCKED);
+                                checkLockInfo(info.getLockInfo(), lock);
+                                verify(info.getLockName().equals(info.getLockInfo().toString()), "ThreadInfo.getLockName() = " + info.getLockName() + " != info.getLockInfo().toString() = " + info.getLockInfo().toString());
+                        } else {
+                                verify(info.getBlockedCount() >= 0, "ThreadInfo.getBlockedCount() = " + info.getBlockedCount() + " < " + 0);
+                                verify(info.getWaitedCount() >= 0, "ThreadInfo.getWaitedCount() = " + info.getWaitedCount() + " < " + 0);
+                                checkMonitorInfo(info.getLockedMonitors(), lockMap);
+                                checkSynchronizers(info.getLockedSynchronizers(), null);
+                                inner.check(info);
+                        }
+                }
+
+                public Thread.State getExpectedThreadState() {
+                        if (inner != null)
+                                return inner.getExpectedThreadState();
+                        else
+                                return Thread.State.BLOCKED;
+                }
+        }
+
+        private class NativeLocker extends Locker {
+                private Object lock;
+                private Wicket step1;
+                private Wicket step2;
+                private Wicket step3;
+                private Map<String, Object[]> lockMap = new HashMap<String, Object[]>();
+
+                public NativeLocker(Object lock, Locker inner) {
+                        super(inner);
+                        this.lock = lock;
+                        this.step1 = Deadlock.this.step1;
+                        this.step2 = Deadlock.this.step2;
+                        this.step3 = Deadlock.this.step3;
+                        lockMap.put("lock", new Object[] { lock });
+                }
+
+                public String getTypeName() {
+                        return "JNI MonitorEnter";
+                }
+
+                public native void lock();
+
+                public void check(ThreadInfo info) {
+                        if (inner != null) {
+                                verify(info.getLockName().equals(info.getLockInfo().toString()), "ThreadInfo.getLockName() = " + info.getLockName() + " != info.getLockInfo().toString() = " + info.getLockInfo().toString());
+                                checkMonitorInfo(info.getLockedMonitors(), lockMap);
+                                checkSynchronizers(info.getLockedSynchronizers(), null);
+                                inner.check(info);
+                        } else {
+                                verify(info.getThreadState() == Thread.State.BLOCKED, "ThreadInfo.getThreadState() = " + info.getThreadState() + " != " + Thread.State.BLOCKED);
+                                verify(info.getBlockedCount() >= 0, "ThreadInfo.getBlockedCount() = " + info.getBlockedCount() + " < " + 0);
+                                verify(info.getWaitedCount() >= 0, "ThreadInfo.getWaitedCount() = " + info.getWaitedCount() + " < " + 0);
+                                checkLockInfo(info.getLockInfo(), lock);
+                        }
+                }
+
+                public Thread.State getExpectedThreadState() {
+                        if (inner != null)
+                                return inner.getExpectedThreadState();
+                        else
+                                return Thread.State.BLOCKED;
+                }
+        }
+
+        private class SynchronizedMethod {
+                public synchronized void synchronizedMethod(Locker inner) {
+                        if (inner != null) {
+                                step1.unlock();
+                                step2.waitFor();
+                                step3.unlock();
+                                inner.lock();
+                        } else
+                                throw new TestBug("Should not reach here");
+                }
+        }
+
+        private class SynchronizedMethodLocker extends Locker {
+                private SynchronizedMethod lock;
+                private Map<String, Object[]> lockMap = new HashMap<String, Object[]>();
+
+                public SynchronizedMethodLocker(SynchronizedMethod lock, Locker inner) {
+                        super(inner);
+                        this.lock = lock;
+                        lockMap.put("synchronizedMethod", new Object[] { lock });
+                }
+
+                public String getTypeName() {
+                        return "SynchronizedMethod";
+                }
+
+                public void lock() {
+                        lock.synchronizedMethod(inner);
+                }
+
+                public void check(ThreadInfo info) {
+                        if (inner != null) {
+                                checkMonitorInfo(info.getLockedMonitors(), lockMap);
+                                checkSynchronizers(info.getLockedSynchronizers(), null);
+                                inner.check(info);
+                        } else {
+                                verify(info.getThreadState() == Thread.State.BLOCKED, "ThreadInfo.getThreadState() = " + info.getThreadState() + " != " + Thread.State.BLOCKED);
+                                verify(info.getBlockedCount() >= 0, "ThreadInfo.getBlockedCount() = " + info.getBlockedCount() + " < " + 0);
+                                verify(info.getWaitedCount() >= 0, "ThreadInfo.getWaitedCount() = " + info.getWaitedCount() + " < " + 0);
+                                checkLockInfo(info.getLockInfo(), lock);
+                                verify(info.getLockName().equals(info.getLockInfo().toString()), "ThreadInfo.getLockName() = " + info.getLockName() + " != info.getLockInfo().toString() = " + info.getLockInfo().toString());
+                        }
+                }
+
+                public Thread.State getExpectedThreadState() {
+                        if (inner != null)
+                                return inner.getExpectedThreadState();
+                        else
+                                return Thread.State.BLOCKED;
+                }
+        }
+
+        private class SynchronizerLocker extends Locker {
+                private Lock lock;
+                private Map<String, Lock[]> lockMap = new HashMap<String, Lock[]>();
+
+                public SynchronizerLocker(Lock lock, Locker inner) {
+                        super(inner);
+                        this.lock = lock;
+                        lockMap.put("lock", new Lock[] { lock });
+                }
+
+                public String getTypeName() {
+                        return "java.util.concurrent.locks synchronizer";
+                }
+
+                public void lock() {
+                        try {
+                                lock.tryLock(10000000, TimeUnit.SECONDS);
+                        } catch (InterruptedException e) {
+                                log.warn(e);
+                        }
+                        try {
+                                if (inner != null) {
+                                        step1.unlock();
+                                        step2.waitFor();
+                                        step3.unlock();
+                                        inner.lock();
+                                } else
+                                        throw new TestBug("Should not reach here");
+                        } finally {
+                                lock.unlock();
+                        }
+                }
+
+                public void check(ThreadInfo info) {
+                        if (inner != null) {
+                                checkMonitorInfo(info.getLockedMonitors(), null);
+                                checkSynchronizers(info.getLockedSynchronizers(), lockMap);
+                                inner.check(info);
+                        } else {
+                                verify(info.getThreadState() == Thread.State.TIMED_WAITING, "ThreadInfo.getThreadState() = " + info.getThreadState() + " != " + Thread.State.TIMED_WAITING);
+                                //checkLockInfo(info.getLockInfo(), lock2); // Do not check this because actual lock is instance of inner class of ReentrantLock
+                                verify(info.getLockName().equals(info.getLockInfo().toString()), "ThreadInfo.getLockName() = " + info.getLockName() + " != info.getLockInfo().toString() = " + info.getLockInfo().toString());
+                        }
+                }
+
+                public Thread.State getExpectedThreadState() {
+                        if (inner != null)
+                                return inner.getExpectedThreadState();
+                        else
+                                return Thread.State.TIMED_WAITING;
+                }
+        }
+
+
+        private class DeadlockThread extends RecursiveMonitoringThread {
+                private boolean ready = false;
+                private Object readyLock = new Object();
+                private Locker locker;
+
+                public DeadlockThread(Locker locker) {
+                        super(Deadlock.this.log, Deadlock.this.recursionType, Deadlock.this.maxDepth);
+                        this.locker = locker;
+                }
+
+                public void runInside() {
+                        synchronized (readyLock) {
+                                ready = true;
+                                readyLock.notifyAll();
+                        }
+                        locker.lock();
+                }
+
+                public void waitState() {
+                        synchronized (readyLock) {
+                                while (!ready) {
+                                        try {
+                                                readyLock.wait();
+                                        } catch (InterruptedException e) {
+                                                log.warn(e);
+                                        }
+                                }
+                        }
+                        waitThreadState(locker.getExpectedThreadState());
+                }
+
+                public void checkThreadInfo(ThreadInfo info) {
+                        super.checkThreadInfo(info);
+                        locker.check(info);
+                }
+
+                public void finish() {
+                        throw new UnsupportedOperationException("Can't finish deadlocked thread");
+                }
+
+                public void end() {
+                        throw new UnsupportedOperationException("Can't end deadlocked thread");
+                }
+
+                protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                        return super.isStackTraceElementExpected(element) ||
+                               element.getClassName().startsWith("nsk.monitoring.share.thread.Deadlock") ||
+                               element.getClassName().startsWith("java.util.concurrent.locks.") ||
+                               element.getClassName().startsWith("jdk.internal.misc.");
+                }
+        }
+
+        private interface Deadlocker {
+                public void createLockers();
+                public void check(ThreadMXBean threadMXBean);
+        }
+
+        private class JavaDeadlocker implements Deadlocker {
+                public void createLockers() {
+                        for (int i = 0; i < locks.length; ++i)
+                                locks[i] = new String(this + "lock " + i);
+                        for (int i = 0; i < locks.length; ++i)
+                                lockers[i] = new JavaLocker(locks[i], new JavaLocker(locks[(i + 1) % locks.length], null));
+                }
+
+                public void check(ThreadMXBean threadMXBean) {
+                        checkDeadlocks(threadMXBean, threadMXBean.findMonitorDeadlockedThreads());
+                        checkDeadlocks(threadMXBean, threadMXBean.findDeadlockedThreads());
+                        for (DeadlockThread thread : threads)
+                                thread.check(threadMXBean);
+                }
+        }
+
+        private class SynchronizedMethodDeadlocker implements Deadlocker {
+                public void createLockers() {
+                        for (int i = 0; i < locks.length; ++i)
+                                locks[i] = new SynchronizedMethod();
+                        for (int i = 0; i < locks.length; ++i)
+                                lockers[i] = new SynchronizedMethodLocker((SynchronizedMethod) locks[i], new SynchronizedMethodLocker((SynchronizedMethod) locks[(i + 1) % locks.length], null));
+                }
+
+                public void check(ThreadMXBean threadMXBean) {
+                        checkDeadlocks(threadMXBean, threadMXBean.findMonitorDeadlockedThreads());
+                        checkDeadlocks(threadMXBean, threadMXBean.findDeadlockedThreads());
+                        for (DeadlockThread thread : threads)
+                                thread.check(threadMXBean);
+                }
+        }
+
+
+        private class NativeDeadlocker implements Deadlocker {
+                public void createLockers() {
+                        for (int i = 0; i < locks.length; ++i)
+                                locks[i] = new String(this + "lock " + i);
+                        for (int i = 0; i < locks.length; ++i)
+                                lockers[i] = new NativeLocker(locks[i], new NativeLocker(locks[(i + 1) % locks.length], null));
+                }
+
+                public void check(ThreadMXBean threadMXBean) {
+                        checkDeadlocks(threadMXBean, threadMXBean.findMonitorDeadlockedThreads());
+                        checkDeadlocks(threadMXBean, threadMXBean.findDeadlockedThreads());
+                        for (DeadlockThread thread : threads)
+                                thread.check(threadMXBean);
+                }
+        }
+
+        private class SynchronizerDeadlocker implements Deadlocker {
+                public void createLockers() {
+                        for (int i = 0; i < locks.length; ++i)
+                                locks[i] = new ReentrantLock();
+                        for (int i = 0; i < locks.length; ++i)
+                                lockers[i] = new SynchronizerLocker((Lock) locks[i], new SynchronizerLocker((Lock) locks[(i + 1) % locks.length], null));
+                }
+
+                public void check(ThreadMXBean threadMXBean) {
+                        checkDeadlocks(threadMXBean, threadMXBean.findDeadlockedThreads());
+                        for (DeadlockThread thread : threads)
+                                thread.check(threadMXBean);
+                }
+        }
+
+        private class MixedDeadlocker implements Deadlocker {
+                private int getCount() {
+                        return 4;
+                }
+
+                private Object createLock(int type, int i) {
+                        switch (type) {
+                        case 0:
+                                return new String("lock " + i);
+                        case 1:
+                                return new String("lock " + i);
+                        case 2:
+                                return new SynchronizedMethod();
+                        case 3:
+                                return new ReentrantLock();
+                        default:
+                                throw new TestBug("Should not reach here");
+                        }
+                }
+
+                private Locker createLocker(int type, Object lock, Locker inner) {
+                        switch (type) {
+                        case 0:
+                                return new JavaLocker(lock, inner);
+                        case 1:
+                                return new NativeLocker(lock, inner);
+                        case 2:
+                                return new SynchronizedMethodLocker((SynchronizedMethod) lock, inner);
+                        case 3:
+                                return new SynchronizerLocker((Lock) lock, inner);
+                        default:
+                                throw new TestBug("Should not reach here");
+                        }
+                }
+
+                public void createLockers() {
+                        int n = getCount();
+                        int threadCount = lockers.length;
+                        if (threadCount != n * n)
+                                throw new TestBug("Thread count is expected to be " + n * n + ", actual: " + threadCount);
+                        int[] types = new int[n];
+                        for (int i = 0; i < n; ++i)
+                                types[i] = i;
+                        int type = 0;
+                        locks[0] = createLock(0, 0);
+                        log.info("Creating lockers");
+                        /*
+                         * This will ensure that we will have each combination
+                         * of lock type and inner lock type in some thread. Together
+                         * all these threads deadlock.
+                         */
+                        for (int i = 0; i < threadCount; ++i) {
+                                int newtype = types[type];
+                                if (i < threadCount - 1)
+                                        locks[i + 1] = createLock(newtype, i);
+                                Locker inner = createLocker(newtype, locks[(i + 1) % threadCount], null);
+                                lockers[i] = createLocker(type, locks[i], inner);
+                                log.info("Locker " + i + " will lock " + locks[i] + " (" + lockers[i].getTypeName() + ") and will wait for " + locks[(i + 1) % threadCount] + " (" + inner.getTypeName() + ")");
+                                types[type] = (types[type] + 1) % n;
+                                type = newtype;
+                        }
+                }
+
+                public void check(ThreadMXBean threadMXBean) {
+                        checkDeadlocks(threadMXBean, threadMXBean.findDeadlockedThreads());
+                        for (DeadlockThread thread : threads)
+                                thread.check(threadMXBean);
+                }
+        }
+
+
+        protected Deadlocker createDeadlocker() {
+                switch (deadlockType) {
+                case JAVA:
+                        return new JavaDeadlocker();
+                case NATIVE:
+                        return new NativeDeadlocker();
+                case SYNCHRONIZED_METHOD:
+                        return new SynchronizedMethodDeadlocker();
+                case SYNCHRONIZER:
+                        return new SynchronizerDeadlocker();
+                case MIXED:
+                        return new MixedDeadlocker();
+                default:
+                        throw new TestBug("Unknown deadlockType: " + deadlockType);
+                }
+        }
+
+        public void begin() {
+                deadlocker = createDeadlocker();
+                step1 = new Wicket(lockers.length);
+                step2 = new Wicket();
+                step3 = new Wicket(lockers.length);
+                deadlocker.createLockers();
+                threads = new DeadlockThread[lockers.length];
+                for (int i = 0; i < threads.length; ++i)
+                        threads[i] = new DeadlockThread(lockers[i]);
+                for (DeadlockThread thread : threads)
+                        thread.begin();
+        }
+
+        public void waitState() {
+                step1.waitFor();
+                while (step2.getWaiters() != threads.length)
+                        Thread.yield();
+                step2.unlock();
+                step3.waitFor();
+                for (DeadlockThread thread : threads)
+                        thread.waitState();
+        }
+
+        private void obtainThreadDump(ThreadMXBean threadMXBean) {
+                threadIds = new long[threads.length];
+                for (int i = 0; i < threads.length; ++i)
+                        threadIds[i] = threads[i].getId();
+                threadInfo = threadMXBean.getThreadInfo(threadIds, true, true);
+        }
+
+        private void checkDeadlocks(ThreadMXBean threadMXBean, long[] ids) {
+                try {
+                        ThreadUtils.verify(ids != null, "Deadlocked thread ids array is null");
+                        ThreadUtils.verify(ids.length == threads.length, "Wrong length of ThreadMXBean.findMonitorDeadlockedThreads(): " + ids.length + " expected: " + threads.length);
+                        for (long id : ids) {
+                                boolean found = false;
+                                for (MonitoringThread thread : threads)
+                                        if (thread.getId() == id)
+                                                found = true;
+                                ThreadUtils.verify(found, "Unexpected thread id found in ThreadMXBean.findMonitorDeadlockedThreads(): " + id);
+                        }
+                        for (DeadlockThread thread : threads) {
+                                boolean found = false;
+                                for (long id : ids)
+                                        if (thread.getId() == id)
+                                                found = true;
+                                ThreadUtils.verify(found, "Expected thread id not found in ThreadMXBean.findMonitorDeadlockedThreads(): " + thread.getId());
+                        }
+                        log.info("Expected deadlock thread ids found: " + ThreadUtils.strIds(ids));
+                } catch (TestFailure t) {
+                        log.info("Thread dump for verified threads (before the check):");
+                        ThreadUtils.threadDump(log, threadInfo);
+                        log.info("Expected thread ids (total " + threads.length + "): " + ThreadUtils.strIds(threadIds));
+                        if (ids == null)
+                                log.info("Obtained ids array is null");
+                        else {
+                                log.info("Obtained thread ids (total " + ids.length + "): " + ThreadUtils.strIds(ids));
+                                log.info("Thread dump for obtained threads:");
+                                ThreadUtils.threadDump(log, threadMXBean.getThreadInfo(ids));
+                        }
+                        throw t;
+                }
+
+        }
+
+        public void check(ThreadMXBean threadMXBean) {
+                obtainThreadDump(threadMXBean);
+                deadlocker.check(threadMXBean);
+        }
+
+        public void finish() {
+                // Unfortunately, in deadlock situation we cannot terminate started threads
+        }
+
+        public void end() {
+                // Unfortunately, in deadlock situation the threads will not ever end
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/FinishedThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.log.Log;
+import java.lang.management.ThreadInfo;
+import nsk.share.TestFailure;
+import nsk.share.TestBug;
+
+/**
+ * Finished Thread is dummy RecursiveMonitoringThread that is getting
+ * started and finished.
+ */
+public class FinishedThread extends RecursiveMonitoringThread {
+        public FinishedThread(Log log, RunType recursionType, int maxDepth) {
+                super(log, recursionType, maxDepth);
+        }
+
+        public void waitState() {
+                try {
+                        if (runner != null)
+                                runner.join();
+                } catch (InterruptedException e) {
+                        log.warn(e);
+                }
+        }
+
+        public void finish() {
+        }
+
+        protected void runInside() {
+        }
+
+        public void checkThreadInfo(ThreadInfo info) {
+                verify(info == null, "ThreadInfo != null");
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/LockerThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+/**
+ * Locker thread is used to lock monitor on which BlockedThread's
+ * waits.
+ */
+public class LockerThread extends Thread {
+        private String lock = new String("a lock");
+        private Object ready = new Object();
+        private Object lockit = new Object();
+        private volatile boolean locked = false;
+
+        public Object getLock() {
+                return lock;
+        }
+
+        public boolean isLocked() {
+                return locked;
+        }
+
+        public void waitState() {
+                synchronized (ready) {
+                        while (!locked) {
+                                try {
+                                        ready.wait();
+                                } catch (InterruptedException e) {
+                                }
+                        }
+                }
+
+                ThreadUtils.waitThreadState(this, Thread.State.WAITING);
+
+                System.out.println("Locker thread reached WAITING state");
+        }
+
+        public void finish() {
+                locked = false;
+                synchronized (lockit) {
+                        lockit.notifyAll();
+                }
+        }
+
+        public void run() {
+                synchronized (lock) {
+                        synchronized (lockit) {
+                                synchronized (ready) {
+                                        locked = true;
+                                        ready.notifyAll();
+                                }
+                                while (locked) {
+                                        try {
+                                                lockit.wait();
+                                        } catch (InterruptedException e) {
+                                        }
+                                }
+                        }
+                }
+
+                System.out.println("Locker thread leaved WAITING state");
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/LockingThreads.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+#include <jni.h>
+#include "jni_tools.h"
+
+#define FIND_CLASS(_class, _className)\
+        if (!NSK_JNI_VERIFY(env, (_class = \
+             NSK_CPP_STUB2(FindClass, env, _className)) != NULL))\
+                return
+
+#define GET_OBJECT_CLASS(_class, _obj)\
+        if (!NSK_JNI_VERIFY(env, (_class = \
+             NSK_CPP_STUB2(GetObjectClass, env, _obj)) != NULL))\
+                return
+
+#define GET_OBJ_FIELD(_value, _obj, _class, _fieldName, _fieldSig)\
+        GET_FIELD_ID(field, _class, _fieldName, _fieldSig);\
+        _value = NSK_CPP_STUB3(GetObjectField, env, _obj, field)
+
+#define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\
+        if (!NSK_JNI_VERIFY(env, (_fieldID = \
+             NSK_CPP_STUB4(GetFieldID, env, _class,\
+             _fieldName, _fieldSig)) != NULL))\
+                return
+
+#define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\
+        if (!NSK_JNI_VERIFY(env, (_methodID = \
+             NSK_CPP_STUB4(GetMethodID, env, _class,\
+             _methodName, _sig)) != NULL))\
+                return
+
+#define CALL_VOID_NOPARAM(_obj, _class, _methodName)\
+            GET_METHOD_ID(method, _class, _methodName, "()V");\
+        if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB3(CallVoidMethod, env, _obj,\
+             method)))\
+                return
+/*
+ * Class:     nsk_monitoring_share_thread_LockingThreads_Thread1
+ * Method:    B
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_nsk_monitoring_share_thread_LockingThreads_00024Thread1_B
+  (JNIEnv *env, jobject this) {
+        jclass testBugClass, threadClass;
+        jobject lock4, lock5;
+        jfieldID field;
+        jmethodID method;
+
+        GET_OBJECT_CLASS(threadClass, this);
+        FIND_CLASS(testBugClass, "nsk/share/TestBug");
+        GET_OBJ_FIELD(lock4, this, threadClass, "lock4", "Lnsk/monitoring/share/thread/LockingThreads$CustomLock;");
+        GET_OBJ_FIELD(lock5, this, threadClass, "lock5", "Lnsk/monitoring/share/thread/LockingThreads$CustomLock;");
+        if ((*env)->MonitorEnter(env, lock4) == JNI_OK) {
+                if ((*env)->MonitorEnter(env, lock5) == JNI_OK) {
+                        CALL_VOID_NOPARAM(this, threadClass, "C");
+                        (*env)->MonitorExit(env, lock5);
+                } else
+                        (*env)->ThrowNew(env, testBugClass, "MonitorEnter(lock5) call failed");
+                (*env)->MonitorExit(env, lock4);
+        } else
+                (*env)->ThrowNew(env, testBugClass, "MonitorEnter(lock4) call failed");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/LockingThreads.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import java.lang.management.*;
+import nsk.share.log.*;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Scenario that starts two threads that use locks * to synchronize.
+ * Based on tests/java/lang/management/ThreadMXBean/LockingThread.java.
+ */
+public class LockingThreads implements ThreadMonitoringScenario, LogAware {
+        private static final String[] expectedMethodsThread1 = {
+                "nsk.monitoring.share.thread.LockingThreads$Thread1.runInside",
+                "nsk.monitoring.share.thread.LockingThreads$Thread1.A",
+                "nsk.monitoring.share.thread.LockingThreads$Thread1.B",
+                "nsk.monitoring.share.thread.LockingThreads$Thread1.C",
+                "nsk.monitoring.share.thread.LockingThreads$Thread1.D",
+                "java.lang.Object.wait",
+        };
+        private static final String[] expectedMethodsThread2 = {
+                "nsk.monitoring.share.thread.LockingThreads$Thread2.runInside",
+                "java.lang.Object.wait",
+        };
+        private CustomLock lock1 = new CustomLock("lock1");
+        private CustomLock lock2 = new CustomLock("lock2");
+        private CustomLock lock3 = new CustomLock("lock3");
+        private CustomLock lock4 = new CustomLock("lock4");
+        private CustomLock lock5 = new CustomLock("lock5");
+        private CustomLock lock6 = new CustomLock("lock6");
+        private CustomLock lock7 = new CustomLock("lock7");
+        private CustomLock lock8 = new CustomLock("lock8");
+        private MonitoringThread thread1;
+        private MonitoringThread thread2;
+        private Log log;
+        private RunType recursionType;
+        private int maxDepth;
+
+        static {
+                System.loadLibrary("LockingThreads");
+        }
+
+        public LockingThreads(Log log, RunType recursionType, int maxDepth) {
+                setLog(log);
+                this.recursionType = recursionType;
+                this.maxDepth = maxDepth;
+        }
+
+        static class CustomLock {
+                private String name;
+
+                public CustomLock(String name) {
+                        this.name = name;
+                }
+
+                public String toString() {
+                        return name;
+                }
+        }
+
+        private class Thread1 extends RecursiveMonitoringThread {
+                private volatile boolean ready = false;
+                private Object readyLock = new Object();
+                private CustomLock lock4;
+                private CustomLock lock5;
+                private Map<String, Object[]> lockedMonitors = new HashMap<String, Object[]>();
+
+                public Thread1(Log log, RunType recursionType, int maxDepth) {
+                        super(log, recursionType, maxDepth);
+                        lock4 = LockingThreads.this.lock4;
+                        lock5 = LockingThreads.this.lock5;
+                        lockedMonitors.put("D", new Object[] {});
+                        lockedMonitors.put("C", new Object[] { lock6 });
+                        lockedMonitors.put("B", new Object[] { lock5, lock4 });
+                        lockedMonitors.put("A", new Object[] { lock3, lock2, lock1});
+                }
+
+                public void checkThreadInfo(ThreadInfo info) {
+                        super.checkThreadInfo(info);
+                        checkLockInfo(info.getLockInfo(), lock7);
+                        checkMonitorInfo(info.getLockedMonitors(), lockedMonitors);
+                }
+
+                protected void runInside() {
+                        A();
+                }
+
+                void A() {
+                        synchronized (lock1) {
+                                synchronized(lock2) {
+                                        synchronized(lock3) {
+                                                B();
+                                        }
+                                }
+                        }
+                }
+
+                private native void B();
+
+                /*
+                void B() {
+                        synchronized (lock4) {
+                                synchronized(lock5) {
+                                        C();
+                                }
+                        }
+                }
+                */
+
+                void C() {
+                        synchronized (lock6) {
+                                D();
+                        }
+                }
+
+                void D() {
+                        synchronized (lock7) {
+                                try {
+                                        synchronized (readyLock) {
+                                                ready = true;
+                                                readyLock.notifyAll();
+                                        }
+                                        lock7.wait();
+                                } catch (InterruptedException e) {
+                                        throw new RuntimeException(e);
+                                }
+                        }
+                }
+
+                public void waitState() {
+                        synchronized (readyLock) {
+                                while (!ready) {
+                                        try {
+                                                readyLock.wait();
+                                        } catch (InterruptedException e) {
+                                                log.warn(e);
+                                        }
+                                }
+                        }
+                        waitThreadState(Thread.State.WAITING);
+                }
+
+                public void finish() {
+                        synchronized (lock7) {
+                                lock7.notifyAll();
+                        }
+                }
+
+                protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                        return super.isStackTraceElementExpected(element) || checkStackTraceElement(element, expectedMethodsThread1);
+                }
+        }
+
+        private class Thread2 extends RecursiveMonitoringThread {
+                private boolean ready = false;
+                private Object readyLock = new Object();
+                private Map<String, Object[]> lockedMonitors = new HashMap<String, Object[]>();
+
+                public Thread2(Log log, RunType recursionType, int maxDepth) {
+                        super(log, recursionType, maxDepth);
+                }
+
+                public void checkThreadInfo(ThreadInfo info) {
+                        super.checkThreadInfo(info);
+                        checkLockInfo(info.getLockInfo(), lock8);
+                        ThreadUtils.printMonitorInfo(log, info.getLockedMonitors());
+                        checkMonitorInfo(info.getLockedMonitors(), lockedMonitors);
+                }
+
+                protected void runInside() {
+                        synchronized (lock8) {
+                                try {
+                                        synchronized (readyLock) {
+                                                ready = true;
+                                                readyLock.notifyAll();
+                                        }
+                                        lock8.wait();
+                                } catch (InterruptedException e) {
+                                        throw new RuntimeException(e);
+                                }
+                        }
+                }
+
+                public void waitState() {
+                        synchronized (readyLock) {
+                                while (!ready) {
+                                        try {
+                                                readyLock.wait();
+                                        } catch (InterruptedException e) {
+                                                log.warn(e);
+                                        }
+                                }
+                        }
+                        waitThreadState(Thread.State.WAITING);
+                }
+
+                public void finish() {
+                        synchronized (lock8) {
+                                lock8.notifyAll();
+                        }
+                }
+
+                protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                        return super.isStackTraceElementExpected(element) || checkStackTraceElement(element, expectedMethodsThread2);
+                }
+        }
+
+
+        public void begin() {
+                thread1 = new Thread1(log, recursionType, maxDepth);
+                thread1.begin();
+                thread2 = new Thread2(log, recursionType, maxDepth);
+                thread2.begin();
+        }
+
+        public void waitState() {
+                thread1.waitState();
+                thread2.waitState();
+        }
+
+        public void check(ThreadMXBean threadMXBean) {
+                thread1.check(threadMXBean);
+                thread2.check(threadMXBean);
+        }
+
+        public void finish() {
+                thread1.finish();
+                thread2.finish();
+        }
+
+        public void end() {
+                thread1.end();
+                thread1.end();
+        }
+
+        public void setLog(Log log) {
+                this.log = log;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/MonitoringThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import java.lang.management.ThreadMXBean;
+import java.lang.management.ThreadInfo;
+import java.lang.management.MonitorInfo;
+import java.lang.management.LockInfo;
+import nsk.share.log.Log;
+import nsk.share.log.LogAware;
+import nsk.share.TestFailure;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.Lock;
+
+/**
+ * Base class for all threads that are used in monitoring testing.
+ */
+public abstract class MonitoringThread extends ThreadMonitoringScenarioBase implements Runnable {
+        private final static String[] expectedMethods = {
+                "java.lang.Thread.run"
+        };
+        protected boolean expectedJava = true;
+        protected boolean expectedSuspended = false;
+        protected Thread runner;
+
+        public MonitoringThread(Log log) {
+                super(log);
+        }
+
+        /**
+         * Check that info for this thread is correct. This method is expected
+         * to be called between calls to waitState() and finish().
+         *
+         * @param info thread info
+         * @throws TestFailure when verification fails
+         */
+        public void checkThreadInfo(ThreadInfo info) {
+                verify(info != null, "ThreadInfo is null");
+                verify(info.getThreadId() == runner.getId(), "info.getId() = " + info.getThreadId() + " != this.getId() " + runner.getId());
+                verify(info.getThreadName().equals(runner.getName()), "info.getName() = " + info.getThreadName() + " != this.getName() " + runner.getName());
+                verify(info.getThreadState().equals(runner.getState()), "info.getState() = " + info.getThreadState() + " != this.getState() " + runner.getState());
+                verify(checkStackTrace(info.getStackTrace()), "Verification of stack trace failed");
+                verify(info.isSuspended() == expectedSuspended, "ThreadInfo.isSuspended() = " + info.isSuspended() + " != " + expectedSuspended);
+                verify(info.isInNative() == !expectedJava, "ThreadInfo.isInNative() = " + info.isInNative() + " != " + !expectedJava);
+        }
+
+        public void begin() {
+                runner = new Thread(this);
+                runner.setName(this.getClass().getName() + '@' + System.identityHashCode(this) + "[id=" + runner.getId() + "]");
+                runner.setDaemon(true);
+                runner.start();
+        }
+
+        public abstract void waitState();
+
+        private void doCheck(ThreadInfo info, String description) {
+                try {
+                        checkThreadInfo(info);
+                } catch (TestFailure t) {
+                        log.info("Failed to check: " + description + " thread: " + this);
+                        printThreadInfo(info);
+                        throw t;
+                }
+        }
+
+        private void doCheck(ThreadInfo[] info, String description) {
+                verify(info.length == 1, "Failed to check: " + description + " thread: " + this + " length of returned array is wrong: " + info.length + " expected: " + 1);
+                doCheck(info[0], description);
+        }
+
+        public void check(ThreadMXBean threadMXBean) {
+                lockedMonitorsAvailable = false;
+                lockedSynchronizersAvailable = false;
+                doCheck(threadMXBean.getThreadInfo(runner.getId(), Integer.MAX_VALUE), "ThreadMXBean.getThreadInfo(long, int)");
+                doCheck(threadMXBean.getThreadInfo(runner.getId()), "ThreadMXBean.getThreadInfo(long)");
+                doCheck(threadMXBean.getThreadInfo(new long[] { runner.getId() }), "ThreadMXBean.getThreadInfo(long[])");
+                doCheck(threadMXBean.getThreadInfo(new long[] { runner.getId() }, Integer.MAX_VALUE), "ThreadMXBean.getThreadInfo(long[], int)");
+                lockedMonitorsAvailable = true;
+                lockedSynchronizersAvailable = true;
+                doCheck(threadMXBean.getThreadInfo(new long[] { runner.getId() }, true, true), "ThreadMXBean.getThreadInfo(long[], boolean, boolean)");
+        }
+
+        public abstract void finish();
+
+        public void end() {
+                try {
+                        if (runner != null)
+                                runner.join();
+                } catch (InterruptedException e) {
+                        log.warn(e);
+                }
+        }
+
+        /**
+         * Run this thread.
+         */
+        public abstract void run();
+
+        protected void waitThreadState(Thread.State state) {
+                ThreadUtils.waitThreadState(runner, state);
+        }
+
+        protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                return super.isStackTraceElementExpected(element) || checkStackTraceElement(element, expectedMethods);
+        }
+
+        public final void setExpectedJava(boolean expectedJava) {
+                this.expectedJava = expectedJava;
+        }
+
+        public final long getId() {
+                return runner.getId();
+        }
+
+        public static void yield() {
+                Thread.yield();
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/MultiScenario.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import java.lang.management.*;
+import nsk.share.log.*;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * MultiScenario is stress scenario that creates many scenarios and runs all of them.
+ */
+public class MultiScenario implements ThreadMonitoringScenario {
+        private ThreadMonitoringScenario[] scenarios;
+        private int count;
+        private ThreadMonitoringScenarioFactory scenarioFactory;
+
+        public MultiScenario(ThreadMonitoringScenarioFactory scenarioFactory, int count) {
+                this.scenarioFactory = scenarioFactory;
+                this.count = count;
+        }
+
+        public void begin() {
+                scenarios = scenarioFactory.createScenarios(count);
+                for (ThreadMonitoringScenario scenario : scenarios)
+                        scenario.begin();
+        }
+
+        public void waitState() {
+                for (ThreadMonitoringScenario scenario : scenarios) {
+                        System.out.println("Waiting: " + scenario);
+                        scenario.waitState();
+                }
+        }
+
+        public void check(ThreadMXBean threadMXBean) {
+                for (ThreadMonitoringScenario scenario : scenarios) {
+                        System.out.println("Checking: " + scenario);
+                        scenario.check(threadMXBean);
+                }
+        }
+
+        public void finish() {
+                /* This is still called when ScenarioFactory.createScenarios() throws exception.. */
+                if (scenarios == null)
+                        return;
+                for (ThreadMonitoringScenario scenario : scenarios)
+                        scenario.finish();
+        }
+
+        public void end() {
+                /* This is still called when ScenarioFactory.createScenarios() throws exception.. */
+                if (scenarios == null)
+                        return;
+                for (ThreadMonitoringScenario scenario : scenarios)
+                        scenario.end();
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/NativeBlockedThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.log.Log;
+import java.lang.management.ThreadInfo;
+import java.lang.management.MonitorInfo;
+import java.lang.management.LockInfo;
+import nsk.share.test.LocalRandom;
+import nsk.monitoring.share.Monitoring;
+
+/**
+ * NativeBlockedThread is RecursiveMonitoringThread that blocks to enter
+ * monitor using JNI function MonitorEnter.
+ */
+public class NativeBlockedThread extends BlockedThread {
+        private static final String[] expectedMethods = {
+                "nsk.monitoring.share.thread.NativeBlockedThread.runInside",
+                "nsk.monitoring.share.thread.NativeBlockedThread.nativeBlock"
+        };
+
+        static {
+                System.loadLibrary("NativeBlockedThread");
+        }
+
+        public NativeBlockedThread(Log log, RunType recursionType, int maxDepth, LockerThread lockerThread) {
+                super(log, recursionType, maxDepth, lockerThread);
+        }
+
+        protected void runInside() {
+                synchronized (readyLock) {
+                        ready = true;
+                        readyLock.notifyAll();
+                }
+                nativeBlock(lock);
+        }
+
+        protected native void nativeBlock(Object lock);
+
+        protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                return super.isStackTraceElementExpected(element) || checkStackTraceElement(element, expectedMethods);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/NewThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.log.Log;
+import java.lang.management.ThreadInfo;
+import nsk.share.TestFailure;
+import nsk.share.TestBug;
+
+/**
+ * New Thread is dummy RecursiveMonitoringThread that is not getting
+ * started.
+ */
+public class NewThread extends RecursiveMonitoringThread {
+        public NewThread(Log log, RunType recursionType, int maxDepth) {
+                super(log, recursionType, maxDepth);
+        }
+
+        public void begin() {
+                // We don't run this thread.
+                runner = new Thread(this);
+        }
+
+        public void waitState() {
+        }
+
+        public void finish() {
+        }
+
+        protected void runInside() {
+                throw new TestBug("Should not reach here");
+        }
+
+        protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                return super.isStackTraceElementExpected(element);
+        }
+
+        public void checkThreadInfo(ThreadInfo info) {
+                verify(info == null, "ThreadInfo != null");
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RecursiveMonitoringThread.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+#include <stdio.h>
+#include "jni_tools.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define FIND_CLASS(_class, _className)\
+    if (!NSK_JNI_VERIFY(env, (_class = \
+            NSK_CPP_STUB2(FindClass, env, _className)) != NULL))\
+        return
+
+#define GET_OBJECT_CLASS(_class, _obj)\
+    if (!NSK_JNI_VERIFY(env, (_class = \
+            NSK_CPP_STUB2(GetObjectClass, env, _obj)) != NULL))\
+        return
+
+#define GET_STATIC_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\
+    if (!NSK_JNI_VERIFY(env, (_fieldID = \
+            NSK_CPP_STUB4(GetStaticFieldID, env, _class,\
+                _fieldName, _fieldSig)) != NULL))\
+        return
+
+#define GET_STATIC_OBJ_FIELD(_value, _class, _fieldName, _fieldSig)\
+    GET_STATIC_FIELD_ID(field, _class, _fieldName, _fieldSig);\
+    _value = NSK_CPP_STUB3(GetStaticObjectField, env, _class, \
+                                field)
+
+#define GET_STATIC_BOOL_FIELD(_value, _class, _fieldName)\
+    GET_STATIC_FIELD_ID(field, _class, _fieldName, "Z");\
+    _value = NSK_CPP_STUB3(GetStaticBooleanField, env, _class, field)
+
+#define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\
+    if (!NSK_JNI_VERIFY(env, (_fieldID = \
+            NSK_CPP_STUB4(GetFieldID, env, _class,\
+                _fieldName, _fieldSig)) != NULL))\
+        return
+
+#define GET_INT_FIELD(_value, _obj, _class, _fieldName)\
+    GET_FIELD_ID(field, _class, _fieldName, "I");\
+    _value = NSK_CPP_STUB3(GetIntField, env, _obj, field)
+
+#define GET_LONG_FIELD(_value, _obj, _class, _fieldName)\
+    GET_FIELD_ID(field, _class, _fieldName, "J");\
+    _value = NSK_CPP_STUB3(GetLongField, env, _obj, field)
+
+#define GET_STATIC_INT_FIELD(_value, _class, _fieldName)\
+    GET_STATIC_FIELD_ID(field, _class, _fieldName, "I");\
+    _value = NSK_CPP_STUB3(GetStaticIntField, env, _class, field)
+
+#define SET_INT_FIELD(_obj, _class, _fieldName, _newValue)\
+    GET_FIELD_ID(field, _class, _fieldName, "I");\
+    NSK_CPP_STUB4(SetIntField, env, _obj, field, _newValue)
+
+#define GET_OBJ_FIELD(_value, _obj, _class, _fieldName, _fieldSig)\
+    GET_FIELD_ID(field, _class, _fieldName, _fieldSig);\
+    _value = NSK_CPP_STUB3(GetObjectField, env, _obj, field)
+
+
+#define GET_ARR_ELEMENT(_arr, _index)\
+    NSK_CPP_STUB3(GetObjectArrayElement, env, _arr, _index)
+
+#define SET_ARR_ELEMENT(_arr, _index, _newValue)\
+    NSK_CPP_STUB4(SetObjectArrayElement, env, _arr, _index, _newValue)
+
+#define GET_STATIC_METHOD_ID(_methodID, _class, _methodName, _sig)\
+    if (!NSK_JNI_VERIFY(env, (_methodID = \
+            NSK_CPP_STUB4(GetStaticMethodID, env, _class,\
+                _methodName, _sig)) != NULL))\
+        return
+
+#define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\
+    if (!NSK_JNI_VERIFY(env, (_methodID = \
+            NSK_CPP_STUB4(GetMethodID, env, _class,\
+                _methodName, _sig)) != NULL))\
+        return
+
+#define CALL_STATIC_VOID_NOPARAM(_class, _methodName)\
+    GET_STATIC_METHOD_ID(method, _class, _methodName, "()V");\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB3(CallStaticVoidMethod, env,\
+                            _class, method)))\
+        return
+
+#define CALL_STATIC_VOID(_class, _methodName, _sig, _param)\
+    GET_STATIC_METHOD_ID(method, _class, _methodName, _sig);\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB4(CallStaticVoidMethod, env,\
+                                                    _class, method, _param)))\
+        return
+
+#define CALL_VOID_NOPARAM(_obj, _class, _methodName)\
+    GET_METHOD_ID(method, _class, _methodName, "()V");\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB3(CallVoidMethod, env, _obj,\
+                                                    method)))\
+        return
+
+#define CALL_VOID(_obj, _class, _methodName, _sig, _param)\
+    GET_METHOD_ID(method, _class, _methodName, _sig);\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB4(CallVoidMethod, env, _obj,\
+                                                    method, _param)))\
+        return
+
+#define CALL_VOID2(_obj, _class, _methodName, _sig, _param1, _param2)\
+    GET_METHOD_ID(method, _class, _methodName, _sig);\
+    if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB5(CallVoidMethod, env, _obj, \
+                                                    method, _param1, _param2)))\
+        return
+
+#define CALL_INT_NOPARAM(_value, _obj, _class, _methodName)\
+    GET_METHOD_ID(method, _class, _methodName, "()I");\
+    _value = NSK_CPP_STUB3(CallIntMethod, env, _obj, method)
+
+#define NEW_OBJ(_obj, _class, _constructorName, _sig, _params)\
+    GET_METHOD_ID(method, _class, _constructorName, _sig);\
+    if (!NSK_JNI_VERIFY(env, (_obj = \
+            NSK_CPP_STUB4(NewObject, env, _class, method, _params)) != NULL))\
+        return
+
+#define MONITOR_ENTER(x) \
+    NSK_JNI_VERIFY(env, NSK_CPP_STUB2(MonitorEnter, env, x) == 0)
+
+#define MONITOR_EXIT(x) \
+    NSK_JNI_VERIFY(env, NSK_CPP_STUB2(MonitorExit, env, x) == 0)
+
+#define TRACE(msg)\
+   GET_OBJ_FIELD(logger, obj, threadClass, "logger", "Lnsk/share/Log$Logger;");\
+   jmsg = NSK_CPP_STUB2(NewStringUTF, env, msg);\
+   CALL_VOID2(logger, loggerClass, "trace",\
+                           "(ILjava/lang/String;)V", 50, jmsg)
+
+
+/*
+ * Class:     nsk_monitoring_share_thread_RecursiveMonitoringThread
+ * Method:    nativeRecursiveMethod
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_nsk_monitoring_share_thread_RecursiveMonitoringThread_nativeRecursiveMethod
+(JNIEnv *env, jobject this, jint currentDepth, jboolean pureNative) {
+        jclass class;
+        jmethodID method;
+
+        GET_OBJECT_CLASS(class, this);
+        if (currentDepth-- > 0) {
+/*              printf("Current depth: %d\n", currentDepth); */
+                CALL_STATIC_VOID_NOPARAM(class, "yield");
+                if (pureNative == JNI_TRUE) {
+                        CALL_VOID2(this, class, "nativeRecursiveMethod", "(IZ)V", currentDepth, pureNative);
+                } else {
+                        CALL_VOID(this, class, "recursiveMethod", "(I)V", currentDepth);
+                }
+        } else {
+                CALL_VOID_NOPARAM(this, class, "runInside");
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RecursiveMonitoringThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.log.Log;
+
+/**
+ * RecursiveMonitoringThread is a thread that recursively executes some
+ * methods and runs method runInside inside. The method may be implemented
+ * by subclasses. The types of methods are determined by recursionType,
+ * which may be JAVA (only java methods), NATIVE (only native
+ * methods) and MIXED (java and native methods).
+ */
+public abstract class RecursiveMonitoringThread extends MonitoringThread {
+        private RunType recursionType;
+        private int maxDepth;
+        private static final String[] expectedMethodsJava = {
+                "nsk.monitoring.share.thread.RecursiveMonitoringThread.recursiveMethod",
+                "nsk.monitoring.share.thread.RecursiveMonitoringThread.run"
+        };
+        private static final String[] expectedMethodsNative = {
+                "nsk.monitoring.share.thread.RecursiveMonitoringThread.nativeRecursiveMethod",
+                "nsk.monitoring.share.thread.RecursiveMonitoringThread.run"
+        };
+        private static final String[] expectedMethodsMixed = {
+                "nsk.monitoring.share.thread.RecursiveMonitoringThread.nativeRecursiveMethod",
+                "nsk.monitoring.share.thread.RecursiveMonitoringThread.recursiveMethod",
+                "nsk.monitoring.share.thread.RecursiveMonitoringThread.run"
+        };
+
+        static {
+                System.loadLibrary("RecursiveMonitoringThread");
+        }
+
+        public RecursiveMonitoringThread(Log log, RunType recursionType, int maxDepth) {
+                super(log);
+                this.recursionType = recursionType;
+                this.maxDepth = maxDepth;
+        }
+
+        public void run() {
+                switch (recursionType) {
+                case JAVA:
+                case MIXED:
+                        recursiveMethod(maxDepth);
+                        break;
+                case NATIVE:
+                        nativeRecursiveMethod(maxDepth, true);
+                        break;
+                }
+        }
+
+        protected void recursiveMethod(int currentDepth) {
+                if (currentDepth-- > 0) {
+                        switch (recursionType) {
+                        case JAVA:
+                                recursiveMethod(currentDepth);
+                                break;
+                        case MIXED:
+                                nativeRecursiveMethod(currentDepth, false);
+                                break;
+                        }
+                } else {
+                        runInside();
+                }
+        }
+
+        protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                if (super.isStackTraceElementExpected(element))
+                        return true;
+                switch (recursionType) {
+                case JAVA:
+                        return checkStackTraceElement(element, expectedMethodsJava);
+                case NATIVE:
+                        return checkStackTraceElement(element, expectedMethodsNative);
+                case MIXED:
+                        return checkStackTraceElement(element, expectedMethodsMixed);
+                default:
+                        throw new IllegalArgumentException("Unknown recursionType: " + recursionType);
+                }
+        }
+
+        protected native void nativeRecursiveMethod(int currentDepth, boolean pureNative);
+
+        protected abstract void runInside();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RunType.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+/**
+ * RunType defines how particular code should run - pure java,
+ * pure native or mixed.
+ */
+public enum RunType {
+        JAVA,
+        NATIVE,
+        MIXED
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RunningThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.log.Log;
+import java.lang.management.ThreadInfo;
+import nsk.share.TestFailure;
+
+/**
+ * RunningThread is a RecursiveMonitoringThread that simply
+ * runs a loop.
+ */
+public class RunningThread extends RecursiveMonitoringThread {
+        private volatile boolean running = false;
+        private volatile boolean ready = false;
+        private Object readyLock = new Object();
+        private static final String[] expectedMethods = {
+                "nsk.monitoring.share.thread.RunningThread.runInside",
+                "java.lang.Thread.yield"
+        };
+
+        public RunningThread(Log log, RunType recursionType, int maxDepth) {
+                super(log, recursionType, maxDepth);
+        }
+
+        public void waitState() {
+                synchronized (readyLock) {
+                        while (!ready) {
+                                try {
+                                        readyLock.wait();
+                                } catch (InterruptedException e) {
+                                        log.warn(e);
+                                }
+                        }
+                }
+                waitThreadState(Thread.State.RUNNABLE);
+        }
+
+        public void finish() {
+                running = false;
+        }
+
+        protected void runInside() {
+                synchronized (readyLock) {
+                        ready = true;
+                        running = true;
+                        readyLock.notifyAll();
+                }
+                while (running)
+                        ;
+        }
+
+        protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                return super.isStackTraceElementExpected(element) || checkStackTraceElement(element, expectedMethods);
+        }
+
+        public void checkThreadInfo(ThreadInfo info) {
+                super.checkThreadInfo(info);
+                verify(info.getThreadState() == Thread.State.RUNNABLE, "ThreadInfo.getState() = " + info.getThreadState() + "!= Thread.State.RUNNABLE");
+                verify(info.getBlockedTime() == 0 || info.getBlockedTime() == -1, "ThreadInfo.getBlockedTime() == " + info.getBlockedTime());
+                verify(info.getBlockedCount() >= 0, "ThreadInfo.getBlockedCount() = " + info.getBlockedCount() + " < 0");
+                verify(info.getWaitedTime() == 0 || info.getWaitedTime() == -1, "ThreadInfo.getWaitedTime() == " + info.getWaitedTime());
+                verify(info.getWaitedCount() == 0, "ThreadInfo.getWaitedCount() = " + info.getWaitedCount() + " != 0");
+                verify(info.getLockInfo() == null, "ThreadInfo.getLockInfo() != null");
+                verify(info.getLockName() == null, "ThreadInfo.getLockName() != null");
+                verify(info.getLockOwnerId() == -1, "ThreadInfo.getLockOwnerId() != -1");
+                verify(info.getLockOwnerName() == null, "ThreadInfo.getLockOwnerName() != null");
+                checkMonitorInfo(info.getLockedMonitors(), null);
+                checkSynchronizers(info.getLockedSynchronizers(), null);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/ScenarioTypeAware.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+/**
+ * ScenarioTypeAware is marker interface for obtaining scenario type.
+ */
+public interface ScenarioTypeAware {
+        public void setScenarioType(String threadType);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SleepingThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.log.Log;
+import java.lang.management.ThreadInfo;
+import java.lang.management.MonitorInfo;
+import java.lang.management.LockInfo;
+
+/**
+ * SleepingThread is RecursiveMonitoringThread that sleeps.
+ */
+public class SleepingThread extends RecursiveMonitoringThread {
+        private String lock = new String("a lock");
+        private volatile boolean sleeping = false;
+        private Object readyLock = new Object();
+        private static final String[] expectedMethods = {
+                "java.lang.Thread.sleep",
+                "nsk.monitoring.share.thread.SleepingThread.runInside"
+        };
+
+        public SleepingThread(Log log, RunType recursionType, int maxDepth) {
+                super(log, recursionType, maxDepth);
+        }
+
+        public void checkThreadInfo(ThreadInfo info) {
+                super.checkThreadInfo(info);
+                verify(info.getThreadState() == Thread.State.TIMED_WAITING, "ThreadInfo.getThreadState() = " + info.getThreadState() + " != " + Thread.State.TIMED_WAITING);
+                verify(info.getBlockedTime() == 0 || info.getBlockedTime() == -1, "ThreadInfo.getBlockedTime() == " + info.getBlockedTime());
+                verify(info.getBlockedCount() >= 0, "ThreadInfo.getBlockedCount() = " + info.getBlockedCount() + " != 0");
+                verify(info.getWaitedTime() == 0 || info.getWaitedTime() == -1, "ThreadInfo.getWaitedTime() == " + info.getWaitedTime());
+                verify(info.getWaitedCount() == 1, "ThreadInfo.getWaitedCount() = " + info.getWaitedCount() + " != 1");
+                verify(info.getLockInfo() == null, "ThreadInfo.getLockInfo() != null ");
+                verify(info.getLockName() == null, "ThreadInfo.getLockName() " + info.getLockName() + " != null");
+                verify(info.getLockOwnerId() == -1, "ThreadInfo.getLockOwnerId() = " + info.getLockOwnerId() + " != null");
+                verify(info.getLockOwnerName() == null, "ThreadInfo.getLockOwnerName() = " + info.getLockOwnerName() + " != null");
+                checkMonitorInfo(info.getLockedMonitors(), null);
+                checkSynchronizers(info.getLockedSynchronizers(), null);
+        }
+
+        public void waitState() {
+                synchronized (readyLock) {
+                        while (!sleeping) {
+                                try {
+                                        readyLock.wait();
+                                } catch (InterruptedException e) {
+                                        log.warn(e);
+                                }
+                        }
+                }
+                waitThreadState(Thread.State.TIMED_WAITING);
+        }
+
+        public void finish() {
+                sleeping = false;
+                runner.interrupt();
+        }
+
+        protected void runInside() {
+                synchronized (readyLock) {
+                        sleeping = true;
+                        readyLock.notifyAll();
+                }
+                while (sleeping) {
+                        try {
+                                Thread.sleep(10000000);
+                        } catch (InterruptedException e) {
+                        }
+                }
+        }
+
+        protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                return super.isStackTraceElementExpected(element) || checkStackTraceElement(element, expectedMethods);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/StandardThreadMonitoringScenarioFactory.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.TestBug;
+import nsk.share.log.Log;
+import nsk.share.log.LogAware;
+
+public class StandardThreadMonitoringScenarioFactory implements ThreadMonitoringScenarioFactory, LogAware {
+        private Log log;
+        private int maxDepth;
+        private LockerThread lockerThread;
+        private final int typeCount = 7;
+        private int threadCount;
+
+        public StandardThreadMonitoringScenarioFactory(Log log, int maxDepth, int threadCount) {
+                setLog(log);
+                this.maxDepth = maxDepth;
+                this.threadCount = threadCount;
+        }
+
+        public int getScenarioCount(int basicThreadCount) {
+                // This is choosen to have one scenario of each type and recursionType.
+                basicThreadCount = Math.min(basicThreadCount, 3);
+                return basicThreadCount * typeCount * 3;
+        }
+
+        public ThreadMonitoringScenario[] createScenarios(int count) {
+                ThreadMonitoringScenario[] scenarios = new ThreadMonitoringScenario[count];
+                for (int i = 0; i < count; ++i)
+                        scenarios[i] = createScenario(i);
+                return scenarios;
+        }
+
+        public ThreadMonitoringScenario createScenario(String scenarioType) {
+                RunType recursionType = RunType.MIXED;
+                if (scenarioType.equals("running"))
+                        return new RunningThread(log, recursionType, maxDepth);
+                else if (scenarioType.equals("sleeping"))
+                        return new SleepingThread(log, recursionType, maxDepth);
+                else if (scenarioType.equals("timedWaiting"))
+                        return new TimedWaitingThread(log, recursionType, maxDepth);
+                else if (scenarioType.equals("waiting"))
+                        return new WaitingThread(log, recursionType, maxDepth);
+                else if (scenarioType.equals("blocked"))
+                        return new BlockedThread(log, recursionType, maxDepth, getLockerThread());
+                else if (scenarioType.equals("nativeBlocked"))
+                        return new NativeBlockedThread(log, recursionType, maxDepth, getLockerThread());
+                else if (scenarioType.equals("new"))
+                        return new NewThread(log, recursionType, maxDepth);
+                else if (scenarioType.equals("finished"))
+                        return new FinishedThread(log, recursionType, maxDepth);
+                else if (scenarioType.equals("lockingThreads"))
+                        return new LockingThreads(log, recursionType, maxDepth);
+                else if (scenarioType.equals("synchronizerLockingThreads"))
+                        return new SynchronizerLockingThreads(log, recursionType, maxDepth);
+                else if (scenarioType.equals("javaDeadlock"))
+                        return new Deadlock(log, recursionType, maxDepth, Deadlock.Type.JAVA, threadCount);
+                else if (scenarioType.equals("nativeDeadlock"))
+                        return new Deadlock(log, recursionType, maxDepth, Deadlock.Type.NATIVE, threadCount);
+                else if (scenarioType.equals("synchronizedMethodDeadlock"))
+                        return new Deadlock(log, recursionType, maxDepth, Deadlock.Type.SYNCHRONIZED_METHOD, threadCount);
+                else if (scenarioType.equals("synchronizerDeadlock"))
+                        return new Deadlock(log, recursionType, maxDepth, Deadlock.Type.SYNCHRONIZER, threadCount);
+                else if (scenarioType.equals("mixedDeadlock"))
+                        return new Deadlock(log, recursionType, maxDepth, Deadlock.Type.MIXED, 16);
+                /*
+                else if (scenarioType.equals("mixedMonitorDeadlock"))
+                        return new Deadlock(log, recursionType, maxDepth, Deadlock.DeadlockType.MIXED, threadCount);
+                else if (scenarioType.equals("mixed2MonitorDeadlock"))
+                        return new MonitorDeadlock(log, recursionType, maxDepth, MonitorDeadlock.DeadlockType.MIXED2, threadCount);
+                        */
+                throw new TestBug("Unknown scenario type: " + scenarioType);
+        }
+
+        protected ThreadMonitoringScenario createScenario(int i) {
+                RunType recursionType;
+                switch (i % 3) {
+                case 0:
+                        recursionType = RunType.JAVA;
+                        break;
+                case 1:
+                        recursionType = RunType.NATIVE;
+                        break;
+                case 2:
+                        recursionType = RunType.MIXED;
+                        break;
+                default:
+                        throw new TestBug("Unknown recursionType.");
+                }
+                switch (i % typeCount) {
+                case 0:
+                        return new SleepingThread(log, recursionType, maxDepth);
+                case 1:
+                        return new TimedWaitingThread(log, recursionType, maxDepth);
+                case 2:
+                        return new RunningThread(log, recursionType, maxDepth);
+                case 3:
+                        return new WaitingThread(log, recursionType, maxDepth);
+                case 4:
+                        return new BlockedThread(log, recursionType, maxDepth, getLockerThread());
+                case 5:
+                        return new LockingThreads(log, recursionType, maxDepth);
+                case 6:
+                        return new SynchronizerLockingThreads(log, recursionType, maxDepth);
+                default:
+                        throw new TestBug("Unknown thread kind");
+                }
+        }
+
+        private LockerThread getLockerThread() {
+                if (lockerThread == null) {
+                        lockerThread = new LockerThread();
+                        lockerThread.start();
+                        lockerThread.waitState();
+                }
+                return lockerThread;
+        }
+
+        public void finish() {
+                if (lockerThread != null) {
+                        lockerThread.finish();
+                        try {
+                                lockerThread.join();
+                        } catch (InterruptedException e) {
+                                log.warn(e);
+                        }
+                        lockerThread = null;
+                }
+        }
+
+        public void setLog(Log log) {
+                this.log = log;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SynchronizerLockingThreads.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import java.lang.management.*;
+import nsk.share.log.*;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+
+/**
+ * Scenario that starts two threads that use locks * to synchronize.
+ * The code is based on tests/java/lang/management/ThreadMXBean/LockingThread.java
+ */
+public class SynchronizerLockingThreads implements ThreadMonitoringScenario, LogAware {
+        private static final String[] expectedMethodsThread1 = {
+                "nsk.monitoring.share.thread.SynchronizerLockingThreads$Thread1.runInside",
+                "nsk.monitoring.share.thread.SynchronizerLockingThreads$Thread1.A",
+                "nsk.monitoring.share.thread.SynchronizerLockingThreads$Thread1.B",
+                "nsk.monitoring.share.thread.SynchronizerLockingThreads$Thread1.C",
+                "nsk.monitoring.share.thread.SynchronizerLockingThreads$Thread1.D",
+                "java.lang.Object.wait"
+        };
+        private static final String[] expectedMethodsThread2 = {
+                "nsk.monitoring.share.thread.SynchronizerLockingThreads$Thread2.runInside"
+        };
+        private ReentrantLock lock1 = new ReentrantLock();
+        private ReentrantLock lock2 = new ReentrantLock();
+        private ReentrantLock lock3 = new ReentrantLock();
+        private ReentrantLock lock4 = new ReentrantLock();
+        private CustomLock lock5 = new CustomLock("lock5");
+        private CustomLock lock6 = new CustomLock("lock6");
+        private CustomLock lock7 = new CustomLock("lock7");
+        private ReentrantLock lock8 = new ReentrantLock();
+        private MonitoringThread thread1;
+        private MonitoringThread thread2;
+        private Log log;
+        private RunType recursionType;
+        private int maxDepth;
+
+        public SynchronizerLockingThreads(Log log, RunType recursionType, int maxDepth) {
+                setLog(log);
+                this.recursionType = recursionType;
+                this.maxDepth = maxDepth;
+                thread1 = new Thread1(log, recursionType, maxDepth);
+                thread2 = new Thread2(log, recursionType, maxDepth);
+        }
+
+        static class CustomLock {
+                private String name;
+
+                public CustomLock(String name) {
+                        this.name = name;
+                }
+
+                public String toString() {
+                        return name;
+                }
+        }
+
+        private class Thread1 extends RecursiveMonitoringThread {
+                private volatile boolean ready = false;
+                private Object readyLock = new Object();
+                private Map<String, Object[]> lockedMonitors = new HashMap<String, Object[]>();
+                private Map<String, Lock[]> lockedSynchronizers = new HashMap<String, Lock[]>();
+
+                public Thread1(Log log, RunType recursionType, int maxDepth) {
+                        super(log, recursionType, maxDepth);
+                        lockedMonitors.put("D", new Object[] {});
+                        lockedMonitors.put("C", new Object[] { lock6 });
+                        lockedMonitors.put("B", new Object[] { lock5 });
+                        lockedMonitors.put("A", new Object[] { });
+                        lockedSynchronizers.put("D", new ReentrantLock[0]); // no sync locked
+                        lockedSynchronizers.put("C", new ReentrantLock[0]); // no sync locked
+                        lockedSynchronizers.put("B", new Lock[] {lock4});
+                        lockedSynchronizers.put("A", new Lock[] {lock3, lock2, lock1});
+                }
+
+                public void checkThreadInfo(ThreadInfo info) {
+                        super.checkThreadInfo(info);
+                        checkLockInfo(info.getLockInfo(), lock7);
+                        checkMonitorInfo(info.getLockedMonitors(), lockedMonitors);
+                        checkSynchronizers(info.getLockedSynchronizers(), lockedSynchronizers);
+                }
+
+                protected void runInside() {
+                        A();
+                }
+
+                void A() {
+                        lock1.lock();
+                        try {
+                                lock2.lock();
+                                try {
+                                        lock3.lock();
+                                        try {
+                                                B();
+                                        } finally {
+                                                lock3.unlock();
+                                        }
+                                } finally {
+                                        lock2.unlock();
+                                }
+                        } finally {
+                                lock1.unlock();
+                        }
+                }
+
+                void B() {
+                        lock4.lock();
+                        try {
+                                synchronized(lock5) {
+                                        C();
+                                }
+                        } finally {
+                                lock4.unlock();
+                        }
+                }
+
+                void C() {
+                        synchronized(lock6) {
+                                D();
+                        }
+                }
+
+                void D() {
+                        synchronized(lock7) {
+                                try {
+                                        synchronized (readyLock) {
+                                                ready = true;
+                                                readyLock.notifyAll();
+                                        }
+                                        lock7.wait();
+                                } catch (InterruptedException e) {
+                                        throw new RuntimeException(e);
+                                }
+                        }
+                }
+
+
+                public void waitState() {
+                        synchronized (readyLock) {
+                                while (!ready) {
+                                        try {
+                                                readyLock.wait();
+                                        } catch (InterruptedException e) {
+                                                log.warn(e);
+                                        }
+                                }
+                        }
+                        waitThreadState(Thread.State.WAITING);
+                }
+
+                public void finish() {
+                        synchronized (lock7) {
+                                lock7.notifyAll();
+                        }
+                }
+
+                protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                        return super.isStackTraceElementExpected(element) || checkStackTraceElement(element, expectedMethodsThread1);
+                }
+        }
+
+        private class Thread2 extends RecursiveMonitoringThread {
+                private boolean ready = false;
+                private Object readyLock = new Object();
+                private Map<String, Object[]> lockedMonitors = new HashMap<String, Object[]>();
+                private Map<String, Lock[]> lockedSynchronizers = new HashMap<String, Lock[]>();
+                private Condition c = lock8.newCondition();
+
+                public Thread2(Log log, RunType recursionType, int maxDepth) {
+                        super(log, recursionType, maxDepth);
+                }
+
+                public void checkThreadInfo(ThreadInfo info) {
+                        super.checkThreadInfo(info);
+                        checkLockInfo(info.getLockInfo(), c);
+                        checkMonitorInfo(info.getLockedMonitors(), lockedMonitors);
+                        checkSynchronizers(info.getLockedSynchronizers(), lockedSynchronizers);
+                }
+
+                protected void runInside() {
+                        lock8.lock();
+                        try {
+                                synchronized (readyLock) {
+                                        ready = true;
+                                        readyLock.notifyAll();
+                                }
+                                c.await();
+                        } catch (InterruptedException e) {
+                                throw new RuntimeException(e);
+                        } finally {
+                                lock8.unlock();
+                        }
+                }
+
+                public void waitState() {
+                        synchronized (readyLock) {
+                                while (!ready) {
+                                        try {
+                                                readyLock.wait();
+                                        } catch (InterruptedException e) {
+                                                log.warn(e);
+                                        }
+                                }
+                        }
+                        waitThreadState(Thread.State.WAITING);
+                }
+
+                public void finish() {
+                        lock8.lock();
+                        try {
+                                c.signalAll();
+                        } finally {
+                                lock8.unlock();
+                        }
+                }
+
+                protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                        return super.isStackTraceElementExpected(element) ||
+                                checkStackTraceElement(element, expectedMethodsThread2) ||
+                                element.getClassName().startsWith("java.util.concurrent.locks.") ||
+                                element.getClassName().startsWith("jdk.internal.misc.");
+                }
+        }
+
+
+        public void begin() {
+                thread1.begin();
+                thread2.begin();
+        }
+
+        public void waitState() {
+                thread1.waitState();
+                thread2.waitState();
+        }
+
+        public void check(ThreadMXBean threadMXBean) {
+                long[] ids = new long[] { thread1.getId(), thread2.getId() };
+                ThreadInfo[] info = threadMXBean.getThreadInfo(ids, true, true);
+                thread1.checkThreadInfo(info[0]);
+                thread2.checkThreadInfo(info[1]);
+        }
+
+        public void finish() {
+                thread1.finish();
+                thread2.finish();
+        }
+
+        public void end() {
+                thread1.end();
+                thread2.end();
+        }
+
+        public void setLog(Log log) {
+                this.log = log;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/ThreadMonitoringScenario.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import java.lang.management.ThreadMXBean;
+
+/**
+ * ThreadMonitoringScenario is basic interface which should be
+ * implemented by all scenarios that excersize ThreadMXBean threads
+ * information.
+ */
+public interface ThreadMonitoringScenario {
+        /**
+         * Begin this scenario. Make necessary preparations and start threads.
+         */
+        public void begin();
+
+        /**
+         * Wait for threads to come into pre-defined state.
+         */
+        public void waitState();
+
+        /**
+         * Check ThreadMXBean information.
+         */
+        public void check(ThreadMXBean threadMXBean);
+
+        /**
+         * Signal threads to finish.
+         */
+        public void finish();
+
+        /**
+         * End this scenario. Wait for threads to exit and make
+         * necessary cleanup.
+         */
+        public void end();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/ThreadMonitoringScenarioBase.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import java.lang.management.ThreadMXBean;
+import java.lang.management.ThreadInfo;
+import java.lang.management.MonitorInfo;
+import java.lang.management.LockInfo;
+import nsk.share.log.Log;
+import nsk.share.log.LogAware;
+import nsk.share.TestFailure;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.Lock;
+
+/**
+ * Base class for all threads that are used in monitoring testing.
+ */
+public abstract class ThreadMonitoringScenarioBase implements LogAware, ThreadMonitoringScenario {
+        protected static boolean lockedMonitorsAvailable = true;
+        protected static boolean lockedSynchronizersAvailable = true;
+        protected Log log;
+
+        public ThreadMonitoringScenarioBase(Log log) {
+                setLog(log);
+        }
+
+        public abstract void begin();
+
+        public abstract void waitState();
+
+        public abstract void finish();
+
+        public abstract void end();
+
+        protected void printThreadInfo(ThreadInfo info) {
+                //ThreadUtils.threadDump(log, threadMXBean.dumpAllThreads(true, true));
+                ThreadUtils.threadInfo(log, info);
+        }
+
+
+        /**
+         * Check that there are no unexpected elements in stack trace.
+         */
+        protected boolean checkStackTrace(StackTraceElement[] elements) {
+                boolean unexpected = false;
+                for (StackTraceElement element : elements)
+                        if (!isStackTraceElementExpected(element)) {
+                                if (!unexpected) {
+                                        log.info("Unexpected stack trace elements for: " + this);
+                                        unexpected = true;
+                                }
+                                log.info(ThreadUtils.INDENT + "at " + element);
+                        }
+                return !unexpected;
+        }
+
+        /**
+         * Verifies that given stack trace element from stack trace is expected
+         * in pre-defined state. This method will be called by checkStackTrace
+         * for each element.
+         *
+         * @param element stack trace element
+         * @return true if element is expected, false otherwise
+         */
+        protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                return false;
+        }
+
+        /**
+         * Check that stack trace element is expected.
+         */
+        protected boolean checkStackTraceElement(StackTraceElement element, String[] expectedMethods) {
+                String name = element.getClassName() + "." + element.getMethodName();
+                for (String method : expectedMethods)
+                        if (method.equals(name))
+                                return true;
+                return false;
+        }
+
+        /**
+         * Check that lock info matches given lock object.
+         *
+         * @param lockInfo lock info
+         * @param lock lock object
+         */
+        protected void checkLockInfo(LockInfo lockInfo, Object lock) {
+                if (lock != null) {
+                        verify(lockInfo.getClassName().equals(lock.getClass().getName()), "LockInfo.getClassName() = " + lockInfo.getClassName() + " differs from lock.getClass().getName() = " + lock.getClass().getName());
+                        verify(lockInfo.getIdentityHashCode() == System.identityHashCode(lock), "LockInfo.getIdentityHashCode() = " + lockInfo.getIdentityHashCode() + " differs from System.identityHashCode(lock) = " + System.identityHashCode(lock));
+                        String expectedToString = lock.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(lock));
+                        verify(lockInfo.toString().equals(expectedToString), "LockInfo.toString() = " + lockInfo.toString() + " differs from expected toString() = " + expectedToString);
+                } else
+                        verify(lockInfo == null, "Unexpected ThreadInfo.getLockInfo(): " + ThreadUtils.strLockInfo(lockInfo));
+        }
+
+        /**
+         * Check that given MonitorInfo matches given lock object and method name.
+         *
+         * @param monitorInfo monitor info
+         * @param lock lock object
+         * @param methodName method name
+         */
+        protected void checkMonitorInfo(MonitorInfo monitorInfo, Object lock, String methodName) {
+                checkLockInfo(monitorInfo, lock);
+                StackTraceElement element = monitorInfo.getLockedStackFrame();
+                String expectedMethodName = element.getClassName() + '.' + element.getMethodName();
+                verify(expectedMethodName.equals(methodName), "Unexpected method name in " + ThreadUtils.strMonitorInfo(monitorInfo) + " expected: " + methodName);
+        }
+
+        /**
+         * Check that monitor info for all given method names and locks is present.
+         *
+         * @param monitorInfo array of monitor info to check
+         * @param lockMap map with method names as keys and locks as values
+         */
+        protected void checkMonitorInfo(MonitorInfo[] monitorInfos, Map<String, Object[]> lockMap) {
+                try {
+                        if (lockMap == null || !lockedMonitorsAvailable) {
+                                verify(monitorInfos.length == 0, "Unexpected MonitorInfo[] objects: " + ThreadUtils.strMonitorInfoArr(monitorInfos));
+                        } else {
+                                int n = 0;
+                                // Check that each entry in the map has corresponding monitorInfo
+                                for (Map.Entry<String, Object[]> entry : lockMap.entrySet()) {
+                                        String methodName = entry.getKey();
+                                        Object[] locks = entry.getValue();
+                                        n += locks.length;
+                                        for (Object lock : locks)
+                                                checkMonitorInfo(monitorInfos, methodName, lock);
+                                }
+                                // Check that each monitorInfo entry corresponds to entry in lockMap
+                                for (MonitorInfo monitorInfo : monitorInfos) {
+                                        StackTraceElement element = monitorInfo.getLockedStackFrame();
+                                        if (element == null)
+                                                continue;
+                                        Object[] locks = lockMap.get(element.getMethodName());
+                                        checkMonitorInfo(monitorInfo, element.getMethodName(), locks);
+                                }
+                                verify(n == monitorInfos.length, "Unexpected monitor info array length: " + monitorInfos.length + " expected: " + n);
+                        }
+                } catch (TestFailure t) {
+                        log.info("Expected monitor info for locks:");
+                        for (Map.Entry<String, Object[]> entry : lockMap.entrySet()) {
+                                for (Object lock : entry.getValue()) {
+                                        String s = "";
+                                        s +=  "methodName: " + entry.getKey();
+                                        s += " className: " + lock.getClass().getName();
+                                        s += " identityHashCode: " + System.identityHashCode(lock);
+                                        log.info(s);
+                                }
+                        }
+                        throw t;
+                }
+        }
+
+        /**
+         * Check that monitor info for given method name and lock is present.
+         *
+         * @param monitorInfos monitor info array
+         * @param methodName method name
+         * @param lock lock object
+         */
+        protected void checkMonitorInfo(MonitorInfo[] monitorInfos, String methodName, Object lock) {
+                String className = lock.getClass().getName();
+                int hashCode = System.identityHashCode(lock);
+                for (MonitorInfo monitorInfo : monitorInfos) {
+                        if (className.equals(monitorInfo.getClassName()) &&
+                            hashCode == monitorInfo.getIdentityHashCode()) {
+                                if (monitorInfo.getLockedStackFrame() == null)
+                                        return;
+                                verify(methodName.equals(monitorInfo.getLockedStackFrame().getMethodName()), "Invalid method name: " + monitorInfo.getLockedStackFrame().getMethodName() + " expected: " + methodName);
+                                return;
+                        }
+                }
+                throw new TestFailure("Expected monitor not found: methodName: " + methodName + " lock: " + lock);
+        }
+
+        /**
+         * Check that monitor info for given method name corresponds to one of locks.
+         *
+         * @param monitorInfo monitor info
+         * @param methodName method name
+         * @param locks lock array
+         */
+        protected void checkMonitorInfo(MonitorInfo monitorInfo, String methodName, Object[] locks) {
+                for (Object lock : locks) {
+                        String className = lock.getClass().getName();
+                        int hashCode = System.identityHashCode(lock);
+                        if (className.equals(monitorInfo.getClassName()) &&
+                            hashCode == monitorInfo.getIdentityHashCode() &&
+                            methodName.equals(monitorInfo.getLockedStackFrame().getMethodName()))
+                                return;
+                }
+                throw new TestFailure("Lock for MonitorInfo not found: " + ThreadUtils.strMonitorInfo(monitorInfo));
+        }
+
+        /**
+         * Check that lock info corresponds to given locks.
+         *
+         * We can only check number of items here.
+         *
+         * @param lockInfos lock info array
+         * @param lockMap lock map
+         */
+        protected void checkSynchronizers(LockInfo[] lockInfos, Map<String, Lock[]> lockMap) {
+                if (lockMap == null || !lockedSynchronizersAvailable)
+                        verify(lockInfos.length == 0, "Unexpected LockInfo[] objects: " + ThreadUtils.strLockInfoArr(lockInfos));
+                else {
+                        // Only check length
+                        int n = 0;
+                        for (Map.Entry<String, Lock[]> entry : lockMap.entrySet()) {
+                                Lock[] locks = entry.getValue();
+                                n += locks.length;
+                        }
+                        verify(lockInfos.length == n, "Unexpected LockInfo[] length: " + lockInfos.length + " expected: " + n);
+                }
+        }
+
+        /**
+         * Obtain full method name for given stack trace element.
+         *
+         * @param element stack trace element
+         * @return full method name, i.e. className.methodName
+         */
+        protected String getMethodName(StackTraceElement element) {
+                return element.getClassName() + '.' + element.getMethodName();
+        }
+
+        /**
+         * Verify condition and throw TestFailure if it does not hold.
+         *
+         * @param condition boolean condition
+         * @param message TestFailure message
+         */
+        protected void verify(boolean condition, String message) {
+                if (!condition)
+                        throw new TestFailure(message + " in: " + this);
+        }
+
+        public final void setLog(Log log) {
+                this.log = log;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/ThreadMonitoringScenarioFactory.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+/**
+ * ThreadMonitoringScenarioFactory is factory for creating ThreadMonitoringScenario's.
+ */
+public interface ThreadMonitoringScenarioFactory {
+        /**
+         * Obtain recommended scenario count for given basic threads count
+         * (which is usually number of processors).
+         *
+         * @param basicCount
+         */
+        public int getScenarioCount(int basicThreadCount);
+
+        /**
+         * Create scenarios for given scenario count.
+         *
+         * @param count scenario count
+         * @return array of scenarios
+         */
+        public ThreadMonitoringScenario[] createScenarios(int count);
+
+        /**
+         * Create scenario by type name.
+         *
+         * @param scenarioType type of scenario
+         * @return created scenario
+         */
+        public ThreadMonitoringScenario createScenario(String scenarioType);
+
+        /**
+         * Clean up resources held by created scenarios. This should be called
+         * after finish() is also called for all created scenarios.
+         */
+        public void finish();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/ThreadUtils.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.log.Log;
+import nsk.share.TestFailure;
+import java.lang.management.LockInfo;
+import java.lang.management.MonitorInfo;
+import java.lang.management.ThreadInfo;
+
+public final class ThreadUtils {
+        private ThreadUtils() {
+        }
+
+        /**
+         * Obtain human readable string representation of lock info.
+         *
+         * @param info lock ingo
+         * @return string representation of info
+         */
+        public static String strLockInfo(LockInfo info) {
+                if (info == null)
+                        return "LockInfo: " + null;
+                else
+                        return "LockInfo: className: " + info.getClassName() + " identityHashCode: " + info.getIdentityHashCode();
+        }
+
+        /**
+         * Obtain human readable string representation of monitor info.
+         *
+         * @param info monitor info
+         * @return string representation of info
+         */
+        public static String strMonitorInfo(MonitorInfo info) {
+                if (info == null)
+                        return "MonitorInfo: null";
+                else
+                        return "MonitorInfo: lockedStackDepth: " + info.getLockedStackDepth() + " lockedStackFrame: " + info.getLockedStackFrame() + strLockInfo(info);
+        }
+
+
+        /**
+         * Obtain human readable string representation of array of lock info.
+         *
+         * @param infos array of lock info
+         * @return string representation of infos
+         */
+        public static String strLockInfoArr(LockInfo[] infos) {
+                String s = "";
+                for (LockInfo info : infos)
+                        s += strLockInfo(info) + " ";
+                return s;
+        }
+
+        /**
+         * Obtain human readable string representation of array of monitor info.
+         *
+         * @param infos array of monitor info
+         * @return string representation of infos
+         */
+        public static String strMonitorInfoArr(MonitorInfo[] infos) {
+                String s = "";
+                for (MonitorInfo info : infos)
+                        s += strMonitorInfo(info) + " ";
+                return s;
+        }
+
+        /**
+         * Print monitor information.
+         *
+         * @param log log
+         * @param monitorInfo monitor info
+         */
+        public static void printMonitorInfo(Log log, MonitorInfo monitorInfo) {
+                log.info(strMonitorInfo(monitorInfo));
+        }
+
+        /**
+         * Print monitor information array.
+         *
+         * @param log log
+         * @param monitorInfos array of monitor info
+         */
+        public static void printMonitorInfo(Log log, MonitorInfo[] monitorInfos) {
+                for (MonitorInfo monitorInfo : monitorInfos)
+                        printMonitorInfo(log, monitorInfo);
+        }
+
+        /**
+         * Print lock information.
+         *
+         * @param log log
+         * @param lockInfo lock info
+         */
+        public static void printLockInfo(Log log, LockInfo lockInfo) {
+                log.info(strLockInfo(lockInfo));
+        }
+
+        /**
+         * Print lock information array.
+         *
+         * @param log log
+         * @param lockInfo array of lock info
+         */
+        public static void printLockInfo(Log log, LockInfo[] lockInfos) {
+                for (LockInfo lockInfo : lockInfos)
+                        printLockInfo(log, lockInfo);
+        }
+
+        public static final String INDENT = "   ";
+
+        /**
+         * Print all thread information for given ThreadInfo.
+         *
+         * @param log log
+         * @param ti thread info
+         */
+        public static void threadInfo(Log log, ThreadInfo info) {
+                //log.info("Thread info: thread " + info.getThreadId() + " " + info.getThreadName() " state: " + info.getThreadState());
+                threadDump(log, info);
+                log.info("Blocked count: " + info.getBlockedCount() + " time: " + info.getBlockedTime());
+                log.info("Waited count: " + info.getWaitedCount() + " time: " + info.getWaitedTime());
+                LockInfo lockInfo = info.getLockInfo();
+                log.info("Lock: " + strLockInfo(lockInfo));
+                log.info("Lock name: " + info.getLockName() + " ownerId: " + info.getLockOwnerId() + " ownerName: " + info.getLockOwnerName());
+                MonitorInfo[] monitorInfo = info.getLockedMonitors();
+                log.info("Locked monitors: total " + monitorInfo.length);
+                printMonitorInfo(log, info.getLockedMonitors());
+                LockInfo[] lockInfos = info.getLockedSynchronizers();
+                log.info("Locked synchronizers: total " + lockInfos.length);
+                printLockInfo(log, lockInfos);
+        }
+
+        /**
+         * Print thread dump information for given ThreadInfo.
+         *
+         * @param log log
+         * @param ti thread info
+         */
+        public static void threadDump(Log log, ThreadInfo ti) {
+                String s = "";
+                s += "\"";
+                s += ti.getThreadName();
+                s += "\"";
+                s += " Id=" + ti.getThreadId();
+                s += " in " + ti.getThreadState();
+                if (ti.getLockName() != null) {
+                        s += " on lock=" + ti.getLockName();
+                }
+                if (ti.isSuspended()) {
+                        s += " (suspended)";
+                }
+                if (ti.isInNative()) {
+                        s += " (running in native)";
+                }
+                if (ti.getLockOwnerName() != null)
+                        s += " owned by " + ti.getLockOwnerName() + " Id=" + ti.getLockOwnerId();
+                log.info(s);
+                printStackTrace(log, ti);
+        }
+
+        /**
+         * Print stack trace information.
+         *
+         * @param log log
+         * @param ti thread info
+         */
+        public static void printStackTrace(Log log, ThreadInfo ti) {
+                StackTraceElement[] stacktrace = ti.getStackTrace();
+                MonitorInfo[] monitors = ti.getLockedMonitors();
+                for (int i = 0; i < stacktrace.length; i++) {
+                        StackTraceElement ste = stacktrace[i];
+                        log.info(INDENT + "at " + ste.toString());
+
+                        for (MonitorInfo mi : monitors) {
+                                if (mi.getLockedStackDepth() == i) {
+                                        log.info(INDENT + "  - locked " + mi);
+                                }
+                        }
+                }
+                System.out.println();
+
+        }
+
+        /**
+         * Dump information about threads.
+         *
+         * @param log log
+         * @param tinfos array of thread information
+         */
+        public static void threadDump(Log log, ThreadInfo[] tinfos) {
+                log.info("Java thread dump");
+                for (ThreadInfo ti : tinfos) {
+                        threadDump(log, ti);
+                        LockInfo[] syncs = ti.getLockedSynchronizers();
+                        printLockInfo(log, syncs);
+                }
+        }
+
+        public final static int waitThreadStateRetries = 10;
+        public final static long waitThreadStateSleepTime = 100;
+
+        public static void waitThreadState(Thread thread, Thread.State state) {
+                int retries = 0;
+                long ctime = System.currentTimeMillis();
+                while (thread.getState() != state) {
+                        if (retries++ > waitThreadStateRetries)
+                                throw new TestFailure("Thread " + thread + " with current state " + thread.getState() + " did not reach state " + state + " with number of  retries: " + retries + ", time: " + (System.currentTimeMillis() - ctime));
+                        try {
+                                Thread.sleep(waitThreadStateSleepTime);
+                        } catch (InterruptedException e) {
+                        }
+                }
+        }
+
+        /**
+         * Verify condition and throw TestFailure if it does not hold.
+         *
+         * @param condition boolean condition
+         * @param message TestFailure message
+         */
+        public static void verify(boolean condition, String message) {
+                if (!condition)
+                        throw new TestFailure(message);
+        }
+
+        /**
+         * Obtain human readable string representation of array of thread ids.
+         *
+         * @param ids array of ids
+         * @return string representation of ids
+         */
+        public static String strIds(long[] ids) {
+                if (ids == null)
+                        return null;
+                String s = "";
+                for (int i = 0; i < ids.length; ++i) {
+                        s += ids[i];
+                        s += ' ';
+                }
+                return s;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/TimedWaitingThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.log.Log;
+import java.lang.management.ThreadInfo;
+import java.lang.management.MonitorInfo;
+import java.lang.management.LockInfo;
+import nsk.share.test.LocalRandom;
+import nsk.share.TestBug;
+
+/**
+ * TimedWaitingThread is RecursiveMonitoringThread that is waiting on a lock.
+ */
+public class TimedWaitingThread extends RecursiveMonitoringThread {
+        private String lock = new String("a lock");
+        private volatile boolean ready = false;
+        private Object readyLock = new Object();
+        private int count = LocalRandom.nextInt(100) + 1;
+        private volatile int n = 0;
+        private static final String[] expectedMethods = {
+                "java.lang.Object.wait",
+                "nsk.monitoring.share.thread.TimedWaitingThread.runInside"
+        };
+
+        public TimedWaitingThread(Log log, RunType recursionType, int maxDepth) {
+                super(log, recursionType, maxDepth);
+        }
+
+        public void checkThreadInfo(ThreadInfo info) {
+                super.checkThreadInfo(info);
+                verify(info.getThreadState() == Thread.State.TIMED_WAITING, "ThreadInfo.getThreadState() = " + info.getThreadState() + " != " + Thread.State.TIMED_WAITING);
+                //verify(info.getBlockedTime() == 0 || info.getBlockedTime() == -1, "ThreadInfo.getBlockedTime() == " + info.getBlockedTime());
+                //verify(info.getBlockedCount() == count, "ThreadInfo.getBlockedCount() = " + info.getBlockedCount() + " != " + count);
+                verify(info.getWaitedTime() == 0 || info.getWaitedTime() == -1, "ThreadInfo.getWaitedTime() == " + info.getWaitedTime());
+                verify(info.getWaitedCount() == count + 1, "ThreadInfo.getWaitedCount() = " + info.getWaitedCount() + " != " + (count + 1));
+                checkLockInfo(info.getLockInfo());
+                verify(info.getLockName().equals(info.getLockInfo().toString()), "ThreadInfo.getLockName() = " + info.getLockName() + " != ThreadInfo.getLockInfo().toString() = " + info.getLockInfo().toString());
+                verify(info.getLockOwnerId() == -1, "ThreadInfo.getLockOwnerId() = " + info.getLockOwnerId() + " != -1");
+                verify(info.getLockOwnerName() == null, "ThreadInfo.getLockOwnerName() = " + info.getLockOwnerName() + " != null");
+                checkMonitorInfo(info.getLockedMonitors(), null);
+                checkSynchronizers(info.getLockedSynchronizers(), null);
+        }
+
+        private void checkLockInfo(LockInfo lockInfo) {
+                verify(lockInfo.getClassName().equals(lock.getClass().getName()), "LockInfo.getClassName() = " + lockInfo.getClassName() + " differs from lock.getClass().getName() = " + lock.getClass().getName());
+                verify(lockInfo.getIdentityHashCode() == System.identityHashCode(lock), "LockInfo.getIdentityHashCode() = " + lockInfo.getIdentityHashCode() + " differs from System.identityHashCode(lock) = " + System.identityHashCode(lock));
+                String expectedToString = lock.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(lock));
+                verify(lockInfo.toString().equals(expectedToString), "LockInfo.toString() = " + lockInfo.toString() + " differs from expected toString() = " + expectedToString);
+        }
+
+        public void waitState() {
+                synchronized (readyLock) {
+                        while (!ready) {
+                                try {
+                                        readyLock.wait();
+                                } catch (InterruptedException e) {
+                                        log.warn(e);
+                                }
+                        }
+                }
+                waitThreadState(Thread.State.TIMED_WAITING);
+        }
+
+        public void finish() {
+                ready = false;
+                synchronized (lock) {
+                        lock.notify();
+                }
+        }
+
+        protected void runInside() {
+                synchronized (lock) {
+                        do {
+                                try {
+                                        for (int i = 0; i < count; ++i)
+                                                lock.wait(1);
+                                        synchronized (readyLock) {
+                                                ready = true;
+                                                readyLock.notifyAll();
+                                        }
+                                        lock.wait(10000000);
+                                } catch (InterruptedException e) {
+                                        throw new TestBug(e);
+                                }
+                        } while (ready);
+                }
+        }
+
+        protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                return super.isStackTraceElementExpected(element) || checkStackTraceElement(element, expectedMethods);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/WaitingThread.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.share.thread;
+
+import nsk.share.log.Log;
+import java.lang.management.ThreadInfo;
+import java.lang.management.MonitorInfo;
+import java.lang.management.LockInfo;
+
+/**
+ * WaitingThread is RecursiveMonitoringThread that is waiting on a lock.
+ */
+public class WaitingThread extends RecursiveMonitoringThread {
+        private String lock = new String("a lock");
+        private volatile boolean ready = false;
+        private Object readyLock = new Object();
+        private static final String[] expectedMethods = {
+                "nsk.monitoring.share.thread.WaitingThread.runInside",
+                "java.lang.Object.wait"
+        };
+
+        public WaitingThread(Log log, RunType recursionType, int maxDepth) {
+                super(log, recursionType, maxDepth);
+        }
+
+        public void checkThreadInfo(ThreadInfo info) {
+                super.checkThreadInfo(info);
+                verify(info.getThreadState() == Thread.State.WAITING, "ThreadInfo.getThreadState() = " + info.getThreadState() + " != " + Thread.State.WAITING);
+                verify(info.getBlockedTime() == 0 || info.getBlockedTime() == -1, "ThreadInfo.getBlockedTime() == " + info.getBlockedTime());
+                verify(info.getBlockedCount() >= 0, "ThreadInfo.getBlockedCount() = " + info.getBlockedCount() + " != 1");
+                verify(info.getWaitedTime() > 0 || info.getWaitedTime() == -1, "ThreadInfo.getWaitedTime() == " + info.getWaitedTime());
+                verify(info.getWaitedCount() == 1, "ThreadInfo.getWaitedCount() = " + info.getWaitedCount() + " != 1");
+                checkLockInfo(info.getLockInfo());
+                verify(info.getLockName().equals(info.getLockInfo().toString()), "ThreadInfo.getLockName() = " + info.getLockName() + " != ThreadInfo.getLockInfo().toString() = " + info.getLockInfo().toString());
+                verify(info.getLockOwnerId() == -1, "ThreadInfo.getLockOwnerId() = " + info.getLockOwnerId() + " != -1");
+                verify(info.getLockOwnerName() == null , "ThreadInfo.getLockOwnerName() = " + info.getLockOwnerName() + " != null");
+                checkMonitorInfo(info.getLockedMonitors(), null);
+                checkSynchronizers(info.getLockedSynchronizers(), null);
+        }
+
+        private void checkLockInfo(LockInfo lockInfo) {
+                verify(lockInfo.getClassName().equals(lock.getClass().getName()), "LockInfo.getClassName() = " + lockInfo.getClassName() + " differs from lock.getClass().getName() = " + lock.getClass().getName());
+                verify(lockInfo.getIdentityHashCode() == System.identityHashCode(lock), "LockInfo.getIdentityHashCode() = " + lockInfo.getIdentityHashCode() + " differs from System.identityHashCode(lock) = " + System.identityHashCode(lock));
+                String expectedToString = lock.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(lock));
+                verify(lockInfo.toString().equals(expectedToString), "LockInfo.toString() = " + lockInfo.toString() + " differs from expected toString() = " + expectedToString);
+        }
+
+        public void waitState() {
+                synchronized (readyLock) {
+                        while (!ready) {
+                                try {
+                                        readyLock.wait();
+                                } catch (InterruptedException e) {
+                                        log.warn(e);
+                                }
+                        }
+                }
+                waitThreadState(Thread.State.WAITING);
+        }
+
+        public void finish() {
+                ready = false;
+                synchronized (lock) {
+                        lock.notifyAll();
+                }
+        }
+
+        protected void runInside() {
+                synchronized (readyLock) {
+                        ready = true;
+                        readyLock.notifyAll();
+                }
+                while (ready) {
+                        synchronized (lock) {
+                                try {
+                                        lock.wait();
+                                } catch (InterruptedException e) {
+                                        log.warn(e);
+                                }
+                        }
+                }
+        }
+
+        protected boolean isStackTraceElementExpected(StackTraceElement element) {
+                return super.isStackTraceElementExpected(element) || checkStackTraceElement(element, expectedMethods);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/libDeadlock.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "Deadlock.c"
+#include "jni_tools.c"
+#include "nsk_tools.c"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/libLockingThreads.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "LockingThreads.c"
+#include "jni_tools.c"
+#include "nsk_tools.c"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/libNativeBlockedThread.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+
+/*
+ * Class:     nsk_monitoring_share_thread_NativeBlockedThread
+ * Method:    nativeBlock
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_nsk_monitoring_share_thread_NativeBlockedThread_nativeBlock
+(JNIEnv *env, jobject this, jobject lock) {
+        if ((*env)->MonitorEnter(env, lock) != JNI_OK) {
+                (*env)->FatalError(env, "MonitorEnter call failed");
+        }
+        (*env)->MonitorExit(env, lock);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/libRecursiveMonitoringThread.c	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "RecursiveMonitoringThread.c"
+#include "jni_tools.c"
+#include "nsk_tools.c"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/GenClassesBuilder.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.stress.classload;
+
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.Utils;
+import jdk.test.lib.process.ProcessTools;
+import nsk.monitoring.share.Generator;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+public class GenClassesBuilder {
+    public static void main(String[] args) {
+        Path srcDst = Paths.get(
+                "genSrc",
+                "nsk",
+                "monitoring",
+                "share",
+                "newclass").toAbsolutePath();
+        Path classesDir = Paths.get("classes").toAbsolutePath();
+        generateSource(srcDst);
+        compileSource(srcDst, classesDir);
+    }
+
+    private static void compileSource(Path srcDst, Path classesDir) {
+        JDKToolLauncher javac = JDKToolLauncher.create("javac")
+                                               .addToolArg("-d")
+                                               .addToolArg(classesDir.toString())
+                                               .addToolArg("-cp")
+                                               .addToolArg(Utils.TEST_CLASS_PATH);
+        try (Stream<Path> stream = Files.walk(srcDst)) {
+            stream.map(Path::toAbsolutePath)
+                  .map(Path::toString)
+                  .filter(s -> s.endsWith(".java"))
+                  .forEach(javac::addToolArg);
+        } catch (IOException e) {
+            throw new Error("traverse source dir " + srcDst, e);
+        }
+        String[] command = javac.getCommand();
+        try {
+            ProcessTools.executeCommand(command)
+                        .shouldHaveExitValue(0);
+        } catch (Error | RuntimeException e) {
+            throw e;
+        } catch (Throwable e) {
+            throw new Error("execution of javac(" + Arrays.toString(command) + ") failed", e);
+        }
+    }
+
+    private static void generateSource(Path dir) {
+        try {
+            Files.createDirectories(dir);
+        } catch (IOException e) {
+            throw new Error("can't create dirs for" + dir, e);
+        }
+        Path pattern = testRoot().resolve("vmTestbase")
+                                 .resolve("nsk")
+                                 .resolve("monitoring")
+                                 .resolve("share")
+                                 .resolve("LoadableClass.pattern")
+                                 .toAbsolutePath();
+        if (Files.notExists(pattern)) {
+            throw new Error("can't find pattern file: " + pattern);
+        }
+        try {
+            Generator.main(new String[]{pattern.toString(), dir.toString()});
+        } catch (Exception e) {
+            throw new Error("can't generate classes", e);
+        }
+    }
+
+    private static Path testRoot() {
+        Path p = Paths.get(Utils.TEST_SRC);
+        while (!Files.exists(p.resolve("TEST.ROOT"))) {
+            p = p.getParent();
+        }
+        return p;
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.stress.classload;
+
+import java.io.*;
+import java.util.*;
+import java.lang.management.*;
+
+import nsk.share.log.Log;
+import nsk.share.test.*;
+import nsk.share.Consts;
+import nsk.monitoring.share.*;
+
+/**
+ * The test checks up <code>getAllClasses()</code>,
+ * <code>getLoadedClassCount()</code>, <code>getTotalLoadedClassCount()</code>,
+ * <code>getUnloadedClassCount()</code> methods after loading classes for
+ * specified parameters such as:
+ * <ul>
+ *      <li>
+ *          <code>${COMMON_CLASSES_LOCATION}/newclass</code> - path that
+ *          contains precompiled loadable classes for which class loading is
+ *          performed. The newclass path should not be included into
+ *          <code>CLASSPATH</code> to avoid spontaneous loading of these
+ *          classes.
+ *      <li>
+ *          <code>loadedClassCount</code> - number of loadable classes.
+ *      <li>
+ *          <code>loaderCount</code> - number of class loaders.
+ * </ul>
+ *
+ * <p>The other parameters which may have an influence on running test are:
+ * <ul>
+ *      <li>
+ *          <code>testMode</code> defines an execution mode either for
+ *          the <code>ClassLoadingMBean</code> interface or for the
+ *          <code>ClassLoadingMetrics</code> interface.
+ *      <li>
+ *          <code>MBeanServer</code> defines a MBean server implemetation
+ *          under which test is executed.
+ *      <li>
+ *          <code>singleClassloaderClass</code> specifies whether class loaders
+ *          are instances of the same class.
+ * </ul>
+ * For details about arguments, see the {@link
+ * nsk.monitoring.share.ArgumentHamdler ArgumentHamdler} description .
+ *
+ * <p>The test makes an initial snapshot of class loading metrics and loads
+ * classes according to specified parameters. After classes have been loaded,
+ * the test makes snapshot of class loading metrics again and compare them
+ * with initial values.
+ *
+ * <p>It is expected that <code>getLoadedClassCount()</code> and
+ * <code>getTotalLoadedClassCount()</code> must be increased by
+ * <code>loadedClassCount * loaderCount</code> after loading.
+ *
+ * <p>The test also fails if a list returned by <code>getAllClasses()</code>
+ * does not contain any pair of names (loadable class name, class loader name)
+ * or size of this list is not equal to <code>getLoadedClassCount()</code>.
+ *
+ */
+public class load001 extends MonitoringTestBase implements Initializable {
+        private ClassLoadingMXBean classLoading;
+        private ClassLoadingController controller;
+        private long currentlyLoadedClassCount = 0;
+        private long initialClassCount;
+        private long initialTotalClassCount;
+        private long initialUnloadedClassCount;
+        private int loadedClassCount;
+        private int loaderCount;
+        private final String ERR = "Unexpected value:: ";
+
+        Stresser stresser;
+
+        public load001(Stresser stresser) {
+            this.stresser = stresser;
+        }
+
+        public void initialize() {
+                argHandler.dump(log);
+                classLoading = monitoringFactory.getClassLoadingMXBean();
+        }
+
+        public void run() {
+                boolean result = true;
+                loadedClassCount = argHandler.getLoadableClassesCount();
+                loaderCount = argHandler.getLoadersCount();
+
+                stresser.start(loaderCount);
+                controller = new ClassLoadingController(log, argHandler, stresser);
+
+                //extra request for metrics to exclude undesirable class loading
+                //during test execution.
+                initialClassCount = classLoading.getLoadedClassCount();
+                initialTotalClassCount = classLoading.getTotalLoadedClassCount();
+                initialUnloadedClassCount = classLoading.getUnloadedClassCount();
+
+                log.info("\nTEST STARTED");
+                initialClassCount = classLoading.getLoadedClassCount();
+                initialTotalClassCount = classLoading.getTotalLoadedClassCount();
+                initialUnloadedClassCount = classLoading.getUnloadedClassCount();
+
+                log.info("\nInitial values:");
+                log.info("---------------");
+                showValues(initialClassCount, initialTotalClassCount,
+                                initialUnloadedClassCount);
+
+                log.info("\nclass loading...");
+                currentlyLoadedClassCount = controller.loadClasses();
+                if (currentlyLoadedClassCount == 0) {
+                        result = false;
+                }
+
+                long classCount = classLoading.getLoadedClassCount();
+                long totalClassCount = classLoading.getTotalLoadedClassCount();
+                long unloadedClassCount = classLoading.getUnloadedClassCount();
+
+                log.info("\nAmount of currently loaded classes:");
+                log.info("-----------------------------------");
+                showValues(classCount, totalClassCount, unloadedClassCount);
+
+                log.info("\nchecking loaded classes...");
+                result = result & checkValues(classCount,  totalClassCount, unloadedClassCount);
+
+                if (result)
+                        log.info("\nTest PASSED");
+                else {
+                        log.info("\nTest FAILED");
+                        setFailed(true);
+                }
+        }
+
+        private void showValues(long classCount,  long totalClassCount, long unloadedClassCount) {
+                log.info("\ttotal loaded class count = " + totalClassCount);
+                log.info("\tcurrently loaded class count = " + classCount);
+                log.info("\tunloaded class count = " + unloadedClassCount);
+        }
+
+        private boolean checkValues(long classCount, long totalClassCount, long unloadedClassCount) {
+                boolean res = true;
+
+                long expectedValue = initialTotalClassCount + currentlyLoadedClassCount;
+                if (totalClassCount < expectedValue) {
+                        log.error(ERR + "total loaded class count=" + totalClassCount
+                                        + " Expected value: "
+                                        + expectedValue);
+                        res = false;
+                }
+
+                expectedValue = initialClassCount + currentlyLoadedClassCount;
+                if (classCount < expectedValue) {
+                        log.error(ERR + "loaded class count=" + classCount
+                                        + " Expected value: "
+                                        + expectedValue);
+                        res = false;
+                }
+
+                expectedValue = classCount + unloadedClassCount;
+                if (totalClassCount != expectedValue) {
+                        log.error(ERR + "total loaded class count=" + totalClassCount
+                                        + " Expected value(classCount + unloadedClassCount): "
+                                        + expectedValue);
+                        res = false;
+                }
+
+                return res;
+        }
+
+        public static void main(String[] args) {
+                Monitoring.runTest(new load001(new Stresser(args)), args);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load001/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load001.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is loaded by 100 loaders, which are the instances of two
+ *     ClassLoader classes.
+ *     Access to the management metrics is accomplished by directly calling
+ *     the methods in the MBean.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load002/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load002.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is loaded by 100 loaders, which are the instances of two
+ *     ClassLoader class.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     Executable class of the test is the same as for the load001 test.
+ *     In contrast to the load001 test, the load002 test is performed for
+ *     the ClassLoadingMBean interface under DEFAULT implementation of
+ *     MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -testMode=server
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load003/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load003.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is loaded by 100 loaders, which are the instances of two
+ *     ClassLoader class.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     Executable class of the test is the same as for the load001 test.
+ *     In contrast to the load001 test, the load003 test is performed for
+ *     the ClassLoadingMBean interface under CUSTOM implementation of
+ *     MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load004/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load004.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is loaded by 100 loaders, which are the instances of the same
+ *     custom ClassLoader class.
+ *     Access to the management metrics is accomplished by directly calling
+ *     the methods in the MBean.
+ *     Executable class of the test is the same as for the load001 test.
+ *     In contrast to the load001 test, the load004 test is performed for
+ *     the case when class loaders are the instances of the same custom
+ *     ClassLoader class.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -singleClassloaderClass
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load005/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load005.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is loaded by 100 loaders, which are the instances of the same
+ *     custom ClassLoader class.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The load005 test is performed for the ClassLoadingMBean interface under
+ *     DEFAULT implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -testMode=server
+ *      -singleClassloaderClass
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load006/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load006/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load006.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is loaded by 100 loaders, which are the instances of the same
+ *     custom ClassLoader class.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The load005 test is performed for the ClassLoadingMBean interface under
+ *     CUSTOM implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -singleClassloaderClass
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load007/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load007/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load007.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are loaded by 100 loaders, which are the instances of two
+ *     custom ClassLoader classes.
+ *     Access to the management metrics is accomplished by directly calling
+ *     the methods in the MBean.
+ *     Executable class of the test is the same as for the load001 test.
+ *     In contrast to the load001 test, the load007 test is performed for
+ *     the case when 100 loaders execute loading.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -loadableClassCount=100
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load008/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load008/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load008.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are loaded by 100 loaders, which are the instances of two
+ *     custom ClassLoader classes.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The load008 test is performed for the ClassLoadingMBean interface under
+ *     DEFAULT implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -testMode=server
+ *      -loadableClassCount=100
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load009/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load009/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load009.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are loaded by 100 loaders, which are the instances of two
+ *     custom ClassLoader classes.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The load009 test is performed for the ClassLoadingMBean interface under
+ *     CUSTOM implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -loadableClassCount=100
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load010/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load010/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load010.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are loaded by 100 loaders, which are the instances of the
+ *     same ClassLoader class.
+ *     Access to the management metrics is accomplished by directly calling
+ *     the methods in the MBean.
+ *     Executable class of the test is the same as for the load004 test.
+ *     In contrast to the load004 test, the load010 test is performed for
+ *     the case when 100 classes are loaded.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -singleClassloaderClass
+ *      -loadableClassCount=100
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load011/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load011/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load011.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are loaded by 100 loaders, which are the instances of the
+ *     same ClassLoader class.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The load011 test is performed for the ClassLoadingMBean interface under
+ *     DEFAULT implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -testMode=server
+ *      -singleClassloaderClass
+ *      -loadableClassCount=100
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load012/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load012/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/load012.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are loaded by 100 loaders, which are the instances of the
+ *     same ClassLoader class.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The load012 test is performed for the ClassLoadingMBean interface under
+ *     CUSTOM implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.load001
+ *      classes
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -singleClassloaderClass
+ *      -loadableClassCount=100
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.stress.classload;
+
+import java.io.*;
+import java.util.*;
+import java.lang.management.*;
+
+import nsk.share.test.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+/**
+ * The test checks up <code>getAllClasses()</code>,
+ * <code>getLoadedClassCount()</code>, <code>getTotalLoadedClassCount()</code>,
+ * <code>getUnloadedClassCount()</code> methods after unloading classes for
+ * specified parameters such as:
+ * <ul>
+ *      <li>
+ *          <code>${COMMON_CLASSES_LOCATION}/newclass</code> - path that
+ *          contains precompiled loadable classes for which class
+ *          loading/unloading is performed. The newclass path should not be
+ *          included into <code>CLASSPATH</code> to avoid spontaneous loading
+ *          of these classes.
+ *      <li>
+ *          <code>loadedClassCount</code> - number of loadable classes.
+ *      <li>
+ *          <code>loaderCount</code> - number of class loaders.
+ * </ul>
+ *
+ * <p>The other parameters which may have an influence on running test are:
+ * <ul>
+ *      <li>
+ *          <code>testMode</code> defines an execution mode either for
+ *          the <code>ClassLoadingMBean</code> interface or for the
+ *          <code>ClassLoadingMetrics</code> interface.
+ *      <li>
+ *          <code>MBeanServer</code> defines a MBean server implemetation
+ *          under which test is executed.
+ *      <li>
+ *          <code>singleClassloaderClass</code> specifies whether class loaders
+ *          are instances of the same class.
+ * </ul>
+ * For details about arguments, see the {@link
+ * nsk.monitoring.share.ArgumentHamdler ArgumentHamdler} description .
+ *
+ * <p>The test loads classes according to specified parameters. After classes
+ * have been loaded, the test makes an initial snapshot of class loading metrics
+ * and tries to unload these classes. Then it makes snapshot of class loading
+ * metrics again and compare them with initial values.
+ *
+ * <p>It is expected that <code>getLoadedClassCount()</code> and
+ * <code>getTotalLoadedClassCount()</code> must be decreased by
+ * <code>loadedClassCount * loaderCount</code> after unloading.
+ *
+ * <p>The test also fails if a list returned by <code>getAllClasses()</code>
+ * contains any pair of names (loadable class name, class loader name) or size
+ * of this list is not equal to <code>getLoadedClassCount()</code>.
+ *
+ */
+public class unload001 extends MonitoringTestBase implements Initializable {
+        private ClassLoadingMXBean classLoading;
+        private ClassLoadingController controller;
+        private int loadedClassCount;
+        private int loaderCount;
+        private final String ERR = "Unexpected value:: ";
+        private long currentlyUnLoadedClassCount = 0;
+        private long initialClassCount;
+        private long initialTotalClassCount;
+        private long initialUnloadedClassCount;
+
+        private Stresser stresser;
+
+        public unload001(Stresser stresser) {
+            this.stresser = stresser;
+        }
+
+        public void initialize() {
+                argHandler.dump(log);
+                classLoading = monitoringFactory.getClassLoadingMXBean();
+        }
+
+        public void run() {
+                boolean result = true;
+                loadedClassCount = argHandler.getLoadableClassesCount();
+                loaderCount = argHandler.getLoadersCount();
+
+                stresser.start(loaderCount);
+                controller =  new ClassLoadingController(log, argHandler, stresser);
+
+                log.info("\nclass loading...");
+                controller.loadClasses();
+
+                //extra request for metrics to exclude undesirable class loading
+                //during test execution.
+                initialClassCount = classLoading.getLoadedClassCount();
+                initialTotalClassCount = classLoading.getTotalLoadedClassCount();
+                initialUnloadedClassCount = classLoading.getUnloadedClassCount();
+
+                log.info("\nTEST STARTED");
+                initialClassCount = classLoading.getLoadedClassCount();
+                initialTotalClassCount = classLoading.getTotalLoadedClassCount();
+                initialUnloadedClassCount = classLoading.getUnloadedClassCount();
+
+                log.info("\nInitial values:");
+                log.info("---------------");
+                showValues(initialClassCount, initialTotalClassCount,
+                                initialUnloadedClassCount);
+
+                log.info("\nclass unloading...");
+                currentlyUnLoadedClassCount = controller.unloadClasses();
+
+                long classCount = classLoading.getLoadedClassCount();
+                long totalClassCount = classLoading.getTotalLoadedClassCount();
+                long unloadedClassCount = classLoading.getUnloadedClassCount();
+
+                log.info("\nAmount of currently loaded classes:");
+                log.info("-----------------------------------");
+                showValues(/*classNames, */classCount, totalClassCount,
+                                unloadedClassCount);
+
+                log.info("\nchecking loaded classes...");
+                result = result & checkValues(classCount, totalClassCount, unloadedClassCount);
+
+                if (result) {
+                        log.info("Test PASSED");
+                } else {
+                        log.info("Test FAILED");
+                        setFailed(true);
+                }
+
+        }
+
+        public static void main(String[] args) {
+            Monitoring.runTest(new unload001(new Stresser(args)), args);
+        }
+
+        private void showValues(long classCount,  long totalClassCount, long unloadedClassCount) {
+                log.info("\ttotal loaded class count = " + totalClassCount);
+                log.info("\tcurrently loaded class count = " + classCount);
+                log.info("\tunloaded class count = " + unloadedClassCount);
+        }
+
+        private boolean checkValues(long classCount, long totalClassCount, long unloadedClassCount) {
+                boolean res = true;
+
+                // We don't check for inequality here because totalClassCount can be greater than
+                // initialTotalClassCount due to Lambda classes generation in controller.unloadClasses()
+                long expectedValue = initialTotalClassCount;
+                if (totalClassCount < expectedValue) {
+                        log.error(ERR + "total loaded class count=" + totalClassCount
+                                        + " Expected value: "
+                                        + expectedValue);
+                        res = false;
+                }
+
+                expectedValue = classCount + unloadedClassCount;
+                if (totalClassCount != expectedValue) {
+                        log.error(ERR + "total loaded class count=" + totalClassCount
+                                        + " Expected value(classCount + "
+                                        + "unloadedClassCount): " + expectedValue);
+                        res = false;
+                }
+
+                if (currentlyUnLoadedClassCount > unloadedClassCount) {
+                        log.error(ERR + "unloaded class count=" + unloadedClassCount
+                                        + " Expected value at least "
+                                        + currentlyUnLoadedClassCount);
+                        res = false;
+                }
+
+                return res;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload001/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload001.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is unloaded by 100 loaders, which are the instances of two
+ *     ClassLoader classes.
+ *     Access to the management metrics is accomplished by directly calling
+ *     the methods in the MBean.
+ * COMMENTS
+ *     Fixed the bug
+ *     4930540 TEST_BUG: classunload tests incorrectly calculate class amount
+ *     Fixed the bug
+ *     4976274 Regression: Retrung "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload002/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload002.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is unloaded by 100 loaders, which are the instances of two
+ *     ClassLoader classes.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     Executable class of the test is the same as for the unload001 test.
+ *     In contrast to the unload001 test, the unload002 test is performed for
+ *     the ClassLoadingMBean interface under DEFAULT implementation of
+ *     MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -testMode=server
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload003/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload003.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is unloaded by 100 loaders, which are the instances of two
+ *     ClassLoader classes.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     Executable class of the test is the same as for the unload001 test.
+ *     In contrast to the unload001 test, the unload003 test is performed for
+ *     the ClassLoadingMBean interface under CUSTOM implementation of
+ *     MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload004/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload004.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is unloaded by 100 loaders, which are the instances of the same
+ *     ClassLoader class.
+ *     Access to the management metrics is accomplished by directly calling
+ *     the methods in the MBean.
+ *     Executable class of the test is the same as for the unload001 test.
+ *     In contrast to the unload001 test, the unload004 test is performed for
+ *     the case when class loaders are the instances of the same custom
+ *     ClassLoader class.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -singleClassloaderClass
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload005/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload005.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is unloaded by 100 loaders, which are the instances of the same
+ *     ClassLoader class.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The unload005 test is performed for the ClassLoadingMBean interface under
+ *     DEFAULT implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -testMode=server
+ *      -singleClassloaderClass
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload006/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload006/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload006.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when one
+ *     class is unloaded by 100 loaders, which are the instances of the same
+ *     ClassLoader class.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The unload006 test is performed for the ClassLoadingMBean interface under
+ *     CUSTOM implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -singleClassloaderClass
+ *      -loadableClassCount=1
+ *      -loadersCount=100
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload007/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload007/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload007.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are unloaded by 100 loaders, which are the instances of two
+ *     custom ClassLoader classes.
+ *     Access to the management metrics is accomplished by directly calling
+ *     the methods in the MBean.
+ *     Executable class of the test is the same as for the unload001 test.
+ *     In contrast to the unload001 test, the unload007 test is performed for
+ *     the case when 100 loaders execute unloading.
+ * COMMENTS
+ *     Fixed the bug
+ *     4929234 TEST_BUG: classunload tests fail because of time out
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -loadableClassCount=100
+ *      -loadersCount=12
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload008/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload008/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload008.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are unloaded by 100 loaders, which are the instances of two
+ *     custom ClassLoader classes.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The unload008 test is performed for the ClassLoadingMBean interface under
+ *     DEFAULT implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4929234 TEST_BUG: classunload tests fail because of time out
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -testMode=server
+ *      -loadableClassCount=100
+ *      -loadersCount=12
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload009/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload009/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload009.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are unloaded by 100 loaders, which are the instances of two
+ *     custom ClassLoader classes.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The unload009 test is performed for the ClassLoadingMBean interface under
+ *     CUSTOM implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4929234 TEST_BUG: classunload tests fail because of time out
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -loadableClassCount=100
+ *      -loadersCount=12
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload010/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload010/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload010.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are unloaded by 100 loaders, which are the instances of the
+ *     same ClassLoader class.
+ *     Access to the management metrics is accomplished by directly calling
+ *     the methods in the MBean.
+ *     Executable class of the test is the same as for the unload004 test.
+ *     In contrast to the unload004 test, the unload010 test is performed for
+ *     the case when 100 classes are unloaded.
+ * COMMENTS
+ *     Fixed the bug
+ *     4929234 TEST_BUG: classunload tests fail because of time out
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -singleClassloaderClass
+ *      -loadableClassCount=100
+ *      -loadersCount=12
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload011/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload011/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload011.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are unloaded by 100 loaders, which are the instances of the
+ *     same ClassLoader class.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The unload011 test is performed for the ClassLoadingMBean interface under
+ *     DEFAULT implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4929234 TEST_BUG: classunload tests fail because of time out
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -testMode=server
+ *      -singleClassloaderClass
+ *      -loadableClassCount=100
+ *      -loadersCount=12
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload012/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/unload012/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/classload/unload012.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, noJFR]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks up getAllClasses(), getLoadedClassCount(),
+ *     getTotalLoadedClassCount(), getUnloadedClassCount() methods when 100
+ *     classes are unloaded by 100 loaders, which are the instances of the
+ *     same ClassLoader class.
+ *     Access to the management metrics is accomplished through the MBeanServer.
+ *     The unload012 test is performed for the ClassLoadingMBean interface under
+ *     CUSTOM implementation of MBean server.
+ * COMMENTS
+ *     Fixed the bug
+ *     4929234 TEST_BUG: classunload tests fail because of time out
+ *     Fixed the bug
+ *     4976274 Regression: "OutOfMemoryError: Java heap space" when -XX:+UseParallelGC
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @comment generate and compile LoadableClassXXX classes
+ * @run driver nsk.monitoring.stress.classload.GenClassesBuilder
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.classload.unload001
+ *      classes
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -singleClassloaderClass
+ *      -loadableClassCount=100
+ *      -loadersCount=12
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.stress.lowmem;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
+import java.lang.management.MemoryType;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import nsk.share.Log;
+import nsk.share.TestFailure;
+import nsk.share.gc.GC;
+import nsk.share.gc.ThreadedGCTest;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.gp.array.ByteArrayProducer;
+import nsk.share.gc.gp.classload.GeneratedClassProducer;
+import nsk.monitoring.share.*;
+import nsk.share.test.ExecutionController;
+
+public class lowmem001 extends ThreadedGCTest {
+
+    // The max heap usage after whih we free memory and restart
+    static final int MAX_HEAP_USAGE = 70;
+    // isOOM is used to stop allocation and free resources
+    // immediately after first OOME
+    // really it could be only if we didn't check usage in time
+    static AtomicBoolean isOOM = new AtomicBoolean(false);
+    static ArgumentHandler argHandler;
+    MemoryMonitor monitor;
+
+    public static void main(String[] args) {
+        argHandler = new ArgumentHandler(args);
+        GC.runTest(new lowmem001(), args);
+    }
+
+    @Override
+    public void run() {
+        Log log = new Log(System.out, true);
+        // System.err is duplicated into buffer
+        // it should be empty
+        MyStream stream = new MyStream(System.err);
+        System.setErr(new PrintStream(stream));
+
+        monitor = Monitor.getMemoryMonitor(log, argHandler);
+        try {
+            monitor.enableMonitoring();
+            monitor.updateThresholds();
+            super.run();
+            monitor.disableMonitoring();
+        } catch (Exception e) {
+            throw new TestFailure(e);
+        }
+        if (isOOM.get() == true) {
+            log.display("The OOME happened during test");
+            // We control memory at 70 %
+            // each time when we want to eat 512 bytes
+            // if we got OOME it is really ugly
+            throw new TestFailure("OOME should not happened.");
+        }
+        if (!monitor.getPassedStatus()) {
+            throw new TestFailure("MemoryMonitor fails. See log.");
+        }
+        if (!stream.isEmpty()) {
+            String string = stream.getString();
+            if (string.contains("java.lang.OutOfMemoryError")) {
+                log.display("WARNING: The System.err contains OutOfMemory.");
+                // the OOME is not error
+                log.complain(string);
+                return;
+            }
+            log.complain(string);
+            throw new TestFailure("Error stream is not empty.");
+        }
+
+    }
+
+    @Override
+    protected Runnable createRunnable(int i) {
+        String memory = argHandler.getTestedMemory();
+        if (memory.equals(MemoryMonitor.HEAP_TYPE)) {
+            return new HeapStresser();
+        }
+        if (memory.equals(MemoryMonitor.NONHEAP_TYPE)) {
+            return new ClassStresser();
+        }
+        // mixed type
+        return i % 2 == 0 ? new HeapStresser() : new ClassStresser();
+    }
+
+    /*
+     * Simple ClassLoader is used for non-heap stressing
+     * should be revised after permgen removal
+     */
+    class ClassStresser extends Thread {
+
+        @Override
+        public void run() {
+            ExecutionController stresser = getExecutionController();
+            GeneratedClassProducer gp = new GeneratedClassProducer();
+            while (stresser.continueExecution()) {
+                try {
+                    gp.create(0);
+                } catch (OutOfMemoryError e) {
+                    // drop 'gc', reset Thresholds and start new iteration
+                    monitor.resetThresholds(MemoryType.NON_HEAP);
+                    return;
+                }
+            }
+        }
+    };
+
+    class HeapStresser extends Thread {
+
+        final long chunkSize = 512;
+        List storage;
+        GarbageProducer gp = new ByteArrayProducer();
+
+
+        @Override
+        public void run() {
+            storage = new LinkedList();
+            ExecutionController stresser = getExecutionController();
+            MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
+
+            while (stresser.continueExecution()) {
+                try {
+                   storage.add(gp.create(chunkSize + new Object().hashCode() % 31));
+                   storage.add(gp.create(chunkSize));
+                   storage.remove(0);
+                    if (isOOM.get() == true || !stresser.continueExecution()) {
+                        stresser.finish();
+                        storage = null;
+                        return;
+                    }
+                    if (Thread.currentThread().isInterrupted()) {
+                        break;
+                    }
+                    // If memory is low free resources and restart
+                    if (bean.getHeapMemoryUsage().getUsed()
+                            > bean.getHeapMemoryUsage().getMax() * MAX_HEAP_USAGE / 100) {
+                        storage = new LinkedList();
+                        monitor.resetThresholds(MemoryType.HEAP);
+                    }
+                } catch (OutOfMemoryError e) {
+                    // Let finish, the managment/memorymonitor could be
+                    // corrupted after OOME
+                    storage = null;
+                    isOOM.set(true);
+                    stresser.finish();
+                    return;
+                }
+            }
+        }
+    }
+
+    static class MyStream extends OutputStream {
+
+        PrintStream err;
+
+        public MyStream(PrintStream err) {
+            this.err = err;
+        }
+        private final static int SIZE = 100000;
+        private char[] value = new char[SIZE];
+        private int count = 0;
+
+        // No additional memory allocation during write
+        @Override
+        public synchronized void write(int b) {
+            if (count < SIZE) {
+                value[count++] = (char) b;
+            }
+            try {
+                err.write(b);
+            } catch (OutOfMemoryError oome) {
+                isOOM.set(true);
+            }
+        }
+
+        public String getString() {
+            return new String(value, 0, count);
+        }
+
+        public boolean isEmpty() {
+            return count == 0;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem001/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem001.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills heap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm -XX:-UseGCOverheadLimit nsk.monitoring.stress.lowmem.lowmem001 -memory=heap
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem002/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem002.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills heap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -memory=heap
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem003/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem003.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills heap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -memory=heap
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem004/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem004.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills nonheap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm -XX:-UseGCOverheadLimit nsk.monitoring.stress.lowmem.lowmem001 -memory=nonheap
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem005/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem005.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills nonheap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -memory=nonheap
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem006/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem006/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem006.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills nonheap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -memory=nonheap
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem007/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem007/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem007.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills both heap and nonheap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm -XX:-UseGCOverheadLimit nsk.monitoring.stress.lowmem.lowmem001 -memory=mixed
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem008/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem008/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem008.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills both heap and nonheap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -memory=mixed
+ *      -testMode=server
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem009/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem009/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem009.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills both heap and nonheap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -memory=mixed
+ *      -testMode=server
+ *      -MBeanServer=custom
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem010/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem010/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem010.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills heap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=directly
+ *      -memory=heap
+ *      -monitoring=polling
+ *      -threshold=usage
+ *      -timeout=30
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem011/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem011/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem011.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills heap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -memory=heap
+ *      -monitoring=polling
+ *      -threshold=usage
+ *      -timeout=30
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem012/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem012/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem012.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills heap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -memory=heap
+ *      -monitoring=polling
+ *      -threshold=usage
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem013/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem013/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem013.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills nonheap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=directly
+ *      -memory=nonheap
+ *      -monitoring=polling
+ *      -threshold=usage
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem014/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem014/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem014.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills nonheap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -memory=nonheap
+ *      -monitoring=polling
+ *      -threshold=usage
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem015/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem015/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem015.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills nonheap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -memory=nonheap
+ *      -monitoring=polling
+ *      -threshold=usage
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem016/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem016/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem016.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills mixed memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=directly
+ *      -memory=mixed
+ *      -monitoring=polling
+ *      -threshold=usage
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem017/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem017/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem017.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills mixed memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -memory=mixed
+ *      -monitoring=polling
+ *      -threshold=usage
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem018/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem018/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem018.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills mixed memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -memory=mixed
+ *      -monitoring=polling
+ *      -threshold=usage
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem019/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem019/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem019.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills heap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=directly
+ *      -memory=heap
+ *      -monitoring=notification
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem020/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem020/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem020.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills heap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -memory=heap
+ *      -monitoring=notification
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem021/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem021/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem021.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills heap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -memory=heap
+ *      -monitoring=notification
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem022/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem022/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem022.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills nonheap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=directly
+ *      -memory=nonheap
+ *      -monitoring=notification
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem023/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem023/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem023.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills nonheap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -memory=nonheap
+ *      -monitoring=notification
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem024/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem024/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem024.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills nonheap memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -memory=nonheap
+ *      -monitoring=notification
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem025/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem025/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem025.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills mixed memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=directly
+ *      -memory=mixed
+ *      -monitoring=notification
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem026/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem026/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem026.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills mixed memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -memory=mixed
+ *      -monitoring=notification
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem027/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem027/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem027.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills mixed memory;
+ *         - implements notifcation mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -memory=mixed
+ *      -monitoring=notification
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem028/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem028/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem028.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills heap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=directly
+ *      -memory=heap
+ *      -monitoring=polling
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem029/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem029/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem029.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills heap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -memory=heap
+ *      -monitoring=polling
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem030/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem030/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem030.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills heap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -memory=heap
+ *      -monitoring=polling
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem031/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem031/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem031.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills nonheap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=directly
+ *      -memory=nonheap
+ *      -monitoring=polling
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem032/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem032/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem032.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills nonheap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -memory=nonheap
+ *      -monitoring=polling
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem033/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem033/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem033.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills nonheap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -memory=nonheap
+ *      -monitoring=polling
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem034/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem034/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem034.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs directly access to the MBeans' methods;
+ *         - fills both heap and nonheap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=directly
+ *      -memory=mixed
+ *      -monitoring=polling
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem035/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem035/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem035.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through default MBeanServer;
+ *         - fills both heap and nonheap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -memory=mixed
+ *      -monitoring=polling
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem036/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem036/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/lowmem/lowmem036.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that enabling of low memory detection does not lead to
+ *     unexpected behaviour: crashes of the VM and undocumented exceptions.
+ *     The test enables low memory detection: it adds NotificationListener
+ *     to the MemoryMBean for notification mechanism of monitoring, or starts
+ *     a special thread for polling mechanism. After that, it starts eating memory.
+ *     Objects are allocated, if "heap" memory is tested; classes are loaded,
+ *     if "nonheap" memory is tested; objects are allocated and classes are
+ *     loaded, if "mixed" memory is tested.
+ *     Notifications are received by the listener in notification mechanism and
+ *     crossing of thresholds are detected in polling mechanism. The thresholds
+ *     are updated as soon as notification is received, or crossing of a threshold
+ *     is detected.
+ *     The test also checks stderr to be empty. Otherwise, it fails. The test
+ *     exits as soon as OutOfMemoryError is caught (if heap memory is tested) or
+ *     all classes are loaded (if nonheap or mixed memory is tested).
+ *     All options of the test are specified in *.cfg file. this particular test
+ *         - performs access to the MBeans' method through custom MBeanServer;
+ *         - fills both heap and nonheap memory;
+ *         - implements polling mechanism of monitoring;
+ *         - tests collection usage thresholds.
+ * COMMENTS
+ *     Fixed the bug
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.monitoring.stress.lowmem.lowmem001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -memory=mixed
+ *      -monitoring=polling
+ *      -threshold=collection
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/cmon001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.stress.thread;
+
+import java.lang.management.*;
+import java.io.*;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class cmon001 {
+    final static long CONST_BARRIER_TIME = 200;
+    final static long ITERATIONS = 50;
+
+    // Precision of value returned by ThreadInfo.getWaitedTime().
+    // System.nanoTime() and ThreadInfo.getWaitedTime() may use
+    // different methods to sample time, so PRECISION is essential to
+    // compare those two times.
+    final static long PRECISION = 3; // Milliseconds
+
+    // Ratio between nano and milli
+    final static long NANO_MILLI = 1000000;
+
+    private static volatile boolean testFailed = false;
+    private static Integer calculated;
+    private static Object common = new Object();
+    private static Object[] finishBarriers;
+    private static long[] startTime;
+    private static long[] endTime;
+    private static long[] waitedTime;
+
+    public static void main(String[] argv) {
+        System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        Log log = new Log(out, argHandler);
+        ThreadMonitor monitor = Monitor.getThreadMonitor(log, argHandler);
+
+        // The test passes, if thread contention monitoring is not supported
+        if (!monitor.isThreadContentionMonitoringSupported()) {
+            log.display("Thread contention monitoring is not supported.");
+            log.display("TEST PASSED.");
+            return Consts.TEST_PASSED;
+        }
+
+        // Enable thread contention monitoring, if it is supported
+        monitor.setThreadContentionMonitoringEnabled(true);
+
+        int threadCount = argHandler.getThreadCount();
+        MyThread threads[] = new MyThread[threadCount];
+        finishBarriers = new Object[threadCount];
+        startTime = new long[threadCount];
+        endTime = new long[threadCount];
+        waitedTime = new long[threadCount];
+
+        for (int i = 0; i < threadCount; i++)
+            finishBarriers[i] = new Object();
+
+        // Begin a loop which will start a number of threads
+        for (int time = 0; time < ITERATIONS; time++) {
+            log.display("Iteration: " + time);
+
+            calculated = new Integer(0);
+
+            // Start all threads. Half of them are user threads,
+            // others - daemon.
+            for (int i = 0; i < threadCount; i++) {
+                threads[i] = new MyThread(i, time, log, monitor);
+                threads[i].setDaemon(i % 2 == 0);
+                threads[i].start();
+            }
+
+            // Wait for all threads to access "calculated" variable
+            while (calculated.intValue() < threadCount)
+                Thread.currentThread().yield();
+            log.display("All threads have finished calculation: " + calculated);
+
+            // Notify all threads to finish
+            for (int i = 0; i < threadCount; i++)
+                synchronized (finishBarriers[i]) {
+                    finishBarriers[i].notify();
+                }
+
+            // Wait for all threads to die
+            for (int i = 0; i < threadCount; i++)
+                try {
+                    threads[i].join();
+                } catch (InterruptedException e) {
+                    log.complain("Unexpected exception");
+                    e.printStackTrace(log.getOutStream());
+                    testFailed = true;
+                }
+            log.display("All threads have died.");
+
+            // Perform checks
+
+            // All threads must increase "calculated" value by one, so
+            // "calculated" must be equal to number of started threads.
+            if (calculated.intValue() != threadCount) {
+                log.complain("Number of threads that accessed the variable: "
+                           + calculated.intValue() + ", expected: "
+                           + threadCount);
+                testFailed = true;
+            }
+
+            // Waited time of each thread must not be greater than overall
+            // time of execution of the thread.
+            // Precision must be taken into account in this case.
+            for (int i = 0; i < threadCount; i++) {
+                long liveNano = endTime[i] - startTime[i];
+                long liveMilli = liveNano / NANO_MILLI;
+                long leastWaitedTime = 2 * CONST_BARRIER_TIME + time;
+
+                if (leastWaitedTime - 2 * PRECISION > waitedTime[i]) {
+                    // that is not a bug. see 5070997 for details
+                    log.display("Thread " + i + " was waiting for a monitor "
+                               + "for at least " + leastWaitedTime
+                               + " milliseconds, but "
+                               + "ThreadInfo.getWaitedTime() returned value "
+                               + waitedTime[i]);
+                }
+
+                if (liveMilli + PRECISION < waitedTime[i]) {
+                    log.complain("Life time of thread " + i + " is " + liveMilli
+                               + " milliseconds, but "
+                               + "ThreadInfo.getWaitedTime() returned value "
+                               + waitedTime[i]);
+                    testFailed = true;
+                }
+            }
+        } // for time
+
+        if (testFailed)
+            log.complain("TEST FAILED.");
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    } // run()
+
+    private static class MyThread extends Thread {
+        int num;
+        int time;
+        Log log;
+        ThreadMonitor monitor;
+        Object constBarrier = new Object();
+        Object varBarrier = new Object();
+
+        MyThread(int num, int time, Log log, ThreadMonitor monitor) {
+            this.num = num;
+            this.time = time;
+            this.log = log;
+            this.monitor = monitor;
+        }
+
+        public void run() {
+            startTime[num] = System.nanoTime();
+
+            // constBarrier does not receive notification, so the thread will
+            // be waiting for CONST_BARRIER_TIME milliseconds
+            synchronized (constBarrier) {
+                try {
+                    constBarrier.wait(CONST_BARRIER_TIME);
+                } catch (InterruptedException e) {
+                    log.complain("Unexpected exception");
+                    e.printStackTrace(log.getOutStream());
+                    testFailed = true;
+                }
+            }
+
+            // varBarrier does not receive notification, so the thread will
+            // be waiting for (CONST_BARRIER_TIME + time) milliseconds. This
+            // time is different for each iteration.
+            synchronized (varBarrier) {
+                try {
+                    varBarrier.wait(CONST_BARRIER_TIME + time);
+                } catch (InterruptedException e) {
+                    log.complain("Unexpected exception");
+                    e.printStackTrace(log.getOutStream());
+                    testFailed = true;
+                }
+            }
+
+            // Increase "calculated" value by one
+            synchronized (common) {
+                synchronized (calculated) {
+                    calculated = new Integer(calculated.intValue() + 1);
+                }
+            }
+
+            synchronized (finishBarriers[num]) {
+                try {
+                    finishBarriers[num].wait(10 * CONST_BARRIER_TIME);
+                } catch (InterruptedException e) {
+                    log.complain("Unexpected exception");
+                    e.printStackTrace(log.getOutStream());
+                    testFailed = true;
+                }
+            }
+
+            // Save all time stats for the thread
+            ThreadInfo info = monitor.getThreadInfo(this.getId(), 0);
+            waitedTime[num] = info.getWaitedTime();
+            endTime[num] = System.nanoTime();
+        }
+    } // class MyThread
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/cmon001/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/cmon001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/cmon001.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that waited time returned by ThreadInfo.getWaitedTime() is
+ *     not greater than overall time of execution of a thread. Also, the test
+ *     checks that waited time is not less than minimal time that each thread
+ *     waits without notifications on Object.wait(long).
+ *     Main thread starts a number of threads that is specified in "-threadCount"
+ *     option. Each thread has three Object.wait(long) blocks; two of them do
+ *     not receieve notifications, therefore a thread will be waiting for at least
+ *     a few milliseconds. All threads access the same Integer variable
+ *     ("calculated") and increase its value by one. Main thread waits until
+ *     "calculated" becomes equal to number of started threads and then perform
+ *     three checks.
+ *     The test fails if "calculated" value is not equal to number of started
+ *     threads. It also fails if value returned by ThreadInfo.getWaitedTime() in
+ *     any thread is greater than overall time of execution of the thread. Also,
+ *     the test fails if waited time is less than time waited in first and second
+ *     Object.wait(long) methods (those objects do not receive notifications).
+ *     Then the test repeats the procedure with starting threads and performing
+ *     checks ITERATIONS times.
+ *     All comparisions of time are made with precision specified in PRECISION
+ *     constant. Values returned by ThreadInfo.getWaitedTime() and
+ *     System.nanoTime() and may use different methods to sample time, so
+ *     PRECISION is essential to compare those two times and is set to 3
+ *     (milliseconds) by default.
+ *     This particular test performs directly access to the MBeans' methods.
+ * COMMENTS
+ *     Fixed the bug
+ *     4983682 TEST BUG: cmon001/2/3 should call System.nanoTime for time
+ *             comparison
+ *     5070997: TEST_BUG: incorrect below-checking of thread waiting time
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.stress.thread.cmon001 -threadCount=400
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/cmon002/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/cmon002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/cmon002.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that waited time returned by ThreadInfo.getWaitedTime() is
+ *     not greater than overall time of execution of a thread. Also, the test
+ *     checks that waited time is not less than minimal time that each thread
+ *     waits without notifications on Object.wait(long).
+ *     Main thread starts a number of threads that is specified in "-threadCount"
+ *     option. Each thread has three Object.wait(long) blocks; two of them do
+ *     not receieve notifications, therefore a thread will be waiting for at least
+ *     a few milliseconds. All threads access the same Integer variable
+ *     ("calculated") and increase its value by one. Main thread waits until
+ *     "calculated" becomes equal to number of started threads and then perform
+ *     three checks.
+ *     The test fails if "calculated" value is not equal to number of started
+ *     threads. It also fails if value returned by ThreadInfo.getWaitedTime() in
+ *     any thread is greater than overall time of execution of the thread. Also,
+ *     the test fails if waited time is less than time waited in first and second
+ *     Object.wait(long) methods (those objects do not receive notifications).
+ *     Then the test repeats the procedure with starting threads and performing
+ *     checks ITERATIONS times.
+ *     All comparisions of time are made with precision specified in PRECISION
+ *     constant. Values returned by ThreadInfo.getWaitedTime() and
+ *     System.nanoTime() and may use different methods to sample time, so
+ *     PRECISION is essential to compare those two times and is set to 3
+ *     (milliseconds) by default.
+ *     This particular test performs access to the MBeans' methods through default
+ *     MBeanServer.
+ * COMMENTS
+ *     Fixed the bug
+ *     4983682 TEST BUG: cmon001/2/3 should call System.nanoTime for time
+ *             comparison
+ *     5070997: TEST_BUG: incorrect below-checking of thread waiting time
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.stress.thread.cmon001 -testMode=server -threadCount=400
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/cmon003/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/cmon003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/cmon003.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that waited time returned by ThreadInfo.getWaitedTime() is
+ *     not greater than overall time of execution of a thread. Also, the test
+ *     checks that waited time is not less than minimal time that each thread
+ *     waits without notifications on Object.wait(long).
+ *     Main thread starts a number of threads that is specified in "-threadCount"
+ *     option. Each thread has three Object.wait(long) blocks; two of them do
+ *     not receieve notifications, therefore a thread will be waiting for at least
+ *     a few milliseconds. All threads access the same Integer variable
+ *     ("calculated") and increase its value by one. Main thread waits until
+ *     "calculated" becomes equal to number of started threads and then perform
+ *     three checks.
+ *     The test fails if "calculated" value is not equal to number of started
+ *     threads. It also fails if value returned by ThreadInfo.getWaitedTime() in
+ *     any thread is greater than overall time of execution of the thread. Also,
+ *     the test fails if waited time is less than time waited in first and second
+ *     Object.wait(long) methods (those objects do not receive notifications).
+ *     Then the test repeats the procedure with starting threads and performing
+ *     checks ITERATIONS times.
+ *     All comparisions of time are made with precision specified in PRECISION
+ *     constant. Values returned by ThreadInfo.getWaitedTime() and
+ *     System.nanoTime() and may use different methods to sample time, so
+ *     PRECISION is essential to compare those two times and is set to 3
+ *     (milliseconds) by default.
+ *     This particular test performs access to the MBeans' methods through custom
+ *     MBeanServer.
+ * COMMENTS
+ *     Fixed the bug
+ *     4983682 TEST BUG: cmon001/2/3 should call System.nanoTime for time
+ *             comparison
+ *     5070997: TEST_BUG: incorrect below-checking of thread waiting time
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.stress.thread.cmon001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -threadCount=400
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.stress.thread;
+
+import java.lang.management.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+public class strace001 {
+    public final static String LIB_NAME = "StackTraceController";
+    private final static String THREAD_NAME
+        = "nsk.monitoring.stress.thread.RunningThread";
+    private final static int ITERATIONS = 50;
+
+    public static volatile boolean finish;
+    public static volatile boolean testFailed = false;
+    public static Object common = new Object();
+    public static Integer activeThreads;
+    private static Log log;
+    private static int depth;
+    private static int threadCount;
+    private static String[] expectedTrace;
+    private static ThreadMonitor monitor;
+    private static ThreadController controller;
+
+    public static void main(String[] argv) {
+        System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        log = new Log(out, argHandler);
+        monitor = Monitor.getThreadMonitor(log, argHandler);
+        threadCount = argHandler.getThreadCount();
+        depth = argHandler.getThreadDepth();
+        controller = new ThreadController(log, threadCount, depth,
+                                          argHandler.getInvocationType());
+        RunningThread threads[] = new RunningThread[threadCount];
+
+        // Fill expectedTrace array according to invocation type that is set in
+        // test options
+        if ( !fillTrace() ) {
+            log.complain("Unknown invocation type: "
+                       + controller.getInvocationType());
+            return Consts.TEST_FAILED;
+        }
+
+        for (int i = 0; i < ITERATIONS; i++) {
+            log.display("\nIteration: " + i);
+            activeThreads = new Integer(0);
+            finish = false;
+
+            // Start all threads. Half of them are user threads,
+            // others - deamon
+            for (int j = 0; j < threadCount; j++) {
+                threads[j] = new RunningThread(j, controller, log, depth);
+                threads[j].setDaemon(i % 2 == 0);
+                threads[j].start();
+            }
+
+            // Wait for all threads to start
+            while (activeThreads.intValue() < threadCount)
+                Thread.currentThread().yield();
+            log.display("All threads started: " + activeThreads);
+
+            // Make a snapshot of stack trace for all threads and check it
+            for (int j = 0; j < threadCount; j++) {
+                boolean isAlive = threads[j].isAlive();
+                ThreadInfo info = monitor.getThreadInfo(threads[j].getId(), Integer.MAX_VALUE);
+
+                // A thread may be dead because of OutOfMemoryError or
+                // StackOverflowError
+                if (isAlive) {
+                    if (info == null) {
+                        log.complain("ThreadInfo for thread " + j + " is null, "
+                                   + "but Thread.isAlive() returned true.");
+                        testFailed = true;
+                        continue;
+                    }
+
+                    StackTraceElement[] snapshot = info.getStackTrace();
+                    if ( !checkTrace(snapshot) ) {
+                        log.display("\nSnapshot of thread: " + j);
+                        printStackTrace(snapshot);
+                        testFailed = true;
+                    }
+                } else
+                    log.display("Thread " + j + " is dead, skipping it.");
+            }
+
+            // Let all threads to complete their job
+            finish = true;
+
+            // Wait for all threads to be dead
+            for (int j = 0; j < threadCount; j++)
+                try {
+                    threads[j].join();
+                } catch (InterruptedException e) {
+                    log.complain("Unexpected exception while joining thread "
+                               + j);
+                    e.printStackTrace(log.getOutStream());
+                    testFailed = true;
+                }
+            log.display("All threads have died.");
+        } // for i
+
+        if (testFailed)
+            log.complain("TEST FAILED.");
+
+        return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
+    }
+
+    // Fill expectedTrace array according to the invocation type that is set in
+    // test options
+    private static boolean fillTrace() {
+        switch (controller.getInvocationType()) {
+            case ThreadController.JAVA_TYPE:
+                expectedTrace = new String[] {
+                    "java.lang.Thread.sleep"
+                    , "java.lang.Thread.yield"
+                    , THREAD_NAME + ".waitForSign"
+                    , THREAD_NAME + ".recursionJava"
+                    , THREAD_NAME + ".run"
+                };
+                break;
+
+            case ThreadController.NATIVE_TYPE:
+                expectedTrace = new String[] {
+                    "java.lang.Thread.sleep"
+                    , "java.lang.Thread.yield"
+                    , THREAD_NAME + ".waitForSign"
+                    , THREAD_NAME + ".recursionNative"
+                    , THREAD_NAME + ".run"
+                };
+                break;
+
+            case ThreadController.MIXED_TYPE:
+                expectedTrace = new String[] {
+                    "java.lang.Thread.sleep"
+                    , "java.lang.Thread.yield"
+                    , THREAD_NAME + ".waitForSign"
+                    , THREAD_NAME + ".recursionNative"
+                    , THREAD_NAME + ".recursionJava"
+                    , THREAD_NAME + ".run"
+                };
+                break;
+
+            default:
+                return false;
+        }
+
+        return true;
+    }
+
+    // The method prints stack trace in style JVM does
+    private static void printStackTrace(StackTraceElement[] elements) {
+        for (int i = 0; i < elements.length; i++) {
+            String s = "\t " + i + ": " + elements[i].getClassName() + "."
+                     + elements[i].getMethodName();
+
+            if (elements[i].isNativeMethod())
+                s = s + "(Native Method)";
+            else
+                s = s + "(" + elements[i].getFileName() + ":"
+                  + elements[i].getLineNumber() + ")";
+            log.display(s);
+        }
+    }
+
+    // The method performs checks of the stack trace
+    private static boolean checkTrace(StackTraceElement[] elements) {
+        int length = elements.length;
+        int expectedLength = depth +3;
+        boolean result = true;
+
+        // Check the length of the trace. It must not be greater than
+        // expectedLength. Number of recursionJava() or recursionNative()
+        // methods must not ne greater than depth, also one Object.wait() or
+        // Thread.yield() method, one run( ) and one waitForSign().
+        if (length > expectedLength) {
+            log.complain("Length of the stack trace is " + length + ", but "
+                       + "expected to be not greater than " + expectedLength);
+            result = false;
+        }
+
+        // Check each element of the snapshot
+        for (int i = 0; i < elements.length; i++) {
+            if (i == elements.length - 1) {
+
+                // The latest method of the snapshot must be RunningThread.run()
+                if ( !checkLastElement(elements[i]) )
+                    result = false;
+            } else {
+
+                // getClassName() and getMethodName() must return correct values
+                // for each element
+                if ( !checkElement(i, elements[i]) )
+                    result = false;
+            }
+        }
+        return result;
+    }
+
+    // The method checks that StackTraceElement.getClassName() and
+    // StackTraceElement.getMethodName() return expected values
+    private static boolean checkElement(int n, StackTraceElement element) {
+        String name = element.getClassName() + "." + element.getMethodName();
+
+        // The latest element is not checked, since it must be "run()"
+        for (int i = 0; i < expectedTrace.length - 1; i++) {
+            if (expectedTrace[i].equals(name))
+                return true;
+        }
+
+        log.complain("Unexpected " + n + " element of the stack trace:\n\t"
+                   + name);
+        return false;
+    }
+
+    // The method checks that StackTraceElement.getClassName() returns
+    // "RunningThread" and StackTraceElement.getMethodName() returns "run"
+    // for the latest element of the snapshot
+    private static boolean checkLastElement(StackTraceElement element) {
+        String name = element.getClassName() + "." + element.getMethodName();
+        String last = expectedTrace[expectedTrace.length - 1];
+
+        if (!last.equals(name)) {
+            log.complain("Unexpected last element of the stack trace:\n\t"
+                   + name + "\nexpected:\n\t" + last);
+            return false;
+        }
+        return true;
+    }
+}
+
+// This thread starts a recursion until it reaches specified depth. Then the
+// thread waits until it gets a notification from main thread. Pure java
+// and native methods are used in the thread. So, the thread is definitly in
+// "running" state when main thread performs its checks.
+class RunningThread extends Thread {
+    private int num;
+    private static ThreadController controller;
+    private Log log;
+    private int depth;
+    private boolean mixed = false;
+    native int recursionNative(int maxDepth, int currentDepth, boolean returnToJava);
+
+    static {
+        try {
+            System.loadLibrary(strace001.LIB_NAME);
+        } catch (UnsatisfiedLinkError e) {
+            System.err.println("Cannot load library " + strace001.LIB_NAME);
+            System.err.println("java.library.path: "
+                             + System.getProperty("java.library.path"));
+            throw e;
+        }
+    }
+
+    RunningThread(int num, ThreadController controller, Log log, int depth) {
+        this.num = num;
+        this.controller = controller;
+        this.log = log;
+        this.depth = depth;
+    }
+
+    public void run() {
+        int result = 0;
+        int invocationType = controller.getInvocationType();
+
+        // This instance of the thread is alive
+        synchronized (strace001.common) {
+            synchronized (strace001.activeThreads) {
+                strace001.activeThreads
+                    = new Integer(strace001.activeThreads.intValue() + 1);
+            }
+        }
+
+        // Choose a method (native or java) to continue recursion
+        try {
+            switch (invocationType) {
+                case ThreadController.JAVA_TYPE:
+                    recursionJava(depth, 0);
+                    break;
+                case ThreadController.NATIVE_TYPE:
+                    result = recursionNative(depth, 0, false);
+
+                    if (result == 1) {
+                        log.display("Fatal error (OutOfMemoryError or "
+                                + "StackOverflow) is thrown in native method of "
+                                + " thread " + num);
+                        return;
+                    } else if (result == 2) {
+                        log.complain("Unexpected exception is thrown in native "
+                                + "method of thread " + num);
+                        strace001.testFailed = true;
+                        return;
+                    }
+                    break;
+                case ThreadController.MIXED_TYPE:
+                    mixed = true;
+                    result = recursionNative(depth, 0, true);
+
+                    if (result == 1) {
+                        log.display("Fatal error (OutOfMemoryError or "
+                                + "StackOverflow) is thrown in native method of "
+                                + " thread " + num);
+                        return;
+                    } else if (result == 2) {
+                        log.complain("Unexpected exception is thrown in native "
+                                + "method of thread " + num);
+                        strace001.testFailed = true;
+                        return;
+                    }
+                    break;
+                default:
+                    log.complain("Unknown invocation type: "
+                            + controller.getInvocationType());
+                    strace001.testFailed = true;
+            }
+        } catch (OutOfMemoryError e) {
+            // Recursion is too deep, so exit peacefully
+            log.display("OutOfMemoryError is thrown in thread " + num);
+        } catch (StackOverflowError e) {
+            // Recursion is too deep, so exit peacefully
+            log.display("StackOverflowError is thrown in thread " + num);
+        }
+    } // run()
+
+    private void recursionJava(int maxDepth, int currentDepth) {
+        // A short delay. Otherwise the method will reach the specified depth
+        // almost instantly
+        try {
+            sleep(1);
+        } catch (InterruptedException e) {
+            log.complain("Unexpected exception");
+            e.printStackTrace(log.getOutStream());
+            strace001.testFailed = true;
+        }
+
+        currentDepth++;
+        if (maxDepth > currentDepth) {
+            yield();
+            if (mixed) {
+                int result = recursionNative(maxDepth, currentDepth, true);
+
+                 if (result == 1) {
+                     log.display("Fatal error (OutOfMemoryError or "
+                               + "StackOverflow) is thrown in native method of "
+                               + " thread " + num);
+                     return;
+                 } else if (result == 2) {
+                     log.complain("Unexpected exception is thrown in native "
+                                + "method of thread " + num);
+                     strace001.testFailed = true;
+                     return;
+                 }
+            } else
+                recursionJava(maxDepth, currentDepth);
+        }
+
+        waitForSign();
+    } // recursionJava()
+
+    private void waitForSign() {
+        // When the depth is reached, wait for a notification from main thread
+        while (!strace001.finish) {
+            try {
+                sleep(1);
+            } catch (InterruptedException e) {
+                log.complain("Unexpected exception");
+                e.printStackTrace(log.getOutStream());
+                strace001.testFailed = true;
+                break;
+            }
+        }
+    } // waitForSign()
+} // class RunningThread
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace001.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that ThreadInfo.getStackTrace() returns correct results for
+ *     a thread in "running" state.
+ *     Main thread starts a number of auxiliary threads. This number is specified
+ *     in "-threadCount" option. Auxiliary threads begin a recursion until they
+ *     reach specified depth ("-depth" option). Each thread may use pure java
+ *     and/or native methods based on "-invocationType" option. Then the threads
+ *     wait until they get a notification from main thread. So, those auxiliary
+ *     threads are definitly in "running" state when main thread performs their
+ *     checks.
+ *     Main thread makes a snapshot of stack trace for all threads and checks it:
+ *         1. If a thread is alive, ThreadMonitor.getThreadInfo(long, -1) must
+ *            return not null ThreadInfo.
+ *         2. The length of a trace must not be greater than (depth + 3). Number
+ *            of recursionJava() or recursionNative() methods must not be greater
+ *            than depth, also one Object.wait() or Thread.yield() method, one
+ *            run(), and one waitForSign().
+ *         3. The latest method of the stack trace must be RunningThread.run().
+ *         4. getClassName() and getMethodName() methods must return expected
+ *            values for each element of the stack trace.
+ *     If one of that testcases fail, the test also fails.
+ *     After all threads are checked, main thread notifies them to complete their
+ *     job. Then the test repeats the procedure with starting threads and
+ *     performing checks ITERATIONS times.
+ *     This particular test performs directly access to the MBeans' methods and
+ *     uses pure java methods in auxiliary threads.
+ * COMMENTS
+ *     Fixed the bug:
+ *     4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native nsk.monitoring.stress.thread.strace001 -threadCount=50 -depth=200
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace002/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace002/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace002.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that ThreadInfo.getStackTrace() returns correct results for
+ *     a thread in "running" state.
+ *     Main thread starts a number of auxiliary threads. This number is specified
+ *     in "-threadCount" option. Auxiliary threads begin a recursion until they
+ *     reach specified depth ("-depth" option). Each thread may use pure java
+ *     and/or native methods based on "-invocationType" option. Then the threads
+ *     wait until they get a notification from main thread. So, those auxiliary
+ *     threads are definitly in "running" state when main thread performs their
+ *     checks.
+ *     Main thread makes a snapshot of stack trace for all threads and checks it:
+ *         1. If a thread is alive, ThreadMonitor.getThreadInfo(long, -1) must
+ *            return not null ThreadInfo.
+ *         2. The length of a trace must not be greater than (depth + 3). Number
+ *            of recursionJava() or recursionNative() methods must not be greater
+ *            than depth, also one Object.wait() or Thread.yield() method, one
+ *            run(), and one waitForSign().
+ *         3. The latest method of the stack trace must be RunningThread.run().
+ *         4. getClassName() and getMethodName() methods must return expected
+ *            values for each element of the stack trace.
+ *     If one of that testcases fail, the test also fails.
+ *     After all threads are checked, main thread notifies them to complete their
+ *     job. Then the test repeats the procedure with starting threads and
+ *     performing checks ITERATIONS times.
+ *     This particular test performs access to the MBeans' methods through default
+ *     MBeanServer and uses pure java methods in auxiliary threads.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.stress.thread.strace001
+ *      -testMode=server
+ *      -threadCount=50
+ *      -depth=200
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace003/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace003/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace003.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that ThreadInfo.getStackTrace() returns correct results for
+ *     a thread in "running" state.
+ *     Main thread starts a number of auxiliary threads. This number is specified
+ *     in "-threadCount" option. Auxiliary threads begin a recursion until they
+ *     reach specified depth ("-depth" option). Each thread may use pure java
+ *     and/or native methods based on "-invocationType" option. Then the threads
+ *     wait until they get a notification from main thread. So, those auxiliary
+ *     threads are definitly in "running" state when main thread performs their
+ *     checks.
+ *     Main thread makes a snapshot of stack trace for all threads and checks it:
+ *         1. If a thread is alive, ThreadMonitor.getThreadInfo(long, -1) must
+ *            return not null ThreadInfo.
+ *         2. The length of a trace must not be greater than (depth + 3). Number
+ *            of recursionJava() or recursionNative() methods must not be greater
+ *            than depth, also one Object.wait() or Thread.yield() method, one
+ *            run(), and one waitForSign().
+ *         3. The latest method of the stack trace must be RunningThread.run().
+ *         4. getClassName() and getMethodName() methods must return expected
+ *            values for each element of the stack trace.
+ *     If one of that testcases fail, the test also fails.
+ *     After all threads are checked, main thread notifies them to complete their
+ *     job. Then the test repeats the procedure with starting threads and
+ *     performing checks ITERATIONS times.
+ *     This particular test performs access to the MBeans' methods through custom
+ *     MBeanServer and uses pure java methods in auxiliary threads.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.stress.thread.strace001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -threadCount=50
+ *      -depth=200
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace004/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace004/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace004.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that ThreadInfo.getStackTrace() returns correct results for
+ *     a thread in "running" state.
+ *     Main thread starts a number of auxiliary threads. This number is specified
+ *     in "-threadCount" option. Auxiliary threads begin a recursion until they
+ *     reach specified depth ("-depth" option). Each thread may use pure java
+ *     and/or native methods based on "-invocationType" option. Then the threads
+ *     wait until they get a notification from main thread. So, those auxiliary
+ *     threads are definitly in "running" state when main thread performs their
+ *     checks.
+ *     Main thread makes a snapshot of stack trace for all threads and checks it:
+ *         1. If a thread is alive, ThreadMonitor.getThreadInfo(long, -1) must
+ *            return not null ThreadInfo.
+ *         2. The length of a trace must not be greater than (depth + 3). Number
+ *            of recursionJava() or recursionNative() methods must not be greater
+ *            than depth, also one Object.wait() or Thread.yield() method, one
+ *            run(), and one waitForSign().
+ *         3. The latest method of the stack trace must be RunningThread.run().
+ *         4. getClassName() and getMethodName() methods must return expected
+ *            values for each element of the stack trace.
+ *     If one of that testcases fail, the test also fails.
+ *     After all threads are checked, main thread notifies them to complete their
+ *     job. Then the test repeats the procedure with starting threads and
+ *     performing checks ITERATIONS times.
+ *     This particular test performs directly access to the MBeans' methods and
+ *     uses native methods in auxiliary threads.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.stress.thread.strace001
+ *      -invocationType=native
+ *      -threadCount=50
+ *      -depth=200
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace005/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace005/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace005.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that ThreadInfo.getStackTrace() returns correct results for
+ *     a thread in "running" state.
+ *     Main thread starts a number of auxiliary threads. This number is specified
+ *     in "-threadCount" option. Auxiliary threads begin a recursion until they
+ *     reach specified depth ("-depth" option). Each thread may use pure java
+ *     and/or native methods based on "-invocationType" option. Then the threads
+ *     wait until they get a notification from main thread. So, those auxiliary
+ *     threads are definitly in "running" state when main thread performs their
+ *     checks.
+ *     Main thread makes a snapshot of stack trace for all threads and checks it:
+ *         1. If a thread is alive, ThreadMonitor.getThreadInfo(long, -1) must
+ *            return not null ThreadInfo.
+ *         2. The length of a trace must not be greater than (depth + 3). Number
+ *            of recursionJava() or recursionNative() methods must not be greater
+ *            than depth, also one Object.wait() or Thread.yield() method, one
+ *            run(), and one waitForSign().
+ *         3. The latest method of the stack trace must be RunningThread.run().
+ *         4. getClassName() and getMethodName() methods must return expected
+ *            values for each element of the stack trace.
+ *     If one of that testcases fail, the test also fails.
+ *     After all threads are checked, main thread notifies them to complete their
+ *     job. Then the test repeats the procedure with starting threads and
+ *     performing checks ITERATIONS times.
+ *     This particular test performs access to the MBeans' methods through default
+ *     MBeanServer and uses native methods in auxiliary threads.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.stress.thread.strace001
+ *      -testMode=server
+ *      -invocationType=native
+ *      -threadCount=50
+ *      -depth=200
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace006/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace006/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace006.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that ThreadInfo.getStackTrace() returns correct results for
+ *     a thread in "running" state.
+ *     Main thread starts a number of auxiliary threads. This number is specified
+ *     in "-threadCount" option. Auxiliary threads begin a recursion until they
+ *     reach specified depth ("-depth" option). Each thread may use pure java
+ *     and/or native methods based on "-invocationType" option. Then the threads
+ *     wait until they get a notification from main thread. So, those auxiliary
+ *     threads are definitly in "running" state when main thread performs their
+ *     checks.
+ *     Main thread makes a snapshot of stack trace for all threads and checks it:
+ *         1. If a thread is alive, ThreadMonitor.getThreadInfo(long, -1) must
+ *            return not null ThreadInfo.
+ *         2. The length of a trace must not be greater than (depth + 3). Number
+ *            of recursionJava() or recursionNative() methods must not be greater
+ *            than depth, also one Object.wait() or Thread.yield() method, one
+ *            run(), and one waitForSign().
+ *         3. The latest method of the stack trace must be RunningThread.run().
+ *         4. getClassName() and getMethodName() methods must return expected
+ *            values for each element of the stack trace.
+ *     If one of that testcases fail, the test also fails.
+ *     After all threads are checked, main thread notifies them to complete their
+ *     job. Then the test repeats the procedure with starting threads and
+ *     performing checks ITERATIONS times.
+ *     This particular test performs access to the MBeans' methods through custom
+ *     MBeanServer and uses native methods in auxiliary threads.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.stress.thread.strace001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -invocationType=native
+ *      -threadCount=50
+ *      -depth=200
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace007/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace007/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace007.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that ThreadInfo.getStackTrace() returns correct results for
+ *     a thread in "running" state.
+ *     Main thread starts a number of auxiliary threads. This number is specified
+ *     in "-threadCount" option. Auxiliary threads begin a recursion until they
+ *     reach specified depth ("-depth" option). Each thread may use pure java
+ *     and/or native methods based on "-invocationType" option. Then the threads
+ *     wait until they get a notification from main thread. So, those auxiliary
+ *     threads are definitly in "running" state when main thread performs their
+ *     checks.
+ *     Main thread makes a snapshot of stack trace for all threads and checks it:
+ *         1. If a thread is alive, ThreadMonitor.getThreadInfo(long, -1) must
+ *            return not null ThreadInfo.
+ *         2. The length of a trace must not be greater than (depth + 3). Number
+ *            of recursionJava() or recursionNative() methods must not be greater
+ *            than depth, also one Object.wait() or Thread.yield() method, one
+ *            run(), and one waitForSign().
+ *         3. The latest method of the stack trace must be RunningThread.run().
+ *         4. getClassName() and getMethodName() methods must return expected
+ *            values for each element of the stack trace.
+ *     If one of that testcases fail, the test also fails.
+ *     After all threads are checked, main thread notifies them to complete their
+ *     job. Then the test repeats the procedure with starting threads and
+ *     performing checks ITERATIONS times.
+ *     This particular test performs directly access to the MBeans' methods and
+ *     uses pure java methods along with native methods in auxiliary threads.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.stress.thread.strace001
+ *      -invocationType=mixed
+ *      -threadCount=50
+ *      -depth=200
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace008/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace008/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace008.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that ThreadInfo.getStackTrace() returns correct results for
+ *     a thread in "running" state.
+ *     Main thread starts a number of auxiliary threads. This number is specified
+ *     in "-threadCount" option. Auxiliary threads begin a recursion until they
+ *     reach specified depth ("-depth" option). Each thread may use pure java
+ *     and/or native methods based on "-invocationType" option. Then the threads
+ *     wait until they get a notification from main thread. So, those auxiliary
+ *     threads are definitly in "running" state when main thread performs their
+ *     checks.
+ *     Main thread makes a snapshot of stack trace for all threads and checks it:
+ *         1. If a thread is alive, ThreadMonitor.getThreadInfo(long, -1) must
+ *            return not null ThreadInfo.
+ *         2. The length of a trace must not be greater than (depth + 3). Number
+ *            of recursionJava() or recursionNative() methods must not be greater
+ *            than depth, also one Object.wait() or Thread.yield() method, one
+ *            run(), and one waitForSign().
+ *         3. The latest method of the stack trace must be RunningThread.run().
+ *         4. getClassName() and getMethodName() methods must return expected
+ *            values for each element of the stack trace.
+ *     If one of that testcases fail, the test also fails.
+ *     After all threads are checked, main thread notifies them to complete their
+ *     job. Then the test repeats the procedure with starting threads and
+ *     performing checks ITERATIONS times.
+ *     This particular test performs access to the MBeans' methods through default
+ *     MBeanServer and uses pure java methods along with native methods in
+ *     auxiliary threads.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.stress.thread.strace001
+ *      -testMode=server
+ *      -invocationType=mixed
+ *      -threadCount=50
+ *      -depth=200
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace009/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace009/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace009.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test checks that ThreadInfo.getStackTrace() returns correct results for
+ *     a thread in "running" state.
+ *     Main thread starts a number of auxiliary threads. This number is specified
+ *     in "-threadCount" option. Auxiliary threads begin a recursion until they
+ *     reach specified depth ("-depth" option). Each thread may use pure java
+ *     and/or native methods based on "-invocationType" option. Then the threads
+ *     wait until they get a notification from main thread. So, those auxiliary
+ *     threads are definitly in "running" state when main thread performs their
+ *     checks.
+ *     Main thread makes a snapshot of stack trace for all threads and checks it:
+ *         1. If a thread is alive, ThreadMonitor.getThreadInfo(long, -1) must
+ *            return not null ThreadInfo.
+ *         2. The length of a trace must not be greater than (depth + 3). Number
+ *            of recursionJava() or recursionNative() methods must not be greater
+ *            than depth, also one Object.wait() or Thread.yield() method, one
+ *            run(), and one waitForSign().
+ *         3. The latest method of the stack trace must be RunningThread.run().
+ *         4. getClassName() and getMethodName() methods must return expected
+ *            values for each element of the stack trace.
+ *     If one of that testcases fail, the test also fails.
+ *     After all threads are checked, main thread notifies them to complete their
+ *     job. Then the test repeats the procedure with starting threads and
+ *     performing checks ITERATIONS times.
+ *     This particular test performs access to the MBeans' methods through custom
+ *     MBeanServer and uses pure java methods along with native methods in
+ *     auxiliary threads.
+ * COMMENTS
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.monitoring.stress.thread.strace001
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -invocationType=mixed
+ *      -threadCount=50
+ *      -depth=200
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace010.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 nsk.monitoring.stress.thread;
+
+import java.io.*;
+import java.lang.management.*;
+
+import nsk.share.*;
+import nsk.monitoring.share.*;
+
+/**
+ * The test starts recursive threads, switches them  to the various
+ * state after reaching defined depth and checks up their stack traces
+ * and states gotten via the ThreadMBean interface. The test may be executed
+ * with the following parameters:
+ * <ul>
+ *      <li>
+ *          <code>depth</code> specifies depth of the recursion.
+ *      <li>
+ *          <code>threadCount</code> specifies amount of the threads.
+ * </ul>
+ *
+ * <p>The other parameters which may have an influence on running test are:
+ * <ul>
+ *      <li>
+ *          <code>testMode</code> defines modes access to MBean:
+ *          <ul>
+ *              <li><code>DIRECTLY</code> - directly access to MBean(default
+ *                  value),
+ *              <li><code>SERVER</code> - an access through MBeanServer
+ *          </ul>
+ *      <li>
+ *          <code>MBeanServer</code> defines a MBean server implemetation
+ *          under which test is executed:
+ *          <ul>
+ *              <li><code>DEFAULT</code> - default JMX implementation of
+ *                  MBeanServer (default value);
+ *              <li><code>CUSTOM</code> - implementation provided by NSK J2SE
+ *                  SQE Team
+ *          </ul>
+ *      <li>
+ *          <code>invocationType</code> defines the following kinds of recursive
+ *                method:
+ *          <ul>
+ *              <li><code>java</code> - pure java ones
+ *              <li><code>native</code> - native recursive ones
+ *          </ul>
+ *  Note:  The recursion are performed by invoking the follow kinds of methods:
+ * </ul>
+ * For details about arguments, see the {@link
+ * nsk.monitoring.share.ArgumentHandler ArgumentHamdler} description .
+ *
+ * <p>The test starts recursive threads via {@link
+ * nsk.monitoring.share.ThreadController ThreadController} according to
+ * specified parameters and switches them to the various state. The test sets
+ * every thread should be switched in one of the following states:
+ * <code>BLOCKED</code>, <code>WAITING</code>, <code>SLEEPING</code> or
+ * <code>RUNNING</code>.
+ * <p>After threads are reaching the specified state, test checks up their stack
+ * traces and states gotten via the ThreadMBean interface.
+ * <p>The test fails if state of some thread gotten via the ThreadMBean
+ * interface doesn't correspond to the state specified by the test or stack
+ * trace contains an extra element. Expected stack trace elements are specified
+ * by {@link nsk.monitoring.share.ThreadMonitor ThreadMonitor}
+ *
+ * @see ThreadMonitor
+ * @see ThreadController
+ * @see ArgumentHandler
+ *
+ */
+public class strace010 {
+
+    public static void main(String[] argv) {
+        System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+    }
+
+    public static int run(String[] argv, PrintStream out) {
+        return new strace010().runIt(argv, out);
+    }
+
+    public int runIt(String [] args, PrintStream out) {
+        boolean res = true;
+
+        ArgumentHandler argHandler = new ArgumentHandler(args);
+
+        Log log = new Log(out, argHandler);
+
+        int threadCount = argHandler.getThreadCount();
+        int maxDepth = argHandler.getThreadDepth();
+
+
+        ThreadMonitor threadMonitor = Monitor.getThreadMonitor(log, argHandler);
+        ThreadController controller = new ThreadController(log, threadCount, maxDepth,
+                                                argHandler.getInvocationType());
+
+        log.display("\nStarting threads.\n");
+        controller.run();
+        log.display("\nStates of the threads are culminated.");
+
+        long[] threadIDs = threadMonitor.getAllThreadIds();
+        ThreadInfo[] info = new ThreadInfo[threadIDs.length];    //info from MBean
+
+        int kinds = controller.getThreadKindCount();
+        int[] threadCounts = new int[kinds];
+
+        for (int i = 0; i < kinds; i++) {
+            threadCounts[i] = 0;
+        }
+        for(int i = 0; i < threadIDs.length; i++) {
+            try {
+                info[i] = threadMonitor.getThreadInfo(threadIDs[i], Integer.MAX_VALUE);
+            } catch (Exception e) {
+                log.complain("\tUnexpected " + e);
+                return Consts.TEST_FAILED;
+            }
+
+            if (info[i] == null) continue;
+            int err = controller.checkThreadInfo(info[i]);
+
+            switch (err) {
+            case ThreadController.ERR_THREAD_NOTFOUND:
+                log.complain("\tThread not found:" + info[i].getThreadName());
+                res = false;
+                break;
+
+            case ThreadController.ERR_STATE:
+                log.complain("\tThread " + info[i].getThreadName()
+                                    + " wrong thread state: "
+                                    + info[i].getThreadState());
+                res = false;
+                break;
+
+            case ThreadController.ERR_STACKTRACE:
+
+                log.complain("\nWrong stack trace for thread name: "
+                                        + info[i].getThreadName());
+                log.complain("----------------------------------");
+                log.complain("\tthread ID:" + info[i].getThreadId()
+                                    + "(" + threadIDs[i] + ")");
+                StackTraceElement[] elements = info[i].getStackTrace();
+                for (int j = 0; j < (elements.length<5?elements.length:5); j++)
+                    log.complain("\t\t" + elements[j]);
+                res = false;
+                break;
+            }
+
+            if ( controller.findThread(info[i].getThreadId()) != null) {
+
+                if (info[i].getThreadState() == Thread.State.BLOCKED) {
+                    threadCounts[ThreadController.BLOCKED_IDX]++;
+
+                } else if (info[i].getThreadState() == Thread.State.WAITING) {
+                    threadCounts[ThreadController.WAITING_IDX]++;
+
+                } else if (info[i].getThreadState() == Thread.State.TIMED_WAITING) {
+                    threadCounts[ThreadController.SLEEPING_IDX]++;
+
+                } else if (info[i].getThreadState() == Thread.State.RUNNABLE) {
+                    threadCounts[ThreadController.RUNNING_IDX]++;
+                }
+            }
+        }
+        controller.reset();
+
+        log.display("");
+        for (int i = 0; i < kinds; i++) {
+            Thread.State state =  ThreadController.THREAD_KINDS[i];
+            log.display("Checked " + threadCounts[i] + " " + state + " threads");
+            if (controller.getThreadCount(state) != threadCounts[i]) {
+                log.complain("Expected amount: " + controller.getThreadCount(state)
+                           + " for " + state
+                           + " threads" + " actual: " + threadCounts[i]);
+                res = false;
+            }
+        }
+        log.display("");
+        controller.reset();
+
+        if (res) {
+            log.display("\nTest PASSED");
+            return Consts.TEST_PASSED;
+        }
+
+        log.display("\nTest FAILED");
+        return Consts.TEST_FAILED;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace010/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace010/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace010.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test starts 50 recursive threads, switches them  to the various
+ *     state after reaching 200 depth and checks up their stack traces
+ *     and states gotten via the ThreadMBean interface.
+ *     Access to the management metrics is accomplished by DIRECTLY calling
+ *     the methods in the MBean.
+ * COMMENTS
+ *     Fixed the bug:
+ *     4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
+ *     Fixed the bug:
+ *     4969687 TEST_BUG: The spec is updated accoring to 4956978, 4957000, 4959889
+ *     Reduced recursion depth value up to 100 because the test fails
+ *     due to timeout in -Xint mode on solaris-sparc(Sun Ultra-10, 333 MHz, 256Mb)
+ *     Adjusted according to
+ *     5014783 Move ThreadState class from java.lang.management to java.lang
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm nsk.monitoring.stress.thread.strace010 -depth=100 -threadCount=30
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace011/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace011/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace011.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test starts 50 recursive threads, switches them  to the various
+ *     state after reaching 200 depth and checks up their stack traces
+ *     and states gotten via the ThreadMBean interface.
+ *     Executable class of the test is the same as for the strace010 test.
+ *     In contrast to the strace010 test, the strace011 test is performed for
+ *     that:
+ *     Access to the management metrics is accomplished by calling via
+ *     default MBeanServer the methods in the MBean.
+ * COMMENTS
+ *     Reduced recursion depth value up to 100 because the test fails
+ *     due to timeout in -Xint mode on solaris-sparc(Sun Ultra-10, 333 MHz, 256Mb)
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.stress.thread.strace010
+ *      -testMode=server
+ *      -depth=100
+ *      -threadCount=30
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace012/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace012/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace012.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test starts 50 recursive threads, switches them  to the various
+ *     state after reaching 200 depth and checks up their stack traces
+ *     and states gotten via the ThreadMBean interface.
+ *     Executable class of the test is the same as for the strace010 test.
+ *     In contrast to the strace010 test, the strace012 test is performed for
+ *     that:
+ *     Access to the management metrics is accomplished by calling via
+ *     custom MBeanServer the methods in the MBean.
+ * COMMENTS
+ *     Reduced recursion depth value up to 100 because the test fails
+ *     due to timeout in -Xint mode on solaris-sparc(Sun Ultra-10, 333 MHz, 256Mb)
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.stress.thread.strace010
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -depth=100
+ *      -threadCount=30
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace013/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace013/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace013.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test starts 50 recursive threads, switches them  to the various
+ *     state after reaching 200 depth and checks up their stack traces
+ *     and states gotten via the ThreadMBean interface.
+ *     Executable class of the test is the same as for the strace010 test.
+ *     In contrast to the strace010 test, the strace013 test is performed for
+ *     the case when recursive method is native.
+ *     Access to the management metrics is accomplished by DIRECTLY calling
+ *     the methods in the MBean.
+ * COMMENTS
+ *     Reduced recursion depth value up to 100 because the test fails
+ *     due to timeout in -Xint mode on solaris-sparc(Sun Ultra-10, 333 MHz, 256Mb)
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.stress.thread.strace010
+ *      -depth=100
+ *      -threadCount=30
+ *      -invocationType=native
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace014/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace014/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace014.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test starts 50 recursive threads, switches them  to the various
+ *     state after reaching 200 depth and checks up their stack traces
+ *     and states gotten via the ThreadMBean interface.
+ *     Executable class of the test is the same as for the strace011 test.
+ *     In contrast to the strace011 test, the strace014 test is performed for
+ *     the case when recursive method is native.
+ *     Access to the management metrics is accomplished by calling via
+ *     default MBeanServer the methods in the MBean.
+ * COMMENTS
+ *     Reduced recursion depth value up to 100 because the test fails
+ *     due to timeout in -Xint mode on solaris-sparc(Sun Ultra-10, 333 MHz, 256Mb)
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.stress.thread.strace010
+ *      -testMode=server
+ *      -depth=100
+ *      -threadCount=30
+ *      -invocationType=native
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace015/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace015/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace015.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test starts 50 recursive threads, switches them  to the various
+ *     state after reaching 200 depth and checks up their stack traces
+ *     and states gotten via the ThreadMBean interface.
+ *     Executable class of the test is the same as for the strace012 test.
+ *     In contrast to the strace012 test, the strace015 test is performed for
+ *     the case when recursive method is native.
+ *     Access to the management metrics is accomplished by calling via
+ *     custom MBeanServer the methods in the MBean.
+ * COMMENTS
+ *     Reduced recursion depth value up to 100 because the test fails
+ *     due to timeout in -Xint mode on solaris-sparc(Sun Ultra-10, 333 MHz, 256Mb)
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.stress.thread.strace010
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -depth=100
+ *      -threadCount=30
+ *      -invocationType=native
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace016/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace016/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace016.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test starts 50 recursive threads, switches them  to the various
+ *     state after reaching 200 depth and checks up their stack traces
+ *     and states gotten via the ThreadMBean interface.
+ *     Executable class of the test is the same as for the strace013 test.
+ *     In contrast to the strace013 test, the strace016 test is performed for
+ *     the case when recursive method is native and pure java by turn.
+ *     Access to the management metrics is accomplished by DIRECTLY calling
+ *     the methods in the MBean.
+ * COMMENTS
+ *     Reduced recursion depth value up to 100 because the test fails
+ *     due to timeout in -Xint mode on solaris-sparc(Sun Ultra-10, 333 MHz, 256Mb)
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.stress.thread.strace010
+ *      -depth=100
+ *      -threadCount=30
+ *      -invocationType=mixed
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace017/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace017/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace017.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test starts 50 recursive threads, switches them  to the various
+ *     state after reaching 200 depth and checks up their stack traces
+ *     and states gotten via the ThreadMBean interface.
+ *     Executable class of the test is the same as for the strace014 test.
+ *     In contrast to the strace014 test, the strace017 test is performed for
+ *     the case when recursive method is native and pure java by turn.
+ *     Access to the management metrics is accomplished by calling via
+ *     default MBeanServer the methods in the MBean.
+ * COMMENTS
+ *     Reduced recursion depth value up to 100 because the test fails
+ *     due to timeout in -Xint mode on solaris-sparc(Sun Ultra-10, 333 MHz, 256Mb)
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.stress.thread.strace010
+ *      -testMode=server
+ *      -depth=100
+ *      -threadCount=30
+ *      -invocationType=mixed
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace018/TEST.properties	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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.
+#
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace018/TestDescription.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @key stress
+ *
+ * @summary converted from VM Testbase nsk/monitoring/stress/thread/strace018.
+ * VM Testbase keywords: [stress, monitoring, nonconcurrent, jdk_desktop]
+ * VM Testbase readme:
+ * DESCRIPTION
+ *     The test starts 50 recursive threads, switches them  to the various
+ *     state after reaching 200 depth and checks up their stack traces
+ *     and states gotten via the ThreadMBean interface.
+ *     Executable class of the test is the same as for the strace015 test.
+ *     In contrast to the strace015 test, the strace018 test is performed for
+ *     the case when recursive method is native and pure java by turn.
+ *     Access to the management metrics is accomplished by calling via
+ *     custom MBeanServer the methods in the MBean.
+ * COMMENTS
+ *     Reduced recursion depth value up to 100 because the test fails
+ *     due to timeout in -Xint mode on solaris-sparc(Sun Ultra-10, 333 MHz, 256Mb)
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm
+ *      nsk.monitoring.stress.thread.strace010
+ *      -testMode=server
+ *      -MBeanServer=custom
+ *      -depth=100
+ *      -threadCount=30
+ *      -invocationType=mixed
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/ArgumentParser.java	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/ArgumentParser.java	Fri May 04 08:50:01 2018 -0700
@@ -100,7 +100,7 @@
  * @see nsk.share.jdwp.ArgumentHandler
  * @see nsk.share.jdi.ArgumentHandler
  * @see nsk.share.jvmti.ArgumentHandler
- * @see nsk.share.monitoring.ArgumentHandler
+ * @see nsk.monitoring.share.ArgumentHandler
  */
 public class ArgumentParser {
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/README	Wed May 02 22:11:35 2018 -0700
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/README	Fri May 04 08:50:01 2018 -0700
@@ -100,7 +100,6 @@
         nsk.share.jdwp
         nsk.share.jdi
         nsk.share.jdb
-        nsk.share.monitoring
         nsk.share.sysdict
 
 Native functions and macroses:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jaxp/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/JDK8201138.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 stream.XMLEventReaderTest;
+
+import java.io.StringReader;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLEventReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.Comment;
+import javax.xml.stream.events.StartDocument;
+import javax.xml.stream.events.StartElement;
+
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+
+/*
+ * @test
+ * @bug 8201138
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventReaderTest.JDK8201138
+ * @run testng/othervm stream.XMLEventReaderTest.JDK8201138
+ * @summary Verifies a fix that set the type and data properly in the loop
+ */
+@Listeners({jaxp.library.BasePolicy.class})
+public class JDK8201138 {
+
+    @Test
+    public void testTypeReset() throws XMLStreamException, FactoryConfigurationError {
+
+        String xmlData = "<?xml version=\"1.0\"?><nextEvent><!-- peeked -->aaa<![CDATA[bbb]]>ccc</nextEvent>";
+
+        XMLEventReader eventReader = XMLInputFactory.newFactory().createXMLEventReader(new StringReader(xmlData));
+        assertTrue(eventReader.nextEvent() instanceof StartDocument, "shall be StartDocument");
+        assertTrue(eventReader.nextEvent() instanceof StartElement, "shall be StartElement");
+        assertTrue(eventReader.peek() instanceof Comment, "shall be Comment");
+        // the following returns empty string before the fix
+        assertTrue(eventReader.getElementText().equals("aaabbbccc"), "The text shall be \"aaabbbccc\"");
+
+        eventReader.close();
+    }
+
+    @Test
+    public void testTypeResetAndBufferClear() throws XMLStreamException, FactoryConfigurationError {
+
+        String xmlData = "<?xml version=\"1.0\"?><nextEvent>aaa<!-- comment --></nextEvent>";
+
+        XMLEventReader eventReader = XMLInputFactory.newFactory().createXMLEventReader(new StringReader(xmlData));
+        assertTrue(eventReader.nextEvent() instanceof StartDocument, "shall be StartDocument");
+        assertTrue(eventReader.nextEvent() instanceof StartElement, "shall be StartElement");
+        assertTrue(eventReader.peek() instanceof Characters, "shall be Characters");
+        // the following throws ClassCastException before the fix
+        assertTrue(eventReader.getElementText().equals("aaa"), "The text shall be \"aaa\"");
+
+        eventReader.close();
+    }
+
+}
--- a/test/jdk/ProblemList.txt	Wed May 02 22:11:35 2018 -0700
+++ b/test/jdk/ProblemList.txt	Fri May 04 08:50:01 2018 -0700
@@ -490,8 +490,6 @@
 
 java/lang/StringCoding/CheckEncodings.sh                        7008363 generic-all
 
-java/lang/String/nativeEncoding/StringPlatformChars.java        8182569 windows-all,solaris-all
-
 ############################################################################
 
 # jdk_instrument
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/ref/ReferenceClone.java	Fri May 04 08:50:01 2018 -0700
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 8201793
+ * @summary Test Reference::clone to throw CloneNotSupportedException
+ */
+
+import java.lang.ref.*;
+
+public class ReferenceClone {
+    private static final ReferenceQueue<Object> QUEUE = new ReferenceQueue<>();
+    public static void main(String... args) {
+        ReferenceClone refClone = new ReferenceClone();
+        refClone.test();
+    }
+
+    public void test() {
+        // test Reference::clone that throws CNSE
+        Object o = new Object();
+        assertCloneNotSupported(new SoftRef(o));
+        assertCloneNotSupported(new WeakRef(o));
+        assertCloneNotSupported(new PhantomRef(o));
+
+        // Reference subclass may override the clone method
+        CloneableReference ref = new CloneableReference(o);
+        try {
+            ref.clone();
+        } catch (CloneNotSupportedException e) {}
+    }
+
+    private void assertCloneNotSupported(CloneableRef ref) {
+        try {
+            ref.clone();
+            throw new RuntimeException("Reference::clone should throw CloneNotSupportedException");
+        } catch (CloneNotSupportedException e) {}
+    }
+
+    // override clone to be public that throws CNSE
+    interface CloneableRef extends Cloneable {
+        public Object clone() throws CloneNotSupportedException;
+    }
+
+    class SoftRef extends SoftReference<Object> implements CloneableRef {
+        public SoftRef(Object referent) {
+            super(referent, QUEUE);
+        }
+        public Object clone() throws CloneNotSupportedException {
+            return super.clone();
+        }
+    }
+
+    class WeakRef extends WeakReference<Object> implements CloneableRef {
+        public WeakRef(Object referent) {
+            super(referent, QUEUE);
+        }
+        public Object clone() throws CloneNotSupportedException {
+            return super.clone();
+        }
+    }
+
+    class PhantomRef extends PhantomReference<Object> implements CloneableRef {
+        public PhantomRef(Object referent) {
+            super(referent, QUEUE);
+        }
+
+        public Object clone() throws CloneNotSupportedException {
+            return super.clone();
+        }
+    }
+
+    // override clone to return a new instance
+    class CloneableReference extends WeakReference<Object> implements Cloneable {
+        public CloneableReference(Object referent) {
+            super(referent, QUEUE);
+        }
+
+        public Object clone() throws CloneNotSupportedException {
+            return new CloneableReference(this.get());
+        }
+    }
+
+}
--- a/test/langtools/ProblemList.txt	Wed May 02 22:11:35 2018 -0700
+++ b/test/langtools/ProblemList.txt	Fri May 04 08:50:01 2018 -0700
@@ -1,6 +1,6 @@
 ###########################################################################
 #
-# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,6 @@
 tools/javac/warnings/suppress/TypeAnnotations.java                              8057683    generic-all    improve ordering of errors with type annotations
 tools/javac/modules/SourceInSymlinkTest.java                                    8180263    windows-all    fails when run on a subst drive
 tools/javac/options/release/ReleaseOptionUnsupported.java                       8193784    generic-all    temporary until support for --release 11 is worked out
-tools/javac/jvm/VerboseOutTest.java                                             8194968    windows-all
 
 ###########################################################################
 #
--- a/test/langtools/TEST.groups	Wed May 02 22:11:35 2018 -0700
+++ b/test/langtools/TEST.groups	Fri May 04 08:50:01 2018 -0700
@@ -1,4 +1,4 @@
-#  Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+#  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
 #  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,14 +28,32 @@
     lib \
     tools \
     -jdk/jshell/ExternalEditorTest.java \
+    -jdk/jshell/FailOverDirectExecutionControlTest.java \
+    -jdk/jshell/FailOverExecutionControlDyingLaunchTest.java \
+    -jdk/jshell/FailOverExecutionControlHangingListenTest.java \
+    -jdk/jshell/JdiHangingListenExecutionControlTest.java \
+    -jdk/jshell/JdiLaunchingExecutionControlTest.java \
+    -jdk/jshell/JdiListeningExecutionControlTest.java \
+    -jdk/jshell/JdiListeningLocalhostExecutionControlTest.java  \
+    -jdk/jshell/ToolBasicTest.java \
+    -jdk/jshell/ToolLocaleMessageTest.java \
     -jdk/jshell/ToolReloadTest.java \
-    -jdk/jshell/ToolLocaleMessageTest.java
+    -jdk/jshell/UserJdiUserRemoteTest.java
 
 # (Almost) no langtools tests are tier 2.
 tier2 = \
     jdk/jshell/ExternalEditorTest.java \
+    jdk/jshell/FailOverDirectExecutionControlTest.java \
+    jdk/jshell/FailOverExecutionControlDyingLaunchTest.java \
+    jdk/jshell/FailOverExecutionControlHangingListenTest.java \
+    jdk/jshell/JdiHangingListenExecutionControlTest.java \
+    jdk/jshell/JdiLaunchingExecutionControlTest.java \
+    jdk/jshell/JdiListeningExecutionControlTest.java \
+    jdk/jshell/JdiListeningLocalhostExecutionControlTest.java \
+    jdk/jshell/ToolBasicTest.java \
+    jdk/jshell/ToolLocaleMessageTest.java \
     jdk/jshell/ToolReloadTest.java \
-    jdk/jshell/ToolLocaleMessageTest.java
+    jdk/jshell/UserJdiUserRemoteTest.java
 
 # No langtools tests are tier 3 either.
 tier3 = 
--- a/test/langtools/jdk/javadoc/doclet/testUserTaglet/TestUserTaglet.java	Wed May 02 22:11:35 2018 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testUserTaglet/TestUserTaglet.java	Fri May 04 08:50:01 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      8176836
+ * @bug      8176836 8201817
  * @summary  Provide Taglet with context
  * @library  ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -52,7 +52,7 @@
         checkOutput("pkg/C.html", true,
             "<li>Element: CLASS C",
             "<li>Element supertypes: [java.lang.Object]",
-            "<li>Doclet: class jdk.javadoc.internal.doclets.formats.html.HtmlDoclet"
+            "<li>Doclet: class jdk.javadoc.doclet.StandardDoclet"
         );
     }
 }
--- a/test/langtools/tools/javac/jvm/VerboseOutTest.java	Wed May 02 22:11:35 2018 -0700
+++ b/test/langtools/tools/javac/jvm/VerboseOutTest.java	Fri May 04 08:50:01 2018 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8194893
+ * @bug 8194893 8194968
  * @summary javac -verbose prints wrong paths for output files
  * @modules jdk.compiler
  * @run main VerboseOutTest
@@ -56,7 +56,7 @@
         if (rc != 0) {
             throw new Exception("compilation failed: rc=" + rc);
         }
-        String expected = "[wrote ./" + className + ".class]";
+        String expected = "[wrote " + Paths.get(".").resolve(className + ".class") + "]";
         if (!log.contains(expected)) {
             throw new Exception("expected output not found: " + expected);
         }