changeset 50718:b91a27ae0b23 enhanced-enums

Automatic merge with default
author mcimadamore
date Thu, 17 May 2018 22:11:55 +0200
parents 07e46dd1329a 1d683e243d8d
children 834e5d05484e
files src/hotspot/share/runtime/vmStructs_trace.hpp src/hotspot/share/trace/noTraceBackend.hpp src/hotspot/share/trace/trace.dtd src/hotspot/share/trace/trace.xml src/hotspot/share/trace/traceBackend.cpp src/hotspot/share/trace/traceBackend.hpp src/hotspot/share/trace/traceDataTypes.hpp src/hotspot/share/trace/traceEvent.hpp src/hotspot/share/trace/traceEventClasses.xsl src/hotspot/share/trace/traceEventIds.xsl src/hotspot/share/trace/traceMacros.hpp src/hotspot/share/trace/traceStream.cpp src/hotspot/share/trace/traceStream.hpp src/hotspot/share/trace/traceTime.hpp src/hotspot/share/trace/traceTypes.xsl src/hotspot/share/trace/traceevents.xml src/hotspot/share/trace/tracerelationdecls.xml src/hotspot/share/trace/tracetypes.xml src/hotspot/share/trace/tracing.hpp src/hotspot/share/trace/tracingExport.cpp src/hotspot/share/trace/tracingExport.hpp src/hotspot/share/trace/xinclude.mod src/hotspot/share/trace/xsl_util.xsl src/hotspot/share/utilities/ticks.inline.hpp src/java.base/macosx/conf/x86_64/jvm.cfg src/java.base/unix/conf/aarch64/jvm.cfg src/java.base/unix/conf/amd64/jvm.cfg src/java.base/unix/conf/arm/jvm.cfg src/java.base/unix/conf/i586/jvm.cfg src/java.base/unix/conf/ia64/jvm.cfg src/java.base/unix/conf/ppc64/jvm.cfg src/java.base/unix/conf/ppc64le/jvm.cfg src/java.base/unix/conf/s390x/jvm.cfg src/java.base/unix/conf/sparc/jvm.cfg src/java.base/unix/conf/sparcv9/jvm.cfg src/java.base/unix/conf/zero/jvm.cfg src/java.base/windows/conf/amd64/jvm.cfg src/java.base/windows/conf/i586/jvm.cfg src/java.base/windows/conf/ia64/jvm.cfg src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
diffstat 1850 files changed, 213138 insertions(+), 5445 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu May 10 22:07:28 2018 +0200
+++ b/.hgtags	Thu May 17 22:11:55 2018 +0200
@@ -484,3 +484,5 @@
 69d7398038c54774d9395b6810e0cca335edc02c jdk-11+10
 e1e60f75cd39312a7f59d2a4f91d624e5aecc95e jdk-11+11
 3ab6ba9f94a9045a526d645af26c933235371d6f jdk-11+12
+758deedaae8406ae60147486107a54e9864aa7b0 jdk-11+13
+3595bd343b65f8c37818ebe6a4c343ddeb1a5f88 jdk-11+14
--- a/make/CompileDemos.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/CompileDemos.gmk	Thu May 17 22:11:55 2018 +0200
@@ -253,6 +253,12 @@
     DEMO_SUBDIR := jfc, \
 ))
 
+$(eval $(call SetupBuildDemo, J2Ddemo, \
+    DEMO_SUBDIR := jfc, \
+    MAIN_CLASS := java2d.J2Ddemo, \
+    JAR_NAME := J2Ddemo, \
+))
+
 $(eval $(call SetupBuildDemo, Metalworks, \
     DEMO_SUBDIR := jfc, \
 ))
--- a/make/CompileJavaModules.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/CompileJavaModules.gmk	Thu May 17 22:11:55 2018 +0200
@@ -509,6 +509,15 @@
 # Exclude BreakIterator classes that are just used in compile process to generate
 # data files and shouldn't go in the product
 jdk.localedata_EXCLUDE_FILES += sun/text/resources/ext/BreakIteratorRules_th.java
+################################################################################
+
+# There is an issue in sjavac that triggers a warning in jdk.jfr that isn't
+# triggered without sjavac.
+ifeq ($(ENABLE_SJAVAC), yes)
+  jdk.jfr_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
+endif
+jdk.jfr_COPY := .xsd .xml .dtd
+jdk.jfr_ADD_JAVAC_FLAGS := -XDstringConcat=inline -Xlint:-exports
 
 ################################################################################
 # If this is an imported module that has prebuilt classes, only compile
--- a/make/CreateJmods.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/CreateJmods.gmk	Thu May 17 22:11:55 2018 +0200
@@ -39,16 +39,16 @@
 JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
 JMODS_TEMPDIR := $(SUPPORT_OUTPUTDIR)/jmods
 
-LIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
+LIBS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
-CMDS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
+CMDS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS))))
-CONF_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
+CONF_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF))))
-CLASSES_DIR := $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
-INCLUDE_HEADERS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
+CLASSES_DIR ?= $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
+INCLUDE_HEADERS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_include $(IMPORT_MODULES_INCLUDE_HEADERS))))
-MAN_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
+MAN_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_man $(IMPORT_MODULES_MAN))))
 
 $(eval $(call FillCacheFind, \
--- a/make/autoconf/hotspot.m4	Thu May 10 22:07:28 2018 +0200
+++ b/make/autoconf/hotspot.m4	Thu May 17 22:11:55 2018 +0200
@@ -26,7 +26,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 cmsgc g1gc parallelgc serialgc nmt cds \
-    static-build link-time-opt aot"
+    static-build link-time-opt aot jfr"
 
 # All valid JVM variants
 VALID_JVM_VARIANTS="server client minimal core zero custom"
@@ -206,7 +206,7 @@
 
   if test "x$ENABLE_AOT" = "xtrue"; then
     # Only enable AOT on X64 platforms.
-    if test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
+    if test "x$OPENJDK_TARGET_CPU" = "xx86_64" || test "x$OPENJDK_TARGET_CPU" = "xaarch64" ; then
       if test -e "${TOPDIR}/src/jdk.aot"; then
         if test -e "${TOPDIR}/src/jdk.internal.vm.compiler"; then
           ENABLE_AOT="true"
@@ -309,6 +309,11 @@
     AC_MSG_ERROR([Specified JVM feature 'cmsgc' requires feature 'serialgc'])
   fi
 
+  # Enable JFR by default, except on linux-sparcv9 and on minimal.
+  if test "x$OPENJDK_TARGET_OS" != xlinux || test "x$OPENJDK_TARGET_CPU" != xsparcv9; then
+    NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jfr"
+  fi
+
   # Turn on additional features based on other parts of configure
   if test "x$INCLUDE_DTRACE" = "xtrue"; then
     JVM_FEATURES="$JVM_FEATURES dtrace"
@@ -396,7 +401,7 @@
     NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES cds"
   fi
 
-  # Enable default features depending on variant.
+  # Enable features depending on variant.
   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"
--- a/make/autoconf/libraries.m4	Thu May 10 22:07:28 2018 +0200
+++ b/make/autoconf/libraries.m4	Thu May 17 22:11:55 2018 +0200
@@ -130,7 +130,7 @@
 
   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lsocket -lsched -ldoor -ldemangle -lnsl \
-        -lrt"
+        -lrt -lkstat"
     BASIC_JVM_LIBS="$BASIC_JVM_LIBS $LIBCXX_JVM"
   fi
 
--- a/make/common/Modules.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/common/Modules.gmk	Thu May 17 22:11:55 2018 +0200
@@ -59,7 +59,9 @@
     java.security.sasl \
     java.xml \
     jdk.internal.vm.ci \
+    jdk.jfr \
     jdk.management \
+    jdk.management.jfr \
     jdk.management.agent \
     jdk.net \
     jdk.sctp \
@@ -152,6 +154,7 @@
     jdk.jdeps \
     jdk.jdi \
     jdk.jdwp.agent \
+    jdk.jfr \
     jdk.jlink \
     jdk.jsobject \
     jdk.jshell \
@@ -159,6 +162,7 @@
     jdk.localedata \
     jdk.management \
     jdk.management.agent \
+    jdk.management.jfr \
     jdk.naming.dns \
     jdk.naming.rmi \
     jdk.net \
--- a/make/common/NativeCompilation.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/common/NativeCompilation.gmk	Thu May 17 22:11:55 2018 +0200
@@ -391,6 +391,13 @@
 #   STRIPFLAGS Optionally change the flags given to the strip command
 #   PRECOMPILED_HEADER Header file to use as precompiled header
 #   PRECOMPILED_HEADER_EXCLUDE List of source files that should not use PCH
+#
+# After being called, some variables are exported from this macro, all prefixed
+# with parameter 1 followed by a '_':
+#   TARGET The library or executable created by the macro
+#   TARGET_DEPS All prerequisites for the target calculated by the macro
+#   ALL_OBJS All object files
+#   IMPORT_LIBRARY The import library created for a shared library on Windows
 SetupNativeCompilation = $(NamedParamsMacroTemplate)
 define SetupNativeCompilationBody
 
@@ -874,7 +881,9 @@
       endif
     endif
 
-    $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP)
+    $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP)
+
+    $$($1_TARGET): $$($1_TARGET_DEPS)
 	$$(call LogInfo, Building static library $$($1_BASENAME))
 	$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
 	    $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
@@ -964,8 +973,10 @@
       endif
     endif
 
-    $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
+    $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
         $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE)
+
+    $$($1_TARGET): $$($1_TARGET_DEPS)
                 ifneq ($$($1_OBJ_FILE_LIST), )
                   ifeq ($$($1_LINK_OBJS_RELATIVE), true)
 		    $$(eval $$(call ListPathsSafely, $1_ALL_OBJS_RELATIVE, $$($1_OBJ_FILE_LIST)))
--- a/make/copy/Copy-java.base.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/copy/Copy-java.base.gmk	Thu May 17 22:11:55 2018 +0200
@@ -79,72 +79,44 @@
 endif
 
 ################################################################################
-#
-# How to install jvm.cfg.
-#
-ifeq ($(call check-jvm-variant, zero), true)
-  JVMCFG_ARCH := zero
-else
-  JVMCFG_ARCH := $(OPENJDK_TARGET_CPU_LEGACY)
+# In jvm.cfg, the first listed KNOWN variant is the default. On most build
+# configurations, that is the server variant.
+ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), windows-x86)
+  DEFAULT_CFG_VARIANT ?= client
 endif
+DEFAULT_CFG_VARIANT ?= server
 
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-  JVMCFG_SRC := $(TOPDIR)/src/java.base/macosx/conf/$(JVMCFG_ARCH)/jvm.cfg
-else
-  JVMCFG_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/$(JVMCFG_ARCH)/jvm.cfg
-  # Allow override by ALT_JVMCFG_SRC if it exists
-  JVMCFG_SRC := $(if $(wildcard $(ALT_JVMCFG_SRC)),$(ALT_JVMCFG_SRC),$(JVMCFG_SRC))
-endif
+# Any variant other than server, client or minimal is represented as server in
+# the cfg file.
+VALID_CFG_VARIANTS := server client minimal
+CFG_VARIANTS := $(filter $(VALID_CFG_VARIANTS), $(JVM_VARIANTS)) \
+    $(if $(filter-out $(VALID_CFG_VARIANTS), $(JVM_VARIANTS)), server)
+
+# Change the order to put the default variant first if present.
+ORDERED_CFG_VARIANTS := \
+    $(if $(filter $(DEFAULT_CFG_VARIANT), $(CFG_VARIANTS)), $(DEFAULT_CFG_VARIANT)) \
+    $(filter-out $(DEFAULT_CFG_VARIANT), $(CFG_VARIANTS))
+
 JVMCFG := $(LIB_DST_DIR)/jvm.cfg
 
-# We have three potential VMs: client, server and minimal.
-# Historically we usually have both client and server and so that is what the
-# committed jvm.cfg expects (including platform specific ergonomics switches
-# to decide whether to use client or server by default). So when we have anything
-# other than client and server we need to define a new jvm.cfg file.
-# The main problem is deciding whether to use aliases for the VMs that are not
-# present and the current position is that we add aliases for client and server, but
-# not for minimal.
-CLIENT_AND_SERVER := $(call check-jvm-variant, client)+$(call check-jvm-variant, server)
-ifeq ($(CLIENT_AND_SERVER), true+true)
-  COPY_JVM_CFG_FILE := true
-else
-  # For zero, the default jvm.cfg file is sufficient
-  ifeq ($(call check-jvm-variant, zero), true)
-    COPY_JVM_CFG_FILE := true
-  endif
-endif
+define print-cfg-line
+	$(call LogInfo, Adding -$1 $2 to jvm.cfg)
+	$(PRINTF) -- "-$1 $2\n" >> $@ $(NEWLINE)
+endef
 
-ifeq ($(COPY_JVM_CFG_FILE), true)
-  $(JVMCFG): $(JVMCFG_SRC)
-	$(call install-file)
-else
-  $(JVMCFG):
-	$(MKDIR) -p $(@D)
-	$(RM) $(@)
-        # Now check for other permutations
-        ifeq ($(call check-jvm-variant, server), true)
-	  $(PRINTF) -- "-server KNOWN\n">>$(@)
-	  $(PRINTF) -- "-client ALIASED_TO -server\n">>$(@)
-          ifeq ($(call check-jvm-variant, minimal), true)
-	    $(PRINTF) -- "-minimal KNOWN\n">>$(@)
-          endif
-        else
-          ifeq ($(call check-jvm-variant, client), true)
-	    $(PRINTF) -- "-client KNOWN\n">>$(@)
-	    $(PRINTF) -- "-server ALIASED_TO -client\n">>$(@)
-            ifeq ($(call check-jvm-variant, minimal), true)
-	      $(PRINTF) -- "-minimal KNOWN\n">>$(@)
-            endif
-          else
-            ifeq ($(call check-jvm-variant, minimal), true)
-	      $(PRINTF) -- "-minimal KNOWN\n">>$(@)
-	      $(PRINTF) -- "-server ALIASED_TO -minimal\n">>$(@)
-	      $(PRINTF) -- "-client ALIASED_TO -minimal\n">>$(@)
-            endif
-          endif
-        endif
-endif
+$(JVMCFG): $(call DependOnVariable, ORDERED_CFG_VARIANTS)
+	$(call MakeTargetDir)
+	$(RM) $@
+	$(foreach v, $(ORDERED_CFG_VARIANTS), \
+	  $(call print-cfg-line,$v,KNOWN) \
+	)
+        # If either of server or client aren't present, add IGNORE lines for
+        # them.
+	$(foreach v, server client, \
+	  $(if $(filter $v, $(ORDERED_CFG_VARIANTS)), , \
+	    $(call print-cfg-line,$v,IGNORE) \
+	  ) \
+	)
 
 TARGETS += $(JVMCFG)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/copy/Copy-jdk.jfr.gmk	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,46 @@
+#
+# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+include CopyCommon.gmk
+
+################################################################################
+
+$(eval $(call SetupCopyFiles, COPY_JFR_METADATA, \
+    SRC := $(TOPDIR)/src/hotspot/share/jfr/metadata, \
+    DEST := $(JDK_OUTPUTDIR)/modules/jdk.jfr/jdk/jfr/internal/types, \
+    FILES := metadata.xml \
+))
+
+TARGETS += $(COPY_JFR_METADATA)
+
+JFR_CONF_DIR := $(TOPDIR)/src/jdk.jfr/share/conf/jfr
+$(eval $(call SetupCopyFiles, COPY_JFR_CONF, \
+    DEST := $(LIB_DST_DIR)/jfr, \
+    FILES := $(wildcard $(JFR_CONF_DIR)/*.jfc), \
+    FLATTEN := true, \
+))
+TARGETS += $(COPY_JFR_CONF)
+
+################################################################################
--- a/make/hotspot/gensrc/GenerateSources.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/hotspot/gensrc/GenerateSources.gmk	Thu May 17 22:11:55 2018 +0200
@@ -38,6 +38,7 @@
 include gensrc/GensrcAdlc.gmk
 include gensrc/GensrcDtrace.gmk
 include gensrc/GensrcJvmti.gmk
+include gensrc/GensrcJfr.gmk
 
 $(eval $(call IncludeCustomExtension, hotspot/gensrc/GenerateSources.gmk))
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/hotspot/gensrc/GensrcJfr.gmk	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,94 @@
+#
+# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+$(eval $(call IncludeCustomExtension, hotspot/gensrc/GensrcJfr.gmk))
+
+################################################################################
+# Build tools needed for the Jfr source code generation
+
+JFR_TOOLS_SRCDIR := $(TOPDIR)/src/hotspot/share/jfr/metadata
+JFR_TOOLS_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/tools/jfr
+
+$(eval $(call SetupJavaCompiler, GENERATE_JFRBYTECODE, \
+    JAVAC := $(JAVAC), \
+    FLAGS := $(DISABLE_WARNINGS), \
+    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
+    SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
+    DISABLE_SJAVAC := true, \
+))
+
+$(eval $(call SetupJavaCompilation, BUILD_JFR_TOOLS, \
+    SETUP := GENERATE_JFRBYTECODE, \
+    SRC := $(JFR_TOOLS_SRCDIR), \
+    INCLUDE_FILES := GenerateJfrFiles.java, \
+    BIN := $(JFR_TOOLS_OUTPUTDIR), \
+))
+
+TOOL_JFR_GEN := $(JAVA_SMALL) -cp $(JFR_TOOLS_OUTPUTDIR) GenerateJfrFiles
+
+################################################################################
+# Setup make rules for Jfr file file generation.
+#
+# Parameter 1 is the name of the rule. This name is used as variable prefix,
+# and the targets generated are listed in a variable by that name. This name is
+# also used as the name of the output file.
+#
+# Remaining parameters are named arguments. These include:
+#   XML_FILE -- The input source file to use
+#   XSD_FILE -- The input schema for validation
+#   OUTPUT_DIR -- The directory to put the generated file in
+SetupJfrGeneration = $(NamedParamsMacroTemplate)
+define SetupJfrGenerationBody
+  $$($1_OUTPUT_DIR)/$1: $$($1_XML_FILE) $$($1_XSD_FILE) $$(BUILD_JFR_TOOLS)
+	$$(call LogInfo, Generating $$(@F))
+	$$(call MakeDir, $$(@D))
+	$$(call ExecuteWithLog, $$@, $$(TOOL_JFR_GEN) $$($1_XML_FILE) $$($1_XSD_FILE) $$($1_OUTPUT_DIR))
+	test -f $$@
+
+  TARGETS += $$($1_OUTPUT_DIR)/$1
+
+endef
+
+################################################################################
+# Create files in gensrc/jfrfiles
+
+JFR_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jfrfiles
+JFR_SRCDIR := $(TOPDIR)/src/hotspot/share/jfr/metadata
+
+METADATA_XML ?= $(JFR_SRCDIR)/metadata.xml
+METADATA_XSD ?= $(JFR_SRCDIR)/metadata.xsd
+
+# Changing these will trigger a rebuild of generated jfr files.
+JFR_DEPS += \
+    $(METADATA_XML) \
+    $(METADATA_XSD) \
+    #
+
+# our generator will generate all files in one go, so only need to setup one target rule
+$(eval $(call SetupJfrGeneration, jfrEventClasses.hpp, \
+    XML_FILE := $(METADATA_XML), \
+    XSD_FILE := $(METADATA_XSD), \
+    OUTPUT_DIR := $(JFR_OUTPUTDIR), \
+))
\ No newline at end of file
--- a/make/hotspot/gensrc/GensrcJvmti.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/hotspot/gensrc/GensrcJvmti.gmk	Thu May 17 22:11:55 2018 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@
 TOOL_JVMTI_ENV_FILL := $(JAVA_SMALL) -cp $(JVMTI_TOOLS_OUTPUTDIR) jvmtiEnvFill
 
 ################################################################################
-# Setup make rules for an xml transform for jvmti/trace file generation.
+# Setup make rules for an xml transform for jvmti file generation.
 #
 # Parameter 1 is the name of the rule. This name is used as variable prefix,
 # and the targets generated are listed in a variable by that name. This name is
@@ -126,48 +126,3 @@
 
   TARGETS += $(COPY_JVMTI_H)
 endif
-
-################################################################################
-# Create trace files in gensrc/tracefiles
-
-TRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/tracefiles
-TRACE_SRCDIR := $(TOPDIR)/src/hotspot/share/trace
-
-# Append list of XSL files to search (might have been set by custom extensions)
-TRACE_XSL_FILES += $(wildcard $(TRACE_SRCDIR)/*.xsl)
-
-TRACE_XML ?= $(TRACE_SRCDIR)/trace.xml
-
-# Changing these will trigger a rebuild of generated trace files.
-TRACE_DEPS += \
-    $(TRACE_XML) \
-    $(TRACE_SRCDIR)/tracetypes.xml \
-    $(TRACE_SRCDIR)/tracerelationdecls.xml \
-    $(TRACE_SRCDIR)/traceevents.xml \
-    $(TRACE_SRCDIR)/trace.dtd \
-    $(TRACE_SRCDIR)/xinclude.mod \
-    #
-
-# Setup rule for generating a trace file
-#
-# $1 is generated source file name in $(TRACE_OUTPUTDIR)
-define SetupTraceGeneration
-  $$(eval $$(call SetupXslTransform, $1, \
-      XML_FILE := $$(TRACE_XML), \
-      XSL_FILE := $$(firstword $$(filter %/$$(basename $1).xsl, $$(TRACE_XSL_FILES))), \
-      OUTPUT_DIR := $$(TRACE_OUTPUTDIR), \
-      DEPS := $$(TRACE_DEPS), \
-  ))
-endef
-
-# Append files to generated (might have been set by custom extensions)
-TRACE_GENSRC_FILES += \
-    traceEventClasses.hpp \
-    traceEventIds.hpp \
-    traceTypes.hpp \
-    #
-
-# Call SetupTraceGeneration for all trace gensrc files
-$(foreach tracefile, $(TRACE_GENSRC_FILES), \
-  $(eval $(call SetupTraceGeneration, $(tracefile))) \
-)
--- a/make/hotspot/lib/CompileJvm.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/hotspot/lib/CompileJvm.gmk	Thu May 17 22:11:55 2018 +0200
@@ -177,6 +177,13 @@
     PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
 ))
 
+# Always recompile vm_version.cpp if libjvm needs to be relinked. This ensures
+# that the internal vm version is updated as it relies on __DATE__ and __TIME__
+# macros.
+VM_VERSION_OBJ := $(JVM_OUTPUTDIR)/objs/vm_version$(OBJ_SUFFIX)
+$(VM_VERSION_OBJ): $(filter-out $(VM_VERSION_OBJ) $(JVM_MAPFILE), \
+    $(BUILD_LIBJVM_TARGET_DEPS))
+
 ifeq ($(OPENJDK_TARGET_OS), windows)
   # It doesn't matter which jvm.lib file gets exported, but we need
   # to pick just one.
--- a/make/hotspot/lib/JvmFeatures.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/hotspot/lib/JvmFeatures.gmk	Thu May 17 22:11:55 2018 +0200
@@ -128,8 +128,9 @@
 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
+      compiledIC_aot_x86_64.cpp compiledIC_aot_aarch64.cpp      \
+      compilerRuntime.cpp aotCodeHeap.cpp aotCompiledMethod.cpp \
+      aotLoader.cpp compiledIC_aot.cpp
 endif
 
 ifneq ($(call check-jvm-feature, cmsgc), true)
@@ -153,6 +154,12 @@
   # If serial is disabled, we cannot use serial as OldGC in parallel
   JVM_EXCLUDE_FILES += psMarkSweep.cpp psMarkSweepDecorator.cpp
 endif
+
+ifneq ($(call check-jvm-feature, jfr), true)
+  JVM_CFLAGS_FEATURES += -DINCLUDE_JFR=0
+  JVM_EXCLUDE_PATTERNS += jfr
+endif
+
 ################################################################################
 
 ifeq ($(call check-jvm-feature, link-time-opt), true)
--- a/make/hotspot/src/classes/build/tools/projectcreator/BuildConfig.java	Thu May 10 22:07:28 2018 +0200
+++ b/make/hotspot/src/classes/build/tools/projectcreator/BuildConfig.java	Thu May 17 22:11:55 2018 +0200
@@ -223,7 +223,7 @@
         sysDefines.add("_WINDOWS");
         sysDefines.add("HOTSPOT_BUILD_USER=\\\""+System.getProperty("user.name")+"\\\"");
         sysDefines.add("HOTSPOT_BUILD_TARGET=\\\""+get("Build")+"\\\"");
-        sysDefines.add("INCLUDE_TRACE=1");
+        sysDefines.add("INCLUDE_JFR=1");
         sysDefines.add("_JNI_IMPLEMENTATION_");
         if (vars.get("PlatformName").equals("Win32")) {
             sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\"");
--- a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java	Thu May 10 22:07:28 2018 +0200
+++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java	Thu May 17 22:11:55 2018 +0200
@@ -109,6 +109,7 @@
     private static final String[] AVAILABLE_TZIDS = TimeZone.getAvailableIDs();
     private static String zoneNameTempFile;
     private static String tzDataDir;
+    private static final Map<String, String> canonicalTZMap = new HashMap<>();
 
     static enum DraftType {
         UNCONFIRMED,
@@ -439,6 +440,15 @@
         // Parse timezone
         handlerTimeZone = new TimeZoneParseHandler();
         parseLDMLFile(new File(TIMEZONE_SOURCE_FILE), handlerTimeZone);
+
+        // canonical tz name map
+        // alias -> primary
+        handlerTimeZone.getData().forEach((k, v) -> {
+            String[] ids = ((String)v).split("\\s");
+            for (int i = 1; i < ids.length; i++) {
+                canonicalTZMap.put(ids[i], ids[0]);
+            }
+        });
     }
 
     private static void parseLDMLFile(File srcfile, AbstractLDMLHandler handler) throws Exception {
@@ -658,7 +668,27 @@
                     handlerMetaZones.get(tzid) == null ||
                     handlerMetaZones.get(tzid) != null &&
                     map.get(METAZONE_ID_PREFIX + handlerMetaZones.get(tzid)) == null) {
-                    // First, check the CLDR meta key
+
+                    // First, check the alias
+                    String canonID = canonicalTZMap.get(tzid);
+                    if (canonID != null && !tzid.equals(canonID)) {
+                        Object value = map.get(TIMEZONE_ID_PREFIX + canonID);
+                        if (value != null) {
+                            names.put(tzid, value);
+                            return;
+                        } else {
+                            String meta = handlerMetaZones.get(canonID);
+                            if (meta != null) {
+                                value = map.get(METAZONE_ID_PREFIX + meta);
+                                if (value != null) {
+                                    names.put(tzid, meta);
+                                    return;
+                                }
+                            }
+                        }
+                    }
+
+                    // Check the CLDR meta key
                     Optional<Map.Entry<String, String>> cldrMeta =
                         handlerMetaZones.getData().entrySet().stream()
                             .filter(me ->
@@ -666,7 +696,7 @@
                                     (String[])map.get(METAZONE_ID_PREFIX + me.getValue())))
                             .findAny();
                     cldrMeta.ifPresentOrElse(meta -> names.put(tzid, meta.getValue()), () -> {
-                        // check the JRE meta key, add if there is not.
+                        // Check the JRE meta key, add if there is not.
                         Optional<Map.Entry<String[], String>> jreMeta =
                             jreMetaMap.entrySet().stream()
                                 .filter(jm -> Arrays.deepEquals(data, jm.getKey()))
@@ -1024,16 +1054,9 @@
     }
 
     private static Stream<String> zidMapEntry() {
-        Map<String, String> canonMap = new HashMap<>();
-        handlerTimeZone.getData().entrySet().stream()
-            .forEach(e -> {
-                String[] ids = ((String)e.getValue()).split("\\s");
-                for (int i = 1; i < ids.length; i++) {
-                    canonMap.put(ids[i], ids[0]);
-                }});
         return ZoneId.getAvailableZoneIds().stream()
                 .map(id -> {
-                    String canonId = canonMap.getOrDefault(id, id);
+                    String canonId = canonicalTZMap.getOrDefault(id, id);
                     String meta = handlerMetaZones.get(canonId);
                     String zone001 = handlerMetaZones.zidMap().get(meta);
                     return zone001 == null ? "" :
--- a/make/jprt.properties	Thu May 10 22:07:28 2018 +0200
+++ b/make/jprt.properties	Thu May 17 22:11:55 2018 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -273,6 +273,7 @@
     ${my.test.target.set:TESTNAME=jdk_instrument},			\
     ${my.test.target.set:TESTNAME=jdk_jmx},				\
     ${my.test.target.set:TESTNAME=jdk_jdi},				\
+    ${my.test.target.set:TESTNAME=jdk_jfr},                             \
     ${my.test.target.set:TESTNAME=svc_tools},                           \
     ${my.make.rule.test.targets.svc.extra}
 
--- a/make/launcher/Launcher-jdk.aot.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/launcher/Launcher-jdk.aot.gmk	Thu May 17 22:11:55 2018 +0200
@@ -41,6 +41,7 @@
     , \
     JAVA_ARGS := --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=$(call CommaList, jdk.internal.vm.compiler  jdk.aot) \
         --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=$(call CommaList, jdk.internal.vm.compiler  jdk.aot) \
+        --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=$(call CommaList, jdk.internal.vm.compiler  jdk.aot) \
         --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.sparc=$(call CommaList, jdk.internal.vm.compiler  jdk.aot) \
         --add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=$(call CommaList, jdk.internal.vm.compiler  jdk.aot) \
         --add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=$(call CommaList, jdk.internal.vm.compiler  jdk.aot) \
--- a/make/launcher/Launcher-jdk.pack.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/launcher/Launcher-jdk.pack.gmk	Thu May 17 22:11:55 2018 +0200
@@ -39,6 +39,7 @@
 # On Mac, we have always exported all symbols, probably due to oversight
 # and/or misunderstanding. To emulate this, don't hide any symbols
 # by default.
+# On AIX/xlc we need at least xlc 13.1 for the symbol hiding
 # Also provide an override for non-conformant libraries.
 ifeq ($(TOOLCHAIN_TYPE), gcc)
   CXXFLAGS_JDKEXE += -fvisibility=hidden
@@ -50,7 +51,9 @@
 else ifeq ($(TOOLCHAIN_TYPE), solstudio)
   CXXFLAGS_JDKEXE += -xldscope=hidden
 else ifeq ($(TOOLCHAIN_TYPE), xlc)
-  CXXFLAGS_JDKEXE += -qvisibility=hidden
+  ifneq ($(CC_VERSION_NUMBER), 12.1)
+    CXXFLAGS_JDKEXE += -qvisibility=hidden
+  endif
 endif
 
 UNPACKEXE_SRC := $(TOPDIR)/src/jdk.pack/share/native/common-unpack \
--- a/make/launcher/LauncherCommon.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/launcher/LauncherCommon.gmk	Thu May 17 22:11:55 2018 +0200
@@ -45,6 +45,7 @@
 # On Mac, we have always exported all symbols, probably due to oversight
 # and/or misunderstanding. To emulate this, don't hide any symbols
 # by default.
+# On AIX/xlc we need at least xlc 13.1 for the symbol hiding
 # Also provide an override for non-conformant libraries.
 ifeq ($(TOOLCHAIN_TYPE), gcc)
   LAUNCHER_CFLAGS += -fvisibility=hidden
@@ -56,7 +57,9 @@
 else ifeq ($(TOOLCHAIN_TYPE), solstudio)
   LAUNCHER_CFLAGS += -xldscope=hidden
 else ifeq ($(TOOLCHAIN_TYPE), xlc)
-  LAUNCHER_CFLAGS += -qvisibility=hidden
+  ifneq ($(CC_VERSION_NUMBER), 12.1)
+    CXXFLAGS_JDKEXE += -qvisibility=hidden
+  endif
 endif
 
 LAUNCHER_SRC := $(TOPDIR)/src/java.base/share/native/launcher
--- a/make/lib/LibCommon.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/lib/LibCommon.gmk	Thu May 17 22:11:55 2018 +0200
@@ -41,6 +41,7 @@
 # On Mac, we have always exported all symbols, probably due to oversight
 # and/or misunderstanding. To emulate this, don't hide any symbols
 # by default.
+# On AIX/xlc we need at least xlc 13.1 for the symbol hiding
 # Also provide an override for non-conformant libraries.
 ifeq ($(TOOLCHAIN_TYPE), gcc)
   CFLAGS_JDKLIB += -fvisibility=hidden
@@ -58,9 +59,11 @@
   CXXFLAGS_JDKLIB += -xldscope=hidden
   EXPORT_ALL_SYMBOLS := -xldscope=global
 else ifeq ($(TOOLCHAIN_TYPE), xlc)
-  CFLAGS_JDKLIB += -qvisibility=hidden
-  CXXFLAGS_JDKLIB += -qvisibility=hidden
-  EXPORT_ALL_SYMBOLS := -qvisibility=default
+  ifneq ($(CC_VERSION_NUMBER), 12.1)
+    CFLAGS_JDKLIB += -qvisibility=hidden
+    CXXFLAGS_JDKLIB += -qvisibility=hidden
+    EXPORT_ALL_SYMBOLS := -qvisibility=default
+  endif
 endif
 
 ################################################################################
--- a/make/nashorn/project.properties	Thu May 10 22:07:28 2018 +0200
+++ b/make/nashorn/project.properties	Thu May 17 22:11:55 2018 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -98,8 +98,8 @@
 dist.nashornapi.javadoc.dir=${dist.javadoc.dir}/nashornapi
 dist.dynalinkapi.javadoc.dir=${dist.javadoc.dir}/dynalinkapi
 
-# configuration for java flight recorder
-run.test.jvmargs.jfr=-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true,disk=true,dumponexit=true,dumponexitpath=${build.dir},stackdepth=128
+# configuration for flight recorder
+run.test.jvmargs.jfr=XX:StartFlightRecording=disk=true,dumponexit=true,dumponexitpath=${build.dir},stackdepth=128
 
 # test library location
 test.lib=test/nashorn/lib
@@ -354,7 +354,7 @@
 # uncomment this jfr.args to enable light recordings. the stack needs to be cranked up to 1024 frames,
 # or everything will as of the now drown in lambda forms and be cut off.
 #
-#jfr.args=-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true,disk=true,dumponexit=true,dumponexitpath="test_suite.jfr",stackdepth=1024 \
+#jfr.args=-XX:StartFlightRecording=disk=true,dumponexit=true,dumponexitpath="test_suite.jfr",stackdepth=1024
 
 jfr.args=
 
--- a/make/nb_native/nbproject/configurations.xml	Thu May 10 22:07:28 2018 +0200
+++ b/make/nb_native/nbproject/configurations.xml	Thu May 17 22:11:55 2018 +0200
@@ -2891,7 +2891,6 @@
               <in>stringUtils.hpp</in>
               <in>ticks.cpp</in>
               <in>ticks.hpp</in>
-              <in>ticks.inline.hpp</in>
               <in>utf8.cpp</in>
               <in>utf8.hpp</in>
               <in>vmError.cpp</in>
@@ -6887,7 +6886,7 @@
             <pElem>../../hotspot/src/share/vm/ci</pElem>
             <pElem>../../hotspot/src/share/vm/oops</pElem>
             <pElem>../../hotspot/src/share/vm/trace</pElem>
-            <pElem>../../build/macosx-x86_64-normal-server-release/hotspot/variant-server/gensrc/tracefiles</pElem>
+            <pElem>../../build/macosx-x86_64-normal-server-release/hotspot/variant-server/gensrc/jfrfiles</pElem>
             <pElem>../../hotspot/src/share/vm/gc/parallel</pElem>
             <pElem>../../hotspot/src/share/vm/gc/shared</pElem>
             <pElem>../../hotspot/src/share/vm/classfile</pElem>
@@ -15408,11 +15407,6 @@
             tool="3"
             flavor2="0">
       </item>
-      <item path="../../src/hotspot/share/utilities/ticks.inline.hpp"
-            ex="false"
-            tool="3"
-            flavor2="0">
-      </item>
       <item path="../../src/hotspot/share/utilities/utf8.cpp"
             ex="false"
             tool="1"
@@ -29190,11 +29184,6 @@
             tool="3"
             flavor2="0">
       </item>
-      <item path="../../src/hotspot/share/utilities/ticks.inline.hpp"
-            ex="false"
-            tool="3"
-            flavor2="0">
-      </item>
       <item path="../../src/hotspot/share/utilities/utf8.cpp"
             ex="false"
             tool="1"
--- a/make/test/JtregNativeHotspot.gmk	Thu May 10 22:07:28 2018 +0200
+++ b/make/test/JtregNativeHotspot.gmk	Thu May 17 22:11:55 2018 +0200
@@ -78,6 +78,17 @@
     -I$(VM_TESTBASE_DIR)/nsk/share/native \
     -I$(VM_TESTBASE_DIR)/nsk/share/locks
 
+MLVM_JVMTI_INCLUDES := \
+    -I$(VM_TESTBASE_DIR)/nsk/share/native \
+    -I$(VM_TESTBASE_DIR)/nsk/share/jni \
+    -I$(VM_TESTBASE_DIR)/nsk/share/jvmti \
+    -I$(VM_TESTBASE_DIR)/nsk/share/jvmti/agent_common \
+    -I$(VM_TESTBASE_DIR)/vm/mlvm/share
+
+MLVM_STRESS_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)
@@ -95,6 +106,11 @@
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libLockingThread := $(NSK_SHARE_LOCKS_INCLUDES)
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libJNIMonitorLocker := $(NSK_SHARE_LOCKS_INCLUDES)
 
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstepBreakPopReturn := $(MLVM_JVMTI_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libIndyRedefineClass := $(MLVM_JVMTI_INCLUDES)
+
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libnativeAndMH := $(MLVM_STRESS_INCLUDES)
+
 ################################################################################
 
 # Platform specific setup
@@ -105,6 +121,8 @@
 ifeq ($(OPENJDK_TARGET_OS), linux)
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libtest-rw := -z noexecstack
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libtest-rwx := -z execstack
+    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libstepBreakPopReturn := -lpthread
+    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libIndyRedefineClass := -lpthread
     BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exeinvoke := -ljvm -lpthread
     BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exestack-gap := -ljvm -lpthread
     BUILD_TEST_exeinvoke_exeinvoke.c_OPTIMIZATION := NONE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/README.txt	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,96 @@
+The classes for the Java2D(TM) demo are contained in the J2Ddemo.jar file.  
+To run the J2D demo:
+
+% java -jar J2Ddemo.jar
+
+-----------------------------------------------------------------------
+Introduction
+-----------------------------------------------------------------------
+
+This Java2D demo consists of a set of demos housed in one GUI 
+framework that uses a JTabbedPane.  You can access different groups of 
+demos by clicking the tabs at the top of the pane. There are demo 
+groups for Arcs_Curves, Clipping, Colors, Composite, Fonts, Images, 
+Lines, Mix, Paint, Paths and Transforms.  On the right-hand side of the 
+pane, the GUI framework features individual and global controls for 
+changing graphics attributes. There's also a memory-usage monitor, and 
+a monitor for tracking the performance, in frames per second, of 
+animation demos.
+
+
+-----------------------------------------------------------------------
+Tips on usage 
+----------------------------------------------------------------------- 
+
+Click on one of the tabs at the top of the pane to select a demo group.  
+When you select a group, a set of surfaces is displayed, each of which 
+contains one of the group's demos. At the bottom of each surface is 
+a set of tools for controlling the demo.  The tools can be displayed
+by selecting the Tools checkbox in the Global Controls panel or
+by clicking on the slim strip of gray bumps at the bottom of the demo
+panel.
+
+If you click on a demo surface, that demo is laid out by itself. A
+new icon button will appear in the demo's tools toolbar one that enables 
+you to create new instances of that demo's surface. 
+
+To run the demo continuously without user interaction, select the 
+Run Window item in the Options menu and press the run button in the 
+new window that's displayed.  To do this from the command line:
+
+    java -jar J2Ddemo.jar -runs=10
+
+To view all the command line options for customizing demo runs:
+
+    java -jar J2Ddemo.jar -help
+
+You can run the demos in stand-alone mode by issuing a command like this
+
+    java -cp J2Ddemo.jar java2d.demos.Clipping.ClipAnim
+
+You can run the demos in groups by issuing a command like this
+
+    java -cp J2Ddemo.jar java2d.DemoGroup Clipping    
+
+To increase or decrease the Memory Monitor sampling rate click on the
+Memory Monitor's title border, a panel with a TextField will appear.
+
+The J2Ddemo Intro (the 'J2D demo' tab) contains a scene table, click in 
+the gray border and a table will appear.
+
+Animated demos have a slider to control the animation rate.  Bring up
+the animated demo toolbar, then click in the gray area of the toolbar
+panel, the toolbar goes away and the slider appears.
+
+Demos that have Custom Controls can have their Custom Control Thread
+activated and stopped by clicking in the gray area of the demos Custom 
+Control panel.
+
+-----------------------------------------------------------------------
+NOTE about demo surfaces 
+----------------------------------------------------------------------- 
+
+The demo groups are in separate packages with their class files stored 
+in directories named according to the demo group name.  All drawing 
+demos extend either the Surface, AnimatingSurface, ControlsSurface or
+AnimatingControlsSurface classes.  Surface is the base class, demos
+must implement the Surface's render method.  All animated demos extend 
+either the AnimatingSurface or the AnimatingControlsSurface classes.  
+Animated demos must implement the reset and step methods.  The demos
+with gui controls extend either the ControlsSurface or the 
+AnimatingControlsSurface classes.  Demos with controls must implement
+the methods in the CustomControlsContext interface.
+
+
+======================================================================
+
+Here are some resources for learning about and using the Java2D(TM)
+
+OpenJDK group page: http://openjdk.java.net/groups/2d/
+
+Learning Java 2D: http://www.oracle.com/technetwork/articles/java/java2dpart1-137217.html
+
+Tutorial : http://download.oracle.com/javase/tutorial/2d/
+Specification: http://download.oracle.com/javase/8/docs/technotes/guides/2d/spec/j2d-bookTOC.html
+Java 2D (TM) API White Paper : http://www.oracle.com/technetwork/java/javase/tech/2d-142228.html
+2D FAQ: http://www.oracle.com/technetwork/java/index-137037.html
Binary file src/demo/share/jfc/J2Ddemo/fonts/A.ttf has changed
Binary file src/demo/share/jfc/J2Ddemo/images/bld.jpg has changed
Binary file src/demo/share/jfc/J2Ddemo/images/bld@2x.jpg has changed
Binary file src/demo/share/jfc/J2Ddemo/images/boat.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/boat@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/box.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/box.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/box@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/boxwave.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/boxwave.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/boxwave@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/clone.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/clone@2x.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/clouds.jpg has changed
Binary file src/demo/share/jfc/J2Ddemo/images/clouds@2x.jpg has changed
Binary file src/demo/share/jfc/J2Ddemo/images/duke.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/duke.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/duke.running.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/duke@2x.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/duke@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/dukeplug.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/dukeplug.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/dukeplug@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/fight.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/fight.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/fight@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/globe.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/globe.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/globe@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/jumptojavastrip.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/loop.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/loop@2x.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/looping.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/looping@2x.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/magnify.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/magnify.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/magnify@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/painting.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/painting.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/painting@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/print.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/print@2x.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/remove.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/remove@2x.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/snooze.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/snooze.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/snooze@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/star7.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/star7.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/star7@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/start.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/start2.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/start2@2x.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/start@2x.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/stop.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/stop2.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/stop2@2x.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/stop@2x.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/surfing.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/surfing.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/surfing@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/thumbsup.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/thumbsup.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/thumbsup@2x.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/tip.gif has changed
Binary file src/demo/share/jfc/J2Ddemo/images/tip.png has changed
Binary file src/demo/share/jfc/J2Ddemo/images/tip@2x.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/AnimatingContext.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,43 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+package java2d;
+
+
+/**
+ * The interface for a DemoSurface that animates.
+ */
+public interface AnimatingContext {
+        public void step(int w, int h);
+        public void reset(int newwidth, int newheight);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/AnimatingControlsSurface.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,81 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package java2d;
+
+
+import static java2d.CustomControlsContext.State.START;
+import java.awt.Component;
+
+
+/**
+ * Demos that animate and have custom controls extend this class.
+ */
+@SuppressWarnings("serial")
+public abstract class AnimatingControlsSurface extends AnimatingSurface
+        implements CustomControlsContext {
+
+    @Override
+    public void setControls(Component[] controls) {
+        this.controls = controls;
+    }
+
+    @Override
+    public void setConstraints(String[] constraints) {
+        this.constraints = constraints;
+    }
+
+    @Override
+    public String[] getConstraints() {
+        return constraints;
+    }
+
+    @Override
+    public Component[] getControls() {
+        return controls;
+    }
+
+    @Override
+    public void handleThread(CustomControlsContext.State state) {
+        for (Component control : controls) {
+            if (control instanceof CustomControls) {
+                if (state == START) {
+                    ((CustomControls) control).start();
+                } else {
+                    ((CustomControls) control).stop();
+                }
+            }
+        }
+    }
+
+    private Component[] controls;
+    private String[] constraints = { java.awt.BorderLayout.NORTH };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/AnimatingSurface.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,111 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+package java2d;
+
+
+/**
+ * Demos that animate extend this class.
+ */
+@SuppressWarnings("serial")
+public abstract class AnimatingSurface extends Surface implements Runnable {
+
+    private volatile boolean running = false;
+
+    private volatile Thread thread;
+
+    public abstract void step(int w, int h);
+
+    public abstract void reset(int newwidth, int newheight);
+
+
+    public synchronized void start() {
+        if (!running() && !dontThread) {
+            thread = new Thread(this);
+            thread.setPriority(Thread.MIN_PRIORITY);
+            thread.setName(name + " Demo");
+            thread.start();
+            running = true;
+        }
+    }
+
+
+    public synchronized void stop() {
+        if (thread != null) {
+            running = false;
+            thread.interrupt();
+        }
+        thread = null;
+        notifyAll();
+    }
+
+
+    @Override
+    @SuppressWarnings("SleepWhileHoldingLock")
+    public void run() {
+
+        while (running() && !isShowing() || getSize().width == 0) {
+            try {
+                Thread.sleep(200);
+            } catch (InterruptedException ignored) {
+            }
+        }
+
+        while (running()) {
+            repaint();
+            try {
+                Thread.sleep(sleepAmount);
+            } catch (InterruptedException ignored) {
+            }
+        }
+        synchronized (this) {
+            running = false;
+        }
+    }
+
+    /**
+     * @return the running
+     */
+    public synchronized boolean running() {
+        return running;
+    }
+
+    /**
+     * Causes surface to repaint immediately
+     */
+    public synchronized void doRepaint() {
+        if (running() && thread != null) {
+            thread.interrupt();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/CloningFeature.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,196 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package java2d;
+
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.SoftBevelBorder;
+
+
+/**
+ * Illustration of how to use the clone feature of the demo.
+ */
+@SuppressWarnings("serial")
+public final class CloningFeature extends JPanel implements Runnable {
+
+    private final DemoInstVarsAccessor demoInstVars;
+    private Thread thread;
+    private JTextArea ta;
+
+    public CloningFeature(DemoInstVarsAccessor demoInstVars) {
+        this.demoInstVars = demoInstVars;
+
+        setLayout(new BorderLayout());
+        EmptyBorder eb = new EmptyBorder(5, 5, 5, 5);
+        SoftBevelBorder sbb = new SoftBevelBorder(BevelBorder.RAISED);
+        setBorder(new CompoundBorder(eb, sbb));
+
+        ta = new JTextArea("Cloning Demonstrated\n\nClicking once on a demo\n");
+        ta.setMinimumSize(new Dimension(300, 500));
+        JScrollPane scroller = new JScrollPane();
+        scroller.getViewport().add(ta);
+        ta.setFont(new Font("Dialog", Font.PLAIN, 14));
+        ta.setForeground(Color.black);
+        ta.setBackground(Color.lightGray);
+        ta.setEditable(false);
+
+        add("Center", scroller);
+
+        start();
+    }
+
+    public void start() {
+        thread = new Thread(this);
+        thread.setPriority(Thread.MAX_PRIORITY);
+        thread.setName("CloningFeature");
+        thread.start();
+    }
+
+    public void stop() {
+        if (thread != null) {
+            thread.interrupt();
+        }
+        thread = null;
+    }
+
+    @Override
+    @SuppressWarnings("SleepWhileHoldingLock")
+    public void run() {
+
+
+        int index = demoInstVars.getTabbedPane().getSelectedIndex();
+        if (index == 0) {
+            demoInstVars.getTabbedPane().setSelectedIndex(1);
+            try {
+                Thread.sleep(3333);
+            } catch (Exception e) {
+                return;
+            }
+        }
+
+        if (!demoInstVars.getControls().toolBarCB.isSelected()) {
+            demoInstVars.getControls().toolBarCB.setSelected(true);
+            try {
+                Thread.sleep(2222);
+            } catch (Exception e) {
+                return;
+            }
+        }
+
+        index = demoInstVars.getTabbedPane().getSelectedIndex() - 1;
+        DemoGroup dg = demoInstVars.getGroup()[index];
+        DemoPanel dp = (DemoPanel) dg.getPanel().getComponent(0);
+        if (dp.surface == null) {
+            ta.append("Sorry your zeroth component is not a Surface.");
+            return;
+        }
+
+        dg.mouseClicked(dp.surface);
+
+        try {
+            Thread.sleep(3333);
+        } catch (Exception e) {
+            return;
+        }
+
+        ta.append("Clicking the ToolBar double document button\n");
+        try {
+            Thread.sleep(3333);
+        } catch (Exception e) {
+            return;
+        }
+
+        dp = (DemoPanel) dg.clonePanels[0].getComponent(0);
+
+        if (dp.tools != null) {
+            for (int i = 0; i < 3 && thread != null; i++) {
+                ta.append("   Cloning\n");
+                dp.tools.cloneB.doClick();
+                try {
+                    Thread.sleep(3333);
+                } catch (Exception e) {
+                    return;
+                }
+            }
+        }
+
+        ta.append("Changing attributes \n");
+
+        try {
+            Thread.sleep(3333);
+        } catch (Exception e) {
+            return;
+        }
+
+        Component cmps[] = dg.clonePanels[0].getComponents();
+        for (int i = 0; i < cmps.length && thread != null; i++) {
+            if ((dp = (DemoPanel) cmps[i]).tools == null) {
+                continue;
+            }
+            switch (i) {
+                case 0:
+                    ta.append("   Changing AntiAliasing\n");
+                    dp.tools.aliasB.doClick();
+                    break;
+                case 1:
+                    ta.append("   Changing Composite & Texture\n");
+                    dp.tools.compositeB.doClick();
+                    dp.tools.textureB.doClick();
+                    break;
+                case 2:
+                    ta.append("   Changing Screen\n");
+                    dp.tools.screenCombo.setSelectedIndex(4);
+                    break;
+                case 3:
+                    ta.append("   Removing a clone\n");
+                    dp.tools.cloneB.doClick();
+            }
+            try {
+                Thread.sleep(3333);
+            } catch (Exception e) {
+                return;
+            }
+        }
+
+        ta.append("\nAll Done!");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/ControlsSurface.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,82 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+package java2d;
+
+
+import static java2d.CustomControlsContext.State.START;
+import java.awt.Component;
+
+
+/**
+ * The class to utilize custom controls for a Demo.
+ */
+@SuppressWarnings("serial")
+public abstract class ControlsSurface extends Surface implements CustomControlsContext {
+
+    @Override
+    public void setControls(Component[] controls) {
+        this.controls = controls;
+    }
+
+    @Override
+    public void setConstraints(String[] constraints) {
+        this.constraints = constraints;
+    }
+
+    @Override
+    public String[] getConstraints() {
+        return constraints;
+    }
+
+    @Override
+    public Component[] getControls() {
+        return controls;
+    }
+
+    @Override
+    public void handleThread(CustomControlsContext.State state) {
+        for (Component control : controls) {
+            if (control instanceof CustomControls) {
+                if (state == START) {
+                    ((CustomControls) control).start();
+                } else {
+                    ((CustomControls) control).stop();
+                }
+            }
+        }
+    }
+
+    private Component[] controls;
+    private String[] constraints = { java.awt.BorderLayout.NORTH };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/CustomControls.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,133 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+package java2d;
+
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JPanel;
+import javax.swing.border.EtchedBorder;
+
+
+/**
+ * A convenience class for demos that use Custom Controls.  This class
+ * sets up the thread for running the custom control.  A notifier thread
+ * is started as well, a flashing 2x2 rect is drawn in the upper right corner
+ * while the custom control thread continues to run.
+ */
+@SuppressWarnings("serial")
+public abstract class CustomControls extends JPanel implements Runnable {
+
+
+    protected Thread thread;
+    protected boolean doNotifier;
+    private CCNotifierThread ccnt;
+    private String name = "foo.bar Demo";
+    private static final Color blue = new Color(204, 204, 255);
+
+
+    public CustomControls() {
+        setBorder(new EtchedBorder());
+        addMouseListener(new MouseAdapter() {
+
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                if (thread == null) { start(); } else { stop(); }
+            }
+        });
+    }
+
+    public CustomControls(String name) {
+        this();
+        this.name = name + " Demo";
+    }
+
+    @Override
+    public void paintComponent(Graphics g) {
+        super.paintComponent(g);
+        g.setColor(doNotifier ? blue : Color.gray);
+        g.fillRect(getSize().width-2, 0, 2, 2);
+    }
+
+    public void start() {
+        if (thread == null) {
+            thread = new Thread(this);
+            thread.setPriority(Thread.MIN_PRIORITY);
+            thread.setName(name + " ccthread");
+            thread.start();
+            (ccnt = new CCNotifierThread()).start();
+            ccnt.setName(name + " ccthread notifier");
+        }
+    }
+
+    public synchronized void stop() {
+        if (thread != null) {
+            thread.interrupt();
+            if (ccnt != null) {
+                ccnt.interrupt();
+            }
+        }
+        thread = null;
+    }
+
+
+    // Custom Controls override the run method
+    @Override
+    public void run() {
+    }
+
+
+    /**
+     * Notifier that the custom control thread is running.
+     */
+    class CCNotifierThread extends Thread {
+
+        @Override
+        @SuppressWarnings("SleepWhileHoldingLock")
+        public void run() {
+            while (thread != null) {
+                doNotifier = !doNotifier;
+                repaint();
+                try {
+                    Thread.sleep(444);
+                } catch (Exception ex) {
+                    break;
+                }
+            }
+            doNotifier = false; repaint();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/CustomControlsContext.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,51 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+package java2d;
+
+
+import java.awt.Component;
+
+
+/**
+ * ControlsSurface or AnimatingControlsSurface classes implement
+ * this interface.
+ */
+public interface CustomControlsContext {
+    public static enum State { START, STOP };
+    public String[] getConstraints();
+    public Component[] getControls();
+    public void setControls(Component[] controls);
+    public void setConstraints(String[] constraints);
+    public void handleThread(CustomControlsContext.State state);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/DemoFonts.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,82 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+package java2d;
+
+
+import java.awt.Font;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ * A cache of the dynamically loaded fonts found in the fonts directory.
+ */
+public class DemoFonts {
+
+    // Prepare a static "cache" mapping font names to Font objects.
+    private static final String[] names =  { "A.ttf" };
+    private static final Map<String,Font> cache =
+               new ConcurrentHashMap<String,Font>(names.length);
+    static {
+        for (String name : names) {
+            cache.put(name, getFont(name));
+        }
+    }
+
+    public static void newDemoFonts() {
+    }
+
+
+    public static Font getFont(String name) {
+        Font font = null;
+        if (cache != null) {
+            if ((font = cache.get(name)) != null) {
+                return font;
+            }
+        }
+        String fName = "/fonts/" + name;
+        try {
+            InputStream is = DemoFonts.class.getResourceAsStream(fName);
+            font = Font.createFont(Font.TRUETYPE_FONT, is);
+        } catch (Exception ex) {
+            Logger.getLogger(DemoFonts.class.getName()).log(Level.SEVERE,
+                    fName + " not loaded.  Using serif font.", ex);
+            font = new Font(Font.SERIF, Font.PLAIN, 24);
+        }
+        return font;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/DemoGroup.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,384 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package java2d;
+
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Image;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+import javax.swing.JToggleButton;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.SoftBevelBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+
+/**
+ * DemoGroup handles multiple demos inside of a panel.  Demos are loaded
+ * from the demos[][] string as listed in J2Ddemo.java.
+ * Demo groups can be loaded individually, for example :
+ *      java DemoGroup Fonts
+ * Loads all the demos found in the demos/Fonts directory.
+ */
+@SuppressWarnings("serial")
+public class DemoGroup extends JPanel
+        implements ChangeListener, ActionListener {
+    private final DemoInstVarsAccessor demoInstVars;
+    public int columns = 2;
+    private static final Font font = new Font(Font.SERIF, Font.PLAIN, 10);
+    private final EmptyBorder emptyB = new EmptyBorder(5, 5, 5, 5);
+    private final BevelBorder bevelB = new BevelBorder(BevelBorder.LOWERED);
+    private String groupName;
+    public JPanel clonePanels[];
+    public JTabbedPane tabbedPane;
+
+    public DemoGroup(String name, DemoInstVarsAccessor demoInstVars) {
+
+        groupName = name;
+        this.demoInstVars = demoInstVars;
+
+        setLayout(new BorderLayout());
+
+        JPanel p = new JPanel(new GridLayout(0, 2));
+        p.setBorder(new CompoundBorder(emptyB, bevelB));
+
+        // Find the named demo group in J2Ddemo.demos[].
+        int ind = -1;
+        while (!name.equals(J2Ddemo.demos[++ind][0])) {
+        }
+        String[] demos = J2Ddemo.demos[ind];
+
+        // If there are an odd number of demos, use GridBagLayout.
+        // Note that we don't use the first entry.
+        int numDemos = demos.length - 1;
+        if (numDemos % 2 == 1) {
+            p.setLayout(new GridBagLayout());
+        }
+
+        MouseAdapter mouseListener = new MouseAdapter() {
+
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                DemoGroup.this.mouseClicked(e.getComponent());
+            }
+        };
+
+        // For each demo in the group, prepare a DemoPanel.
+        for (int i = 1; i <= numDemos; i++) {
+            DemoPanel dp =
+                    new DemoPanel("java2d.demos." + name + "." + demos[i], demoInstVars);
+            dp.setDemoBorder(p);
+            if (dp.surface != null) {
+                dp.surface.addMouseListener(mouseListener);
+                dp.surface.setMonitor(demoInstVars.getPerformanceMonitor() != null);
+            }
+            if (p.getLayout() instanceof GridBagLayout) {
+                int x = p.getComponentCount() % 2;
+                int y = p.getComponentCount() / 2;
+                int w = (i == numDemos) ? 2 : 1;
+                J2Ddemo.addToGridBag(p, dp, x, y, w, 1, 1, 1);
+            } else {
+                p.add(dp);
+            }
+        }
+
+        add(p);
+    }
+
+    public void mouseClicked(Component component) {
+        String className = component.toString();
+
+        if (tabbedPane == null) {
+            shutDown(getPanel());
+            JPanel p = new JPanel(new BorderLayout());
+            p.setBorder(new CompoundBorder(emptyB, bevelB));
+
+            tabbedPane = new JTabbedPane();
+            tabbedPane.setFont(font);
+
+            JPanel tmpP = (JPanel) getComponent(0);
+            tabbedPane.addTab(groupName, tmpP);
+
+            clonePanels = new JPanel[tmpP.getComponentCount()];
+            for (int i = 0; i < clonePanels.length; i++) {
+                clonePanels[i] = new JPanel(new BorderLayout());
+                DemoPanel dp = (DemoPanel) tmpP.getComponent(i);
+                DemoPanel c = new DemoPanel(dp.className, demoInstVars);
+                c.setDemoBorder(clonePanels[i]);
+                if (c.surface != null) {
+                    c.surface.setMonitor(demoInstVars.getPerformanceMonitor() != null);
+                    Image cloneImg = DemoImages.getImage("clone.gif", this);
+                    c.tools.cloneB = c.tools.addTool(cloneImg,
+                            "Clone the Surface", this);
+                    Dimension d = c.tools.toolbar.getPreferredSize();
+                    c.tools.toolbar.setPreferredSize(
+                            new Dimension(d.width + 27, d.height));
+                    if (demoInstVars.getBackgroundColor() != null) {
+                        c.surface.setBackground(demoInstVars.getBackgroundColor());
+                    }
+                }
+                clonePanels[i].add(c);
+                String s = dp.className.substring(dp.className.indexOf('.') + 1);
+                tabbedPane.addTab(s, clonePanels[i]);
+            }
+            p.add(tabbedPane);
+            remove(tmpP);
+            add(p);
+
+            tabbedPane.addChangeListener(this);
+            revalidate();
+        }
+
+        className = className.substring(0, className.indexOf('['));
+
+        for (int i = 0; i < tabbedPane.getTabCount(); i++) {
+            String s1 = className.substring(className.indexOf('.') + 1);
+            if (tabbedPane.getTitleAt(i).equals(s1)) {
+                tabbedPane.setSelectedIndex(i);
+                break;
+            }
+        }
+
+        revalidate();
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        JButton b = (JButton) e.getSource();
+        if (b.getToolTipText().startsWith("Clone")) {
+            cloneDemo();
+        } else {
+            removeClone(b.getParent().getParent().getParent().getParent());
+        }
+    }
+    private int index;
+
+    @Override
+    public void stateChanged(ChangeEvent e) {
+        shutDown((JPanel) tabbedPane.getComponentAt(index));
+        index = tabbedPane.getSelectedIndex();
+        setup(false);
+    }
+
+    public JPanel getPanel() {
+        if (tabbedPane != null) {
+            return (JPanel) tabbedPane.getSelectedComponent();
+        } else {
+            return (JPanel) getComponent(0);
+        }
+    }
+
+    public void setup(boolean issueRepaint) {
+
+        JPanel p = getPanel();
+
+        // Let PerformanceMonitor know which demos are running
+        if (demoInstVars.getPerformanceMonitor() != null) {
+            demoInstVars.getPerformanceMonitor().surf.setPanel(p);
+            demoInstVars.getPerformanceMonitor().surf.setSurfaceState();
+        }
+
+        GlobalControls c = demoInstVars.getControls();
+        // .. tools check against global controls settings ..
+        // .. & start demo & custom control thread if need be ..
+        for (int i = 0; i < p.getComponentCount(); i++) {
+            DemoPanel dp = (DemoPanel) p.getComponent(i);
+            if (dp.surface != null && c != null) {
+                Tools t = dp.tools;
+                t.setVisible(isValid());
+                t.issueRepaint = issueRepaint;
+                JToggleButton b[] = { t.toggleB, t.aliasB, t.renderB,
+                    t.textureB, t.compositeB };
+                JCheckBox cb[] = { c.toolBarCB, c.aliasCB, c.renderCB,
+                    c.textureCB, c.compositeCB };
+                for (int j = 0; j < b.length; j++) {
+                    if (c.obj != null && c.obj.equals(cb[j])) {
+                        if (b[j].isSelected() != cb[j].isSelected()) {
+                            b[j].doClick();
+                        }
+                    } else if (c.obj == null) {
+                        if (b[j].isSelected() != cb[j].isSelected()) {
+                            b[j].doClick();
+                        }
+                    }
+                }
+                t.setVisible(true);
+                if (c.screenCombo.getSelectedIndex()
+                        != t.screenCombo.getSelectedIndex()) {
+                    t.screenCombo.setSelectedIndex(c.screenCombo.
+                            getSelectedIndex());
+                }
+                if (demoInstVars.getVerboseCB().isSelected()) {
+                    dp.surface.verbose(c);
+                }
+                dp.surface.setSleepAmount(c.slider.getValue());
+                if (demoInstVars.getBackgroundColor() != null) {
+                    dp.surface.setBackground(demoInstVars.getBackgroundColor());
+                }
+                t.issueRepaint = true;
+            }
+            dp.start();
+        }
+        revalidate();
+    }
+
+    public void shutDown(JPanel p) {
+        for (int i = 0; i < p.getComponentCount(); i++) {
+            ((DemoPanel) p.getComponent(i)).stop();
+        }
+        System.gc();
+    }
+
+    public void cloneDemo() {
+        JPanel panel = clonePanels[tabbedPane.getSelectedIndex() - 1];
+        if (panel.getComponentCount() == 1) {
+            panel.invalidate();
+            panel.setLayout(new GridLayout(0, columns, 5, 5));
+            panel.revalidate();
+        }
+        DemoPanel original = (DemoPanel) getPanel().getComponent(0);
+        DemoPanel clone = new DemoPanel(original.className, demoInstVars);
+        if (columns == 2) {
+            clone.setDemoBorder(panel);
+        }
+        Image removeImg = DemoImages.getImage("remove.gif", this);
+        clone.tools.cloneB =
+                clone.tools.addTool(removeImg, "Remove the Surface", this);
+        Dimension d = clone.tools.toolbar.getPreferredSize();
+        clone.tools.toolbar.setPreferredSize(
+                new Dimension(d.width + 27, d.height));
+        if (demoInstVars.getBackgroundColor() != null) {
+            clone.surface.setBackground(demoInstVars.getBackgroundColor());
+        }
+        if (demoInstVars.getControls() != null) {
+            if (clone.tools.isExpanded
+                    != demoInstVars.getControls().toolBarCB.isSelected()) {
+                clone.tools.toggleB.doClick();
+            }
+        }
+        clone.start();
+        clone.surface.setMonitor(demoInstVars.getPerformanceMonitor() != null);
+        panel.add(clone);
+        panel.repaint();
+        panel.revalidate();
+    }
+
+    public void removeClone(Component theClone) {
+        JPanel panel = clonePanels[tabbedPane.getSelectedIndex() - 1];
+        if (panel.getComponentCount() == 2) {
+            Component cmp = panel.getComponent(0);
+            panel.removeAll();
+            panel.setLayout(new BorderLayout());
+            panel.revalidate();
+            panel.add(cmp);
+        } else {
+            panel.remove(theClone);
+            int cmpCount = panel.getComponentCount();
+            for (int j = 1; j < cmpCount; j++) {
+                int top = (j + 1 >= 3) ? 0 : 5;
+                int left = ((j + 1) % 2) == 0 ? 0 : 5;
+                EmptyBorder eb = new EmptyBorder(top, left, 5, 5);
+                SoftBevelBorder sbb = new SoftBevelBorder(BevelBorder.RAISED);
+                JPanel p = (JPanel) panel.getComponent(j);
+                p.setBorder(new CompoundBorder(eb, sbb));
+            }
+        }
+        panel.repaint();
+        panel.revalidate();
+    }
+
+    public static void main(String args[]) {
+        class DemoInstVarsAccessorImpl extends DemoInstVarsAccessorImplBase {
+            private volatile JCheckBoxMenuItem ccthreadCB;
+
+            public void setCcthreadCB(JCheckBoxMenuItem ccthreadCB) {
+                this.ccthreadCB = ccthreadCB;
+            }
+
+            @Override
+            public JCheckBoxMenuItem getCcthreadCB() {
+                return ccthreadCB;
+            }
+        }
+        DemoInstVarsAccessorImpl demoInstVars = new DemoInstVarsAccessorImpl();
+        final DemoGroup group = new DemoGroup(args[0], demoInstVars);
+        JFrame f = new JFrame("Java2D(TM) Demo - DemoGroup");
+        f.addWindowListener(new WindowAdapter() {
+
+            @Override
+            public void windowClosing(WindowEvent e) {
+                System.exit(0);
+            }
+
+            @Override
+            public void windowDeiconified(WindowEvent e) {
+                group.setup(false);
+            }
+
+            @Override
+            public void windowIconified(WindowEvent e) {
+                group.shutDown(group.getPanel());
+            }
+        });
+        f.getContentPane().add("Center", group);
+        f.pack();
+        int FRAME_WIDTH = 620;
+        int FRAME_HEIGHT = 530;
+        f.setSize(FRAME_WIDTH, FRAME_HEIGHT);
+        f.setLocationRelativeTo(null);  // centers f on screen
+        f.setVisible(true);
+        for (String arg : args) {
+            if (arg.startsWith("-ccthread")) {
+                demoInstVars.setCcthreadCB(new JCheckBoxMenuItem("CCThread", true));
+            }
+        }
+        group.setup(false);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/DemoImages.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,105 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package java2d;
+
+
+import java.awt.Component;
+import java.awt.Image;
+import java.awt.MediaTracker;
+import java.net.URL;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ * A collection of all the demo images found in the images directory.
+ * Certain classes are preloaded; the rest are loaded lazily.
+ */
+@SuppressWarnings("serial")
+public class DemoImages extends Component {
+
+    private static final String[] names = {
+        "bld.jpg", "boat.png", "box.png",
+        "boxwave.png", "clouds.jpg", "duke.gif", "duke.running.gif",
+        "dukeplug.png", "fight.png", "globe.png",
+        "jumptojavastrip.png", "magnify.png", "painting.png",
+        "remove.gif", "snooze.png", "star7.gif", "surfing.png",
+        "thumbsup.png", "tip.png", "duke.png", "print.gif",
+        "loop.gif", "looping.gif", "start.gif", "start2.gif",
+        "stop.gif", "stop2.gif", "clone.gif"
+    };
+    private static final Map<String, Image> cache =
+            new ConcurrentHashMap<String, Image>(names.length);
+
+    private DemoImages() {
+    }
+
+    public static void newDemoImages() {
+        DemoImages demoImages = new DemoImages();
+        for (String name : names) {
+            cache.put(name, getImage(name, demoImages));
+        }
+    }
+
+
+    /*
+     * Gets the named image using the toolkit of the specified component.
+     * Note that this has to work even before we have had a chance to
+     * instantiate DemoImages and preload the cache.
+     */
+    public static Image getImage(String name, Component cmp) {
+        Image img = null;
+        if (cache != null) {
+            if ((img = cache.get(name)) != null) {
+                return img;
+            }
+        }
+
+        ClassLoader cl = cmp.getClass().getClassLoader();
+        URL fileLoc = cl.getResource("images/" + name);
+        img = cmp.getToolkit().getImage(fileLoc);
+
+        MediaTracker tracker = new MediaTracker(cmp);
+        tracker.addImage(img, 0);
+        try {
+            tracker.waitForID(0);
+            if (tracker.isErrorAny()) {
+                System.out.println("Error loading image " + name);
+            }
+        } catch (Exception ex) {
+            Logger.getLogger(DemoImages.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return img;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/DemoInstVarsAccessor.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,27 @@
+package java2d;
+
+import java.awt.Color;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JTabbedPane;
+
+/**
+ * The interface provides access to instance variables of 'J2Ddemo' object, which
+ * were static variables of 'J2Ddemo' class read/written from various parts of the
+ * demo classes. The interface is a part of the fix which changed static variables
+ * for instance variables in certain demo classes.
+ */
+public interface DemoInstVarsAccessor {
+    public GlobalControls getControls();
+    public MemoryMonitor getMemoryMonitor();
+    public PerformanceMonitor getPerformanceMonitor();
+    public JTabbedPane getTabbedPane();
+    public DemoGroup[] getGroup();
+    public void setGroupColumns(int columns);
+    public JCheckBoxMenuItem getVerboseCB();
+    public JCheckBoxMenuItem getCcthreadCB();
+    public JCheckBoxMenuItem getPrintCB();
+    public Color getBackgroundColor();
+    public JCheckBoxMenuItem getMemoryCB();
+    public JCheckBoxMenuItem getPerfCB();
+    public Intro getIntro();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/DemoInstVarsAccessorImplBase.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,79 @@
+package java2d;
+
+import java.awt.Color;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JTabbedPane;
+
+/**
+ * The implementation of 'DemoInstVarsAccessor' interface with empty methods.
+ * It is used, when some parts of the demo are executed as standalone applications
+ * not creating 'J2Ddemo' instances, for example in 'TextureChooser.main',
+ * 'DemoGroup.main', 'Surface.createDemoFrame'.
+ */
+public class DemoInstVarsAccessorImplBase implements DemoInstVarsAccessor {
+    private JCheckBoxMenuItem printCB = new JCheckBoxMenuItem("Default Printer");
+
+    @Override
+    public GlobalControls getControls() {
+        return null;
+    }
+
+    @Override
+    public MemoryMonitor getMemoryMonitor() {
+        return null;
+    }
+
+    @Override
+    public PerformanceMonitor getPerformanceMonitor() {
+        return null;
+    }
+
+    @Override
+    public JTabbedPane getTabbedPane() {
+        return null;
+    }
+
+    @Override
+    public DemoGroup[] getGroup() {
+        return null;
+    }
+
+    @Override
+    public void setGroupColumns(int columns) {
+    }
+
+    @Override
+    public JCheckBoxMenuItem getVerboseCB() {
+        return null;
+    }
+
+    @Override
+    public JCheckBoxMenuItem getCcthreadCB() {
+        return null;
+    }
+
+    @Override
+    public JCheckBoxMenuItem getPrintCB() {
+        return printCB;
+    }
+
+    @Override
+    public Color getBackgroundColor() {
+        return null;
+    }
+
+    @Override
+    public JCheckBoxMenuItem getMemoryCB() {
+        return null;
+    }
+
+    @Override
+    public JCheckBoxMenuItem getPerfCB() {
+        return null;
+    }
+
+    @Override
+    public Intro getIntro() {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/DemoPanel.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,124 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package java2d;
+
+
+import static java2d.CustomControlsContext.State.START;
+import static java2d.CustomControlsContext.State.STOP;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JPanel;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.SoftBevelBorder;
+
+
+/**
+ * The panel for the Surface, Custom Controls & Tools.
+ * Other component types welcome.
+ */
+@SuppressWarnings("serial")
+public class DemoPanel extends JPanel {
+    private final DemoInstVarsAccessor demoInstVars;
+    public Surface surface;
+    public CustomControlsContext ccc;
+    public Tools tools;
+    public String className;
+
+    public DemoPanel(Object obj, DemoInstVarsAccessor demoInstVars) {
+        this.demoInstVars = demoInstVars;
+
+        setLayout(new BorderLayout());
+        try {
+            if (obj instanceof String) {
+                className = (String) obj;
+                obj = Class.forName(className).newInstance();
+            }
+            if (obj instanceof Component) {
+                add((Component) obj);
+            }
+            if (obj instanceof Surface) {
+                add("South", tools = new Tools(surface = (Surface) obj, demoInstVars));
+            }
+            if (obj instanceof CustomControlsContext) {
+                ccc = (CustomControlsContext) obj;
+                Component cmps[] = ccc.getControls();
+                String cons[] = ccc.getConstraints();
+                for (int i = 0; i < cmps.length; i++) {
+                    add(cmps[i], cons[i]);
+                }
+            }
+        } catch (Exception e) {
+            Logger.getLogger(DemoPanel.class.getName()).log(Level.SEVERE, null,
+                    e);
+        }
+    }
+
+    public void start() {
+        if (surface != null) {
+            surface.startClock();
+        }
+        if (tools != null && surface != null) {
+            if (tools.startStopB != null && tools.startStopB.isSelected()) {
+                surface.animating.start();
+            }
+        }
+        if (ccc != null
+                && demoInstVars.getCcthreadCB() != null
+                && demoInstVars.getCcthreadCB().isSelected()) {
+            ccc.handleThread(START);
+        }
+    }
+
+    public void stop() {
+        if (surface != null) {
+            if (surface.animating != null) {
+                surface.animating.stop();
+            }
+            surface.bimg = null;
+        }
+        if (ccc != null) {
+            ccc.handleThread(STOP);
+        }
+    }
+
+    public void setDemoBorder(JPanel p) {
+        int top = (p.getComponentCount() + 1 >= 3) ? 0 : 5;
+        int left = ((p.getComponentCount() + 1) % 2) == 0 ? 0 : 5;
+        EmptyBorder eb = new EmptyBorder(top, left, 5, 5);
+        SoftBevelBorder sbb = new SoftBevelBorder(BevelBorder.RAISED);
+        setBorder(new CompoundBorder(eb, sbb));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/GlobalControls.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,151 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package java2d;
+
+
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridBagLayout;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JPanel;
+import javax.swing.JSlider;
+import javax.swing.SwingConstants;
+import javax.swing.border.EtchedBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+
+/**
+ * Global Controls panel for changing graphic attributes of
+ * the demo surface.
+ */
+@SuppressWarnings("serial")
+public class GlobalControls extends JPanel implements ItemListener,
+        ChangeListener {
+    private final DemoInstVarsAccessor demoInstVars;
+    public static final String[] screenNames = {
+        "Auto Screen", "On Screen", "Off Screen",
+        "INT_xRGB", "INT_ARGB", "INT_ARGB_PRE", "INT_BGR",
+        "3BYTE_BGR", "4BYTE_ABGR", "4BYTE_ABGR_PRE", "USHORT_565_RGB",
+        "USHORT_x555_RGB", "BYTE_GRAY", "USHORT_GRAY",
+        "BYTE_BINARY", "BYTE_INDEXED", "BYTE_BINARY 2 bit", "BYTE_BINARY 4 bit",
+        "INT_RGBx", "USHORT_555x_RGB" };
+    public final JComboBox screenCombo;
+    public TextureChooser texturechooser;
+    public JCheckBox aliasCB, renderCB, toolBarCB;
+    public JCheckBox compositeCB, textureCB;
+    public JSlider slider;
+    public Object obj;
+    private Font font = new Font(Font.SERIF, Font.PLAIN, 12);
+
+    @SuppressWarnings("LeakingThisInConstructor")
+    public GlobalControls(DemoInstVarsAccessor demoInstVars) {
+        this.demoInstVars = demoInstVars;
+
+        setLayout(new GridBagLayout());
+        setBorder(new TitledBorder(new EtchedBorder(), "Global Controls"));
+
+        aliasCB = createCheckBox("Anti-Aliasing", true, 0);
+        renderCB = createCheckBox("Rendering Quality", false, 1);
+        textureCB = createCheckBox("Texture", false, 2);
+        compositeCB = createCheckBox("AlphaComposite", false, 3);
+
+        screenCombo = new JComboBox();
+        screenCombo.setPreferredSize(new Dimension(120, 18));
+        screenCombo.setLightWeightPopupEnabled(true);
+        screenCombo.setFont(font);
+        for (int i = 0; i < screenNames.length; i++) {
+            screenCombo.addItem(screenNames[i]);
+        }
+        screenCombo.addItemListener(this);
+        J2Ddemo.addToGridBag(this, screenCombo, 0, 4, 1, 1, 0.0, 0.0);
+
+        toolBarCB = createCheckBox("Tools", false, 5);
+
+        slider = new JSlider(SwingConstants.HORIZONTAL, 0, 200, 30);
+        slider.addChangeListener(this);
+        TitledBorder tb = new TitledBorder(new EtchedBorder());
+        tb.setTitleFont(font);
+        tb.setTitle("Anim delay = 30 ms");
+        slider.setBorder(tb);
+        slider.setMinimumSize(new Dimension(80, 46));
+        J2Ddemo.addToGridBag(this, slider, 0, 6, 1, 1, 1.0, 1.0);
+
+        texturechooser = new TextureChooser(0, demoInstVars);
+        J2Ddemo.addToGridBag(this, texturechooser, 0, 7, 1, 1, 1.0, 1.0);
+    }
+
+    private JCheckBox createCheckBox(String s, boolean b, int y) {
+        JCheckBox cb = new JCheckBox(s, b);
+        cb.setFont(font);
+        cb.setHorizontalAlignment(SwingConstants.LEFT);
+        cb.addItemListener(this);
+        J2Ddemo.addToGridBag(this, cb, 0, y, 1, 1, 1.0, 1.0);
+        return cb;
+    }
+
+    @Override
+    public void stateChanged(ChangeEvent e) {
+        int value = slider.getValue();
+        TitledBorder tb = (TitledBorder) slider.getBorder();
+        tb.setTitle("Anim delay = " + String.valueOf(value) + " ms");
+        int index = demoInstVars.getTabbedPane().getSelectedIndex() - 1;
+        DemoGroup dg = demoInstVars.getGroup()[index];
+        JPanel p = dg.getPanel();
+        for (int i = 0; i < p.getComponentCount(); i++) {
+            DemoPanel dp = (DemoPanel) p.getComponent(i);
+            if (dp.tools != null && dp.tools.slider != null) {
+                dp.tools.slider.setValue(value);
+            }
+        }
+        slider.repaint();
+    }
+
+    @Override
+    public void itemStateChanged(ItemEvent e) {
+        if (demoInstVars.getTabbedPane().getSelectedIndex() != 0) {
+            obj = e.getSource();
+            int index = demoInstVars.getTabbedPane().getSelectedIndex() - 1;
+            demoInstVars.getGroup()[index].setup(true);
+            obj = null;
+        }
+    }
+
+    @Override
+    public Dimension getPreferredSize() {
+        return new Dimension(135, 260);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/GlobalPanel.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,100 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package java2d;
+
+
+import java.awt.BorderLayout;
+import java.awt.GridBagLayout;
+import javax.swing.JPanel;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+
+/**
+ * Panel that holds the Demo groups, Controls and Monitors for each tab.
+ * It's a special "always visible" panel for the Controls, MemoryMonitor &
+ * PerformanceMonitor.
+ */
+@SuppressWarnings("serial")
+public class GlobalPanel extends JPanel implements ChangeListener {
+    private final DemoInstVarsAccessor demoInstVars;
+    private JPanel p;
+    private int index;
+
+    public GlobalPanel(DemoInstVarsAccessor demoInstVars) {
+        this.demoInstVars = demoInstVars;
+
+        setLayout(new BorderLayout());
+        p = new JPanel(new GridBagLayout());
+        EmptyBorder eb = new EmptyBorder(5, 0, 5, 5);
+        BevelBorder bb = new BevelBorder(BevelBorder.LOWERED);
+        p.setBorder(new CompoundBorder(eb, bb));
+        J2Ddemo.addToGridBag(p, demoInstVars.getControls(), 0, 0, 1, 1, 0, 0);
+        J2Ddemo.addToGridBag(p, demoInstVars.getMemoryMonitor(), 0, 1, 1, 1, 0, 0);
+        J2Ddemo.addToGridBag(p, demoInstVars.getPerformanceMonitor(), 0, 2, 1, 1, 0, 0);
+        add(demoInstVars.getIntro());
+    }
+
+    @Override
+    public void stateChanged(ChangeEvent e) {
+
+        demoInstVars.getGroup()[index].shutDown(demoInstVars.getGroup()[index].getPanel());
+        if (demoInstVars.getTabbedPane().getSelectedIndex() == 0) {
+            demoInstVars.getMemoryMonitor().surf.stop();
+            demoInstVars.getPerformanceMonitor().surf.stop();
+            removeAll();
+            add(demoInstVars.getIntro());
+            demoInstVars.getIntro().start();
+        } else {
+            if (getComponentCount() == 1) {
+                demoInstVars.getIntro().stop();
+                remove(demoInstVars.getIntro());
+                add(p, BorderLayout.EAST);
+                if (demoInstVars.getMemoryCB().getState()) {
+                    demoInstVars.getMemoryMonitor().surf.start();
+                }
+                if (demoInstVars.getPerfCB().getState()) {
+                    demoInstVars.getPerformanceMonitor().surf.start();
+                }
+            } else {
+                remove(demoInstVars.getGroup()[index]);
+            }
+            index = demoInstVars.getTabbedPane().getSelectedIndex() - 1;
+            add(demoInstVars.getGroup()[index]);
+            demoInstVars.getGroup()[index].setup(false);
+        }
+        revalidate();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/demo/share/jfc/J2Ddemo/java2d/Intro.java	Thu May 17 22:11:55 2018 +0200
@@ -0,0 +1,1784 @@
+/*
+ *
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package java2d;
+
+
+import static java.awt.Color.BLACK;
+import static java.awt.Color.GRAY;
+import static java.awt.Color.RED;
+import static java.awt.Color.WHITE;
+import static java.awt.Color.YELLOW;
+import java.awt.AlphaComposite;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Paint;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.TexturePaint;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.FlatteningPathIterator;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSlider;
+import javax.swing.JTable;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.EtchedBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableModel;
+
+
+/**
+ * Introduction to the J2Ddemo.
+ *
+ * @author Brian Lichtenwalter
+ * @author Alexander Kouznetsov
+ */
+@SuppressWarnings("serial")
+public class Intro extends JPanel {
+
+    private static final Color myBlack = new Color(20, 20, 20);
+    private static final Color myWhite = new Color(240, 240, 255);
+    private static final Color myRed = new Color(149, 43, 42);
+    private static final Color myBlue = new Color(94, 105, 176);
+    private static final Color myYellow = new Color(255, 255, 140);
+    private ScenesTable scenesTable;
+    private boolean doTable;
+    private final Surface surface;
+
+    public Intro() {
+        EmptyBorder eb = new EmptyBorder(80, 110, 80, 110);
+        BevelBorder bb = new BevelBorder(BevelBorder.LOWERED);
+        setBorder(new CompoundBorder(eb, bb));
+        setLayout(new BorderLayout());
+        setBackground(GRAY);
+        setToolTipText("click for scene table");
+        add(surface = new Surface());
+        addMouseListener(new MouseAdapter() {
+
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                removeAll();
+                if ((doTable = !doTable)) {
+                    setToolTipText("click for animation");
+                    surface.stop();
+                    if (scenesTable == null) {
+                        scenesTable = new ScenesTable(Intro.this);
+                    }
+                    add(scenesTable);
+                } else {
+                    setToolTipText("click for scene table");
+                    surface.start();
+                    add(surface);
+                }
+                revalidate();
+                repaint();
+            }
+        });
+    }
+
+    public void start() {
+        if (!doTable) {
+            surface.start();
+        }
+    }
+
+    public void stop() {
+        if (!doTable) {
+            surface.stop();
+        }
+    }
+
+    public static void main(String argv[]) {
+        final Intro intro = new Intro();
+        WindowListener l = new WindowAdapter() {
+
+            @Override
+            public void windowClosing(WindowEvent e) {
+                System.exit(0);
+            }
+
+            @Override
+            public void windowDeiconified(WindowEvent e) {
+                intro.start();
+            }
+
+            @Override
+            public void windowIconified(WindowEvent e) {
+                intro.stop();
+            }
+        };
+        JFrame f = new JFrame("Java2D(TM) Demo - Intro");
+        f.addWindowListener(l);
+        f.getContentPane().add("Center", intro);
+        f.pack();
+        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+        int w = 720;
+        int h = 510;
+        f.setLocation(screenSize.width / 2 - w / 2, screenSize.height / 2 - h
+                / 2);
+        f.setSize(w, h);
+        f.setVisible(true);
+        intro.start();
+    }
+
+
+    /**
+     * ScenesTable is the list of scenes known to the Director.
+     * Scene participation, scene name and scene pause amount columns.
+     * Global animation delay for scene's steps.
+     */
+    static class ScenesTable extends JPanel implements ActionListener,
+            ChangeListener {
+        private final Intro intro;
+        private JTable table;
+        private TableModel dataModel;
+
+        @SuppressWarnings("LeakingThisInConstructor")
+        public ScenesTable(final Intro intro) {
+            this.intro = intro;
+
+            setBackground(WHITE);
+            setLayout(new BorderLayout());
+            final String[] names = { "", "Scenes", "Pause" };
+
+            dataModel = new AbstractTableModel() {
+
+                @Override
+                public int getColumnCount() {
+                    return names.length;
+                }
+
+                @Override
+                public int getRowCount() {
+                    return intro.surface.director.size();
+                }
+
+                @Override
+                public Object getValueAt(int row, int col) {
+                    Surface.Scene scene = intro.surface.director.get(row);
+                    if (col == 0) {
+                        return scene.participate;
+                    } else if (col == 1) {
+                        return scene.name;
+                    } else {
+                        return scene.pauseAmt;
+                    }
+                }
+
+                @Override
+                public String getColumnName(int col) {
+                    return names[col];
+                }
+
+                @Override
+                public Class<?> getColumnClass(int c) {
+                    return getValueAt(0, c).getClass();
+                }
+
+                @Override
+                public boolean isCellEditable(int row, int col) {
+                    return col != 1 ? true : false;
+                }
+
+                @Override
+                public void setValueAt(Object aValue, int row, int col) {
+                    Surface.Scene scene = intro.surface.director.get(row);
+                    if (col == 0) {
+                        scene.participate = aValue;
+                    } else if (col == 1) {
+                        scene.name = aValue;
+                    } else {
+                        scene.pauseAmt = aValue;
+                    }
+                }
+            };
+
+            table = new JTable(dataModel);
+            TableColumn col = table.getColumn("");
+            col.setWidth(16);
+            col.setMinWidth(16);
+            col.setMaxWidth(20);
+            col = table.getColumn("Pause");
+            col.setWidth(60);
+            col.setMinWidth(60);
+            col.setMaxWidth(60);
+            table.sizeColumnsToFit(0);
+
+            JScrollPane scrollpane = new JScrollPane(table);
+            add(scrollpane);
+
+            JPanel panel = new JPanel(new BorderLayout());
+            JButton b = new JButton("Unselect All");
+            b.setHorizontalAlignment(JButton.LEFT);
+            Font font = new Font(Font.SERIF, Font.PLAIN, 10);
+            b.setFont(font);
+            b.addActionListener(this);
+            panel.add("West", b);
+
+            JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 200,
+                    (int) intro.surface.sleepAmt);
+            slider.addChangeListener(this);
+            TitledBorder tb = new TitledBorder(new EtchedBorder());
+            tb.setTitleFont(font);
+            tb.setTitle("Anim delay = " + String.valueOf(intro.surface.sleepAmt)
+                    + " ms");
+            slider.setBorder(tb);
+            slider.setPreferredSize(new Dimension(140, 40));
+            slider.setMinimumSize(new Dimension(100, 40));
+            slider.setMaximumSize(new Dimension(180, 40));
+            panel.add("East", slider);
+
+            add("South", panel);
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            JButton b = (JButton) e.getSource();
+            b.setSelected(!b.isSelected());
+            b.setText(b.isSelected() ? "Select All" : "Unselect All");
+            for (int i = 0; i < intro.surface.director.size(); i++) {
+                Surface.Scene scene = intro.surface.director.get(i);
+                scene.participate = Boolean.valueOf(!b.isSelected());
+            }
+            table.tableChanged(new TableModelEvent(dataModel));
+        }
+
+        @Override
+        public void stateChanged(ChangeEvent e) {
+            JSlider slider = (JSlider) e.getSource();
+            int value = slider.getValue();
+            TitledBorder tb = (TitledBorder) slider.getBorder();
+            tb.setTitle("Anim delay = " + String.valueOf(value) + " ms");
+            intro.surface.sleepAmt = (long) value;
+            slider.repaint();
+        }
+    }  // End ScenesTable class
+
+
+    /**
+     * Surface is the stage where the Director plays its scenes.
+     */
+    static class Surface extends JPanel implements Runnable {
+
+        private final Image dukeanim, duke;
+        private BufferedImage bimg;
+        public Director director;
+        public int index;
+        public long sleepAmt = 30;
+        private Thread thread;
+
+        @SuppressWarnings("LeakingThisInConstructor")
+        public Surface() {
+            setBackground(myBlack);
+            setLayout(new BorderLayout());
+            addMouseListener(new MouseAdapter() {
+
+                @Override
+                public void mouseClicked(MouseEvent e) {
+                    if (thread == null) {
+                        start();
+                    } else {
+                        stop();
+                    }
+                }
+            });
+            dukeanim = DemoImages.getImage("duke.running.gif", this);
+            duke = DemoImages.getImage("duke.png", this);
+            director = new Director(this);
+        }
+
+        public FontMetrics getMetrics(Font font) {
+            return getFontMetrics(font);
+        }
+
+        @Override
+        public void paint(Graphics g) {
+            Dimension d = getSize();
+            if (d.width <= 0 || d.height <= 0) {
+                return;
+            }
+            if (bimg == null || bimg.getWidth() != d.width || bimg.getHeight()
+                    != d.height) {
+                bimg = getGraphicsConfiguration().createCompatibleImage(d.width,
+                        d.height);
+                // reset future scenes
+                for (int i = index + 1; i < director.size(); i++) {
+                    (director.get(i)).reset(d.width, d.height);
+                }
+            }
+
+            Scene scene = director.get(index);
+            if (scene.index <= scene.length) {
+                if (thread != null) {
+                    scene.step(d.width, d.height);
+                }
+
+                Graphics2D g2 = bimg.createGraphics();
+                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                        RenderingHints.VALUE_ANTIALIAS_ON);
+                g2.setBackground(getBackground());
+                g2.clearRect(0, 0, d.width, d.height);
+
+                scene.render(d.width, d.height, g2);
+
+                if (thread != null) {
+                    // increment scene.index after scene.render
+                    scene.index++;
+                }
+                g2.dispose();
+            }
+            g.drawImage(bimg, 0, 0, this);
+        }
+
+        public void start() {
+            if (thread == null) {
+                thread = new Thread(this);
+                thread.setPriority(Thread.MIN_PRIORITY);
+                thread.setName("Intro");
+                thread.start();
+            }
+        }
+
+        public synchronized void stop() {
+            if (thread != null) {
+                thread.interrupt();
+            }
+            thread = null;
+            notifyAll();
+        }
+
+        public void reset() {
+            index = 0;
+            Dimension d = getSize();
+            for (Scene scene : director) {
+                scene.reset(d.width, d.height);
+            }
+        }
+
+        @Override
+        @SuppressWarnings("SleepWhileHoldingLock")
+        public void run() {
+
+            Thread me = Thread.currentThread();
+
+            while (thread == me && !isShowing() || getSize().width <= 0) {
+                try {
+                    Thread.sleep(500);
+                } catch (InterruptedException e) {
+                    return;