Merge
authorduke
Wed, 05 Jul 2017 18:04:20 +0200
changeset 12003 819fb57bfc94
parent 12002 9bf30f58c4bc (current diff)
parent 12001 b5b83d23d606 (diff)
child 12007 50bfd843bf37
Merge
--- a/.hgtags-top-repo	Thu Mar 01 12:23:07 2012 -0800
+++ b/.hgtags-top-repo	Wed Jul 05 18:04:20 2017 +0200
@@ -149,3 +149,4 @@
 221a378e06a326f45e5d89e2123cd6323e0181d1 jdk8-b25
 2accafff224ae39caf5f532c305251ba624bf2c0 jdk8-b26
 1533dfab9903e4edcfead3b0192643f38c418b9b jdk8-b27
+6e2541d60f4e342b5b67140271d7611643929dc3 jdk8-b28
--- a/hotspot/.hgtags	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/.hgtags	Wed Jul 05 18:04:20 2017 +0200
@@ -226,3 +226,5 @@
 931e5f39e365a0d550d79148ff87a7f9e864d2e1 hs23-b16
 3b24e7e01d20ca590d0f86b1222bb7c3f1a2aa2d jdk8-b27
 975c4105f1e2ef1190a75b77124033f1fd4290b5 hs24-b01
+b183b0863611b85dbac16f3b08b40ba978756d19 jdk8-b28
+030b5306d60f140e822e4a6d301744cb110ff0c8 hs24-b02
--- a/hotspot/make/bsd/makefiles/buildtree.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/bsd/makefiles/buildtree.make	Wed Jul 05 18:04:20 2017 +0200
@@ -58,6 +58,7 @@
 # needs to be set here since this Makefile doesn't include defs.make
 OS_VENDOR:=$(shell uname -s)
 
+-include $(SPEC)
 include $(GAMMADIR)/make/scm.make
 include $(GAMMADIR)/make/altsrc.make
 
@@ -247,6 +248,8 @@
 	    echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
 	    echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
 	echo; \
+	[ -n "$(SPEC)" ] && \
+	    echo "include $(SPEC)"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
 	) > $@
--- a/hotspot/make/bsd/makefiles/gcc.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/bsd/makefiles/gcc.make	Wed Jul 05 18:04:20 2017 +0200
@@ -27,53 +27,57 @@
 #------------------------------------------------------------------------
 # CC, CXX & AS
 
-# When cross-compiling the ALT_COMPILER_PATH points
-# to the cross-compilation toolset
-ifdef CROSS_COMPILE_ARCH
- CXX = $(ALT_COMPILER_PATH)/g++
- CC  = $(ALT_COMPILER_PATH)/gcc
- HOSTCXX = g++
- HOSTCC  = gcc
-else ifneq ($(OS_VENDOR), Darwin)
- CXX = g++
- CC  = gcc
- HOSTCXX = $(CXX)
- HOSTCC  = $(CC)
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+  # When cross-compiling the ALT_COMPILER_PATH points
+  # to the cross-compilation toolset
+  ifdef CROSS_COMPILE_ARCH
+    CXX = $(ALT_COMPILER_PATH)/g++
+    CC  = $(ALT_COMPILER_PATH)/gcc
+    HOSTCXX = g++
+    HOSTCC  = gcc
+  else ifneq ($(OS_VENDOR), Darwin)
+    CXX = g++
+    CC  = gcc
+    HOSTCXX = $(CXX)
+    HOSTCC  = $(CC)
+  endif
+
+  # i486 hotspot requires -mstackrealign on Darwin.
+  # llvm-gcc supports this in Xcode 3.2.6 and 4.0.
+  # gcc-4.0 supports this on earlier versions.
+  # Prefer llvm-gcc where available.
+  ifeq ($(OS_VENDOR), Darwin)
+    ifeq ($(origin CXX), default)
+      CXX = llvm-g++
+    endif
+    ifeq ($(origin CC), default)
+      CC  = llvm-gcc
+    endif
+
+    ifeq ($(ARCH), i486)
+      LLVM_SUPPORTS_STACKREALIGN := $(shell \
+       [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
+       && echo true || echo false)
+
+      ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
+        CXX32 ?= llvm-g++
+        CC32  ?= llvm-gcc
+      else
+        CXX32 ?= g++-4.0
+        CC32  ?= gcc-4.0
+      endif
+      CXX = $(CXX32)
+      CC  = $(CC32)
+    endif
+
+    HOSTCXX = $(CXX)
+    HOSTCC  = $(CC)
+  endif
+
+  AS   = $(CC) -c -x assembler-with-cpp
 endif
 
-# i486 hotspot requires -mstackrealign on Darwin.
-# llvm-gcc supports this in Xcode 3.2.6 and 4.0.
-# gcc-4.0 supports this on earlier versions.
-# Prefer llvm-gcc where available.
-ifeq ($(OS_VENDOR), Darwin)
-  ifeq ($(origin CXX), default)
-   CXX = llvm-g++
-  endif
-  ifeq ($(origin CC), default)
-   CC  = llvm-gcc
-  endif
-
-  ifeq ($(ARCH), i486)
-  LLVM_SUPPORTS_STACKREALIGN := $(shell \
-   [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
-   && echo true || echo false)
-
-  ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
-    CXX32 ?= llvm-g++
-    CC32  ?= llvm-gcc
-  else
-    CXX32 ?= g++-4.0
-    CC32  ?= gcc-4.0
-  endif
-  CXX = $(CXX32)
-  CC  = $(CC32)
-  endif
-
-  HOSTCXX = $(CXX)
-  HOSTCC  = $(CC)
-endif
-
-AS   = $(CC) -c -x assembler-with-cpp
 
 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
 # prints the numbers (e.g. "2.95", "3.2.1")
--- a/hotspot/make/bsd/makefiles/sparcWorks.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/bsd/makefiles/sparcWorks.make	Wed Jul 05 18:04:20 2017 +0200
@@ -25,12 +25,15 @@
 #------------------------------------------------------------------------
 # CC, CXX & AS
 
-CXX = CC
-CC  = cc
-AS  = $(CC) -c
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+  CXX = CC
+  CC  = cc
+  AS  = $(CC) -c
 
-HOSTCXX = $(CXX)
-HOSTCC  = $(CC)
+  HOSTCXX = $(CXX)
+  HOSTCC  = $(CC)
+endif
 
 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
 ARCHFLAG/i486    = -m32
--- a/hotspot/make/defs.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/defs.make	Wed Jul 05 18:04:20 2017 +0200
@@ -24,6 +24,11 @@
 
 # The common definitions for hotspot builds.
 
+# Optionally include SPEC file generated by configure.
+ifneq ($(SPEC),)
+  include $(SPEC)
+endif
+
 # Default to verbose build logs (show all compile lines):
 MAKE_VERBOSE=y
 
--- a/hotspot/make/hotspot_version	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/hotspot_version	Wed Jul 05 18:04:20 2017 +0200
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=24
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=01
+HS_BUILD_NUMBER=02
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=8
--- a/hotspot/make/linux/makefiles/buildtree.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/linux/makefiles/buildtree.make	Wed Jul 05 18:04:20 2017 +0200
@@ -55,6 +55,7 @@
 # The makefiles are split this way so that "make foo" will run faster by not
 # having to read the dependency files for the vm.
 
+-include $(SPEC)
 include $(GAMMADIR)/make/scm.make
 include $(GAMMADIR)/make/altsrc.make
 
@@ -244,6 +245,8 @@
 	    echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
 	    echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
 	echo; \
+	[ -n "$(SPEC)" ] && \
+	    echo "include $(SPEC)"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
 	) > $@
--- a/hotspot/make/linux/makefiles/gcc.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/linux/makefiles/gcc.make	Wed Jul 05 18:04:20 2017 +0200
@@ -25,21 +25,26 @@
 #------------------------------------------------------------------------
 # CC, CXX & AS
 
-# When cross-compiling the ALT_COMPILER_PATH points
-# to the cross-compilation toolset
-ifdef CROSS_COMPILE_ARCH
-CXX = $(ALT_COMPILER_PATH)/g++
-CC  = $(ALT_COMPILER_PATH)/gcc
-HOSTCXX = g++
-HOSTCC  = gcc
-else
-CXX = g++
-CC  = gcc
-HOSTCXX = $(CXX)
-HOSTCC  = $(CC)
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+  # When cross-compiling the ALT_COMPILER_PATH points
+  # to the cross-compilation toolset
+  ifdef CROSS_COMPILE_ARCH
+    CXX = $(ALT_COMPILER_PATH)/g++
+    CC  = $(ALT_COMPILER_PATH)/gcc
+    HOSTCXX = g++
+    HOSTCC  = gcc
+    STRIP = $(ALT_COMPILER_PATH)/strip
+  else
+    CXX = g++
+    CC  = gcc
+    HOSTCXX = $(CXX)
+    HOSTCC  = $(CC)
+    STRIP = strip
+  endif
+  AS  = $(CC) -c
 endif
 
-AS  = $(CC) -c
 
 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
 # prints the numbers (e.g. "2.95", "3.2.1")
@@ -261,9 +266,3 @@
 ifdef MINIMIZE_RAM_USAGE
 CFLAGS += -DMINIMIZE_RAM_USAGE
 endif
-
-ifdef CROSS_COMPILE_ARCH
-  STRIP = $(ALT_COMPILER_PATH)/strip
-else
-  STRIP = strip
-endif
--- a/hotspot/make/linux/makefiles/sparcWorks.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/linux/makefiles/sparcWorks.make	Wed Jul 05 18:04:20 2017 +0200
@@ -25,12 +25,15 @@
 #------------------------------------------------------------------------
 # CC, CXX & AS
 
-CXX = CC
-CC  = cc
-AS  = $(CC) -c
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+  CXX = CC
+  CC  = cc
+  AS  = $(CC) -c
 
-HOSTCXX = $(CXX)
-HOSTCC  = $(CC)
+  HOSTCXX = $(CXX)
+  HOSTCC  = $(CC)
+endif
 
 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
 ARCHFLAG/i486    = -m32
--- a/hotspot/make/solaris/makefiles/buildtree.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/solaris/makefiles/buildtree.make	Wed Jul 05 18:04:20 2017 +0200
@@ -55,6 +55,7 @@
 # The makefiles are split this way so that "make foo" will run faster by not
 # having to read the dependency files for the vm.
 
+-include $(SPEC)
 include $(GAMMADIR)/make/scm.make
 include $(GAMMADIR)/make/altsrc.make
 
@@ -237,6 +238,8 @@
 	    echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
 	    echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
 	echo; \
+	[ -n "$(SPEC)" ] && \
+	    echo "include $(SPEC)"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
 	) > $@
--- a/hotspot/make/solaris/makefiles/gcc.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/solaris/makefiles/gcc.make	Wed Jul 05 18:04:20 2017 +0200
@@ -25,9 +25,13 @@
 #------------------------------------------------------------------------
 # CC, CXX & AS
 
-CXX = g++
-CC  = gcc
-AS  = $(CC) -c
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+  CXX = g++
+  CC  = gcc
+  AS  = $(CC) -c
+  MCS = /usr/ccs/bin/mcs
+endif
 
 Compiler = gcc
 
@@ -193,5 +197,3 @@
 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) 
 DEBUG_CFLAGS += -gstabs 
 endif 
-
-MCS = /usr/ccs/bin/mcs
--- a/hotspot/make/solaris/makefiles/sparcWorks.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/solaris/makefiles/sparcWorks.make	Wed Jul 05 18:04:20 2017 +0200
@@ -22,18 +22,22 @@
 #  
 #
 
-# Compiler-specific flags for sparcworks.
-
-# tell make which C and C++ compilers to use
-CC	= cc
-CXX	= CC
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+  # Compiler-specific flags for sparcworks.
+  CC	= cc
+  CXX	= CC
 
-# Note that this 'as' is an older version of the Sun Studio 'fbe', and will
-#   use the older style options. The 'fbe' options will match 'cc' and 'CC'.
-AS	= /usr/ccs/bin/as
+  # Note that this 'as' is an older version of the Sun Studio 'fbe', and will
+  #   use the older style options. The 'fbe' options will match 'cc' and 'CC'.
+  AS	= /usr/ccs/bin/as
 
-NM	= /usr/ccs/bin/nm
-NAWK    = /bin/nawk
+  NM    = /usr/ccs/bin/nm
+  NAWK  = /bin/nawk
+
+  MCS	= /usr/ccs/bin/mcs
+  STRIP	= /usr/ccs/bin/strip
+endif
 
 REORDER_FLAG = -xF
 
@@ -557,9 +561,6 @@
 #LINK_INTO = LIBJVM
 endif
 
-MCS	= /usr/ccs/bin/mcs
-STRIP	= /usr/ccs/bin/strip
-
 # Solaris platforms collect lots of redundant file-ident lines,
 # to the point of wasting a significant percentage of file space.
 # (The text is stored in ELF .comment sections, contributed by
--- a/hotspot/make/windows/build.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/windows/build.make	Wed Jul 05 18:04:20 2017 +0200
@@ -297,6 +297,10 @@
 	@ echo BUILDARCH=$(BUILDARCH)         			>> $@
 	@ echo Platform_arch=$(Platform_arch)        		>> $@
 	@ echo Platform_arch_model=$(Platform_arch_model)	>> $@
+	@ echo CXX=$(CXX)					>> $@
+	@ echo LD=$(LD)						>> $@
+	@ echo MT=$(MT)						>> $@
+	@ echo RC=$(RC)						>> $@
 	@ sh $(WorkSpace)/make/windows/get_msc_ver.sh		>> $@
 
 checks: checkVariant checkWorkSpace checkSA
--- a/hotspot/make/windows/makefiles/compile.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/windows/makefiles/compile.make	Wed Jul 05 18:04:20 2017 +0200
@@ -23,7 +23,9 @@
 #
 
 # Generic compiler settings
+!if "x$(CXX)" == "x"
 CXX=cl.exe
+!endif
 
 # CXX Flags: (these vary slightly from VC6->VS2003->VS2005 compilers)
 #   /nologo   Supress copyright message at every cl.exe startup
@@ -183,8 +185,10 @@
 LD_FLAGS = /manifest $(LD_FLAGS) $(BUFFEROVERFLOWLIB)
 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 # as resources inside build artifacts.
+!if "x$(MT)" == "x"
 MT=mt.exe
 !endif
+!endif
 
 !if "$(COMPILER_NAME)" == "VS2008"
 PRODUCT_OPT_OPTION   = /O2 /Oy-
@@ -194,8 +198,10 @@
 LD_FLAGS = /manifest $(LD_FLAGS)
 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 # as resources inside build artifacts.
+!if "x$(MT)" == "x"
 MT=mt.exe
 !endif
+!endif
 
 !if "$(COMPILER_NAME)" == "VS2010"
 PRODUCT_OPT_OPTION   = /O2 /Oy-
@@ -205,7 +211,9 @@
 LD_FLAGS = /manifest $(LD_FLAGS)
 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 # as resources inside build artifacts.
+!if "x$(MT)" == "x"
 MT=mt.exe
+!endif
 !if "$(BUILDARCH)" == "i486"
 LD_FLAGS = /SAFESEH $(LD_FLAGS)
 !endif
@@ -225,7 +233,9 @@
 !endif
 
 # Generic linker settings
+!if "x$(LD)" == "x"
 LD=link.exe
+!endif
 LD_FLAGS= $(LD_FLAGS) kernel32.lib user32.lib gdi32.lib winspool.lib \
  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
  uuid.lib Wsock32.lib winmm.lib /nologo /machine:$(MACHINE) /opt:REF \
@@ -237,7 +247,9 @@
 !endif
 
 # Resource compiler settings
+!if "x$(RC)" == "x"
 RC=rc.exe
+!endif
 RC_FLAGS=/D "HS_VER=$(HS_VER)" \
 	 /D "HS_DOTVER=$(HS_DOTVER)" \
 	 /D "HS_BUILD_ID=$(HS_BUILD_ID)" \
--- a/hotspot/make/windows/makefiles/defs.make	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/make/windows/makefiles/defs.make	Wed Jul 05 18:04:20 2017 +0200
@@ -202,3 +202,19 @@
   # Must pass this down to nmake.
   MAKE_ARGS += BUILD_WIN_SA=1
 endif
+
+# Propagate compiler and tools paths from configure to nmake. 
+# Need to make sure they contain \\ and not /.
+ifneq ($(SPEC),)
+  ifeq ($(USING_CYGWIN), true)
+    MAKE_ARGS += CXX="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(CXX)))"
+    MAKE_ARGS += LD="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(LD)))"
+    MAKE_ARGS += RC="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(RC)))"
+    MAKE_ARGS += MT="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(MT)))"
+  else
+    MAKE_ARGS += CXX="$(subst /,\\,$(CXX))"
+    MAKE_ARGS += LD="$(subst /,\\,$(LD))"
+    MAKE_ARGS += RC="$(subst /,\\,$(RC))"
+    MAKE_ARGS += MT="$(subst /,\\,$(MT))"
+  endif
+endif
--- a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -47,6 +47,12 @@
   assert(!(oop_result1->is_valid() || oop_result2->is_valid()) || oop_result1 != oop_result2, "registers must be different");
   assert(oop_result1 != thread && oop_result2 != thread, "registers must be different");
   assert(args_size >= 0, "illegal args_size");
+  bool align_stack = false;
+#ifdef _LP64
+  // At a method handle call, the stack may not be properly aligned
+  // when returning with an exception.
+  align_stack = (stub_id() == Runtime1::handle_exception_from_callee_id);
+#endif
 
 #ifdef _LP64
   mov(c_rarg0, thread);
@@ -59,11 +65,21 @@
   push(thread);
 #endif // _LP64
 
-  set_last_Java_frame(thread, noreg, rbp, NULL);
+  int call_offset;
+  if (!align_stack) {
+    set_last_Java_frame(thread, noreg, rbp, NULL);
+  } else {
+    address the_pc = pc();
+    call_offset = offset();
+    set_last_Java_frame(thread, noreg, rbp, the_pc);
+    andptr(rsp, -(StackAlignmentInBytes));    // Align stack
+  }
 
   // do the call
   call(RuntimeAddress(entry));
-  int call_offset = offset();
+  if (!align_stack) {
+    call_offset = offset();
+  }
   // verify callee-saved register
 #ifdef ASSERT
   guarantee(thread != rax, "change this code");
@@ -78,7 +94,7 @@
   }
   pop(rax);
 #endif
-  reset_last_Java_frame(thread, true, false);
+  reset_last_Java_frame(thread, true, align_stack);
 
   // discard thread and arguments
   NOT_LP64(addptr(rsp, num_rt_args()*BytesPerWord));
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -1181,14 +1181,13 @@
                                       BasicType* in_sig_bt) {
   // if map is non-NULL then the code should store the values,
   // otherwise it should load them.
-  int handle_index = 0;
+  int slot = arg_save_area;
   // Save down double word first
   for ( int i = 0; i < total_in_args; i++) {
     if (in_regs[i].first()->is_XMMRegister() && in_sig_bt[i] == T_DOUBLE) {
-      int slot = handle_index * VMRegImpl::slots_per_word + arg_save_area;
       int offset = slot * VMRegImpl::stack_slot_size;
-      handle_index += 2;
-      assert(handle_index <= stack_slots, "overflow");
+      slot += VMRegImpl::slots_per_word;
+      assert(slot <= stack_slots, "overflow");
       if (map != NULL) {
         __ movdbl(Address(rsp, offset), in_regs[i].first()->as_XMMRegister());
       } else {
@@ -1197,10 +1196,7 @@
     }
     if (in_regs[i].first()->is_Register() &&
         (in_sig_bt[i] == T_LONG || in_sig_bt[i] == T_ARRAY)) {
-      int slot = handle_index * VMRegImpl::slots_per_word + arg_save_area;
       int offset = slot * VMRegImpl::stack_slot_size;
-      handle_index += 2;
-      assert(handle_index <= stack_slots, "overflow");
       if (map != NULL) {
         __ movq(Address(rsp, offset), in_regs[i].first()->as_Register());
         if (in_sig_bt[i] == T_ARRAY) {
@@ -1209,14 +1205,15 @@
       } else {
         __ movq(in_regs[i].first()->as_Register(), Address(rsp, offset));
       }
+      slot += VMRegImpl::slots_per_word;
     }
   }
   // Save or restore single word registers
   for ( int i = 0; i < total_in_args; i++) {
     if (in_regs[i].first()->is_Register()) {
-      int slot = handle_index++ * VMRegImpl::slots_per_word + arg_save_area;
       int offset = slot * VMRegImpl::stack_slot_size;
-      assert(handle_index <= stack_slots, "overflow");
+      slot++;
+      assert(slot <= stack_slots, "overflow");
 
       // Value is in an input register pass we must flush it to the stack
       const Register reg = in_regs[i].first()->as_Register();
@@ -1241,9 +1238,9 @@
       }
     } else if (in_regs[i].first()->is_XMMRegister()) {
       if (in_sig_bt[i] == T_FLOAT) {
-        int slot = handle_index++ * VMRegImpl::slots_per_word + arg_save_area;
         int offset = slot * VMRegImpl::stack_slot_size;
-        assert(handle_index <= stack_slots, "overflow");
+        slot++;
+        assert(slot <= stack_slots, "overflow");
         if (map != NULL) {
           __ movflt(Address(rsp, offset), in_regs[i].first()->as_XMMRegister());
         } else {
@@ -1368,6 +1365,174 @@
   __ bind(done);
 }
 
+
+class ComputeMoveOrder: public StackObj {
+  class MoveOperation: public ResourceObj {
+    friend class ComputeMoveOrder;
+   private:
+    VMRegPair        _src;
+    VMRegPair        _dst;
+    int              _src_index;
+    int              _dst_index;
+    bool             _processed;
+    MoveOperation*  _next;
+    MoveOperation*  _prev;
+
+    static int get_id(VMRegPair r) {
+      return r.first()->value();
+    }
+
+   public:
+    MoveOperation(int src_index, VMRegPair src, int dst_index, VMRegPair dst):
+      _src(src)
+    , _src_index(src_index)
+    , _dst(dst)
+    , _dst_index(dst_index)
+    , _next(NULL)
+    , _prev(NULL)
+    , _processed(false) {
+    }
+
+    VMRegPair src() const              { return _src; }
+    int src_id() const                 { return get_id(src()); }
+    int src_index() const              { return _src_index; }
+    VMRegPair dst() const              { return _dst; }
+    void set_dst(int i, VMRegPair dst) { _dst_index = i, _dst = dst; }
+    int dst_index() const              { return _dst_index; }
+    int dst_id() const                 { return get_id(dst()); }
+    MoveOperation* next() const       { return _next; }
+    MoveOperation* prev() const       { return _prev; }
+    void set_processed()               { _processed = true; }
+    bool is_processed() const          { return _processed; }
+
+    // insert
+    void break_cycle(VMRegPair temp_register) {
+      // create a new store following the last store
+      // to move from the temp_register to the original
+      MoveOperation* new_store = new MoveOperation(-1, temp_register, dst_index(), dst());
+
+      // break the cycle of links and insert new_store at the end
+      // break the reverse link.
+      MoveOperation* p = prev();
+      assert(p->next() == this, "must be");
+      _prev = NULL;
+      p->_next = new_store;
+      new_store->_prev = p;
+
+      // change the original store to save it's value in the temp.
+      set_dst(-1, temp_register);
+    }
+
+    void link(GrowableArray<MoveOperation*>& killer) {
+      // link this store in front the store that it depends on
+      MoveOperation* n = killer.at_grow(src_id(), NULL);
+      if (n != NULL) {
+        assert(_next == NULL && n->_prev == NULL, "shouldn't have been set yet");
+        _next = n;
+        n->_prev = this;
+      }
+    }
+  };
+
+ private:
+  GrowableArray<MoveOperation*> edges;
+
+ public:
+  ComputeMoveOrder(int total_in_args, VMRegPair* in_regs, int total_c_args, VMRegPair* out_regs,
+                    BasicType* in_sig_bt, GrowableArray<int>& arg_order, VMRegPair tmp_vmreg) {
+    // Move operations where the dest is the stack can all be
+    // scheduled first since they can't interfere with the other moves.
+    for (int i = total_in_args - 1, c_arg = total_c_args - 1; i >= 0; i--, c_arg--) {
+      if (in_sig_bt[i] == T_ARRAY) {
+        c_arg--;
+        if (out_regs[c_arg].first()->is_stack() &&
+            out_regs[c_arg + 1].first()->is_stack()) {
+          arg_order.push(i);
+          arg_order.push(c_arg);
+        } else {
+          if (out_regs[c_arg].first()->is_stack() ||
+              in_regs[i].first() == out_regs[c_arg].first()) {
+            add_edge(i, in_regs[i].first(), c_arg, out_regs[c_arg + 1]);
+          } else {
+            add_edge(i, in_regs[i].first(), c_arg, out_regs[c_arg]);
+          }
+        }
+      } else if (in_sig_bt[i] == T_VOID) {
+        arg_order.push(i);
+        arg_order.push(c_arg);
+      } else {
+        if (out_regs[c_arg].first()->is_stack() ||
+            in_regs[i].first() == out_regs[c_arg].first()) {
+          arg_order.push(i);
+          arg_order.push(c_arg);
+        } else {
+          add_edge(i, in_regs[i].first(), c_arg, out_regs[c_arg]);
+        }
+      }
+    }
+    // Break any cycles in the register moves and emit the in the
+    // proper order.
+    GrowableArray<MoveOperation*>* stores = get_store_order(tmp_vmreg);
+    for (int i = 0; i < stores->length(); i++) {
+      arg_order.push(stores->at(i)->src_index());
+      arg_order.push(stores->at(i)->dst_index());
+    }
+ }
+
+  // Collected all the move operations
+  void add_edge(int src_index, VMRegPair src, int dst_index, VMRegPair dst) {
+    if (src.first() == dst.first()) return;
+    edges.append(new MoveOperation(src_index, src, dst_index, dst));
+  }
+
+  // Walk the edges breaking cycles between moves.  The result list
+  // can be walked in order to produce the proper set of loads
+  GrowableArray<MoveOperation*>* get_store_order(VMRegPair temp_register) {
+    // Record which moves kill which values
+    GrowableArray<MoveOperation*> killer;
+    for (int i = 0; i < edges.length(); i++) {
+      MoveOperation* s = edges.at(i);
+      assert(killer.at_grow(s->dst_id(), NULL) == NULL, "only one killer");
+      killer.at_put_grow(s->dst_id(), s, NULL);
+    }
+    assert(killer.at_grow(MoveOperation::get_id(temp_register), NULL) == NULL,
+           "make sure temp isn't in the registers that are killed");
+
+    // create links between loads and stores
+    for (int i = 0; i < edges.length(); i++) {
+      edges.at(i)->link(killer);
+    }
+
+    // at this point, all the move operations are chained together
+    // in a doubly linked list.  Processing it backwards finds
+    // the beginning of the chain, forwards finds the end.  If there's
+    // a cycle it can be broken at any point,  so pick an edge and walk
+    // backward until the list ends or we end where we started.
+    GrowableArray<MoveOperation*>* stores = new GrowableArray<MoveOperation*>();
+    for (int e = 0; e < edges.length(); e++) {
+      MoveOperation* s = edges.at(e);
+      if (!s->is_processed()) {
+        MoveOperation* start = s;
+        // search for the beginning of the chain or cycle
+        while (start->prev() != NULL && start->prev() != s) {
+          start = start->prev();
+        }
+        if (start->prev() == s) {
+          start->break_cycle(temp_register);
+        }
+        // walk the chain forward inserting to store list
+        while (start != NULL) {
+          stores->append(start);
+          start->set_processed();
+          start = start->next();
+        }
+      }
+    }
+    return stores;
+  }
+};
+
+
 // ---------------------------------------------------------------------------
 // Generate a native wrapper for a given method.  The method takes arguments
 // in the Java compiled code convention, marshals them to the native
@@ -1488,12 +1653,12 @@
       if (in_regs[i].first()->is_Register()) {
         const Register reg = in_regs[i].first()->as_Register();
         switch (in_sig_bt[i]) {
-          case T_ARRAY:
           case T_BOOLEAN:
           case T_BYTE:
           case T_SHORT:
           case T_CHAR:
           case T_INT:  single_slots++; break;
+          case T_ARRAY:
           case T_LONG: double_slots++; break;
           default:  ShouldNotReachHere();
         }
@@ -1690,36 +1855,43 @@
 
 #endif /* ASSERT */
 
-  if (is_critical_native) {
-    // The mapping of Java and C arguments passed in registers are
-    // rotated by one, which helps when passing arguments to regular
-    // Java method but for critical natives that creates a cycle which
-    // can cause arguments to be killed before they are used.  Break
-    // the cycle by moving the first argument into a temporary
-    // register.
-    for (int i = 0; i < total_c_args; i++) {
-      if (in_regs[i].first()->is_Register() &&
-          in_regs[i].first()->as_Register() == rdi) {
-        __ mov(rbx, rdi);
-        in_regs[i].set1(rbx->as_VMReg());
-      }
-    }
-  }
-
   // This may iterate in two different directions depending on the
   // kind of native it is.  The reason is that for regular JNI natives
   // the incoming and outgoing registers are offset upwards and for
   // critical natives they are offset down.
-  int c_arg = total_c_args - 1;
-  int stride = -1;
-  int init = total_in_args - 1;
-  if (is_critical_native) {
-    // stride forwards
-    c_arg = 0;
-    stride = 1;
-    init = 0;
+  GrowableArray<int> arg_order(2 * total_in_args);
+  VMRegPair tmp_vmreg;
+  tmp_vmreg.set1(rbx->as_VMReg());
+
+  if (!is_critical_native) {
+    for (int i = total_in_args - 1, c_arg = total_c_args - 1; i >= 0; i--, c_arg--) {
+      arg_order.push(i);
+      arg_order.push(c_arg);
+    }
+  } else {
+    // Compute a valid move order, using tmp_vmreg to break any cycles
+    ComputeMoveOrder cmo(total_in_args, in_regs, total_c_args, out_regs, in_sig_bt, arg_order, tmp_vmreg);
   }
-  for (int i = init, count = 0; count < total_in_args; i += stride, c_arg += stride, count++ ) {
+
+  int temploc = -1;
+  for (int ai = 0; ai < arg_order.length(); ai += 2) {
+    int i = arg_order.at(ai);
+    int c_arg = arg_order.at(ai + 1);
+    __ block_comment(err_msg("move %d -> %d", i, c_arg));
+    if (c_arg == -1) {
+      assert(is_critical_native, "should only be required for critical natives");
+      // This arg needs to be moved to a temporary
+      __ mov(tmp_vmreg.first()->as_Register(), in_regs[i].first()->as_Register());
+      in_regs[i] = tmp_vmreg;
+      temploc = i;
+      continue;
+    } else if (i == -1) {
+      assert(is_critical_native, "should only be required for critical natives");
+      // Read from the temporary location
+      assert(temploc != -1, "must be valid");
+      i = temploc;
+      temploc = -1;
+    }
 #ifdef ASSERT
     if (in_regs[i].first()->is_Register()) {
       assert(!reg_destroyed[in_regs[i].first()->as_Register()->encoding()], "destroyed reg!");
@@ -1779,7 +1951,7 @@
 
   // point c_arg at the first arg that is already loaded in case we
   // need to spill before we call out
-  c_arg++;
+  int c_arg = total_c_args - total_in_args;
 
   // Pre-load a static method's oop into r14.  Used both by locking code and
   // the normal JNI call code.
@@ -3620,8 +3792,12 @@
   //
   // address OptoRuntime::handle_exception_C(JavaThread* thread)
 
-  __ set_last_Java_frame(noreg, noreg, NULL);
+  // At a method handle call, the stack may not be properly aligned
+  // when returning with an exception.
+  address the_pc = __ pc();
+  __ set_last_Java_frame(noreg, noreg, the_pc);
   __ mov(c_rarg0, r15_thread);
+  __ andptr(rsp, -(StackAlignmentInBytes));    // Align stack
   __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C)));
 
   // Set an oopmap for the call site.  This oopmap will only be used if we
@@ -3632,9 +3808,9 @@
 
   OopMapSet* oop_maps = new OopMapSet();
 
-  oop_maps->add_gc_map( __ pc()-start, new OopMap(SimpleRuntimeFrame::framesize, 0));
-
-  __ reset_last_Java_frame(false, false);
+  oop_maps->add_gc_map(the_pc - start, new OopMap(SimpleRuntimeFrame::framesize, 0));
+
+  __ reset_last_Java_frame(false, true);
 
   // Restore callee-saved registers
 
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -710,6 +710,21 @@
     return start;
   }
 
+  // Support for intptr_t get_previous_sp()
+  //
+  // This routine is used to find the previous stack pointer for the
+  // caller.
+  address generate_get_previous_sp() {
+    StubCodeMark mark(this, "StubRoutines", "get_previous_sp");
+    address start = __ pc();
+
+    __ movptr(rax, rsp);
+    __ addptr(rax, 8); // return address is at the top of the stack.
+    __ ret(0);
+
+    return start;
+  }
+
   //----------------------------------------------------------------------------------------------------
   // Support for void verify_mxcsr()
   //
@@ -3060,6 +3075,7 @@
 
     // platform dependent
     StubRoutines::x86::_get_previous_fp_entry = generate_get_previous_fp();
+    StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp();
 
     StubRoutines::x86::_verify_mxcsr_entry    = generate_verify_mxcsr();
 
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86_64.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86_64.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -43,6 +43,7 @@
 // a description of how to extend it, see the stubRoutines.hpp file.
 
 address StubRoutines::x86::_get_previous_fp_entry = NULL;
+address StubRoutines::x86::_get_previous_sp_entry = NULL;
 
 address StubRoutines::x86::_verify_mxcsr_entry = NULL;
 
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86_64.hpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86_64.hpp	Wed Jul 05 18:04:20 2017 +0200
@@ -41,6 +41,7 @@
 
  private:
   static address _get_previous_fp_entry;
+  static address _get_previous_sp_entry;
   static address _verify_mxcsr_entry;
 
   static address _f2i_fixup;
@@ -61,6 +62,11 @@
     return _get_previous_fp_entry;
   }
 
+  static address get_previous_sp_entry()
+  {
+    return _get_previous_sp_entry;
+  }
+
   static address verify_mxcsr_entry()
   {
     return _verify_mxcsr_entry;
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -4690,14 +4690,12 @@
                      char *addr, size_t bytes, bool read_only,
                      bool allow_exec) {
   int prot;
-  int flags;
+  int flags = MAP_PRIVATE;
 
   if (read_only) {
     prot = PROT_READ;
-    flags = MAP_SHARED;
   } else {
     prot = PROT_READ | PROT_WRITE;
-    flags = MAP_PRIVATE;
   }
 
   if (allow_exec) {
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -1013,15 +1013,6 @@
   // use debugger to set breakpoint here
 }
 
-// Returns an estimate of the current stack pointer. Result must be guaranteed to
-// point into the calling threads stack, and be no lower than the current stack
-// pointer.
-address os::current_stack_pointer() {
-  volatile int dummy;
-  address sp = (address)&dummy + 8;     // %%%% need to confirm if this is right
-  return sp;
-}
-
 static thread_t main_thread;
 
 // Thread start routine for all new Java threads
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -324,16 +324,6 @@
   os::breakpoint();
 }
 
-// Returns an estimate of the current stack pointer. Result must be guaranteed
-// to point into the calling threads stack, and be no lower than the current
-// stack pointer.
-
-address os::current_stack_pointer() {
-  int dummy;
-  address sp = (address)&dummy;
-  return sp;
-}
-
 // os::current_stack_base()
 //
 //   Returns the base of the stack, which is the stack's
--- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -1126,3 +1126,8 @@
                       : "r" (fpu_cntrl) : "memory");
 #endif // !AMD64
 }
+
+#ifndef PRODUCT
+void os::verify_stack_alignment() {
+}
+#endif
--- a/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -562,3 +562,8 @@
   }
 };
 #endif // !_LP64
+
+#ifndef PRODUCT
+void os::verify_stack_alignment() {
+}
+#endif
--- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -756,3 +756,8 @@
   // guard page, only enable glibc guard page for non-Java threads.
   return (thr_type == java_thread ? 0 : page_size());
 }
+
+#ifndef PRODUCT
+void os::verify_stack_alignment() {
+}
+#endif
--- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -862,3 +862,11 @@
                       : "r" (fpu_cntrl) : "memory");
 #endif // !AMD64
 }
+
+#ifndef PRODUCT
+void os::verify_stack_alignment() {
+#ifdef AMD64
+  assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
+#endif
+}
+#endif
--- a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -506,3 +506,8 @@
   }
 };
 #endif // !_LP64
+
+#ifndef PRODUCT
+void os::verify_stack_alignment() {
+}
+#endif
--- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -251,6 +251,15 @@
   return frame(fr->sender_sp(), frame::unpatchable, fr->sender_pc());
 }
 
+// Returns an estimate of the current stack pointer. Result must be guaranteed to
+// point into the calling threads stack, and be no lower than the current stack
+// pointer.
+address os::current_stack_pointer() {
+  volatile int dummy;
+  address sp = (address)&dummy + 8;     // %%%% need to confirm if this is right
+  return sp;
+}
+
 frame os::current_frame() {
   intptr_t* sp = StubRoutines::Sparc::flush_callers_register_windows_func()();
   frame myframe(sp, frame::unpatchable,
@@ -815,3 +824,8 @@
    __asm__ __volatile__ ("wr %%g0, 0, %%fprs \n\t" : : :);
   }
 #endif //defined(__sparc) && defined(COMPILER2)
+
+#ifndef PRODUCT
+void os::verify_stack_alignment() {
+}
+#endif
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -237,6 +237,12 @@
   return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
 }
 
+extern "C" intptr_t *_get_current_sp();  // in .il file
+
+address os::current_stack_pointer() {
+  return (address)_get_current_sp();
+}
+
 extern "C" intptr_t *_get_current_fp();  // in .il file
 
 frame os::current_frame() {
@@ -954,3 +960,11 @@
   _solaris_raw_setup_fpu(fpu_cntrl);
 }
 #endif // AMD64
+
+#ifndef PRODUCT
+void os::verify_stack_alignment() {
+#ifdef AMD64
+  assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
+#endif
+}
+#endif
--- a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.il	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.il	Wed Jul 05 18:04:20 2017 +0200
@@ -37,6 +37,12 @@
       movl     %gs:0, %eax 
       .end
 
+  // Get current sp
+      .inline _get_current_sp,0
+      .volatile
+      movl     %esp, %eax 
+      .end
+
   // Get current fp
       .inline _get_current_fp,0
       .volatile
--- a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.il	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.il	Wed Jul 05 18:04:20 2017 +0200
@@ -30,6 +30,12 @@
       movq     %fs:0, %rax 
       .end
 
+  // Get current sp
+      .inline _get_current_sp,0
+      .volatile
+      movq     %rsp, %rax 
+      .end
+
   // Get current fp
       .inline _get_current_fp,0
       .volatile
--- a/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -370,6 +370,26 @@
   return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
 }
 
+#ifndef AMD64
+// Returns an estimate of the current stack pointer. Result must be guaranteed
+// to point into the calling threads stack, and be no lower than the current
+// stack pointer.
+address os::current_stack_pointer() {
+  int dummy;
+  address sp = (address)&dummy;
+  return sp;
+}
+#else
+// Returns the current stack pointer. Accurate value needed for
+// os::verify_stack_alignment().
+address os::current_stack_pointer() {
+  typedef address get_sp_func();
+  get_sp_func* func = CAST_TO_FN_PTR(get_sp_func*,
+                                     StubRoutines::x86::get_previous_sp_entry());
+  return (*func)();
+}
+#endif
+
 
 #ifndef AMD64
 intptr_t* _get_previous_fp() {
@@ -546,3 +566,11 @@
   __asm fldcw fpu_cntrl_word;
 #endif // !AMD64
 }
+
+#ifndef PRODUCT
+void os::verify_stack_alignment() {
+#ifdef AMD64
+  assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
+#endif
+}
+#endif
--- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
     private boolean osr;
     private Method method;
     private CallSite call = new CallSite();
+    private CallSite lateInlineCall = new CallSite();
     private int osrBci;
     private String icount;
     private String bcount;
@@ -80,6 +81,13 @@
             sb.append(site);
             sb.append("\n");
         }
+        if (getLateInlineCall().getCalls() != null) {
+            sb.append("late inline:\n");
+            for (CallSite site : getLateInlineCall().getCalls()) {
+                sb.append(site);
+                sb.append("\n");
+            }
+        }
         return sb.toString();
     }
 
@@ -115,6 +123,12 @@
                     site.print(stream, indent + 2);
                 }
             }
+            if (printInlining && lateInlineCall.getCalls() != null) {
+                stream.println("late inline:");
+                for (CallSite site : lateInlineCall.getCalls()) {
+                    site.print(stream, indent + 2);
+                }
+            }
         }
     }
 
@@ -215,7 +229,11 @@
     }
 
     public void setMethod(Method method) {
-        this.method = method;
+        // Don't change method if it is already set to avoid changing
+        // it by post parse inlining info.
+        if (getMethod() == null) {
+            this.method = method;
+        }
     }
 
     public CallSite getCall() {
@@ -226,6 +244,10 @@
         this.call = call;
     }
 
+    public CallSite getLateInlineCall() {
+        return lateInlineCall;
+    }
+
     public double getElapsedTime() {
         return end - start;
     }
--- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -146,6 +146,7 @@
     private CallSite site;
     private Stack<Phase> phaseStack = new Stack<Phase>();
     private UncommonTrapEvent currentTrap;
+    private Stack<CallSite> late_inline_scope;
 
     long parseLong(String l) {
         try {
@@ -302,6 +303,7 @@
             }
             events.add(compile);
             compiles.put(makeId(atts), compile);
+            site = compile.getCall();
         } else if (qname.equals("type")) {
             type(search(atts, "id"), search(atts, "name"));
         } else if (qname.equals("bc")) {
@@ -360,12 +362,22 @@
                 // uncommon trap inserted during parsing.
                 // ignore for now
             }
+        } else if (qname.equals("late_inline")) {
+            late_inline_scope = new Stack<CallSite>();
+            site = new CallSite(-999, method(search(atts, "method")));
+            late_inline_scope.push(site);
         } else if (qname.equals("jvms")) {
             // <jvms bci='4' method='java/io/DataInputStream readChar ()C' bytes='40' count='5815' iicount='20815'/>
             if (currentTrap != null) {
                 currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci")));
+            } else if (late_inline_scope != null) {
+                bci = Integer.parseInt(search(atts, "bci"));
+                site = new CallSite(bci, method(search(atts, "method")));
+                late_inline_scope.push(site);
             } else {
-                // Ignore <eliminate_allocation type='667'> and <eliminate_lock lock='1'>
+                // Ignore <eliminate_allocation type='667'>,
+                //        <eliminate_lock lock='1'>,
+                //        <replace_string_concat arguments='2' string_alloc='0' multiple='0'>
             }
         } else if (qname.equals("nmethod")) {
             String id = makeId(atts);
@@ -379,7 +391,7 @@
             Method m = method(search(atts, "method"));
             if (scopes.size() == 0) {
                 compile.setMethod(m);
-                scopes.push(compile.getCall());
+                scopes.push(site);
             } else {
                 if (site.getMethod() == m) {
                     scopes.push(site);
@@ -393,7 +405,7 @@
             }
         } else if (qname.equals("parse_done")) {
             CallSite call = scopes.pop();
-            call.setEndNodes(Integer.parseInt(search(atts, "nodes")));
+            call.setEndNodes(Integer.parseInt(search(atts, "nodes", "1")));
             call.setTimeStamp(Double.parseDouble(search(atts, "stamp")));
             scopes.push(call);
         }
@@ -408,6 +420,43 @@
             scopes.pop();
         } else if (qname.equals("uncommon_trap")) {
             currentTrap = null;
+        } else if (qname.equals("late_inline")) {
+            // Populate late inlining info.
+
+            // late_inline scopes are specified in reverse order:
+            // compiled method should be on top of stack.
+            CallSite caller = late_inline_scope.pop();
+            Method m = compile.getMethod();
+            if (m != caller.getMethod()) {
+                System.out.println(m);
+                System.out.println(caller.getMethod() + " bci: " + bci);
+                throw new InternalError("call site and late_inline info don't match");
+            }
+
+            // late_inline contains caller+bci info, convert it
+            // to bci+callee info used by LogCompilation.
+            site = compile.getLateInlineCall();
+            do {
+                bci = caller.getBci();
+                // Next inlined call.
+                caller = late_inline_scope.pop();
+                CallSite callee =  new CallSite(bci, caller.getMethod());
+                site.add(callee);
+                site = callee;
+            } while (!late_inline_scope.empty());
+
+            if (caller.getBci() != -999) {
+                System.out.println(caller.getMethod());
+                throw new InternalError("broken late_inline info");
+            }
+            if (site.getMethod() != caller.getMethod()) {
+                System.out.println(site.getMethod());
+                System.out.println(caller.getMethod());
+                throw new InternalError("call site and late_inline info don't match");
+            }
+            // late_inline is followed by parse with scopes.size() == 0,
+            // 'site' will be pushed to scopes.
+            late_inline_scope = null;
         } else if (qname.equals("task")) {
             types.clear();
             methods.clear();
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -1884,7 +1884,7 @@
 
   if (move_resolver.has_mappings()) {
     // insert moves after first instruction
-    move_resolver.set_insert_position(block->lir(), 1);
+    move_resolver.set_insert_position(block->lir(), 0);
     move_resolver.resolve_and_append_moves();
   }
 }
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -509,6 +509,9 @@
   template(clear_name,                                 "clear")                                                   \
   template(trigger_method_signature,                   "(ILjava/lang/management/MemoryUsage;)V")                                                 \
   template(startAgent_name,                            "startAgent")                                              \
+  template(startRemoteAgent_name,                      "startRemoteManagementAgent")                              \
+  template(startLocalAgent_name,                       "startLocalManagementAgent")                               \
+  template(stopRemoteAgent_name,                       "stopRemoteManagementAgent")                               \
   template(java_lang_management_ThreadInfo_constructor_signature, "(Ljava/lang/Thread;ILjava/lang/Object;Ljava/lang/Thread;JJJJ[Ljava/lang/StackTraceElement;)V") \
   template(java_lang_management_ThreadInfo_with_locks_constructor_signature, "(Ljava/lang/Thread;ILjava/lang/Object;Ljava/lang/Thread;JJJJ[Ljava/lang/StackTraceElement;[Ljava/lang/Object;[I[Ljava/lang/Object;)V") \
   template(long_long_long_long_void_signature,         "(JJJJ)V")                                                 \
--- a/hotspot/src/share/vm/oops/cpCacheOop.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/vm/oops/cpCacheOop.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -504,17 +504,17 @@
 
 void ConstantPoolCacheEntry::print(outputStream* st, int index) const {
   // print separator
-  if (index == 0) tty->print_cr("                 -------------");
+  if (index == 0) st->print_cr("                 -------------");
   // print entry
-  tty->print("%3d  ("PTR_FORMAT")  ", index, (intptr_t)this);
+  st->print("%3d  ("PTR_FORMAT")  ", index, (intptr_t)this);
   if (is_secondary_entry())
-    tty->print_cr("[%5d|secondary]", main_entry_index());
+    st->print_cr("[%5d|secondary]", main_entry_index());
   else
-    tty->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index());
-  tty->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)(oop)_f1);
-  tty->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)_f2);
-  tty->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)_flags);
-  tty->print_cr("                 -------------");
+    st->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index());
+  st->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)(oop)_f1);
+  st->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)_f2);
+  st->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)_flags);
+  st->print_cr("                 -------------");
 }
 
 void ConstantPoolCacheEntry::verify(outputStream* st) const {
--- a/hotspot/src/share/vm/opto/connode.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/vm/opto/connode.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1051,6 +1051,7 @@
 //------------------------------Value------------------------------------------
 const Type *CastX2PNode::Value( PhaseTransform *phase ) const {
   const Type* t = phase->type(in(1));
+  if (t == Type::TOP) return Type::TOP;
   if (t->base() == Type_X && t->singleton()) {
     uintptr_t bits = (uintptr_t) t->is_intptr_t()->get_con();
     if (bits == 0)   return TypePtr::NULL_PTR;
@@ -1121,6 +1122,7 @@
 //------------------------------Value------------------------------------------
 const Type *CastP2XNode::Value( PhaseTransform *phase ) const {
   const Type* t = phase->type(in(1));
+  if (t == Type::TOP) return Type::TOP;
   if (t->base() == Type::RawPtr && t->singleton()) {
     uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con();
     return TypeX::make(bits);
--- a/hotspot/src/share/vm/opto/escape.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/vm/opto/escape.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -2035,40 +2035,14 @@
           Node* store = ini->find_captured_store(offset, type2aelembytes(ft), phase);
           if (store != NULL && store->is_Store()) {
             value = store->in(MemNode::ValueIn);
-          } else if (ptn->edge_count() > 0) { // Are there oop stores?
-            // Check for a store which follows allocation without branches.
+          } else {
+            // There could be initializing stores which follow allocation.
             // For example, a volatile field store is not collected
-            // by Initialize node. TODO: it would be nice to use idom() here.
-            //
-            // Search all references to the same field which use different
-            // AddP nodes, for example, in the next case:
-            //
-            //    Point p[] = new Point[1];
-            //    if ( x ) { p[0] = new Point(); p[0].x = x; }
-            //    if ( p[0] != null ) { y = p[0].x; } // has CastPP
+            // by Initialize node.
             //
-            for (uint next = ei; (next < ae_cnt) && (value == NULL); next++) {
-              uint fpi = pta->edge_target(next); // Field (AddP)
-              PointsToNode *ptf = ptnode_adr(fpi);
-              if (ptf->offset() == offset) {
-                Node* nf = ptf->_node;
-                for (DUIterator_Fast imax, i = nf->fast_outs(imax); i < imax; i++) {
-                  store = nf->fast_out(i);
-                  if (store->is_Store() && store->in(0) != NULL) {
-                    Node* ctrl = store->in(0);
-                    while(!(ctrl == ini || ctrl == alloc || ctrl == NULL ||
-                            ctrl == C->root() || ctrl == C->top() || ctrl->is_Region() ||
-                            ctrl->is_IfTrue() || ctrl->is_IfFalse())) {
-                       ctrl = ctrl->in(0);
-                    }
-                    if (ctrl == ini || ctrl == alloc) {
-                      value = store->in(MemNode::ValueIn);
-                      break;
-                    }
-                  }
-                }
-              }
-            }
+            // Need to check for dependent loads to separate such stores from
+            // stores which follow loads. For now, add initial value NULL so
+            // that compare pointers optimization works correctly.
           }
         }
         if (value == NULL || value != ptnode_adr(value->_idx)->_node) {
--- a/hotspot/src/share/vm/runtime/interfaceSupport.hpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/vm/runtime/interfaceSupport.hpp	Wed Jul 05 18:04:20 2017 +0200
@@ -436,6 +436,7 @@
 #define VM_LEAF_BASE(result_type, header)                            \
   TRACE_CALL(result_type, header)                                    \
   debug_only(NoHandleMark __hm;)                                     \
+  os::verify_stack_alignment();                                      \
   /* begin of body */
 
 
@@ -445,6 +446,7 @@
   TRACE_CALL(result_type, header)                                    \
   HandleMarkCleaner __hm(thread);                                    \
   Thread* THREAD = thread;                                           \
+  os::verify_stack_alignment();                                      \
   /* begin of body */
 
 
@@ -454,6 +456,7 @@
   TRACE_CALL(result_type, header)                                    \
   debug_only(NoHandleMark __hm;)                                     \
   Thread* THREAD = thread;                                           \
+  os::verify_stack_alignment();                                      \
   /* begin of body */
 
 
--- a/hotspot/src/share/vm/runtime/os.hpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/vm/runtime/os.hpp	Wed Jul 05 18:04:20 2017 +0200
@@ -404,6 +404,8 @@
   static address current_stack_base();
   static size_t current_stack_size();
 
+  static void verify_stack_alignment() PRODUCT_RETURN;
+
   static int message_box(const char* title, const char* message);
   static char* do_you_want_to_debug(const char* message);
 
--- a/hotspot/src/share/vm/services/diagnosticCommand.cpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,6 +49,11 @@
   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(true, false));
   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(true, false));
 
+  //Enhanced JMX Agent Support
+  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(true,false));
+  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(true,false));
+  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(true,false));
+
 }
 
 #ifndef HAVE_EXTRA_DCMD
@@ -344,3 +349,185 @@
     return 0;
   }
 }
+
+// Enhanced JMX Agent support
+
+JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) :
+
+  DCmdWithParser(output, heap_allocated),
+
+  _config_file
+  ("config.file",
+   "set com.sun.management.config.file", "STRING", false),
+
+  _jmxremote_port
+  ("jmxremote.port",
+   "set com.sun.management.jmxremote.port", "STRING", false),
+
+  _jmxremote_rmi_port
+  ("jmxremote.rmi.port",
+   "set com.sun.management.jmxremote.rmi.port", "STRING", false),
+
+  _jmxremote_ssl
+  ("jmxremote.ssl",
+   "set com.sun.management.jmxremote.ssl", "STRING", false),
+
+  _jmxremote_registry_ssl
+  ("jmxremote.registry.ssl",
+   "set com.sun.management.jmxremote.registry.ssl", "STRING", false),
+
+  _jmxremote_authenticate
+  ("jmxremote.authenticate",
+   "set com.sun.management.jmxremote.authenticate", "STRING", false),
+
+  _jmxremote_password_file
+  ("jmxremote.password.file",
+   "set com.sun.management.jmxremote.password.file", "STRING", false),
+
+  _jmxremote_access_file
+  ("jmxremote.access.file",
+   "set com.sun.management.jmxremote.access.file", "STRING", false),
+
+  _jmxremote_login_config
+  ("jmxremote.login.config",
+   "set com.sun.management.jmxremote.login.config", "STRING", false),
+
+  _jmxremote_ssl_enabled_cipher_suites
+  ("jmxremote.ssl.enabled.cipher.suites",
+   "set com.sun.management.jmxremote.ssl.enabled.cipher.suite", "STRING", false),
+
+  _jmxremote_ssl_enabled_protocols
+  ("jmxremote.ssl.enabled.protocols",
+   "set com.sun.management.jmxremote.ssl.enabled.protocols", "STRING", false),
+
+  _jmxremote_ssl_need_client_auth
+  ("jmxremote.ssl.need.client.auth",
+   "set com.sun.management.jmxremote.need.client.auth", "STRING", false),
+
+  _jmxremote_ssl_config_file
+  ("jmxremote.ssl.config.file",
+   "set com.sun.management.jmxremote.ssl_config_file", "STRING", false)
+
+  {
+    _dcmdparser.add_dcmd_option(&_config_file);
+    _dcmdparser.add_dcmd_option(&_jmxremote_port);
+    _dcmdparser.add_dcmd_option(&_jmxremote_rmi_port);
+    _dcmdparser.add_dcmd_option(&_jmxremote_ssl);
+    _dcmdparser.add_dcmd_option(&_jmxremote_registry_ssl);
+    _dcmdparser.add_dcmd_option(&_jmxremote_authenticate);
+    _dcmdparser.add_dcmd_option(&_jmxremote_password_file);
+    _dcmdparser.add_dcmd_option(&_jmxremote_access_file);
+    _dcmdparser.add_dcmd_option(&_jmxremote_login_config);
+    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_cipher_suites);
+    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_protocols);
+    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_need_client_auth);
+    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_config_file);
+}
+
+
+int JMXStartRemoteDCmd::num_arguments() {
+  ResourceMark rm;
+  JMXStartRemoteDCmd* dcmd = new JMXStartRemoteDCmd(NULL, false);
+  if (dcmd != NULL) {
+    DCmdMark mark(dcmd);
+    return dcmd->_dcmdparser.num_arguments();
+  } else {
+    return 0;
+  }
+}
+
+
+void JMXStartRemoteDCmd::execute(TRAPS) {
+    ResourceMark rm(THREAD);
+    HandleMark hm(THREAD);
+
+    // Load and initialize the sun.management.Agent class
+    // invoke startRemoteManagementAgent(string) method to start
+    // the remote management server.
+    // throw java.lang.NoSuchMethodError if the method doesn't exist
+
+    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
+    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
+    instanceKlassHandle ik (THREAD, k);
+
+    JavaValue result(T_VOID);
+
+    // Pass all command line arguments to java as key=value,...
+    // All checks are done on java side
+
+    int len = 0;
+    stringStream options;
+    char comma[2] = {0,0};
+
+    // Leave default values on Agent.class side and pass only
+    // agruments explicitly set by user. All arguments passed
+    // to jcmd override properties with the same name set by
+    // command line with -D or by managmenent.properties
+    // file.
+#define PUT_OPTION(a) \
+    if ( (a).is_set() ){ \
+        options.print("%scom.sun.management.%s=%s", comma, (a).name(), (a).value()); \
+        comma[0] = ','; \
+    }
+
+    PUT_OPTION(_config_file);
+    PUT_OPTION(_jmxremote_port);
+    PUT_OPTION(_jmxremote_rmi_port);
+    PUT_OPTION(_jmxremote_ssl);
+    PUT_OPTION(_jmxremote_registry_ssl);
+    PUT_OPTION(_jmxremote_authenticate);
+    PUT_OPTION(_jmxremote_password_file);
+    PUT_OPTION(_jmxremote_access_file);
+    PUT_OPTION(_jmxremote_login_config);
+    PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites);
+    PUT_OPTION(_jmxremote_ssl_enabled_protocols);
+    PUT_OPTION(_jmxremote_ssl_need_client_auth);
+    PUT_OPTION(_jmxremote_ssl_config_file);
+
+#undef PUT_OPTION
+
+    Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);
+    JavaCalls::call_static(&result, ik, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);
+}
+
+JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
+  DCmd(output, heap_allocated)
+{
+  // do nothing
+}
+
+void JMXStartLocalDCmd::execute(TRAPS) {
+    ResourceMark rm(THREAD);
+    HandleMark hm(THREAD);
+
+    // Load and initialize the sun.management.Agent class
+    // invoke startLocalManagementAgent(void) method to start
+    // the local management server
+    // throw java.lang.NoSuchMethodError if method doesn't exist
+
+    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
+    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
+    instanceKlassHandle ik (THREAD, k);
+
+    JavaValue result(T_VOID);
+    JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);
+}
+
+
+void JMXStopRemoteDCmd::execute(TRAPS) {
+    ResourceMark rm(THREAD);
+    HandleMark hm(THREAD);
+
+    // Load and initialize the sun.management.Agent class
+    // invoke stopRemoteManagementAgent method to stop the
+    // management server
+    // throw java.lang.NoSuchMethodError if method doesn't exist
+
+    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
+    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
+    instanceKlassHandle ik (THREAD, k);
+
+    JavaValue result(T_VOID);
+    JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);
+}
+
--- a/hotspot/src/share/vm/services/diagnosticCommand.hpp	Thu Mar 01 12:23:07 2012 -0800
+++ b/hotspot/src/share/vm/services/diagnosticCommand.hpp	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -214,4 +214,82 @@
   virtual void execute(TRAPS);
 };
 
+// Enhanced JMX Agent support
+
+class JMXStartRemoteDCmd : public DCmdWithParser {
+
+  // Explicitly list all properties that could be
+  // passed to Agent.startRemoteManagementAgent()
+  // com.sun.management is omitted
+
+  DCmdArgument<char *> _config_file;
+  DCmdArgument<char *> _jmxremote_port;
+  DCmdArgument<char *> _jmxremote_rmi_port;
+  DCmdArgument<char *> _jmxremote_ssl;
+  DCmdArgument<char *> _jmxremote_registry_ssl;
+  DCmdArgument<char *> _jmxremote_authenticate;
+  DCmdArgument<char *> _jmxremote_password_file;
+  DCmdArgument<char *> _jmxremote_access_file;
+  DCmdArgument<char *> _jmxremote_login_config;
+  DCmdArgument<char *> _jmxremote_ssl_enabled_cipher_suites;
+  DCmdArgument<char *> _jmxremote_ssl_enabled_protocols;
+  DCmdArgument<char *> _jmxremote_ssl_need_client_auth;
+  DCmdArgument<char *> _jmxremote_ssl_config_file;
+
+public:
+  JMXStartRemoteDCmd(outputStream *output, bool heap_allocated);
+
+  static const char *name() {
+    return "ManagementAgent.start";
+  }
+
+  static const char *description() {
+    return "Start remote management agent.";
+  }
+
+  static int num_arguments();
+
+  virtual void execute(TRAPS);
+
+};
+
+class JMXStartLocalDCmd : public DCmd {
+
+  // Explicitly request start of local agent,
+  // it will not be started by start dcmd
+
+
+public:
+  JMXStartLocalDCmd(outputStream *output, bool heap_allocated);
+
+  static const char *name() {
+    return "ManagementAgent.start_local";
+  }
+
+  static const char *description() {
+    return "Start local management agent.";
+  }
+
+  virtual void execute(TRAPS);
+
+};
+
+class JMXStopRemoteDCmd : public DCmd {
+public:
+  JMXStopRemoteDCmd(outputStream *output, bool heap_allocated) :
+  DCmd(output, heap_allocated) {
+    // Do Nothing
+  }
+
+  static const char *name() {
+    return "ManagementAgent.stop";
+  }
+
+  static const char *description() {
+    return "Stop remote management agent.";
+  }
+
+  virtual void execute(TRAPS);
+};
+
 #endif // SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP
--- a/jdk/.hgtags	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/.hgtags	Wed Jul 05 18:04:20 2017 +0200
@@ -149,3 +149,4 @@
 ec17fbe5b8fbc52da070eec43b4711d9354b2ab8 jdk8-b25
 5aca406e87cb9144a9405be312dadd728a9c6fe2 jdk8-b26
 c68342532e2e7deb3a25fc04ed3e4c142278f747 jdk8-b27
+1e1d41daaded291ab3a370ca6a27f7325701978e jdk8-b28
--- a/jdk/make/Makefile	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/make/Makefile	Wed Jul 05 18:04:20 2017 +0200
@@ -197,7 +197,7 @@
 #
 # 'all' target intro
 #
-all:: 
+all::
 	@$(ECHO) $(PLATFORM) $(ARCH) $(RELEASE) build started: $(shell $(DATE) '+%y-%m-%d %H:%M')
 
 # Just in case anyone uses this old name, same as 'build'
@@ -234,7 +234,17 @@
 
 SUBDIRS       = tools java javax sun com
 SUBDIRS_tools = launchers
-SUBDIRS_misc  = org sunw jpda mkdemo mksample
+SUBDIRS_misc  = org sunw jpda
+
+# demos
+ifndef NO_DEMOS
+  SUBDIRS_misc += mkdemo
+endif
+
+# samples
+ifndef NO_SAMPLES
+  SUBDIRS_misc += mksample
+endif
 
 # Alternate classes implementation
 ifndef OPENJDK
@@ -383,4 +393,3 @@
 .PHONY: all build clean clobber optimized debug fastdebug create_links \
 	import import_product import_fastdebug import_debug \
 	test test_run test_start test_clean test_summary
-
--- a/jdk/make/common/Release.gmk	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/make/common/Release.gmk	Wed Jul 05 18:04:20 2017 +0200
@@ -234,7 +234,7 @@
 	 $(INITIAL_IMAGE_JRE) $(INITIAL_IMAGE_JDK) \
 	 trim-image-jre trim-image-jdk \
          identify-image-jre identify-image-jdk \
-	 process-image-jre process-image-jdk sec-files sec-files-win jgss-files 
+	 process-image-jre process-image-jdk sec-files sec-files-win jgss-files
 
 # Don't use these
 image-jre:: initial-image-jre trim-image-jre identify-image-jre process-image-jre
@@ -496,7 +496,7 @@
 $(JDK_IMAGE_DIR)/sample/SAMPLES_LICENSE: $(SHARE_JDK_DOC_SRC)/SAMPLES_LICENSE
 	$(process-doc-file)
 
-# JRE files 
+# JRE files
 $(JRE_IMAGE_DIR)/%: $(SHARE_JRE_DOC_SRC)/%
 	$(process-doc-file)
 ifeq ($(PLATFORM), windows)
@@ -1095,8 +1095,12 @@
 	@#
 	@# demo, include
 	@#
+ifndef NO_DEMOS
 	$(CP) -r -f $(DEMODIR) $(JDK_IMAGE_DIR)
+endif
+ifndef NO_SAMPLES
 	$(CP) -r -f $(SAMPLEDIR) $(JDK_IMAGE_DIR)
+endif
 	$(CP) -r $(INCLUDEDIR) $(JDK_IMAGE_DIR)
 	@#
 	@# Swing BeanInfo generation
@@ -1359,4 +1363,3 @@
 
 # Force rule
 FRC:
-
--- a/jdk/make/common/shared/Sanity-Settings.gmk	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/make/common/shared/Sanity-Settings.gmk	Wed Jul 05 18:04:20 2017 +0200
@@ -134,6 +134,8 @@
 ALL_SETTINGS+=$(call addOptionalSetting,PEDANTIC)
 ALL_SETTINGS+=$(call addOptionalSetting,DEV_ONLY)
 ALL_SETTINGS+=$(call addOptionalSetting,NO_DOCS)
+ALL_SETTINGS+=$(call addOptionalSetting,NO_DEMOS)
+ALL_SETTINGS+=$(call addOptionalSetting,NO_SAMPLES)
 ALL_SETTINGS+=$(call addOptionalSetting,NO_IMAGES)
 ALL_SETTINGS+=$(call addOptionalSetting,TOOLS_ONLY)
 ALL_SETTINGS+=$(call addOptionalSetting,INSANE)
@@ -263,4 +265,3 @@
   ALL_SETTINGS+=$(call addAltSetting,PREVIOUS_JRE_FILE)
   ALL_SETTINGS+=$(call addAltSetting,PREVIOUS_RELEASE_IMAGE)
 endif
-
--- a/jdk/make/tools/src/build/tools/javazic/Mappings.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/make/tools/src/build/tools/javazic/Mappings.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package build.tools.javazic;
 
 import  java.util.ArrayList;
+import  java.util.HashMap;
 import  java.util.LinkedList;
 import  java.util.List;
 import  java.util.Map;
@@ -162,6 +163,20 @@
         for (String key : toBeRemoved) {
             aliases.remove(key);
         }
+        // Eliminate any alias-to-alias mappings. For example, if
+        // there are A->B and B->C, A->B is changed to A->C.
+        Map<String, String> newMap = new HashMap<String, String>();
+        for (String key : aliases.keySet()) {
+            String realid = aliases.get(key);
+            String leaf = realid;
+            while (aliases.get(leaf) != null) {
+                leaf = aliases.get(leaf);
+            }
+            if (!realid.equals(leaf)) {
+                newMap.put(key, leaf);
+            }
+        }
+        aliases.putAll(newMap);
     }
 
     Map<String,String> getAliases() {
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Wed Jul 05 18:04:20 2017 +0200
@@ -55,7 +55,6 @@
 
 import java.awt.Font;
 import java.awt.Color;
-import java.awt.event.KeyEvent;
 import java.awt.event.ActionEvent;
 
 import java.security.AccessController;
@@ -523,6 +522,7 @@
         Object ScrollbarBackgroundColor = new DesktopProperty(
                                                        "win.scrollbar.backgroundColor",
                                                         table.get("scrollbar"));
+        Object buttonFocusColor = new FocusColorProperty();
 
         Object TextBackground         = new XPColorValue(Part.EP_EDIT, null, Prop.FILLCOLOR,
                                                          WindowBackgroundColor);
@@ -629,7 +629,7 @@
             "Button.highlight", ControlHighlightColor,
             "Button.disabledForeground", InactiveTextColor,
             "Button.disabledShadow", ControlHighlightColor,
-            "Button.focus", black,
+            "Button.focus", buttonFocusColor,
             "Button.dashedRectGapX", new XPValue(Integer.valueOf(3), Integer.valueOf(5)),
             "Button.dashedRectGapY", new XPValue(Integer.valueOf(3), Integer.valueOf(4)),
             "Button.dashedRectGapWidth", new XPValue(Integer.valueOf(6), Integer.valueOf(10)),
@@ -652,7 +652,7 @@
             "CheckBox.darkShadow", ControlDarkShadowColor,
             "CheckBox.light", ControlLightColor,
             "CheckBox.highlight", ControlHighlightColor,
-            "CheckBox.focus", black,
+            "CheckBox.focus", buttonFocusColor,
             "CheckBox.focusInputMap",
                new UIDefaults.LazyInputMap(new Object[] {
                             "SPACE", "pressed",
@@ -1007,7 +1007,7 @@
             "RadioButton.darkShadow", ControlDarkShadowColor,
             "RadioButton.light", ControlLightColor,
             "RadioButton.highlight", ControlHighlightColor,
-            "RadioButton.focus", black,
+            "RadioButton.focus", buttonFocusColor,
             "RadioButton.focusInputMap",
                new UIDefaults.LazyInputMap(new Object[] {
                           "SPACE", "pressed",
@@ -2614,4 +2614,19 @@
         }
     }
 
+    private static class FocusColorProperty extends DesktopProperty {
+        public FocusColorProperty () {
+            // Fallback value is never used bacause of the configureValue method doesn't return null
+            super("win.3d.backgroundColor", Color.BLACK);
+        }
+
+        @Override
+        protected Object configureValue(Object value) {
+            if (! ((Boolean)Toolkit.getDefaultToolkit().getDesktopProperty("win.highContrast.on")).booleanValue()){
+                return Color.BLACK;
+            }
+            return Color.BLACK.equals(value) ? Color.WHITE : Color.BLACK;
+        }
+    }
+
 }
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java	Wed Jul 05 18:04:20 2017 +0200
@@ -89,6 +89,11 @@
         }
     }
 
+    protected void uninstallDefaults(AbstractButton b) {
+        super.uninstallDefaults(b);
+        initialized = false;
+    }
+
     protected Color getFocusColor() {
         return focusColor;
     }
--- a/jdk/src/share/classes/java/awt/Component.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/java/awt/Component.java	Wed Jul 05 18:04:20 2017 +0200
@@ -10070,11 +10070,12 @@
         }
         Window window = getContainingWindow();
         if (window != null) {
-            if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants()) {
+            if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants() || window.isDisposing()) {
                 if (mixingLog.isLoggable(PlatformLogger.FINE)) {
                     mixingLog.fine("containing window = " + window +
                             "; has h/w descendants = " + window.hasHeavyweightDescendants() +
-                            "; has l/w descendants = " + window.hasLightweightDescendants());
+                            "; has l/w descendants = " + window.hasLightweightDescendants() +
+                            "; disposing = " + window.isDisposing());
                 }
                 return false;
             }
--- a/jdk/src/share/classes/java/awt/Window.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/java/awt/Window.java	Wed Jul 05 18:04:20 2017 +0200
@@ -226,6 +226,7 @@
     static boolean systemSyncLWRequests = false;
     boolean     syncLWRequests = false;
     transient boolean beforeFirstShow = true;
+    private transient boolean disposing = false;
 
     static final int OPENED = 0x01;
 
@@ -1162,36 +1163,41 @@
     void doDispose() {
     class DisposeAction implements Runnable {
         public void run() {
-            // Check if this window is the fullscreen window for the
-            // device. Exit the fullscreen mode prior to disposing
-            // of the window if that's the case.
-            GraphicsDevice gd = getGraphicsConfiguration().getDevice();
-            if (gd.getFullScreenWindow() == Window.this) {
-                gd.setFullScreenWindow(null);
-            }
-
-            Object[] ownedWindowArray;
-            synchronized(ownedWindowList) {
-                ownedWindowArray = new Object[ownedWindowList.size()];
-                ownedWindowList.copyInto(ownedWindowArray);
+            disposing = true;
+            try {
+                // Check if this window is the fullscreen window for the
+                // device. Exit the fullscreen mode prior to disposing
+                // of the window if that's the case.
+                GraphicsDevice gd = getGraphicsConfiguration().getDevice();
+                if (gd.getFullScreenWindow() == Window.this) {
+                    gd.setFullScreenWindow(null);
+                }
+
+                Object[] ownedWindowArray;
+                synchronized(ownedWindowList) {
+                    ownedWindowArray = new Object[ownedWindowList.size()];
+                    ownedWindowList.copyInto(ownedWindowArray);
+                }
+                for (int i = 0; i < ownedWindowArray.length; i++) {
+                    Window child = (Window) (((WeakReference)
+                                   (ownedWindowArray[i])).get());
+                    if (child != null) {
+                        child.disposeImpl();
+                    }
+                }
+                hide();
+                beforeFirstShow = true;
+                removeNotify();
+                synchronized (inputContextLock) {
+                    if (inputContext != null) {
+                        inputContext.dispose();
+                        inputContext = null;
+                    }
+                }
+                clearCurrentFocusCycleRootOnHide();
+            } finally {
+                disposing = false;
             }
-            for (int i = 0; i < ownedWindowArray.length; i++) {
-                Window child = (Window) (((WeakReference)
-                               (ownedWindowArray[i])).get());
-                if (child != null) {
-                    child.disposeImpl();
-                }
-            }
-            hide();
-            beforeFirstShow = true;
-            removeNotify();
-            synchronized (inputContextLock) {
-                if (inputContext != null) {
-                    inputContext.dispose();
-                    inputContext = null;
-                }
-            }
-            clearCurrentFocusCycleRootOnHide();
         }
     }
         DisposeAction action = new DisposeAction();
@@ -2734,6 +2740,10 @@
         return visible;
     }
 
+    boolean isDisposing() {
+        return disposing;
+    }
+
     /**
      * @deprecated As of J2SE 1.4, replaced by
      * {@link Component#applyComponentOrientation Component.applyComponentOrientation}.
--- a/jdk/src/share/classes/java/lang/reflect/Executable.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/java/lang/reflect/Executable.java	Wed Jul 05 18:04:20 2017 +0200
@@ -180,7 +180,7 @@
 
     /**
      * Returns the {@code Class} object representing the class or interface
-     * that declares the method represented by this executable object.
+     * that declares the executable represented by this object.
      */
     public abstract Class<?> getDeclaringClass();
 
@@ -215,18 +215,18 @@
      * Returns an array of {@code Class} objects that represent the formal
      * parameter types, in declaration order, of the executable
      * represented by this object.  Returns an array of length
-     * 0 if the underlying method takes no parameters.
+     * 0 if the underlying executable takes no parameters.
      *
-     * @return the parameter types for the method this object
+     * @return the parameter types for the executable this object
      * represents
      */
     public abstract Class<?>[] getParameterTypes();
 
     /**
      * Returns an array of {@code Type} objects that represent the formal
-     * parameter types, in declaration order, of the method represented by
-     * this executable object. Returns an array of length 0 if the
-     * underlying method takes no parameters.
+     * parameter types, in declaration order, of the executable represented by
+     * this object. Returns an array of length 0 if the
+     * underlying executable takes no parameters.
      *
      * <p>If a formal parameter type is a parameterized type,
      * the {@code Type} object returned for it must accurately reflect
@@ -236,16 +236,16 @@
      * type, it is created. Otherwise, it is resolved.
      *
      * @return an array of {@code Type}s that represent the formal
-     *     parameter types of the underlying method, in declaration order
+     *     parameter types of the underlying executable, in declaration order
      * @throws GenericSignatureFormatError
      *     if the generic method signature does not conform to the format
      *     specified in
      *     <cite>The Java&trade; Virtual Machine Specification</cite>
      * @throws TypeNotPresentException if any of the parameter
-     *     types of the underlying method refers to a non-existent type
+     *     types of the underlying executable refers to a non-existent type
      *     declaration
      * @throws MalformedParameterizedTypeException if any of
-     *     the underlying method's parameter types refer to a parameterized
+     *     the underlying executable's parameter types refer to a parameterized
      *     type that cannot be instantiated for any reason
      */
     public Type[] getGenericParameterTypes() {
@@ -277,15 +277,15 @@
      * type, it is created. Otherwise, it is resolved.
      *
      * @return an array of Types that represent the exception types
-     *     thrown by the underlying method
+     *     thrown by the underlying executable
      * @throws GenericSignatureFormatError
      *     if the generic method signature does not conform to the format
      *     specified in
      *     <cite>The Java&trade; Virtual Machine Specification</cite>
-     * @throws TypeNotPresentException if the underlying method's
+     * @throws TypeNotPresentException if the underlying executable's
      *     {@code throws} clause refers to a non-existent type declaration
      * @throws MalformedParameterizedTypeException if
-     *     the underlying method's {@code throws} clause refers to a
+     *     the underlying executable's {@code throws} clause refers to a
      *     parameterized type that cannot be instantiated for any reason
      */
     public Type[] getGenericExceptionTypes() {
@@ -330,7 +330,7 @@
      * Returns an array of arrays that represent the annotations on
      * the formal parameters, in declaration order, of the executable
      * represented by this object. (Returns an array of length zero if
-     * the underlying method is parameterless.  If the executable has
+     * the underlying executable is parameterless.  If the executable has
      * one or more parameters, a nested array of length zero is
      * returned for each parameter with no annotations.) The
      * annotation objects contained in the returned arrays are
@@ -339,7 +339,7 @@
      * to other callers.
      *
      * @return an array of arrays that represent the annotations on the formal
-     *    parameters, in declaration order, of the exectuable represented by this
+     *    parameters, in declaration order, of the executable represented by this
      *    object
      */
     public abstract Annotation[][] getParameterAnnotations();
--- a/jdk/src/share/classes/java/util/Collections.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/java/util/Collections.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1489,6 +1489,8 @@
                 }
                 public int hashCode()    {return e.hashCode();}
                 public boolean equals(Object o) {
+                    if (this == o)
+                        return true;
                     if (!(o instanceof Map.Entry))
                         return false;
                     Map.Entry t = (Map.Entry)o;
@@ -1709,6 +1711,8 @@
         }
 
         public boolean equals(Object o) {
+            if (this == o)
+                return true;
             synchronized (mutex) {return c.equals(o);}
         }
         public int hashCode() {
@@ -1863,6 +1867,8 @@
         }
 
         public boolean equals(Object o) {
+            if (this == o)
+                return true;
             synchronized (mutex) {return list.equals(o);}
         }
         public int hashCode() {
@@ -2073,6 +2079,8 @@
         }
 
         public boolean equals(Object o) {
+            if (this == o)
+                return true;
             synchronized (mutex) {return m.equals(o);}
         }
         public int hashCode() {
--- a/jdk/src/share/classes/javax/swing/JViewport.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/JViewport.java	Wed Jul 05 18:04:20 2017 +0200
@@ -27,9 +27,7 @@
 
 import java.awt.*;
 import java.awt.event.*;
-import java.awt.image.VolatileImage;
 import java.awt.peer.ComponentPeer;
-import java.applet.Applet;
 import java.beans.Transient;
 import javax.swing.plaf.ViewportUI;
 
@@ -265,6 +263,14 @@
      */
     private boolean hasHadValidView;
 
+    /**
+     * When view is changed we have to synchronize scrollbar values
+     * with viewport (see the BasicScrollPaneUI#syncScrollPaneWithViewport method).
+     * This flag allows to invoke that method while ScrollPaneLayout#layoutContainer
+     * is running.
+     */
+    private boolean viewChanged;
+
     /** Creates a <code>JViewport</code>. */
     public JViewport() {
         super();
@@ -830,7 +836,9 @@
             backingStoreImage = null;
         }
         super.reshape(x, y, w, h);
-        if (sizeChanged) {
+        if (sizeChanged || viewChanged) {
+            viewChanged = false;
+
             fireStateChanged();
         }
     }
@@ -967,6 +975,8 @@
             hasHadValidView = true;
         }
 
+        viewChanged = true;
+
         revalidate();
         repaint();
     }
--- a/jdk/src/share/classes/sun/font/SunFontManager.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/sun/font/SunFontManager.java	Wed Jul 05 18:04:20 2017 +0200
@@ -2619,10 +2619,6 @@
         physicalFonts.remove(oldFont.fullName);
         fullNameToFont.remove(oldFont.fullName.toLowerCase(Locale.ENGLISH));
         FontFamily.remove(oldFont);
-        if (oldFont instanceof FileFont) {
-            ((FileFont)oldFont).deregisterFontAndClearStrikeCache();
-        }
-
         if (localeFullNamesToFont != null) {
             Map.Entry[] mapEntries =
                 (Map.Entry[])localeFullNamesToFont.entrySet().
--- a/jdk/src/share/classes/sun/management/Agent.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/sun/management/Agent.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,30 +25,34 @@
 
 package sun.management;
 
+import java.io.BufferedInputStream;
 import java.io.File;
-import java.io.InputStream;
 import java.io.FileInputStream;
-import java.io.BufferedInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
+
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.management.ManagementFactory;
+
 import java.text.MessageFormat;
+
+import java.util.MissingResourceException;
 import java.util.Properties;
 import java.util.ResourceBundle;
-import java.util.MissingResourceException;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.Method;
 
 import javax.management.remote.JMXConnectorServer;
 
+import static sun.management.AgentConfigurationError.*;
 import sun.management.jmxremote.ConnectorBootstrap;
-import static sun.management.AgentConfigurationError.*;
 import sun.misc.VMSupport;
 
 /**
  * This Agent is started by the VM when -Dcom.sun.management.snmp
  * or -Dcom.sun.management.jmxremote is set. This class will be
- * loaded by the system class loader.
+ * loaded by the system class loader. Also jmx framework could
+ * be started by jcmd
  */
 public class Agent {
     // management properties
@@ -69,7 +73,33 @@
         "com.sun.management.jmxremote.localConnectorAddress";
 
     private static final String SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME =
-            "sun.management.snmp.AdaptorBootstrap";
+        "sun.management.snmp.AdaptorBootstrap";
+
+    // The only active agent allowed
+    private static JMXConnectorServer jmxServer = null;
+
+    // Parse string com.sun.management.prop=xxx,com.sun.management.prop=yyyy
+    // and return property set if args is null or empty
+    // return empty property set
+    private static Properties parseString(String args){
+        Properties argProps = new Properties();
+        if (args != null) {
+           for (String option : args.split(",")) {
+               String s[] = option.split("=", 2);
+               String name = s[0].trim();
+               String value = (s.length > 1) ? s[1].trim() : "";
+
+               if (!name.startsWith("com.sun.management.")) {
+                  error(INVALID_OPTION, name);
+               }
+
+               argProps.setProperty(name, value);
+           }
+        }
+
+        return argProps;
+    }
+
 
     // invoked by -javaagent or -Dcom.sun.management.agent.class
     public static void premain(String args) throws Exception {
@@ -82,37 +112,104 @@
             args = JMXREMOTE;           // default to local management
         }
 
-        // Parse agent options into properties
+        Properties arg_props = parseString(args);
+
+        // Read properties from the config file
+         Properties config_props = new Properties();
+         String fname = arg_props.getProperty(CONFIG_FILE);
+         readConfiguration(fname, config_props);
+
+         // Arguments override config file
+         config_props.putAll(arg_props);
+         startAgent(config_props);
+    }
 
-        Properties arg_props = new Properties();
-        if (args != null) {
-            String[] options = args.split(",");
-            for (int i=0; i<options.length; i++) {
-                String[] option = options[i].split("=");
-                if (option.length >= 1 && option.length <= 2) {
-                    String name = option[0];
-                    String value = (option.length == 1) ? "" : option[1];
-                    if (name != null && name.length() > 0) {
+    // jcmd ManagementAgent.start_local entry point
+    // Also called due to command-line via startAgent()
+    private static synchronized void startLocalManagementAgent(){
+        Properties agentProps = VMSupport.getAgentProperties();
 
-                        // Assume that any com.sun.management.* options are okay
-                        if (name.startsWith("com.sun.management.")) {
-                            arg_props.setProperty(name, value);
-                        } else {
-                            error(INVALID_OPTION, name);
-                        }
-                    }
-                }
+        // start local connector if not started
+        if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
+            JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
+            String address = cs.getAddress().toString();
+            // Add the local connector address to the agent properties
+            agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);
+
+            try {
+                // export the address to the instrumentation buffer
+                ConnectorAddressLink.export(address);
+            } catch (Exception x) {
+                // Connector server started but unable to export address
+                // to instrumentation buffer - non-fatal error.
+                warning(EXPORT_ADDRESS_FAILED, x.getMessage());
             }
         }
+    }
 
-        // Read properties from the config file
-        Properties config_props = new Properties();
-        String fname = arg_props.getProperty(CONFIG_FILE);
-        readConfiguration(fname, config_props);
+    // jcmd ManagementAgent.start entry point
+    // This method starts the remote JMX agent and starts neither
+    // the local JMX agent nor the SNMP agent
+    // @see #startLocalManagementAgent and also @see #startAgent.
+    private static synchronized void startRemoteManagementAgent(String args) throws Exception {
+        if (jmxServer != null) {
+            throw new RuntimeException(getText(INVALID_STATE, "Agent already started"));
+        }
+
+        Properties argProps    = parseString(args);
+        Properties configProps = new Properties();
+
+        // Load the management properties from the config file
+        // if config file is not specified readConfiguration implicitly
+        // reads <java.home>/lib/management/management.properties
+
+        String fname = System.getProperty(CONFIG_FILE);
+        readConfiguration(fname, configProps);
+
+        // management properties can be overridden by system properties
+        // which take precedence
+        configProps.putAll(System.getProperties());
+
+        // if user specifies config file into command line for either
+        // jcmd utilities or attach command it overrides properties set in
+        // command line at the time of VM start
+        String fnameUser = argProps.getProperty(CONFIG_FILE);
+        if (fnameUser != null) {
+            readConfiguration(fnameUser, configProps);
+        }
 
-        // Arguments override config file
-        config_props.putAll(arg_props);
-        startAgent(config_props);
+        // arguments specified in command line of jcmd utilities
+        // override both system properties and one set by config file
+        // specified in jcmd command line
+        configProps.putAll(argProps);
+
+        // jcmd doesn't allow to change ThreadContentionMonitoring, but user
+        // can specify this property inside config file, so enable optional
+        // monitoring functionality if this property is set
+        final String enableThreadContentionMonitoring =
+            configProps.getProperty(ENABLE_THREAD_CONTENTION_MONITORING);
+
+        if (enableThreadContentionMonitoring != null) {
+            ManagementFactory.getThreadMXBean().
+                setThreadContentionMonitoringEnabled(true);
+        }
+
+        String jmxremotePort = configProps.getProperty(JMXREMOTE_PORT);
+        if (jmxremotePort != null) {
+            jmxServer = ConnectorBootstrap.
+                           startRemoteConnectorServer(jmxremotePort, configProps);
+        }
+    }
+
+    private static synchronized void stopRemoteManagementAgent() throws Exception {
+        if (jmxServer != null) {
+            ConnectorBootstrap.unexportRegistry();
+
+            // Attempt to stop already stopped agent
+            // Don't cause any errors.
+            jmxServer.stop();
+            jmxServer = null;
+        }
     }
 
     private static void startAgent(Properties props) throws Exception {
@@ -130,7 +227,7 @@
 
         try {
             if (snmpPort != null) {
-                loadSnmpAgent(snmpPort, props);
+               loadSnmpAgent(snmpPort, props);
             }
 
             /*
@@ -142,31 +239,14 @@
              * of this "local" server is exported as a counter to the jstat
              * instrumentation buffer.
              */
-            if (jmxremote != null || jmxremotePort != null) {
+             if (jmxremote != null || jmxremotePort != null) {
                 if (jmxremotePort != null) {
-                    ConnectorBootstrap.initialize(jmxremotePort, props);
+                   jmxServer = ConnectorBootstrap.
+                               startRemoteConnectorServer(jmxremotePort, props);
                 }
+                startLocalManagementAgent();
+             }
 
-                Properties agentProps = VMSupport.getAgentProperties();
-                // start local connector if not started
-                // System.out.println("local address : " +
-                  //     agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP));
-                if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
-                    JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
-                    String address = cs.getAddress().toString();
-                    // Add the local connector address to the agent properties
-                    agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);
-
-                    try {
-                        // export the address to the instrumentation buffer
-                        ConnectorAddressLink.export(address);
-                    } catch (Exception x) {
-                        // Connector server started but unable to export address
-                        // to instrumentation buffer - non-fatal error.
-                        warning(EXPORT_ADDRESS_FAILED, x.getMessage());
-                    }
-                }
-            }
         } catch (AgentConfigurationError e) {
             error(e.getError(), e.getParams());
         } catch (Exception e) {
@@ -187,9 +267,9 @@
         props.putAll(System.getProperties());
 
         return props;
-    }
+   }
 
-    public static synchronized Properties getManagementProperties() {
+   public static synchronized Properties getManagementProperties() {
         if (mgmtProps == null) {
             String configFile = System.getProperty(CONFIG_FILE);
             String snmpPort = System.getProperty(SNMP_PORT);
--- a/jdk/src/share/classes/sun/management/AgentConfigurationError.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/sun/management/AgentConfigurationError.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,6 +53,8 @@
         "agent.err.invalid.agentclass";
     public static final String INVALID_JMXREMOTE_PORT =
         "agent.err.invalid.jmxremote.port";
+    public static final String INVALID_JMXREMOTE_RMI_PORT =
+        "agent.err.invalid.jmxremote.rmi.port";
     public static final String PASSWORD_FILE_NOT_SET =
         "agent.err.password.file.notset";
     public static final String PASSWORD_FILE_NOT_READABLE =
@@ -105,6 +107,8 @@
         "agent.err.snmp.adaptor.start.failed";
     public static final String SNMP_MIB_INIT_FAILED =
         "agent.err.snmp.mib.init.failed";
+    public static final String INVALID_STATE =
+        "agent.err.invalid.state";
 
     private final String error;
     private final String[] params;
--- a/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,25 +28,22 @@
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
-import java.io.IOException;
-
+import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
 import java.net.MalformedURLException;
 import java.net.UnknownHostException;
-
 import java.rmi.NoSuchObjectException;
 import java.rmi.Remote;
 import java.rmi.RemoteException;
 import java.rmi.registry.Registry;
-import java.rmi.server.RemoteObject;
 import java.rmi.server.RMIClientSocketFactory;
 import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.RemoteObject;
 import java.rmi.server.UnicastRemoteObject;
-
 import java.security.KeyStore;
 import java.security.Principal;
-
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -55,35 +52,31 @@
 import java.util.Set;
 import java.util.StringTokenizer;
 
-import java.lang.management.ManagementFactory;
-
-import javax.net.ssl.*;
-
 import javax.management.MBeanServer;
 import javax.management.remote.JMXAuthenticator;
 import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
 import javax.management.remote.rmi.RMIConnectorServer;
-
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
 import javax.rmi.ssl.SslRMIClientSocketFactory;
 import javax.rmi.ssl.SslRMIServerSocketFactory;
-
 import javax.security.auth.Subject;
 
-import sun.rmi.server.UnicastRef;
-import sun.rmi.server.UnicastServerRef;
-import sun.rmi.server.UnicastServerRef2;
+import com.sun.jmx.remote.internal.RMIExporter;
+import com.sun.jmx.remote.security.JMXPluggableAuthenticator;
+import com.sun.jmx.remote.util.ClassLogger;
 
 import sun.management.Agent;
 import sun.management.AgentConfigurationError;
 import static sun.management.AgentConfigurationError.*;
 import sun.management.ConnectorAddressLink;
 import sun.management.FileSystem;
-import com.sun.jmx.remote.util.ClassLogger;
-
-import com.sun.jmx.remote.internal.RMIExporter;
-import com.sun.jmx.remote.security.JMXPluggableAuthenticator;
+import sun.rmi.server.UnicastRef;
+import sun.rmi.server.UnicastServerRef;
+import sun.rmi.server.UnicastServerRef2;
 
 /**
  * This class initializes and starts the RMIConnectorServer for JSR 163
@@ -114,6 +107,8 @@
 
         public static final String PORT =
                 "com.sun.management.jmxremote.port";
+        public static final String RMI_PORT =
+                "com.sun.management.jmxremote.rmi.port";
         public static final String CONFIG_FILE_NAME =
                 "com.sun.management.config.file";
         public static final String USE_LOCAL_ONLY =
@@ -266,34 +261,61 @@
         private final String accessFile;
     }
 
-    /**
-     * Initializes and starts the JMX Connector Server.
-     * If the com.sun.management.jmxremote.port property is not defined,
-     * simply return. Otherwise, attempts to load the config file, and
-     * then calls {@link #initialize(java.lang.String, java.util.Properties)}.
-     *
-     **/
-    public static synchronized JMXConnectorServer initialize() {
+    // The variable below is here to support stop functionality
+    // It would be overriten if you call startRemoteCommectionServer second
+    // time. It's OK for now as logic in Agent.java forbids mutiple agents
+    private static Registry registry = null;
+
+    public static void unexportRegistry() {
+        // Remove the entry from registry
+        try {
+            if (registry != null) {
+                UnicastRemoteObject.unexportObject(registry, true);
+                registry = null;
+            }
+        } catch(NoSuchObjectException ex) {
+            // This exception can appears only if we attempt
+            // to unexportRegistry second time. So it's safe
+            // to ignore it without additional messages.
+        }
+    }
 
-        // Load a new management properties
-        final Properties props = Agent.loadManagementProperties();
-        if (props == null) {
-            return null;
-        }
+     /**
+      * Initializes and starts the JMX Connector Server.
+      * If the com.sun.management.jmxremote.port property is not defined,
+      * simply return. Otherwise, attempts to load the config file, and
+      * then calls {@link #startRemoteConnectorServer
+      *                            (java.lang.String, java.util.Properties)}.
+      *
+      * This method is used by some jtreg tests.
+      **/
+      public static synchronized JMXConnectorServer initialize() {
 
-        final String portStr = props.getProperty(PropertyNames.PORT);
-
+         // Load a new management properties
+         final Properties props = Agent.loadManagementProperties();
+         if (props == null) {
+              return null;
+         }
 
-        // System.out.println("initializing: {port=" + portStr + ",
-        //                     properties="+props+"}");
-        return initialize(portStr, props);
+         final String portStr = props.getProperty(PropertyNames.PORT);
+         return startRemoteConnectorServer(portStr, props);
+     }
+
+    /**
+     * This method is used by some jtreg tests.
+     *
+     * @see #startRemoteConnectorServer
+     *             (String portStr, Properties props)
+     */
+    public static synchronized JMXConnectorServer initialize(String portStr, Properties props)  {
+         return startRemoteConnectorServer(portStr, props);
     }
 
     /**
      * Initializes and starts a JMX Connector Server for remote
      * monitoring and management.
      **/
-    public static synchronized JMXConnectorServer initialize(String portStr, Properties props) {
+    public static synchronized JMXConnectorServer startRemoteConnectorServer(String portStr, Properties props) {
 
         // Get port number
         final int port;
@@ -306,6 +328,22 @@
             throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, portStr);
         }
 
+        // User can specify a port to be used to export rmi object,
+        // in order to simplify firewall rules
+        // if port is not specified random one will be allocated.
+        int rmiPort = 0;
+        String rmiPortStr = props.getProperty(PropertyNames.RMI_PORT);
+        try {
+            if (rmiPortStr != null) {
+               rmiPort = Integer.parseInt(rmiPortStr);
+            }
+        } catch (NumberFormatException x) {
+            throw new AgentConfigurationError(INVALID_JMXREMOTE_RMI_PORT, x, rmiPortStr);
+        }
+        if (rmiPort < 0) {
+            throw new AgentConfigurationError(INVALID_JMXREMOTE_RMI_PORT, rmiPortStr);
+        }
+
         // Do we use authentication?
         final String useAuthenticationStr =
                 props.getProperty(PropertyNames.USE_AUTHENTICATION,
@@ -387,9 +425,10 @@
         }
 
         if (log.debugOn()) {
-            log.debug("initialize",
-                    Agent.getText("jmxremote.ConnectorBootstrap.initialize") +
+            log.debug("startRemoteConnectorServer",
+                    Agent.getText("jmxremote.ConnectorBootstrap.starting") +
                     "\n\t" + PropertyNames.PORT + "=" + port +
+                    "\n\t" + PropertyNames.RMI_PORT + "=" + rmiPort +
                     "\n\t" + PropertyNames.USE_SSL + "=" + useSsl +
                     "\n\t" + PropertyNames.USE_REGISTRY_SSL + "=" + useRegistrySsl +
                     "\n\t" + PropertyNames.SSL_CONFIG_FILE_NAME + "=" + sslConfigFileName +
@@ -404,7 +443,7 @@
                     (useAuthentication ? (loginConfigName == null ? ("\n\t" + PropertyNames.PASSWORD_FILE_NAME + "=" +
                     passwordFileName) : ("\n\t" + PropertyNames.LOGIN_CONFIG_NAME + "=" +
                     loginConfigName)) : "\n\t" +
-                    Agent.getText("jmxremote.ConnectorBootstrap.initialize.noAuthentication")) +
+                    Agent.getText("jmxremote.ConnectorBootstrap.noAuthentication")) +
                     (useAuthentication ? ("\n\t" + PropertyNames.ACCESS_FILE_NAME + "=" +
                     accessFileName) : "") +
                     "");
@@ -415,15 +454,15 @@
         JMXServiceURL url = null;
         try {
             final JMXConnectorServerData data = exportMBeanServer(
-                    mbs, port, useSsl, useRegistrySsl,
+                    mbs, port, rmiPort, useSsl, useRegistrySsl,
                     sslConfigFileName, enabledCipherSuitesList,
                     enabledProtocolsList, sslNeedClientAuth,
                     useAuthentication, loginConfigName,
                     passwordFileName, accessFileName);
             cs = data.jmxConnectorServer;
             url = data.jmxRemoteURL;
-            log.config("initialize",
-                    Agent.getText("jmxremote.ConnectorBootstrap.initialize.ready",
+            log.config("startRemoteConnectorServer",
+                    Agent.getText("jmxremote.ConnectorBootstrap.ready",
                     url.toString()));
         } catch (Exception e) {
             throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
@@ -442,7 +481,7 @@
             // Remote connector server started but unable to export remote
             // connector address and associated configuration properties to
             // the instrumentation buffer - non-fatal error.
-            log.debug("initialize", e);
+            log.debug("startRemoteConnectorServer", e);
         }
         return cs;
     }
@@ -517,9 +556,9 @@
         try {
             if (fs.supportsFileSecurity(file)) {
                 if (!fs.isAccessUserOnly(file)) {
-                    final String msg = Agent.getText("jmxremote.ConnectorBootstrap.initialize.password.readonly",
+                    final String msg = Agent.getText("jmxremote.ConnectorBootstrap.password.readonly",
                             passwordFileName);
-                    log.config("initialize", msg);
+                    log.config("startRemoteConnectorServer", msg);
                     throw new AgentConfigurationError(PASSWORD_FILE_ACCESS_NOT_RESTRICTED,
                             passwordFileName);
                 }
@@ -560,9 +599,9 @@
             if (fs.supportsFileSecurity(file)) {
                 if (!fs.isAccessUserOnly(file)) {
                     final String msg = Agent.getText(
-                            "jmxremote.ConnectorBootstrap.initialize.file.readonly",
+                            "jmxremote.ConnectorBootstrap.file.readonly",
                             restrictedFileName);
-                    log.config("initialize", msg);
+                    log.config("startRemoteConnectorServer", msg);
                     throw new AgentConfigurationError(
                             FILE_ACCESS_NOT_RESTRICTED, restrictedFileName);
                 }
@@ -662,6 +701,7 @@
     private static JMXConnectorServerData exportMBeanServer(
             MBeanServer mbs,
             int port,
+            int rmiPort,
             boolean useSsl,
             boolean useRegistrySsl,
             String sslConfigFileName,
@@ -679,7 +719,7 @@
          * IDs.  */
         System.setProperty("java.rmi.server.randomIDs", "true");
 
-        JMXServiceURL url = new JMXServiceURL("rmi", null, 0);
+        JMXServiceURL url = new JMXServiceURL("rmi", null, rmiPort);
 
         Map<String, Object> env = new HashMap<>();
 
@@ -736,7 +776,6 @@
             }
         }
 
-        final Registry registry;
         if (useRegistrySsl) {
             registry =
                     new SingleEntryRegistry(port, csf, ssf,
@@ -747,10 +786,12 @@
                     "jmxrmi", exporter.firstExported);
         }
 
-        JMXServiceURL remoteURL = new JMXServiceURL(
-                "service:jmx:rmi:///jndi/rmi://" + url.getHost() + ":" +
-                ((UnicastRef) ((RemoteObject) registry).getRef()).getLiveRef().getPort() +
-                "/jmxrmi");
+
+        int registryPort =
+            ((UnicastRef) ((RemoteObject) registry).getRef()).getLiveRef().getPort();
+        String jmxUrlStr =  String.format("service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi",
+                                           url.getHost(), registryPort);
+        JMXServiceURL remoteURL = new JMXServiceURL(jmxUrlStr);
 
         /* Our exporter remembers the first object it was asked to
         export, which will be an RMIServerImpl appropriate for
--- a/jdk/src/share/classes/sun/management/resources/agent.properties	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/sun/management/resources/agent.properties	Wed Jul 05 18:04:20 2017 +0200
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,8 +43,9 @@
 agent.err.premain.notfound         = premain(String) does not exist in agent class
 agent.err.agentclass.access.denied = Access to premain(String) is denied
 agent.err.invalid.agentclass       = Invalid com.sun.management.agent.class property value
-
+agent.err.invalid.state            = Invalid agent state
 agent.err.invalid.jmxremote.port   = Invalid com.sun.management.jmxremote.port number
+agent.err.invalid.jmxremote.rmi.port = Invalid com.sun.management.jmxremote.rmi.port number
 
 agent.err.file.not.set               = File not specified
 agent.err.file.not.readable          = File not readable
@@ -78,11 +79,11 @@
 agent.err.snmp.adaptor.start.failed = Failed to start SNMP adaptor with address
 agent.err.snmp.mib.init.failed     = Failed to initialize SNMP MIB with error
 
-jmxremote.ConnectorBootstrap.initialize = Starting JMX Connector Server:
-jmxremote.ConnectorBootstrap.initialize.noAuthentication = No Authentication
-jmxremote.ConnectorBootstrap.initialize.ready = JMX Connector ready at: {0}
-jmxremote.ConnectorBootstrap.initialize.password.readonly = Password file read access must be restricted: {0}
-jmxremote.ConnectorBootstrap.initialize.file.readonly = File read access must be restricted: {0}
+jmxremote.ConnectorBootstrap.starting = Starting JMX Connector Server:
+jmxremote.ConnectorBootstrap.noAuthentication = No Authentication
+jmxremote.ConnectorBootstrap.ready = JMX Connector ready at: {0}
+jmxremote.ConnectorBootstrap.password.readonly = Password file read access must be restricted: {0}
+jmxremote.ConnectorBootstrap.file.readonly = File read access must be restricted: {0}
 
 jmxremote.AdaptorBootstrap.getTargetList.processing = Processing ACL
 jmxremote.AdaptorBootstrap.getTargetList.adding = Adding target: {0}
--- a/jdk/src/share/classes/sun/security/provider/PolicyFile.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/sun/security/provider/PolicyFile.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1246,7 +1246,10 @@
      * @return the set of permissions according to the policy.
      */
     private PermissionCollection getPermissions(Permissions perms,
-                               final CodeSource cs) {
+                                                final CodeSource cs) {
+
+        if (cs == null)
+            return perms;
 
         CodeSource canonCodeSource = AccessController.doPrivileged(
             new java.security.PrivilegedAction<CodeSource>(){
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -79,13 +79,18 @@
     private static final int TRANSITION_NSHIFT = 12;
 
     // Flag for supporting JDK backward compatible IDs, such as "EST".
-    private static final boolean USE_OLDMAPPING;
+    static final boolean USE_OLDMAPPING;
     static {
       String oldmapping = AccessController.doPrivileged(
           new sun.security.action.GetPropertyAction("sun.timezone.ids.oldmapping", "false")).toLowerCase(Locale.ROOT);
       USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true"));
     }
 
+    // IDs having conflicting data between Olson and JDK 1.1
+    static final String[] conflictingIDs = {
+        "EST", "MST", "HST"
+    };
+
     private static final CalendarSystem gcal = CalendarSystem.getGregorianCalendar();
 
     /**
@@ -808,6 +813,16 @@
 
     private static SoftReference<Map<String, String>> aliasTable;
 
+    static Map<String, String> getCachedAliasTable() {
+        Map<String, String> aliases = null;
+
+        SoftReference<Map<String, String>> cache = aliasTable;
+        if (cache != null) {
+            aliases = cache.get();
+        }
+        return aliases;
+    }
+
     /**
      * Returns a Map from alias time zone IDs to their standard
      * time zone IDs.
@@ -816,23 +831,22 @@
      *    to their standard time zone IDs, or null if
      *    <code>ZoneInfoMappings</code> file is not available.
      */
-    public synchronized static Map<String, String> getAliasTable() {
-        Map<String, String> aliases = null;
-
-        SoftReference<Map<String, String>> cache = aliasTable;
-        if (cache != null) {
-            aliases = cache.get();
-            if (aliases != null) {
-                return aliases;
-            }
-        }
-
-        aliases = ZoneInfoFile.getZoneAliases();
-        if (aliases != null) {
-            aliasTable = new SoftReference<>(aliases);
-        }
-        return aliases;
-    }
+     public synchronized static Map<String, String> getAliasTable() {
+         Map<String, String> aliases = getCachedAliasTable();
+         if (aliases == null) {
+             aliases = ZoneInfoFile.getZoneAliases();
+             if (aliases != null) {
+                 if (!USE_OLDMAPPING) {
+                     // Remove the conflicting IDs from the alias table.
+                     for (String key : conflictingIDs) {
+                         aliases.remove(key);
+                     }
+                 }
+                 aliasTable = new SoftReference<Map<String, String>>(aliases);
+             }
+         }
+         return aliases;
+     }
 
     private void readObject(ObjectInputStream stream)
             throws IOException, ClassNotFoundException {
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -473,6 +473,8 @@
 
     private static Map<String, ZoneInfo> zoneInfoObjects = null;
 
+    private static final ZoneInfo GMT = new ZoneInfo("GMT", 0);
+
     private static final String ziDir = AccessController.doPrivileged(
         new PrivilegedAction<String>() {
             public String run() {
@@ -553,8 +555,15 @@
      * id.
      */
     public static ZoneInfo getZoneInfo(String id) {
+        //treat GMT zone as special
+        if ("GMT".equals(id))
+            return (ZoneInfo) GMT.clone();
         ZoneInfo zi = getFromCache(id);
         if (zi == null) {
+            Map<String, String> aliases = ZoneInfo.getCachedAliasTable();
+            if (aliases != null && aliases.get(id) != null) {
+                return null;
+            }
             zi = createZoneInfo(id);
             if (zi == null) {
                 return null;
@@ -1031,30 +1040,26 @@
      * @return the buffer, or null if any I/O error occurred.
      */
     private static byte[] readZoneInfoFile(final String fileName) {
+        if (fileName.indexOf("..") >= 0) {
+            return null;
+        }
         byte[] buffer = null;
 
         try {
             buffer = AccessController.doPrivileged(new PrivilegedExceptionAction<byte[]>() {
                 public byte[] run() throws IOException {
                     File file = new File(ziDir, fileName);
-                    if (!file.exists() || !file.isFile()) {
-                        return null;
-                    }
-                    file = file.getCanonicalFile();
-                    String path = file.getCanonicalPath();
                     byte[] buf = null;
-                    if (path != null && path.startsWith(ziDir)) {
-                        int filesize = (int)file.length();
-                        if (filesize > 0) {
-                            FileInputStream fis = new FileInputStream(file);
-                            buf = new byte[filesize];
-                            try {
-                                if (fis.read(buf) != filesize) {
-                                    throw new IOException("read error on " + fileName);
-                                }
-                            } finally {
-                                fis.close();
+                    int filesize = (int)file.length();
+                    if (filesize > 0) {
+                        FileInputStream fis = new FileInputStream(file);
+                        buf = new byte[filesize];
+                        try {
+                            if (fis.read(buf) != filesize) {
+                                throw new IOException("read error on " + fileName);
                             }
+                        } finally {
+                            fis.close();
                         }
                     }
                     return buf;
--- a/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java	Wed Jul 05 18:04:20 2017 +0200
@@ -105,7 +105,6 @@
         this.target = target;
 
         //ComponentAccessor.enableEvents(target,AWTEvent.MOUSE_WHEEL_EVENT_MASK);
-        target.enableInputMethods(true);
 
         firstChangeSkipped = false;
         String text = ((TextArea)target).getText();
@@ -113,7 +112,6 @@
         jtext.setWrapStyleWord(true);
         jtext.getDocument().addDocumentListener(jtext);
         XToolkit.specialPeerMap.put(jtext,this);
-        jtext.enableInputMethods(true);
         textPane = new AWTTextPane(jtext,this, target.getParent());
 
         setBounds(x, y, width, height, SET_BOUNDS);
--- a/jdk/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java	Wed Jul 05 18:04:20 2017 +0200
@@ -73,8 +73,6 @@
         xtext = new XAWTTextField(text,this, target.getParent());
         xtext.getDocument().addDocumentListener(xtext);
         xtext.setCursor(target.getCursor());
-        target.enableInputMethods(true);
-        xtext.enableInputMethods(true);
         XToolkit.specialPeerMap.put(xtext,this);
 
         TextField txt = (TextField) target;
--- a/jdk/test/ProblemList.txt	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/test/ProblemList.txt	Wed Jul 05 18:04:20 2017 +0200
@@ -1,6 +1,6 @@
 ###########################################################################
 #
-# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -125,15 +125,15 @@
 # 7123972
 java/lang/annotation/loaderLeak/Main.java			generic-all
 
-# 7079093
-java/lang/instrument/ManifestTest.sh                            windows-all
-
 # 6944188
 java/lang/management/ThreadMXBean/ThreadStateTest.java          generic-all
 
 # 7067973
 java/lang/management/MemoryMXBean/CollectionUsageThreshold.java generic-all
 
+# 7148492
+java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java	generic-all
+
 ############################################################################
 
 # jdk_management
@@ -144,9 +144,8 @@
 # 7144846
 javax/management/remote/mandatory/connection/ReconnectTest.java	generic-all
 
-# 7073626
-sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh          windows-all
-sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh       windows-all
+# 7149181 
+sun/management/jmxremote/startstop/JMXStartStopTest.sh          generic-all
 
 ############################################################################
 
@@ -185,6 +184,10 @@
 # 7102702
 java/net/PortUnreachableException/OneExceptionOnly.java         windows-all
 
+# 7148829
+sun/net/InetAddress/nameservice/simple/CacheTest.java		generic-all
+sun/net/InetAddress/nameservice/simple/DefaultCaching.java	generic-all
+
 ############################################################################
 
 # jdk_io
@@ -215,6 +218,9 @@
 # 6948101
 java/rmi/transport/pinLastArguments/PinLastArguments.java	generic-all
 
+# 7146541
+java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java	linux-all
+
 # 7132247
 java/rmi/registry/readTest/readTest.sh				windows-all
 
@@ -339,4 +345,3 @@
 java/util/TimeZone/TimeZoneDatePermissionCheck.sh               solaris-all
 
 ############################################################################
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI/7089914/bug7089914.java	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Portions Copyright (c) 2012 IBM Corporation
+ */
+
+/* @test
+ * @bug 7089914
+ * @summary Focus on image icons are not visible in javaws cache with high contrast mode
+ * @author Sean Chou
+ */
+
+import javax.swing.*;
+import java.lang.reflect.Field;
+
+public class bug7089914 {
+
+    public static void main(String[] args) throws Exception {
+        try {
+            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+        } catch (Exception e) {
+            System.out.println("Not WindowsLookAndFeel, test skipped");
+
+            return;
+        }
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+
+                JRadioButton rb = new JRadioButton();
+
+                if (!"com.sun.java.swing.plaf.windows.WindowsRadioButtonUI".equals(rb.getUI().getClass().getName())) {
+                    throw new RuntimeException("Unexpected UI class of JRadioButton");
+                }
+
+                try {
+                    Field initializedField = rb.getUI().getClass().getDeclaredField("initialized");
+                    initializedField.setAccessible(true);
+
+                    if (!initializedField.getBoolean(rb.getUI())) {
+                        throw new RuntimeException("initialized is false");
+                    }
+
+                    rb.getUI().uninstallUI(rb);
+
+                    if (initializedField.getBoolean(rb.getUI())) {
+                        throw new RuntimeException("initialized is true");
+                    }
+                } catch (NoSuchFieldException | IllegalAccessException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        });
+    }
+}
--- a/jdk/test/java/lang/instrument/ManifestTest.sh	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/test/java/lang/instrument/ManifestTest.sh	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -396,7 +396,7 @@
         touch $FAIL_MARKER
     fi
 
-    MESG=`cat expect_boot_cp_line`
+    MESG=`cat expect_boot_cp_line | tr -d '\n\r'`
     grep -s "$MESG" output.log > /dev/null
     result=$?
     if [ "$result" = 0 ]; then
@@ -406,7 +406,7 @@
         touch $FAIL_MARKER
     fi
 
-    MESG=`cat expect_redef_line`
+    MESG=`cat expect_redef_line | tr -d '\n\r'`
     grep -s "$MESG" output.log > /dev/null
     result=$?
     if [ "$result" = 0 ]; then
@@ -416,7 +416,7 @@
         touch $FAIL_MARKER
     fi
 
-    MESG=`cat expect_retrans_line`
+    MESG=`cat expect_retrans_line | tr -d '\n\r'`
     grep -s "$MESG" output.log > /dev/null
     result=$?
     if [ "$result" = 0 ]; then
@@ -426,7 +426,7 @@
         touch $FAIL_MARKER
     fi
 
-    MESG=`cat expect_set_nmp_line`
+    MESG=`cat expect_set_nmp_line | tr -d '\n\r'`
     grep -s "$MESG" output.log > /dev/null
     result=$?
     if [ "$result" = 0 ]; then
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Collections/EqualsTest.java	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7144488
+ * @summary Infinite recursion for some equals tests in Collections
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class EqualsTest {
+    public static void main(String[] args) {
+        boolean test;
+
+        /* synchronizedList test */
+        List list = Collections.synchronizedList(new ArrayList());
+        list.add(list);
+        test = list.equals(list);
+        assertTrue(test);
+        list.remove(list);
+
+        /* synchronizedSet test */
+        Set s = Collections.synchronizedSet(new HashSet());
+        s.add(s);
+        test = s.equals(s);
+        assertTrue(test);
+
+        /* synchronizedMap test */
+        Map m =  Collections.synchronizedMap(new HashMap());
+        test = m.equals(m);
+        assertTrue(test);
+
+    }
+
+    private static void assertTrue(boolean b) {
+        if (!b)
+            throw new RuntimeException("assertion failed");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTable/4220171/bug4220171.java	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4220171
+ * @author Konstantin Eremin
+ * @summary Tests
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main bug4220171
+ */
+import java.awt.Color;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import javax.swing.*;
+import javax.swing.border.LineBorder;
+import sun.awt.SunToolkit;
+
+public class bug4220171 {
+
+    private static JTable table;
+
+    public static void main(String args[]) throws Exception {
+
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+        robot.setAutoDelay(50);
+
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        clickMouse(robot, 0, 0);
+        Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_ENTER);
+        toolkit.realSync();
+        checkCell(0, 0);
+
+        clickMouse(robot, 0, 1);
+        Util.hitKeys(robot, KeyEvent.VK_D, KeyEvent.VK_E, KeyEvent.VK_ENTER);
+        toolkit.realSync();
+        checkCell(0, 1);
+
+        clickMouse(robot, 1, 0);
+        Util.hitKeys(robot, KeyEvent.VK_1, KeyEvent.VK_2, KeyEvent.VK_ENTER);
+        toolkit.realSync();
+        checkCell(1, 0);
+
+        clickMouse(robot, 1, 1);
+        Util.hitKeys(robot, KeyEvent.VK_4, KeyEvent.VK_5, KeyEvent.VK_ENTER);
+        toolkit.realSync();
+        checkCell(1, 1);
+    }
+
+    static void checkCell(final int row, final int column) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                if (table.getValueAt(row, column) != null) {
+                    throw new RuntimeException(
+                            String.format("Cell (%d, %d) is editable", row, column));
+                }
+            }
+        });
+    }
+
+    static void clickMouse(Robot robot, int row, int column) throws Exception {
+        Point point = getCellClickPoint(row, column);
+        robot.mouseMove(point.x, point.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+    }
+
+    private static Point getCellClickPoint(final int row, final int column) throws Exception {
+        final Point[] result = new Point[1];
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                Rectangle rect = table.getCellRect(row, column, false);
+                Point point = new Point(rect.x + rect.width / 2,
+                        rect.y + rect.height / 2);
+                SwingUtilities.convertPointToScreen(point, table);
+                result[0] = point;
+            }
+        });
+
+        return result[0];
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame("Test");
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setSize(200, 200);
+
+        table = new JTable(2, 2);
+        table.setEnabled(false);
+
+        frame.getContentPane().add(table);
+        frame.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JToolBar/4247996/bug4247996.java	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 4247996 4260485
+ * @summary Test that rollover toolbar doesn't corrupt buttons
+ * @author Peter Zhelezniakov
+ * @run main bug4247996
+ */
+import java.awt.*;
+import javax.swing.*;
+import sun.awt.SunToolkit;
+
+public class bug4247996 {
+
+    private static JButton button;
+    private static JToggleButton toogleButton;
+
+    public static void main(String[] args) throws Exception {
+
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+        robot.setAutoDelay(50);
+
+        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        Point point = getButtonCenter();
+        robot.mouseMove(point.x, point.y);
+        toolkit.realSync();
+
+        checkButtonsSize();
+
+    }
+
+    private static void checkButtonsSize() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                if (!button.getSize().equals(toogleButton.getSize())) {
+                    throw new RuntimeException("Button sizes are different!");
+                }
+            }
+        });
+    }
+
+    private static Point getButtonCenter() throws Exception {
+        final Point[] result = new Point[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                Point p = button.getLocationOnScreen();
+                Dimension size = button.getSize();
+                result[0] = new Point(p.x + size.width / 2, p.y + size.height / 2);
+            }
+        });
+        return result[0];
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame("Test");
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setSize(200, 200);
+
+        JButton rButton = new JButton("Rollover");
+        rButton.setRolloverEnabled(true);
+        JToolBar nrToolbar = new JToolBar();
+        nrToolbar.add(rButton);
+        nrToolbar.remove(rButton);
+
+        if (!rButton.isRolloverEnabled()) {
+            throw new Error("Failed (bug 4260485): "
+                    + "toolbar overrode button's rollover property");
+        }
+
+        JToolBar rToolbar = new JToolBar();
+        rToolbar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
+        rToolbar.add(button = new JButton("Test"));
+        rToolbar.add(toogleButton = new JToggleButton("Test"));
+
+        frame.getContentPane().add(rToolbar, BorderLayout.NORTH);
+        frame.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JToolTip/4846413/bug4846413.java	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4846413
+ * @summary Checks if No tooltip modification when no KeyStroke modifier
+ * @library ../../regtesthelpers
+ * @build Util
+ * @author Konstantin Eremin
+ * @run main bug4846413
+ */
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import javax.swing.*;
+import java.awt.event.*;
+import javax.swing.plaf.metal.MetalToolTipUI;
+import sun.awt.SunToolkit;
+
+public class bug4846413 {
+
+    private static volatile boolean isTooltipAdded;
+    private static JButton button;
+
+    public static void main(String[] args) throws Exception {
+
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+        robot.setAutoDelay(50);
+
+        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        Point movePoint = getButtonPoint();
+        robot.mouseMove(movePoint.x, movePoint.y);
+        toolkit.realSync();
+
+        long timeout = System.currentTimeMillis() + 9000;
+        while (!isTooltipAdded && (System.currentTimeMillis() < timeout)) {
+            try {Thread.sleep(500);} catch (Exception e) {}
+        }
+
+        checkToolTip();
+    }
+
+    private static void checkToolTip() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                JToolTip tooltip = (JToolTip) Util.findSubComponent(
+                        JFrame.getFrames()[0], "JToolTip");
+
+                if (tooltip == null) {
+                    throw new RuntimeException("Tooltip has not been found!");
+                }
+
+                MetalToolTipUI tooltipUI = (MetalToolTipUI) MetalToolTipUI.createUI(tooltip);
+                tooltipUI.installUI(tooltip);
+
+                if (!"-Insert".equals(tooltipUI.getAcceleratorString())) {
+                    throw new RuntimeException("Tooltip acceleration is not properly set!");
+                }
+
+            }
+        });
+    }
+
+    private static Point getButtonPoint() throws Exception {
+        final Point[] result = new Point[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                Point p = button.getLocationOnScreen();
+                Dimension size = button.getSize();
+                result[0] = new Point(p.x + size.width / 2, p.y + size.height / 2);
+            }
+        });
+        return result[0];
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame("Test");
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setSize(200, 200);
+
+        button = new JButton("Press me");
+        button.setToolTipText("test");
+        button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+                KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0, true), "someCommand");
+        button.getActionMap().put("someCommand", null);
+        frame.getContentPane().add(button);
+
+        JLayeredPane layeredPane = (JLayeredPane) Util.findSubComponent(
+                frame, "JLayeredPane");
+        layeredPane.addContainerListener(new ContainerAdapter() {
+
+            @Override
+            public void componentAdded(ContainerEvent e) {
+                isTooltipAdded = true;
+            }
+        });
+
+        frame.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/4330357/bug4330357.java	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4330357
+ * @summary Tests that real editor in JTree cleans up after editing was stopped
+ * @library ../../regtesthelpers
+ * @build Util
+ * @author Peter Zhelezniakov
+ * @run main bug4330357
+ */
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.tree.*;
+import sun.awt.SunToolkit;
+
+public class bug4330357 {
+
+    private static JTree tree;
+    private static JButton button;
+    private static Robot robot;
+
+    public static void main(String[] args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        robot = new Robot();
+        robot.setAutoDelay(50);
+
+        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        clickMouse(getTreeRowClickPoint(1));
+        Util.hitKeys(robot, KeyEvent.VK_F2);
+        Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_C);
+        toolkit.realSync();
+
+        if (!hasComponent(JTextField.class)) {
+            throw new RuntimeException("Cell editor is missed for path: color");
+        }
+
+
+        clickMouse(getButtonClickPoint());
+        toolkit.realSync();
+
+        clickMouse(getTreeRowClickPoint(2));
+        Util.hitKeys(robot, KeyEvent.VK_F2);
+        toolkit.realSync();
+
+        if (!hasComponent(JComboBox.class)) {
+            throw new RuntimeException("Cell editor is missed for path: sports");
+        }
+
+        if (hasComponent(JTextField.class)) {
+            throw new RuntimeException("Cell editor is wrongly shown for path: color");
+        }
+    }
+
+    static void clickMouse(Point point) {
+        robot.mouseMove(point.x, point.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+    }
+
+    private static Point getTreeRowClickPoint(final int row) throws Exception {
+        final Point[] result = new Point[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+
+                Rectangle rect = tree.getRowBounds(row);
+                Point p = new Point(rect.x + rect.width / 2, rect.y + 2);
+                SwingUtilities.convertPointToScreen(p, tree);
+                result[0] = p;
+            }
+        });
+
+        return result[0];
+    }
+
+    private static Point getButtonClickPoint() throws Exception {
+        final Point[] result = new Point[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                Point p = button.getLocationOnScreen();
+                Dimension size = button.getSize();
+                result[0] = new Point(p.x + size.width / 2, p.y + size.height / 2);
+            }
+        });
+        return result[0];
+    }
+
+    static boolean hasComponent(final Class cls) throws Exception {
+        final boolean[] result = new boolean[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                result[0] = Util.findSubComponent(tree, cls.getName()) != null;
+            }
+        });
+
+        return result[0];
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame("Test");
+        frame.setSize(200, 200);
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        tree = new JTree();
+        tree.setEditable(true);
+
+        final TestEditor testEditor = new TestEditor();
+        tree.setCellEditor(new DefaultTreeCellEditor(tree,
+                (DefaultTreeCellRenderer) tree.getCellRenderer(),
+                testEditor));
+
+        button = new JButton("stop");
+
+        button.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent ae) {
+                testEditor.stopCellEditing();
+            }
+        });
+
+        frame.getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
+        frame.getContentPane().add(button, BorderLayout.SOUTH);
+        frame.setVisible(true);
+    }
+
+    static class TestEditor extends AbstractCellEditor implements TreeCellEditor {
+
+        private JComboBox comboBox;
+        private JTextField textField;
+        private boolean comboBoxActive;
+
+        TestEditor() {
+            comboBox = new JComboBox(new String[]{"one", "two"});
+            textField = new JTextField();
+        }
+
+        public Component getTreeCellEditorComponent(JTree tree, Object value,
+                boolean isSelected,
+                boolean expanded,
+                boolean leaf, int row) {
+            if (row % 2 == 0) {
+                comboBoxActive = true;
+                return comboBox;
+            }
+            comboBoxActive = false;
+            return textField;
+        }
+
+        public Object getCellEditorValue() {
+            if (comboBoxActive) {
+                return comboBox.getSelectedItem();
+            }
+            return textField.getText();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JViewport/7107099/bug7107099.java	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7107099
+   @summary JScrollBar does not show up even if there are enough lebgth of textstring in textField
+   @author Pavel Porvatov
+*/
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class bug7107099 {
+    private static JFrame frame;
+    private static JTextArea textarea;
+    private static JScrollPane scrollPane;
+
+    private static int value;
+    private static int min;
+    private static int max;
+    private static int extent;
+
+    public static void main(String[] args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                textarea = new JTextArea("before###1###\nbefore###2###\nbefore###3###\nbefore###4###\nbefore###5###\n");
+
+                scrollPane = new JScrollPane(textarea);
+                scrollPane.setPreferredSize(new Dimension(100, 50));
+
+                frame = new JFrame();
+                frame.setLayout(new BorderLayout());
+                frame.setSize(200, 200);
+                frame.add(scrollPane, BorderLayout.SOUTH);
+                frame.setVisible(true);
+            }
+        });
+
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
+
+                value = model.getValue();
+                min = model.getMinimum();
+                max = model.getMaximum();
+                extent = model.getExtent();
+
+                // Do tricky manipulation for testing purpose
+                textarea.setText(null);
+                scrollPane.setViewportView(textarea);
+                textarea.setText("after###1###\nafter###1###\nafter###1###\nafter###1###\nafter###1###\n");
+                textarea.setCaretPosition(0);
+            }
+        });
+
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
+
+                if (value != model.getValue() ||
+                        min != model.getMinimum() ||
+                        max != model.getMaximum() ||
+                        extent != model.getExtent()) {
+                    throw new RuntimeException("Test bug7107099 failed");
+                }
+
+                System.out.println("Test bug7107099 passed");
+
+                frame.dispose();
+            }
+        });
+    }
+}
--- a/jdk/test/sun/management/AgentCheckTest.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/test/sun/management/AgentCheckTest.java	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,10 +35,10 @@
     public static void main(String[] args){
         String [][] testStrings = {
             {"agent.err.error", "", ""},
-            {"jmxremote.ConnectorBootstrap.initialize", "", ""},
-            {"jmxremote.ConnectorBootstrap.initialize.noAuthentication", "", ""},
-            {"jmxremote.ConnectorBootstrap.initialize.ready", "Phony JMXServiceURL", ""},
-            {"jmxremote.ConnectorBootstrap.initialize.password.readonly", "Phony passwordFileName", ""},
+            {"jmxremote.ConnectorBootstrap.starting", "", ""},
+            {"jmxremote.ConnectorBootstrap.noAuthentication", "", ""},
+            {"jmxremote.ConnectorBootstrap.ready", "Phony JMXServiceURL", ""},
+            {"jmxremote.ConnectorBootstrap.password.readonly", "Phony passwordFileName", ""},
             {"jmxremote.AdaptorBootstrap.getTargetList.processing", "", ""},
             {"jmxremote.AdaptorBootstrap.getTargetList.adding", "Phony target", ""},
             {"jmxremote.AdaptorBootstrap.getTargetList.starting", "", ""},
--- a/jdk/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh	Wed Jul 05 18:04:20 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,13 @@
 OS=`uname -s`
 UMASK=`umask`
 
+if [[ $OS == CYGWIN_NT* ]] ; then
+    OS="Windows_NT"
+    if [ -z "$SystemRoot" ] ;  then
+	SystemRoot=$SYSTEMROOT
+    fi
+fi
+
 case $OS in
 SunOS | Linux)
     PATHSEP=":"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopDoSomething.java	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.RandomAccessFile;
+
+public class JMXStartStopDoSomething {
+
+
+    public void doSomething(){
+        try {
+            for (int i=0; i < 10; ++i) {
+                RandomAccessFile f = new RandomAccessFile("/dev/null","r");
+                int n = f.read();
+                f.close();
+            }
+
+        } catch (Throwable e) {
+            System.err.println("Something bad happens:" +e);
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+        System.err.println("main enter");
+        int count = 1;
+        while(count > 0) {
+            JMXStartStopDoSomething p = new JMXStartStopDoSomething();
+            p.doSomething();
+            Thread.sleep(1);
+        }
+        // System.err.println("main exit");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.management.*;
+import javax.management.remote.*;
+
+import sun.management.AgentConfigurationError;
+import sun.management.jmxremote.ConnectorBootstrap;
+
+public class JMXStartStopTest {
+
+    static boolean verbose = false;
+
+    static void dbg_print(String msg){
+        if (verbose) {
+            System.err.println("DBG: " +msg);
+        }
+    }
+
+    static void dbg_print(String msg, Throwable ex){
+        if (verbose) {
+            System.err.println("DBG: " + msg + " " + ex.getMessage() );
+            ex.printStackTrace(System.err);
+        }
+    }
+
+    public static int listMBeans(MBeanServerConnection server, ObjectName pattern, QueryExp query)
+    throws Exception {
+
+        Set names = server.queryNames(pattern,query);
+        for (Iterator i=names.iterator(); i.hasNext(); ) {
+            ObjectName name = (ObjectName)i.next();
+            MBeanInfo info = server.getMBeanInfo(name);
+            dbg_print("Got MBean: " + name);
+
+            MBeanAttributeInfo[] attrs = info.getAttributes();
+            if (attrs == null)
+                continue;
+
+            for (int j=0; j<attrs.length; j++) {
+                if (attrs[j].isReadable()) {
+                    Object o = server.getAttribute(name,attrs[j].getName());
+                }
+            }
+        }
+        return names.size();
+    }
+
+
+    public void run_local(String strPid)
+    throws Exception {
+
+        String jmxUrlStr = null;
+        int pid = Integer.parseInt(strPid);
+
+        try {
+            jmxUrlStr = sun.management.ConnectorAddressLink.importFrom(pid);
+            dbg_print("Local Service URL: " +jmxUrlStr);
+            if ( jmxUrlStr == null ) {
+                throw new Exception("No Service URL. Local agent not started?");
+            }
+
+            JMXServiceURL url = new JMXServiceURL(jmxUrlStr);
+            Map m = new HashMap();
+
+            JMXConnector c = JMXConnectorFactory.connect(url,m);
+
+            MBeanServerConnection conn = c.getMBeanServerConnection();
+            ObjectName pattern = new ObjectName("java.lang:type=Memory,*");
+
+            int count = listMBeans(conn,pattern,null);
+            if (count == 0)
+                throw new Exception("Expected at least one matching "+ "MBean for "+pattern);
+
+
+        } catch (IOException e) {
+            dbg_print("Cannot find process : " + pid);
+            throw e;
+        }
+    }
+
+    public void run(String args[]) throws Exception {
+
+        dbg_print("RmiRegistry lookup...");
+
+        int port = 4567;
+        if (args != null && args.length > 0) {
+            port = Integer.parseInt(args[0]);
+        }
+        dbg_print("Using port: " + port);
+
+        int rmiPort = 0;
+        if (args != null && args.length > 1) {
+            rmiPort = Integer.parseInt(args[1]);
+        }
+        dbg_print("Using rmi port: " + rmiPort);
+
+        Registry registry = LocateRegistry.getRegistry(port);
+
+        // "jmxrmi"
+        String[] relist = registry.list();
+        for (int i = 0; i < relist.length; ++i) {
+            dbg_print("Got registry: " + relist[i]);
+        }
+
+        String jmxUrlStr = (rmiPort != 0) ?
+                           String.format("service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", rmiPort, port) :
+                           String.format("service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi",port);
+
+        JMXServiceURL url = new JMXServiceURL(jmxUrlStr);
+        Map m = new HashMap();
+
+        JMXConnector c = JMXConnectorFactory.connect(url,m);
+
+        MBeanServerConnection conn = c.getMBeanServerConnection();
+        ObjectName pattern = new ObjectName("java.lang:type=Memory,*");
+
+        int count = listMBeans(conn,pattern,null);
+        if (count == 0)
+            throw new Exception("Expected at least one matching "+ "MBean for "+pattern);
+    }
+
+
+    public static void main(String args[]) {
+        JMXStartStopTest manager = new JMXStartStopTest();
+        try {
+            if (args!=null && args[0].equals("local")) {
+                manager.run_local(args[1]);
+            } else {
+                manager.run(args);
+            }
+        } catch (RuntimeException r) {
+            dbg_print("No connection: ", r);
+            System.out.println("NO_CONN");
+            System.exit(1);
+        } catch (Throwable t) {
+            dbg_print("No connection: ", t);
+            System.out.println("NO_CONN");
+            System.exit(2);
+        }
+        System.out.println("OK_CONN");
+        System.exit(0);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.sh	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,603 @@
+#!/bin/sh
+
+# Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+
+# @test
+# @bug 7110104
+# @build JMXStartStopTest JMXStartStopDoSomething
+# @run shell JMXStartStopTest.sh --jtreg --no-compile
+# @summary No word Failed expected in the test output
+
+_verbose=no
+_server=no
+_jtreg=no
+_compile=yes
+_testsuite="01,02,03,04,05,06,07,08,09,10,11,12,13"
+_port_one=50234
+_port_two=50235
+
+
+_testclasses=".classes"
+_testsrc=`pwd`
+
+_logname=".classes/JMXStartStopTest_output.txt"
+
+
+_compile(){
+
+    if [ ! -e ${_testclasses} ]
+    then
+	  mkdir -p ${_testclasses} 
+    fi   
+
+    rm -f ${_testclasses}/JMXStartStopTest.class
+
+    # Compile testcase
+    ${TESTJAVA}/bin/javac -d ${_testclasses} JMXStartStopDoSomething.java JMXStartStopTest.java 
+
+    if [ ! -e ${_testclasses}/JMXStartStopTest.class ]
+    then
+      echo "ERROR: Can't compile"
+      exit -1
+    fi
+}
+
+_app_start(){
+
+  if [ "${_verbose}" = "yes" ]
+  then
+     echo "RUN: ${TESTJAVA}/bin/java -server $* -cp ${_testclasses} JMXStartStopDoSomething "
+  fi 
+  ${TESTJAVA}/bin/java -server $* -cp ${_testclasses} JMXStartStopDoSomething  >> ${_logname} 2>&1 &
+  sleep 1 
+
+  pid=`_get_pid`
+  if [ "x${pid}" = "x" ]
+  then
+     echo "ERROR: Test app not started"
+     exit -1
+  fi
+
+}
+
+_get_pid(){
+    ${TESTJAVA}/bin/jps | sed -n "/JMXStartStopDoSomething/s/ .*//p"
+}
+
+_app_stop(){
+    pid=`_get_pid`
+    if [ "x${pid}" != "x" ]
+    then
+       kill $pid
+    fi
+
+    # Stop on first failed test under jtreg
+    if [ "x$1" = "xFailed" -a "${_jtreg}" = "yes" ]
+    then
+      exit -1
+    fi
+}
+   
+testme(){
+    ${TESTJAVA}/bin/java -cp ${_testclasses} JMXStartStopTest $*
+}   
+
+  
+_jcmd(){
+  if [ "${_verbose}" = "yes" ]
+  then
+     echo "RUN: ${TESTJAVA}/bin/jcmd JMXStartStopDoSomething $*"
+     ${TESTJAVA}/bin/jcmd JMXStartStopDoSomething $* 
+  else
+     ${TESTJAVA}/bin/jcmd JMXStartStopDoSomething $* > /dev/null 2>/dev/null
+  fi
+} 
+
+_echo(){
+    echo "$*"
+    echo "$*" >> ${_logname}
+}
+   
+# ============= TESTS ======================================
+   
+test_01(){
+# Run an app with JMX enabled stop it and 
+# restart on other port
+		
+    _echo "**** Test one ****"		
+
+    _app_start  -Dcom.sun.management.jmxremote.port=$1 \
+                -Dcom.sun.management.jmxremote.authenticate=false \
+	        -Dcom.sun.management.jmxremote.ssl=false 
+
+    res1=`testme $1`
+
+    _jcmd ManagementAgent.stop
+
+    res2=`testme $1`
+
+    _jcmd ManagementAgent.start jmxremote.port=$2
+
+    res3=`testme $2`
+
+
+    if [ "${res1}" = "OK_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
+    then
+	_echo "Passed"
+    else
+	_echo "Failed r1(OK):${res1} r2(NO):${res2} r3(OK):${res3}"
+    _app_stop "Failed"
+    fi
+
+    _app_stop
+
+}  
+   
+test_02(){
+# Run an app without JMX enabled 
+# start JMX by jcmd
+
+_echo "**** Test two ****"		
+_app_start  
+
+_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
+
+res1=`testme $1`
+
+if [ "${res1}" = "OK_CONN" ] 
+then
+    _echo "Passed"
+else
+    _echo "Failed r1(OK):${res1}"
+    _app_stop "Failed"
+fi
+
+_app_stop
+
+}   
+   
+test_03(){
+# Run an app without JMX enabled 
+# start JMX by jcmd on one port than on other one
+
+_echo "**** Test three ****"		
+_app_start  
+
+_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
+
+# Second agent shouldn't start
+_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
+
+# First agent should connect
+res1=`testme $1`
+
+if [ "${res1}" = "OK_CONN" ] 
+then
+    _echo "Passed $1"
+else
+    _echo "Failed r1(NO):${res1}"
+    _app_stop "Failed"
+fi
+
+#Second agent shouldn't connect
+res1=`testme $2`
+
+if [ "${res1}" = "NO_CONN" ] 
+then
+    _echo "Passed $2"
+else
+    _echo "Failed r1(OK):${res1}"
+fi
+
+_app_stop
+}   
+   
+test_04(){
+# Run an app without JMX enabled 
+# start JMX by jcmd on one port, specify rmi port explicitly
+
+_echo "**** Test four ****"		
+_app_start  
+
+_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
+
+# First agent should connect
+res1=`testme $1 $2`
+
+if [ "${res1}" = "OK_CONN" ] 
+then
+    _echo "Passed $1 $2"
+else
+    _echo "Failed r1(NO):${res1}"
+    _app_stop "Failed"
+fi
+
+_app_stop
+}   
+
+test_05(){
+# Run an app without JMX enabled, it will enable local server
+# but should leave remote server disabled  
+
+_echo "**** Test five ****"		
+_app_start  
+
+_jcmd ManagementAgent.start jmxremote=1 
+
+# First agent should connect
+res1=`testme $1`
+
+if [ "${res1}" = "NO_CONN" ] 
+then
+    _echo "Passed $1 $2"
+else
+    _echo "Failed r1(OK):${res1}"
+    _app_stop "Failed"
+fi
+
+_app_stop
+}   
+
+test_06(){
+# Run an app without JMX enabled 
+# start JMX by jcmd on one port, specify rmi port explicitly
+# attempt to start it again
+# 1) with the same port 
+# 2) with other port
+# 3) attempt to stop it twice
+# Check for valid messages in the output	
+
+_echo "**** Test six ****"		
+_app_start  
+
+_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
+
+# First agent should connect
+res1=`testme $1 $2`
+
+if [ "${res1}" = "OK_CONN" ] 
+then
+    _echo "Passed $1 $2"
+else
+    _echo "Failed r1(NO):${res1}"
+    _app_stop "Failed"
+fi
+
+_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
+
+_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
+
+_jcmd ManagementAgent.stop
+
+_jcmd ManagementAgent.stop
+
+_jcmd ManagementAgent.start jmxremote.port=22 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
+
+_app_stop
+}   
+
+test_07(){
+# Run an app without JMX enabled, but with some properties set 
+# in command line.
+# make sure these properties overriden corectly 
+
+_echo "**** Test seven ****"		
+
+_app_start   -Dcom.sun.management.jmxremote.authenticate=false \
+             -Dcom.sun.management.jmxremote.ssl=true 
+
+res1=`testme $1`
+
+_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
+
+res2=`testme $2`
+
+
+if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ] 
+then
+   echo "Passed"
+else
+	_echo "Failed r1(NO):${res1} r2(OK):${res2}"
+    _app_stop "Failed"
+fi
+
+_app_stop
+}   
+
+test_08(){
+# Run an app with JMX enabled and with some properties set 
+# in command line.
+# stop JMX agent and then start it again with different property values
+# make sure these properties overriden corectly 
+
+_echo "**** Test eight ****"		
+
+_app_start  -Dcom.sun.management.jmxremote.port=$1 \
+	    -Dcom.sun.management.jmxremote.authenticate=false \
+	    -Dcom.sun.management.jmxremote.ssl=true 
+
+res1=`testme $1`
+
+_jcmd ManagementAgent.stop
+
+res2=`testme $1`
+
+_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
+
+res3=`testme $2`
+
+
+if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
+then
+    _echo "Passed"
+else
+    _echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}"
+    _app_stop "Failed"
+fi
+ 
+_app_stop
+}   
+
+test_09(){
+# Run an app with JMX enabled and with some properties set 
+# in command line.
+# stop JMX agent and then start it again with different property values
+# specifing some property in management config file and some of them
+# in command line
+# make sure these properties overriden corectly 
+
+_echo "**** Test nine ****"		
+
+_app_start -Dcom.sun.management.config.file=${_testsrc}/management_cl.properties \
+           -Dcom.sun.management.jmxremote.authenticate=false 
+
+res1=`testme $1`
+
+_jcmd ManagementAgent.stop
+
+res2=`testme $1`
+
+_jcmd ManagementAgent.start config.file=${_testsrc}/management_jcmd.properties \
+       jmxremote.authenticate=false jmxremote.port=$2
+
+res3=`testme $2`
+
+if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
+then
+    _echo "Passed"
+else
+    _echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}"
+    _app_stop "Failed"
+fi
+ 
+_app_stop
+}   
+
+test_10(){
+# Run an app with JMX enabled and with some properties set 
+# in command line.
+# stop JMX agent and then start it again with different property values
+# stop JMX agent again and then start it without property value
+# make sure these properties overriden corectly 
+
+_echo "**** Test ten ****"		
+
+_app_start  -Dcom.sun.management.jmxremote.port=$1 \
+	    -Dcom.sun.management.jmxremote.authenticate=false \
+	    -Dcom.sun.management.jmxremote.ssl=true 
+
+res1=`testme $1`
+
+_jcmd ManagementAgent.stop
+_jcmd ManagementAgent.start jmxremote.ssl=false jmxremote.port=$1
+
+
+res2=`testme $1`
+
+_jcmd ManagementAgent.stop
+_jcmd ManagementAgent.start jmxremote.port=$1
+
+res3=`testme $1`
+
+if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" -a "${res3}" = "NO_CONN" ] 
+then
+    _echo "Passed"
+else
+    _echo "Failed r1(NO):${res1} r2(OK):${res2} r3(NO):${res3}"
+    _app_stop "Failed"
+fi
+ 
+_app_stop
+}   
+
+test_11(){
+# Run an app with JMX enabled 
+# stop remote agent 
+# make sure local agent is not affected
+
+_echo "**** Test eleven ****"		
+
+_app_start  -Dcom.sun.management.jmxremote.port=$2 \
+	    -Dcom.sun.management.jmxremote.authenticate=false \
+	    -Dcom.sun.management.jmxremote.ssl=false 
+	  
+res1=`testme $2`
+
+_jcmd ManagementAgent.stop
+
+pid=`${TESTJAVA}/bin/jps | sed -n "/JMXStartStopDoSomething/s/ .*//p"`
+res2=`testme local ${pid}`
+
+if [ "${res1}" = "OK_CONN" -a "${res2}" = "OK_CONN" ] 
+then
+    _echo "Passed"
+else
+    _echo "Failed r1(OK):${res1} r2(OK):${res2}"
+    _app_stop "Failed"
+fi
+ 
+_app_stop
+}   
+
+test_12(){
+# Run an app with JMX disabled 
+# start local agent only
+
+_echo "**** Test twelve ****"		
+
+_app_start 
+	  
+res1=`testme $1`
+
+_jcmd ManagementAgent.start_local
+
+pid=`_get_pid`
+if [ "x${pid}" = "x" ]
+then
+  res2="NO_CONN"
+else
+  res2=`testme local ${pid}`
+fi
+
+if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ] 
+then
+    _echo "Passed"
+else
+    _echo "Failed r1(NO):${res1} r2(OK):${res2}"
+    _app_stop "Failed"
+fi
+ 
+_app_stop
+}   
+
+test_13(){
+# Run an app with -javaagent make sure it works as expected - system properties are ignored
+
+_echo "**** Test 13 ****"		
+
+AGENT="${TESTJAVA}/jre/lib/management-agent.jar"
+if [ ! -f ${AGENT} ]
+ then
+  AGENT="${TESTJAVA}/lib/management-agent.jar"
+fi
+
+_app_start -javaagent:${AGENT}=com.sun.management.jmxremote.port=$1,com.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false 
+	  
+res1=`testme $1`
+
+if [ "${res1}" = "NO_CONN" ] 
+then
+    _echo "Passed"
+else
+    _echo "Failed r1(NO):${res1}"
+    _app_stop "Failed"
+fi
+ 
+_app_stop
+}   
+
+
+#============== Server tests =======================
+
+server_test_01(){
+		
+    _echo "**** Server test one ****"		
+
+    _app_start  -Dcom.sun.management.jmxremote.port=$1 \
+                -Dcom.sun.management.jmxremote.rmi.port=$2 \
+                -Dcom.sun.management.jmxremote.authenticate=false \
+                -Dcom.sun.management.jmxremote.ssl=false 
+
+}  
+
+ 
+# ============= MAIN =======================================
+
+if [ "x${TESTJAVA}" = "x" ]
+then
+  echo "TESTJAVA env have to be set"
+  exit
+fi
+
+if [ ! -x "${TESTJAVA}/bin/jcmd" ]
+then
+  echo "${TESTJAVA}/bin/jcmd"
+  echo "Doesn't exist or not an executable"
+
+  if [ "${_verbose}" != "yes" ]
+  then
+    exit
+  fi
+fi
+
+
+#------------------------------------------------------------------------------
+# reading parameters 
+
+for parm in "$@"  
+do
+   case $parm in
+  --verbose)      _verbose=yes  ;;
+  --server)       _server=yes   ;;
+  --jtreg)        _jtreg=yes    ;;
+  --no-compile)   _compile=no   ;;
+  --testsuite=*)  _testsuite=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
+  --port-one=*)   _port_one=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
+  --port-two=*)   _port_two=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
+  *) 
+     echo "Undefined parameter $parm. Try --help for help" 
+     exit 
+   ;;
+ esac 
+done
+
+if [ ${_compile} = "yes" ]
+then
+ _compile
+fi
+
+if [ ${_jtreg} = "yes" ]
+then
+ _testclasses=${TESTCLASSES}
+ _testsrc=${TESTSRC}
+ _logname="JMXStartStopTest_output.txt"
+fi
+
+rm -f ${_logname}
+
+# Start server mode tests
+# All of them require manual cleanup
+if [ "x${_server}" = "xyes" ]
+then
+  
+ server_test_01 ${_port_one} ${_port_two}
+
+else
+
+ # Local mode tests
+ for i in `echo ${_testsuite} | sed -e "s/,/ /g"`
+ do
+  test_${i} ${_port_one} ${_port_two}
+ done
+
+fi
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/jmxremote/startstop/REMOTE_TESTING.txt	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,11 @@
+1. Setup two hosts
+2. Make sure tcp connection between them works
+3. run tcpdump -i <interface> host <host2_name> and 'tcp[13] & 2!=0'
+   on host 1
+4. run JMXStartStopTest.sh --server on host2
+5. run jconsole on host1
+6. connect jconsole to host2:50234
+   Make sure jconsole works
+   Make sure only host2.50234 and host2.50235 appears in tcpdump output.
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/jmxremote/startstop/management_cl.properties	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,2 @@
+com.sun.management.jmxremote.ssl=true
+com.sun.management.internal.read_from_config_file_cl=true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/jmxremote/startstop/management_jcmd.properties	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,3 @@
+com.sun.management.jmxremote.ssl=false
+jmxremote.authenticate=true
+com.sun.management.internal.read_from_config_file_jcmd=true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/provider/PolicyFile/NullCodeSource.java	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7147830
+ * @summary PolicyFile.getPermissions(CodeSource) should return
+ *          empty permissions when passed in null code source
+ */
+
+import java.security.CodeSource;
+import java.security.PermissionCollection;
+import java.security.Policy;
+
+public class NullCodeSource {
+    public static void main(String[] args) throws Exception {
+        Policy policy = Policy.getPolicy();
+        PermissionCollection perms = policy.getPermissions((CodeSource)null);
+        if (perms.elements().hasMoreElements()) {
+            System.err.println(perms);
+            throw new Exception("PermissionCollection is not empty");
+        }
+    }
+}
--- a/jdk/test/tools/launcher/Settings.java	Thu Mar 01 12:23:07 2012 -0800
+++ b/jdk/test/tools/launcher/Settings.java	Wed Jul 05 18:04:20 2017 +0200
@@ -75,14 +75,14 @@
     static void runTestOptionDefault() throws IOException {
         TestResult tr = null;
         tr = doExec(javaCmd, "-Xms64m", "-Xmx512m",
-                "-Xss128k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
+                "-Xss256k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
         containsAllOptions(tr);
         if (!tr.isOK()) {
             System.out.println(tr.status);
             throw new RuntimeException("test fails");
         }
         tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m",
-                "-Xss122880", "-XshowSettings", "-jar", testJar.getAbsolutePath());
+                "-Xss256000", "-XshowSettings", "-jar", testJar.getAbsolutePath());
         containsAllOptions(tr);
         if (!tr.isOK()) {
             System.out.println(tr.status);
--- a/make/sanity-rules.gmk	Thu Mar 01 12:23:07 2012 -0800
+++ b/make/sanity-rules.gmk	Wed Jul 05 18:04:20 2017 +0200
@@ -38,7 +38,7 @@
 endif
 
 ifeq ($(BUILD_JDK), true)
-  sanity:: jdk-sanity 
+  sanity:: jdk-sanity
 endif
 
 # Only need these sanity rules when not doing a debug build
@@ -64,7 +64,7 @@
 purge-sanity: $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE)
 	-@$(RM) $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE)
 
-pre-sanity: purge-sanity 
+pre-sanity: purge-sanity
 
 # this should be the last rule in any target's sanity rule.
 post-sanity post-sanity-hotspot post-sanity-jdk post-sanity-install post-sanity-deploy:
@@ -132,7 +132,7 @@
 	   "        $* defined. Please unset it and restart your build. \n" \
 	   "" >> $(ERROR_FILE)
 
-# Check the environment variables	
+# Check the environment variables
 environment: $(DO_NOT_SET_LIST:%=%.do_not_set)
 ifeq ($(LANGTOOLS_SRC_AVAILABLE), true)
   ifneq ($(BUILD_LANGTOOLS), true)
@@ -205,7 +205,15 @@
   endif
 endif
 ifeq ($(GENERATE_DOCS),false)
-	@$(ECHO) "WARNING: This build does not include running javadoc.\n" \
+	@$(ECHO) "WARNING: This build does not include generating javadoc.\n" \
+	   "" >> $(WARNING_FILE)
+endif
+ifdef NO_DEMOS
+	@$(ECHO) "WARNING: This build and any install images will not include demos.\n" \
+	   "" >> $(WARNING_FILE)
+endif
+ifdef NO_SAMPLES
+	@$(ECHO) "WARNING: This build and any install images will not include samples.\n" \
 	   "" >> $(WARNING_FILE)
 endif
 ifdef NO_IMAGES
@@ -231,7 +239,7 @@
     HOSTNAME := $(shell hostname)
   endif
 endif
-settings:: 
+settings::
 	@$(ECHO) "Build Machine Information:" >> $(MESSAGE_FILE)
 ifeq ($(PLATFORM), windows)
 	@$(ECHO) "   build machine = $(COMPUTERNAME)"  >> $(MESSAGE_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/scripts/normalizer.pl	Wed Jul 05 18:04:20 2017 +0200
@@ -0,0 +1,208 @@
+#!/usr/bin/perl
+
+#
+# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# Parses java files:
+#   1. Removes from the end of lines spaces and TABs
+#   2. Replaces TABs by spaces
+#   3. Replaces all NewLine separators by Unix NewLine separators
+#   4. Makes one and only one empty line at the end of each file
+
+if ($#ARGV < 0) {
+    &usage;
+    
+    die;
+}
+
+use Cwd 'abs_path';
+
+my @extensions = ("java");
+
+# Read options
+my $dirpos = 0;
+
+while ($dirpos < $#ARGV) {
+    if ($ARGV[$dirpos] eq "-e") {
+        @extensions = split(/,/, $ARGV[$dirpos + 1]);
+    } else {
+        last;
+    }
+
+    $dirpos += 2;
+}
+
+if ($dirpos > $#ARGV) {
+    &usage;
+
+    die;
+}
+
+use Cwd;
+my $currdir = getcwd;
+
+my $allfiles = 0;
+
+my $filecount = 0;
+
+my @tabvalues;
+
+# Init tabvalues
+push (@tabvalues, " ");
+
+for (my $i = 1; $i < 8; $i++) {
+    push(@tabvalues, $tabvalues[$i - 1] . " ");
+}
+
+open(FILELIST, ">$currdir/filelist") or die "Failed while open $currdir/filelist: $!\n";
+
+while ($dirpos <= $#ARGV) {
+    use File::Find;
+
+    find(\&parse_file, abs_path($ARGV[$dirpos]));
+
+    $dirpos += 1;
+}
+
+close(FILELIST);
+
+use Cwd 'chdir';
+chdir $currdir;
+
+print "Checked $allfiles file(s)\n";
+print "Modified $filecount file(s)\n";
+print "See results in the file $currdir/filelist\n";
+
+sub parse_file {
+    my $filename = $File::Find::name;
+
+    # Skip directories
+    return if -d;
+    
+    # Skip SCCS files
+    return if ($filename =~ /\/SCCS\//);
+
+    # Skip files with invalid extensions
+    my $accepted = 0;
+    foreach my $ext (@extensions) {
+        if ($_ =~ /\.$ext$/i) {
+            $accepted = 1;
+
+            last;
+        }
+    }
+    return if ($accepted == 0);
+
+    use File::Basename;
+    my $dirname = dirname($filename);
+
+    use Cwd 'chdir';
+    chdir $dirname;
+
+    open(FILE, $filename) or die "Failed while open $filename: $!\n";
+    
+    # Read file
+    my @content;
+    my $line;
+    my $emptylinescount = 0;
+    my $modified = 0;
+    
+    while ($line = <FILE>) {
+        my $originalline = $line;
+
+        # Process line
+        
+        # Remove from the end of the line spaces and return character
+        while ($line =~ /\s$/) {
+            chop($line);
+        }
+
+        # Replace TABs
+        for (my $i = 0; $i < length($line); $i++) {
+            if (substr($line, $i, 1) =~ /\t/) {
+                $line = substr($line, 0, $i) . $tabvalues[7 - ($i % 8)] . substr($line, $i + 1);
+            }
+        }
+        
+        if (length($line) == 0) {
+            $emptylinescount++;
+        } else {
+            while ($emptylinescount > 0) {
+                push(@content, "");
+                
+                $emptylinescount--;
+            }
+            
+            push(@content, $line);
+        }
+
+        if ($originalline ne ($line . "\n")) {
+            $modified = 1;
+        }
+
+    }
+    
+    $allfiles++;
+    
+    if ($emptylinescount > 0) {
+        $modified = 1;
+    }
+
+    close(FILE);
+    
+    if ($modified != 0) {
+        # Write file
+        open(FILE, ">$filename") or die "Failed while open $filename: $!\n";
+    
+        for (my $i = 0; $i <= $#content; $i++) {
+            print FILE "$content[$i]\n";
+        }
+    
+        close(FILE);
+
+        # Print name from current dir
+        if (index($filename, $currdir) == 0) {
+           print FILELIST substr($filename, length($currdir) + 1);
+        } else {
+           print FILELIST $filename;
+        }
+        print FILELIST "\n";
+
+        $filecount++;
+
+        print "$filename: modified\n";
+    }
+}
+
+sub usage {
+    print "Usage:\n";
+    print "  normalizer.pl [-options] <dir> [dir2 dir3 ...]\n";
+    print "  Available options:\n";
+    print "    -e    comma separated files extensions. By default accepts only java files\n";
+    print "\n";
+    print "Examples:\n";
+    print "  normalizer.pl -e c,cpp,h,hpp .\n";
+}
+
+