Merge
authorduke
Wed, 05 Jul 2017 18:50:02 +0200
changeset 16753 f0c59b913d72
parent 16752 ec149fe77498 (current diff)
parent 16751 4eb3ca9d34b1 (diff)
child 16787 cf9ff35e3ae7
Merge
hotspot/test/gc/6941923/test6941923.sh
hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java
hotspot/test/runtime/NMT/AllocTestType.java
--- a/.hgtags-top-repo	Thu Apr 11 09:39:48 2013 -0700
+++ b/.hgtags-top-repo	Wed Jul 05 18:50:02 2017 +0200
@@ -206,3 +206,4 @@
 29153d0df68f84162ffe8c2cf4f402a3f2245e85 jdk8-b82
 466685ba01bfb7bc1e1ac61490fd8c0f3cc18763 jdk8-b83
 01f631f89fa392b4e484d0812c40ea8f9d2353aa jdk8-b84
+7fc358f5943676b82f1dccd3152b1ac07d92e38b jdk8-b85
--- a/common/autoconf/compare.sh.in	Thu Apr 11 09:39:48 2013 -0700
+++ b/common/autoconf/compare.sh.in	Wed Jul 05 18:50:02 2017 +0200
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
--- a/common/bin/compare.sh	Thu Apr 11 09:39:48 2013 -0700
+++ b/common/bin/compare.sh	Wed Jul 05 18:50:02 2017 +0200
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
--- a/common/bin/hgforest.sh	Thu Apr 11 09:39:48 2013 -0700
+++ b/common/bin/hgforest.sh	Wed Jul 05 18:50:02 2017 +0200
@@ -30,7 +30,7 @@
 # Python always buffers stdout significantly, thus we will not see any output from hg clone jdk,
 # until a lot of time has passed! By passing -u to python, we get incremental updates
 # on stdout. Much nicer.
-whichhg="`which hg`"
+whichhg="`which hg 2> /dev/null | grep -v '^no hg in'`"
 
 if [ "${whichhg}" = "" ] ; then
   echo Cannot find hg!
@@ -51,7 +51,7 @@
    bpython="`basename "$python"`"
 fi
 
-if [ "python" = "$bpython" -a -x "$python" ] ; then
+if [ -x "$python" -a ! -d "$python" -a "`${python} -V 2>&1 | cut -f 1 -d ' '`" = "Python" ] ; then
   hg="${python} -u ${whichhg}"
 else
   echo Cannot find python from hg launcher. Running plain hg, which probably has buffered stdout.
--- a/common/makefiles/Main.gmk	Thu Apr 11 09:39:48 2013 -0700
+++ b/common/makefiles/Main.gmk	Wed Jul 05 18:50:02 2017 +0200
@@ -196,7 +196,7 @@
 
 
 # Remove everything, except the output from configure.
-clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-nashorn clean-images clean-overlay-images clean-bootcycle-build clean-docs
+clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-nashorn clean-images clean-overlay-images clean-bootcycle-build clean-docs clean-test
 	@($(CD) $(OUTPUT_ROOT) && $(RM) -r tmp source_tips build.log* build-trace*.log*)
 	@$(ECHO) Cleaned all build artifacts.
 
@@ -237,6 +237,8 @@
 clean-docs:
 	$(call CleanComponent,docs)
 	$(call CleanComponent,docstemp)
+clean-test:
+	$(call CleanComponent,testoutput)
 
 .PHONY: langtools corba jaxp jaxws hotspot jdk nashorn images overlay-images install
 .PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only nashorn-only images-only overlay-images-only install-only
--- a/hotspot/.hgtags	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/.hgtags	Wed Jul 05 18:50:02 2017 +0200
@@ -330,3 +330,6 @@
 8d0f263a370c5f3e61791bb06054560804117288 hs25-b25
 af788b85010ebabbc1e8f52c6766e08c7a95cf99 jdk8-b84
 a947f40fb536e5b9e0aa210cf26abb430f80887a hs25-b26
+42fe530cd478744a4d12a0cbf803f0fc804bab1a jdk8-b85
+09b0d3e9ba6cdf7da07d4010d2d1df14596f6864 hs25-b27
+6d88a566d369f6a1f86912cad7d0912686b2fda1 hs25-b28
--- a/hotspot/make/bsd/makefiles/fastdebug.make	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/make/bsd/makefiles/fastdebug.make	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2012 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 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
--- a/hotspot/make/hotspot_version	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/make/hotspot_version	Wed Jul 05 18:50:02 2017 +0200
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=25
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=26
+HS_BUILD_NUMBER=28
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=8
--- a/hotspot/make/linux/makefiles/gcc.make	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/make/linux/makefiles/gcc.make	Wed Jul 05 18:50:02 2017 +0200
@@ -126,14 +126,12 @@
 # Compiler warnings are treated as errors
 WARNINGS_ARE_ERRORS = -Werror
 
-# Except for a few acceptable ones
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function
+
 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
-# conversions which might affect the values. To avoid that, we need to turn
-# it off explicitly. 
-ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef
-else
-WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef
+# conversions which might affect the values. Only enable it in earlier versions.
+ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
+WARNING_FLAGS += -Wconversion
 endif
 
 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -214,14 +214,6 @@
   return enc;
 }
 
-static int encode(XMMRegister r) {
-  int enc = r->encoding();
-  if (enc >= 8) {
-    enc -= 8;
-  }
-  return enc;
-}
-
 void Assembler::emit_arith_b(int op1, int op2, Register dst, int imm8) {
   assert(dst->has_byte_register(), "must have byte register");
   assert(isByte(op1) && isByte(op2), "wrong opcode");
--- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -41,11 +41,6 @@
 
 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
 
-// Workaround for C++ overloading nastiness on '0' for RegisterOrConstant.
-static RegisterOrConstant constant(int value) {
-  return RegisterOrConstant(value);
-}
-
 void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg) {
   if (VerifyMethodHandles)
     verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
--- a/hotspot/src/cpu/x86/vm/x86_64.ad	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad	Wed Jul 05 18:50:02 2017 +0200
@@ -1693,17 +1693,6 @@
   return PTR_RBP_REG_mask();
 }
 
-static Address build_address(int b, int i, int s, int d) {
-  Register index = as_Register(i);
-  Address::ScaleFactor scale = (Address::ScaleFactor)s;
-  if (index == rsp) {
-    index = noreg;
-    scale = Address::no_scale;
-  }
-  Address addr(as_Register(b), index, scale, d);
-  return addr;
-}
-
 %}
 
 //----------ENCODING BLOCK-----------------------------------------------------
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -152,7 +152,6 @@
 // utility functions
 
 static int SR_initialize();
-static int SR_finalize();
 
 julong os::available_memory() {
   return Bsd::available_memory();
@@ -1200,6 +1199,9 @@
   } else if (strchr(pname, *os::path_separator()) != NULL) {
     int n;
     char** pelements = split_path(pname, &n);
+    if (pelements == NULL) {
+      return false;
+    }
     for (int i = 0 ; i < n ; i++) {
       // Really shouldn't be NULL, but check can't hurt
       if (pelements[i] == NULL || strlen(pelements[i]) == 0) {
@@ -2766,10 +2768,6 @@
   return 0;
 }
 
-static int SR_finalize() {
-  return 0;
-}
-
 
 // returns true on success and false on error - really an error is fatal
 // but this seems the normal response to library errors
@@ -3578,16 +3576,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 // debug support
 
-static address same_page(address x, address y) {
-  int page_bits = -os::vm_page_size();
-  if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits))
-    return x;
-  else if (x > y)
-    return (address)(intptr_t(y) | ~page_bits) + 1;
-  else
-    return (address)(intptr_t(y) & page_bits);
-}
-
 bool os::find(address addr, outputStream* st) {
   Dl_info dlinfo;
   memset(&dlinfo, 0, sizeof(dlinfo));
@@ -3611,8 +3599,8 @@
 
     if (Verbose) {
       // decode some bytes around the PC
-      address begin = same_page(addr-40, addr);
-      address end   = same_page(addr+40, addr);
+      address begin = clamp_address_in_page(addr-40, addr, os::vm_page_size());
+      address end   = clamp_address_in_page(addr+40, addr, os::vm_page_size());
       address       lowest = (address) dlinfo.dli_sname;
       if (!lowest)  lowest = (address) dlinfo.dli_fbase;
       if (begin < lowest)  begin = lowest;
--- a/hotspot/src/os/bsd/vm/perfMemory_bsd.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/os/bsd/vm/perfMemory_bsd.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -672,15 +672,15 @@
   RESTARTABLE(::open(filename, oflags), result);
   if (result == OS_ERR) {
     if (errno == ENOENT) {
-      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
-                  "Process not found");
+      THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+                  "Process not found", OS_ERR);
     }
     else if (errno == EACCES) {
-      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
-                  "Permission denied");
+      THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+                  "Permission denied", OS_ERR);
     }
     else {
-      THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno));
+      THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
     }
   }
 
@@ -828,7 +828,7 @@
   char* mapAddress;
   int result;
   int fd;
-  size_t size;
+  size_t size = 0;
   const char* luser = NULL;
 
   int mmap_prot;
@@ -899,9 +899,12 @@
 
   if (*sizep == 0) {
     size = sharedmem_filesize(fd, CHECK);
-    assert(size != 0, "unexpected size");
+  } else {
+    size = *sizep;
   }
 
+  assert(size > 0, "unexpected size <= 0");
+
   mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
 
   // attempt to close the file - restart if it gets interrupted,
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -176,7 +176,6 @@
 // utility functions
 
 static int SR_initialize();
-static int SR_finalize();
 
 julong os::available_memory() {
   return Linux::available_memory();
@@ -1633,6 +1632,9 @@
   } else if (strchr(pname, *os::path_separator()) != NULL) {
     int n;
     char** pelements = split_path(pname, &n);
+    if (pelements == NULL) {
+      return false;
+    }
     for (int i = 0 ; i < n ; i++) {
       // Really shouldn't be NULL, but check can't hurt
       if (pelements[i] == NULL || strlen(pelements[i]) == 0) {
@@ -3655,10 +3657,6 @@
   return 0;
 }
 
-static int SR_finalize() {
-  return 0;
-}
-
 
 // returns true on success and false on error - really an error is fatal
 // but this seems the normal response to library errors
@@ -4500,16 +4498,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 // debug support
 
-static address same_page(address x, address y) {
-  int page_bits = -os::vm_page_size();
-  if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits))
-    return x;
-  else if (x > y)
-    return (address)(intptr_t(y) | ~page_bits) + 1;
-  else
-    return (address)(intptr_t(y) & page_bits);
-}
-
 bool os::find(address addr, outputStream* st) {
   Dl_info dlinfo;
   memset(&dlinfo, 0, sizeof(dlinfo));
@@ -4533,8 +4521,8 @@
 
     if (Verbose) {
       // decode some bytes around the PC
-      address begin = same_page(addr-40, addr);
-      address end   = same_page(addr+40, addr);
+      address begin = clamp_address_in_page(addr-40, addr, os::vm_page_size());
+      address end   = clamp_address_in_page(addr+40, addr, os::vm_page_size());
       address       lowest = (address) dlinfo.dli_sname;
       if (!lowest)  lowest = (address) dlinfo.dli_fbase;
       if (begin < lowest)  begin = lowest;
--- a/hotspot/src/os/linux/vm/perfMemory_linux.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/os/linux/vm/perfMemory_linux.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -672,15 +672,15 @@
   RESTARTABLE(::open(filename, oflags), result);
   if (result == OS_ERR) {
     if (errno == ENOENT) {
-      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
-                  "Process not found");
+      THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+                  "Process not found", OS_ERR);
     }
     else if (errno == EACCES) {
-      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
-                  "Permission denied");
+      THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+                  "Permission denied", OS_ERR);
     }
     else {
-      THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno));
+      THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
     }
   }
 
@@ -828,7 +828,7 @@
   char* mapAddress;
   int result;
   int fd;
-  size_t size;
+  size_t size = 0;
   const char* luser = NULL;
 
   int mmap_prot;
@@ -899,9 +899,12 @@
 
   if (*sizep == 0) {
     size = sharedmem_filesize(fd, CHECK);
-    assert(size != 0, "unexpected size");
+  } else {
+    size = *sizep;
   }
 
+  assert(size > 0, "unexpected size <= 0");
+
   mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
 
   // attempt to close the file - restart if it gets interrupted,
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1885,6 +1885,9 @@
   } else if (strchr(pname, *os::path_separator()) != NULL) {
     int n;
     char** pelements = split_path(pname, &n);
+    if (pelements == NULL) {
+      return false;
+    }
     for (int i = 0 ; i < n ; i++) {
       // really shouldn't be NULL but what the heck, check can't hurt
       if (pelements[i] == NULL || strlen(pelements[i]) == 0) {
@@ -5787,16 +5790,6 @@
 
 //---------------------------------------------------------------------------------
 
-static address same_page(address x, address y) {
-  intptr_t page_bits = -os::vm_page_size();
-  if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits))
-    return x;
-  else if (x > y)
-    return (address)(intptr_t(y) | ~page_bits) + 1;
-  else
-    return (address)(intptr_t(y) & page_bits);
-}
-
 bool os::find(address addr, outputStream* st) {
   Dl_info dlinfo;
   memset(&dlinfo, 0, sizeof(dlinfo));
@@ -5822,8 +5815,8 @@
 
     if (Verbose) {
       // decode some bytes around the PC
-      address begin = same_page(addr-40, addr);
-      address end   = same_page(addr+40, addr);
+      address begin = clamp_address_in_page(addr-40, addr, os::vm_page_size());
+      address end   = clamp_address_in_page(addr+40, addr, os::vm_page_size());
       address       lowest = (address) dlinfo.dli_sname;
       if (!lowest)  lowest = (address) dlinfo.dli_fbase;
       if (begin < lowest)  begin = lowest;
--- a/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -687,15 +687,15 @@
   RESTARTABLE(::open(filename, oflags), result);
   if (result == OS_ERR) {
     if (errno == ENOENT) {
-      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
-                  "Process not found");
+      THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+                  "Process not found", OS_ERR);
     }
     else if (errno == EACCES) {
-      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
-                  "Permission denied");
+      THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+                  "Permission denied", OS_ERR);
     }
     else {
-      THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno));
+      THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
     }
   }
 
@@ -843,7 +843,7 @@
   char* mapAddress;
   int result;
   int fd;
-  size_t size;
+  size_t size = 0;
   const char* luser = NULL;
 
   int mmap_prot;
@@ -914,9 +914,12 @@
 
   if (*sizep == 0) {
     size = sharedmem_filesize(fd, CHECK);
-    assert(size != 0, "unexpected size");
+  } else {
+    size = *sizep;
   }
 
+  assert(size > 0, "unexpected size <= 0");
+
   mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
 
   // attempt to close the file - restart if it gets interrupted,
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1182,6 +1182,9 @@
   } else if (strchr(pname, *os::path_separator()) != NULL) {
     int n;
     char** pelements = split_path(pname, &n);
+    if (pelements == NULL) {
+      return false;
+    }
     for (int i = 0 ; i < n ; i++) {
       char* path = pelements[i];
       // Really shouldn't be NULL, but check can't hurt
--- a/hotspot/src/os/windows/vm/perfMemory_windows.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/os/windows/vm/perfMemory_windows.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1581,7 +1581,7 @@
   ResourceMark rm;
 
   void *mapAddress = 0;
-  size_t size;
+  size_t size = 0;
   HANDLE fmh;
   DWORD ofm_access;
   DWORD mv_access;
@@ -1652,9 +1652,12 @@
 
   if (*sizep == 0) {
     size = sharedmem_filesize(rfilename, CHECK);
-    assert(size != 0, "unexpected size");
+  } else {
+    size = *sizep;
   }
 
+  assert(size > 0, "unexpected size <= 0");
+
   // Open the file mapping object with the given name
   fmh = open_sharedmem_object(robjectname, ofm_access, CHECK);
 
--- a/hotspot/src/share/tools/launcher/wildcard.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/tools/launcher/wildcard.c	Wed Jul 05 18:50:02 2017 +0200
@@ -368,8 +368,10 @@
     const char *basename;
     FileList fl = FileList_new(16);
     WildcardIterator it = WildcardIterator_for(wildcard);
-    if (it == NULL)
+    if (it == NULL) {
+        FileList_free(fl);
         return NULL;
+    }
     while ((basename = WildcardIterator_next(it)) != NULL)
         if (isJarFileName(basename))
             FileList_add(fl, wildcardConcat(wildcard, basename));
--- a/hotspot/src/share/vm/adlc/output_c.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/adlc/output_c.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -63,11 +63,10 @@
     RegDef *reg_def = NULL;
     RegDef *next = NULL;
     registers->reset_RegDefs();
-    for( reg_def = registers->iter_RegDefs(); reg_def != NULL; reg_def = next ) {
+    for (reg_def = registers->iter_RegDefs(); reg_def != NULL; reg_def = next) {
       next = registers->iter_RegDefs();
       const char *comma = (next != NULL) ? "," : " // no trailing comma";
-      fprintf(fp,"  \"%s\"%s\n",
-                 reg_def->_regname, comma );
+      fprintf(fp,"  \"%s\"%s\n", reg_def->_regname, comma);
     }
 
     // Finish defining enumeration
@@ -79,10 +78,10 @@
     reg_def = NULL;
     next = NULL;
     registers->reset_RegDefs();
-    for( reg_def = registers->iter_RegDefs(); reg_def != NULL; reg_def = next ) {
+    for (reg_def = registers->iter_RegDefs(); reg_def != NULL; reg_def = next) {
       next = registers->iter_RegDefs();
       const char *comma = (next != NULL) ? "," : " // no trailing comma";
-      fprintf(fp,"\t%s%s\n", reg_def->_concrete, comma );
+      fprintf(fp,"\t%s%s\n", reg_def->_concrete, comma);
     }
     // Finish defining array
     fprintf(fp,"\t};\n");
@@ -104,19 +103,17 @@
     RegDef *reg_def = NULL;
     RegDef *next    = NULL;
     registers->reset_RegDefs();
-    for( reg_def = registers->iter_RegDefs(); reg_def != NULL; reg_def = next ) {
+    for (reg_def = registers->iter_RegDefs(); reg_def != NULL; reg_def = next) {
       next = registers->iter_RegDefs();
       const char* register_encode = reg_def->register_encode();
       const char *comma = (next != NULL) ? "," : " // no trailing comma";
       int encval;
       if (!ADLParser::is_int_token(register_encode, encval)) {
-        fprintf(fp,"  %s%s  // %s\n",
-                register_encode, comma, reg_def->_regname );
+        fprintf(fp,"  %s%s  // %s\n", register_encode, comma, reg_def->_regname);
       } else {
         // Output known constants in hex char format (backward compatibility).
         assert(encval < 256, "Exceeded supported width for register encoding");
-        fprintf(fp,"  (unsigned char)'\\x%X'%s  // %s\n",
-                encval,          comma, reg_def->_regname );
+        fprintf(fp,"  (unsigned char)'\\x%X'%s  // %s\n", encval, comma, reg_def->_regname);
       }
     }
     // Finish defining enumeration
@@ -133,9 +130,10 @@
     fprintf(fp,"// Enumeration of register class names\n");
     fprintf(fp, "enum machRegisterClass {\n");
     registers->_rclasses.reset();
-    for( const char *class_name = NULL;
-         (class_name = registers->_rclasses.iter()) != NULL; ) {
-      fprintf(fp,"  %s,\n", toUpper( class_name ));
+    for (const char *class_name = NULL; (class_name = registers->_rclasses.iter()) != NULL;) {
+      const char * class_name_to_upper = toUpper(class_name);
+      fprintf(fp,"  %s,\n", class_name_to_upper);
+      delete[] class_name_to_upper;
     }
     // Finish defining enumeration
     fprintf(fp, "  _last_Mach_Reg_Class\n");
@@ -148,7 +146,7 @@
 void ArchDesc::declare_register_masks(FILE *fp_hpp) {
   const char  *rc_name;
 
-  if( _register ) {
+  if (_register) {
     // Build enumeration of user-defined register classes.
     defineRegClassEnum(fp_hpp, _register);
 
@@ -156,24 +154,27 @@
     fprintf(fp_hpp,"\n");
     fprintf(fp_hpp,"// Register masks, one for each register class.\n");
     _register->_rclasses.reset();
-    for( rc_name = NULL;
-         (rc_name = _register->_rclasses.iter()) != NULL; ) {
-      const char *prefix    = "";
-      RegClass   *reg_class = _register->getRegClass(rc_name);
-      assert( reg_class, "Using an undefined register class");
+    for (rc_name = NULL; (rc_name = _register->_rclasses.iter()) != NULL;) {
+      const char *prefix = "";
+      RegClass *reg_class = _register->getRegClass(rc_name);
+      assert(reg_class, "Using an undefined register class");
+
+      const char* rc_name_to_upper = toUpper(rc_name);
 
       if (reg_class->_user_defined == NULL) {
-        fprintf(fp_hpp, "extern const RegMask _%s%s_mask;\n", prefix, toUpper( rc_name ) );
-        fprintf(fp_hpp, "inline const RegMask &%s%s_mask() { return _%s%s_mask; }\n", prefix, toUpper( rc_name ), prefix, toUpper( rc_name ));
+        fprintf(fp_hpp, "extern const RegMask _%s%s_mask;\n", prefix,  rc_name_to_upper);
+        fprintf(fp_hpp, "inline const RegMask &%s%s_mask() { return _%s%s_mask; }\n", prefix, rc_name_to_upper, prefix, rc_name_to_upper);
       } else {
-        fprintf(fp_hpp, "inline const RegMask &%s%s_mask() { %s }\n", prefix, toUpper( rc_name ), reg_class->_user_defined);
+        fprintf(fp_hpp, "inline const RegMask &%s%s_mask() { %s }\n", prefix, rc_name_to_upper, reg_class->_user_defined);
       }
 
-      if( reg_class->_stack_or_reg ) {
+      if (reg_class->_stack_or_reg) {
         assert(reg_class->_user_defined == NULL, "no user defined reg class here");
-        fprintf(fp_hpp, "extern const RegMask _%sSTACK_OR_%s_mask;\n", prefix, toUpper( rc_name ) );
-        fprintf(fp_hpp, "inline const RegMask &%sSTACK_OR_%s_mask() { return _%sSTACK_OR_%s_mask; }\n", prefix, toUpper( rc_name ), prefix, toUpper( rc_name ) );
+        fprintf(fp_hpp, "extern const RegMask _%sSTACK_OR_%s_mask;\n", prefix, rc_name_to_upper);
+        fprintf(fp_hpp, "inline const RegMask &%sSTACK_OR_%s_mask() { return _%sSTACK_OR_%s_mask; }\n", prefix, rc_name_to_upper, prefix, rc_name_to_upper);
       }
+      delete[] rc_name_to_upper;
+
     }
   }
 }
@@ -183,34 +184,41 @@
 void ArchDesc::build_register_masks(FILE *fp_cpp) {
   const char  *rc_name;
 
-  if( _register ) {
+  if (_register) {
     // Generate a list of register masks, one for each class.
     fprintf(fp_cpp,"\n");
     fprintf(fp_cpp,"// Register masks, one for each register class.\n");
     _register->_rclasses.reset();
-    for( rc_name = NULL;
-         (rc_name = _register->_rclasses.iter()) != NULL; ) {
-      const char *prefix    = "";
-      RegClass   *reg_class = _register->getRegClass(rc_name);
-      assert( reg_class, "Using an undefined register class");
-
-      if (reg_class->_user_defined != NULL) continue;
+    for (rc_name = NULL; (rc_name = _register->_rclasses.iter()) != NULL;) {
+      const char *prefix = "";
+      RegClass *reg_class = _register->getRegClass(rc_name);
+      assert(reg_class, "Using an undefined register class");
+
+      if (reg_class->_user_defined != NULL) {
+        continue;
+      }
 
       int len = RegisterForm::RegMask_Size();
-      fprintf(fp_cpp, "const RegMask _%s%s_mask(", prefix, toUpper( rc_name ) );
-      { int i;
-        for( i = 0; i < len-1; i++ )
-          fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i,false));
-        fprintf(fp_cpp," 0x%x );\n",reg_class->regs_in_word(i,false));
+      const char* rc_name_to_upper = toUpper(rc_name);
+      fprintf(fp_cpp, "const RegMask _%s%s_mask(", prefix, rc_name_to_upper);
+
+      {
+        int i;
+        for(i = 0; i < len - 1; i++) {
+          fprintf(fp_cpp," 0x%x,", reg_class->regs_in_word(i, false));
+        }
+        fprintf(fp_cpp," 0x%x );\n", reg_class->regs_in_word(i, false));
       }
 
-      if( reg_class->_stack_or_reg ) {
+      if (reg_class->_stack_or_reg) {
         int i;
-        fprintf(fp_cpp, "const RegMask _%sSTACK_OR_%s_mask(", prefix, toUpper( rc_name ) );
-        for( i = 0; i < len-1; i++ )
-          fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i,true));
-        fprintf(fp_cpp," 0x%x );\n",reg_class->regs_in_word(i,true));
+        fprintf(fp_cpp, "const RegMask _%sSTACK_OR_%s_mask(", prefix, rc_name_to_upper);
+        for(i = 0; i < len - 1; i++) {
+          fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i, true));
+        }
+        fprintf(fp_cpp," 0x%x );\n",reg_class->regs_in_word(i, true));
       }
+      delete[] rc_name_to_upper;
     }
   }
 }
@@ -2676,7 +2684,9 @@
       if (strcmp(first_reg_class, "stack_slots") == 0) {
         fprintf(fp,"  return &(Compile::current()->FIRST_STACK_mask());\n");
       } else {
-        fprintf(fp,"  return &%s_mask();\n", toUpper(first_reg_class));
+        const char* first_reg_class_to_upper = toUpper(first_reg_class);
+        fprintf(fp,"  return &%s_mask();\n", first_reg_class_to_upper);
+        delete[] first_reg_class_to_upper;
       }
     } else {
       // Build a switch statement to return the desired mask.
@@ -2688,7 +2698,9 @@
         if( !strcmp(reg_class, "stack_slots") ) {
           fprintf(fp, "  case %d: return &(Compile::current()->FIRST_STACK_mask());\n", index);
         } else {
-          fprintf(fp, "  case %d: return &%s_mask();\n", index, toUpper(reg_class));
+          const char* reg_class_to_upper = toUpper(reg_class);
+          fprintf(fp, "  case %d: return &%s_mask();\n", index, reg_class_to_upper);
+          delete[] reg_class_to_upper;
         }
       }
       fprintf(fp,"  }\n");
--- a/hotspot/src/share/vm/adlc/output_h.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/adlc/output_h.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -2069,9 +2069,21 @@
   void closing()     { fprintf(_cpp, "  _LAST_MACH_OPER\n");
                        OutputMap::closing();
   }
-  void map(OpClassForm &opc)  { fprintf(_cpp, "  %s", _AD.machOperEnum(opc._ident) ); }
-  void map(OperandForm &oper) { fprintf(_cpp, "  %s", _AD.machOperEnum(oper._ident) ); }
-  void map(char        *name) { fprintf(_cpp, "  %s", _AD.machOperEnum(name)); }
+  void map(OpClassForm &opc)  {
+    const char* opc_ident_to_upper = _AD.machOperEnum(opc._ident);
+    fprintf(_cpp, "  %s", opc_ident_to_upper);
+    delete[] opc_ident_to_upper;
+  }
+  void map(OperandForm &oper) {
+    const char* oper_ident_to_upper = _AD.machOperEnum(oper._ident);
+    fprintf(_cpp, "  %s", oper_ident_to_upper);
+    delete[] oper_ident_to_upper;
+  }
+  void map(char *name) {
+    const char* name_to_upper = _AD.machOperEnum(name);
+    fprintf(_cpp, "  %s", name_to_upper);
+    delete[] name_to_upper;
+  }
 
   bool do_instructions()      { return false; }
   void map(InstructForm &inst){ assert( false, "ShouldNotCallThis()"); }
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -711,25 +711,6 @@
   }
 }
 
-static Value maxvalue(IfOp* ifop) {
-  switch (ifop->cond()) {
-    case If::eql: return NULL;
-    case If::neq: return NULL;
-    case If::lss: // x <  y ? x : y
-    case If::leq: // x <= y ? x : y
-      if (ifop->x() == ifop->tval() &&
-          ifop->y() == ifop->fval()) return ifop->y();
-      return NULL;
-
-    case If::gtr: // x >  y ? y : x
-    case If::geq: // x >= y ? y : x
-      if (ifop->x() == ifop->tval() &&
-          ifop->y() == ifop->fval()) return ifop->y();
-      return NULL;
-
-  }
-}
-
 static ciType* phi_declared_type(Phi* phi) {
   ciType* t = phi->operand_at(0)->declared_type();
   if (t == NULL) {
--- a/hotspot/src/share/vm/c1/c1_ValueMap.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/c1/c1_ValueMap.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -316,6 +316,7 @@
   ShortLoopOptimizer*   _short_loop_optimizer;
   Instruction*          _insertion_point;
   ValueStack *          _state;
+  bool                  _insert_is_pred;
 
   void set_invariant(Value v) const    { _gvn->set_processed(v); }
   bool is_invariant(Value v) const     { return _gvn->is_processed(v); }
@@ -339,6 +340,7 @@
 
   assert(insertion_block->end()->as_Base() == NULL, "cannot insert into entry block");
   _insertion_point = insertion_block->end()->prev();
+  _insert_is_pred = loop_header->is_predecessor(insertion_block);
 
   BlockEnd *block_end = insertion_block->end();
   _state = block_end->state_before();
@@ -379,13 +381,13 @@
     } else if (cur->as_LoadField() != NULL) {
       LoadField* lf = (LoadField*)cur;
       // deoptimizes on NullPointerException
-      cur_invariant = !lf->needs_patching() && !lf->field()->is_volatile() && !_short_loop_optimizer->has_field_store(lf->field()->type()->basic_type()) && is_invariant(lf->obj());
+      cur_invariant = !lf->needs_patching() && !lf->field()->is_volatile() && !_short_loop_optimizer->has_field_store(lf->field()->type()->basic_type()) && is_invariant(lf->obj()) && _insert_is_pred;
     } else if (cur->as_ArrayLength() != NULL) {
       ArrayLength *length = cur->as_ArrayLength();
       cur_invariant = is_invariant(length->array());
     } else if (cur->as_LoadIndexed() != NULL) {
       LoadIndexed *li = (LoadIndexed *)cur->as_LoadIndexed();
-      cur_invariant = !_short_loop_optimizer->has_indexed_store(as_BasicType(cur->type())) && is_invariant(li->array()) && is_invariant(li->index());
+      cur_invariant = !_short_loop_optimizer->has_indexed_store(as_BasicType(cur->type())) && is_invariant(li->array()) && is_invariant(li->index()) && _insert_is_pred;
     }
 
     if (cur_invariant) {
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1723,9 +1723,6 @@
       } else {
         coll->set_contended_group(0); // default contended group
       }
-      coll->set_contended(true);
-    } else {
-      coll->set_contended(false);
     }
   }
 }
--- a/hotspot/src/share/vm/classfile/classFileParser.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/classfile/classFileParser.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -150,7 +150,6 @@
     void set_contended_group(u2 group) { _contended_group = group; }
     u2 contended_group() { return _contended_group; }
 
-    void set_contended(bool contended) { set_annotation(_sun_misc_Contended); }
     bool is_contended() { return has_annotation(_sun_misc_Contended); }
   };
 
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -70,15 +70,19 @@
   _is_anonymous(is_anonymous), _keep_alive(is_anonymous), // initially
   _metaspace(NULL), _unloading(false), _klasses(NULL),
   _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL),
-  _next(NULL), _dependencies(NULL),
+  _next(NULL), _dependencies(),
   _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true)) {
     // empty
 }
 
 void ClassLoaderData::init_dependencies(TRAPS) {
+  _dependencies.init(CHECK);
+}
+
+void ClassLoaderData::Dependencies::init(TRAPS) {
   // Create empty dependencies array to add to. CMS requires this to be
   // an oop so that it can track additions via card marks.  We think.
-  _dependencies = (oop)oopFactory::new_objectArray(2, CHECK);
+  _list_head = oopFactory::new_objectArray(2, CHECK);
 }
 
 bool ClassLoaderData::claim() {
@@ -95,13 +99,17 @@
   }
 
   f->do_oop(&_class_loader);
-  f->do_oop(&_dependencies);
+  _dependencies.oops_do(f);
   _handles->oops_do(f);
   if (klass_closure != NULL) {
     classes_do(klass_closure);
   }
 }
 
+void ClassLoaderData::Dependencies::oops_do(OopClosure* f) {
+  f->do_oop((oop*)&_list_head);
+}
+
 void ClassLoaderData::classes_do(KlassClosure* klass_closure) {
   for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
     klass_closure->do_klass(k);
@@ -154,14 +162,14 @@
   // It's a dependency we won't find through GC, add it. This is relatively rare
   // Must handle over GC point.
   Handle dependency(THREAD, to);
-  from_cld->add_dependency(dependency, CHECK);
+  from_cld->_dependencies.add(dependency, CHECK);
 }
 
 
-void ClassLoaderData::add_dependency(Handle dependency, TRAPS) {
+void ClassLoaderData::Dependencies::add(Handle dependency, TRAPS) {
   // Check first if this dependency is already in the list.
   // Save a pointer to the last to add to under the lock.
-  objArrayOop ok = (objArrayOop)_dependencies;
+  objArrayOop ok = _list_head;
   objArrayOop last = NULL;
   while (ok != NULL) {
     last = ok;
@@ -184,16 +192,17 @@
   objArrayHandle new_dependency(THREAD, deps);
 
   // Add the dependency under lock
-  locked_add_dependency(last_handle, new_dependency);
+  locked_add(last_handle, new_dependency, THREAD);
 }
 
-void ClassLoaderData::locked_add_dependency(objArrayHandle last_handle,
-                                            objArrayHandle new_dependency) {
+void ClassLoaderData::Dependencies::locked_add(objArrayHandle last_handle,
+                                               objArrayHandle new_dependency,
+                                               Thread* THREAD) {
 
   // Have to lock and put the new dependency on the end of the dependency
   // array so the card mark for CMS sees that this dependency is new.
   // Can probably do this lock free with some effort.
-  MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
+  ObjectLocker ol(Handle(THREAD, _list_head), THREAD);
 
   oop loader_or_mirror = new_dependency->obj_at(0);
 
--- a/hotspot/src/share/vm/classfile/classLoaderData.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -93,6 +93,18 @@
 class ClassLoaderData : public CHeapObj<mtClass> {
   friend class VMStructs;
  private:
+  class Dependencies VALUE_OBJ_CLASS_SPEC {
+    objArrayOop _list_head;
+    void locked_add(objArrayHandle last,
+                    objArrayHandle new_dependency,
+                    Thread* THREAD);
+   public:
+    Dependencies() : _list_head(NULL) {}
+    void add(Handle dependency, TRAPS);
+    void init(TRAPS);
+    void oops_do(OopClosure* f);
+  };
+
   friend class ClassLoaderDataGraph;
   friend class ClassLoaderDataGraphMetaspaceIterator;
   friend class MetaDataFactory;
@@ -100,10 +112,11 @@
 
   static ClassLoaderData * _the_null_class_loader_data;
 
-  oop _class_loader;       // oop used to uniquely identify a class loader
-                           // class loader or a canonical class path
-  oop _dependencies;       // oop to hold dependencies from this class loader
-                           // data to others.
+  oop _class_loader;          // oop used to uniquely identify a class loader
+                              // class loader or a canonical class path
+  Dependencies _dependencies; // holds dependencies from this class loader
+                              // data to others.
+
   Metaspace * _metaspace;  // Meta-space where meta-data defined by the
                            // classes in the class loader are allocated.
   Mutex* _metaspace_lock;  // Locks the metaspace for allocations and setup.
@@ -134,9 +147,6 @@
   static Metaspace* _ro_metaspace;
   static Metaspace* _rw_metaspace;
 
-  void add_dependency(Handle dependency, TRAPS);
-  void locked_add_dependency(objArrayHandle last, objArrayHandle new_dependency);
-
   void set_next(ClassLoaderData* next) { _next = next; }
   ClassLoaderData* next() const        { return _next; }
 
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1592,9 +1592,10 @@
 // Used for assertions and verification only
 Klass* SystemDictionary::find_class(Symbol* class_name, ClassLoaderData* loader_data) {
   #ifndef ASSERT
-  guarantee(VerifyBeforeGC   ||
-            VerifyDuringGC   ||
-            VerifyBeforeExit ||
+  guarantee(VerifyBeforeGC      ||
+            VerifyDuringGC      ||
+            VerifyBeforeExit    ||
+            VerifyDuringStartup ||
             VerifyAfterGC, "too expensive");
   #endif
   assert_locked_or_safepoint(SystemDictionary_lock);
--- a/hotspot/src/share/vm/classfile/verifier.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/classfile/verifier.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -63,6 +63,7 @@
 
 #define NOFAILOVER_MAJOR_VERSION                       51
 #define NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION  51
+#define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION       52
 
 // Access to external entry for VerifyClassCodes - old byte code verifier
 
@@ -2320,6 +2321,11 @@
       types = (1 << JVM_CONSTANT_InterfaceMethodref) |
               (1 << JVM_CONSTANT_Methodref);
       break;
+    case Bytecodes::_invokestatic:
+      types = (_klass->major_version() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ?
+        (1 << JVM_CONSTANT_Methodref) :
+        ((1 << JVM_CONSTANT_InterfaceMethodref) | (1 << JVM_CONSTANT_Methodref));
+      break;
     default:
       types = 1 << JVM_CONSTANT_Methodref;
   }
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1206,11 +1206,8 @@
   assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range");
   assert(!method->is_abstract() && (osr_bci == InvocationEntryBci || !method->is_native()), "cannot compile abstract/native methods");
   assert(!method->method_holder()->is_not_initialized(), "method holder must be initialized");
-
-  if (!TieredCompilation) {
-    comp_level = CompLevel_highest_tier;
-  }
-
+  // allow any levels for WhiteBox
+  assert(WhiteBoxAPI || TieredCompilation || comp_level == CompLevel_highest_tier, "only CompLevel_highest_tier must be used in non-tiered");
   // return quickly if possible
 
   // lock, make sure that the compilation
--- a/hotspot/src/share/vm/compiler/compileLog.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/compiler/compileLog.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -60,28 +60,6 @@
 }
 
 
-// Advance kind up to a null or space, return this tail.
-// Make sure kind is null-terminated, not space-terminated.
-// Use the buffer if necessary.
-static const char* split_attrs(const char* &kind, char* buffer) {
-  const char* attrs = strchr(kind, ' ');
-  // Tease apart the first word from the rest:
-  if (attrs == NULL) {
-    return "";  // no attrs, no split
-  } else if (kind == buffer) {
-    ((char*) attrs)[-1] = 0;
-    return attrs;
-  } else {
-    // park it in the buffer, so we can put a null on the end
-    assert(!(kind >= buffer && kind < buffer+100), "not obviously in buffer");
-    int klen = attrs - kind;
-    strncpy(buffer, kind, klen);
-    buffer[klen] = 0;
-    kind = buffer;  // return by reference
-    return attrs;
-  }
-}
-
 // see_tag, pop_tag:  Override the default do-nothing methods on xmlStream.
 // These methods provide a hook for managing the the extra context markup.
 void CompileLog::see_tag(const char* tag, bool push) {
--- a/hotspot/src/share/vm/compiler/compilerOracle.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/compiler/compilerOracle.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -237,13 +237,6 @@
   "help"
 };
 
-static const char * command_name(OracleCommand command) {
-  if (command < OracleFirstCommand || command >= OracleCommandCount) {
-    return "unknown command";
-  }
-  return command_names[command];
-}
-
 class MethodMatcher;
 static MethodMatcher* lists[OracleCommandCount] = { 0, };
 
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -48,6 +48,7 @@
 #include "memory/iterator.hpp"
 #include "memory/referencePolicy.hpp"
 #include "memory/resourceArea.hpp"
+#include "memory/tenuredGeneration.hpp"
 #include "oops/oop.inline.hpp"
 #include "prims/jvmtiExport.hpp"
 #include "runtime/globals_extension.hpp"
@@ -916,7 +917,31 @@
     return;
   }
 
-  size_t expand_bytes = 0;
+  // Compute some numbers about the state of the heap.
+  const size_t used_after_gc = used();
+  const size_t capacity_after_gc = capacity();
+
+  CardGeneration::compute_new_size();
+
+  // Reset again after a possible resizing
+  cmsSpace()->reset_after_compaction();
+
+  assert(used() == used_after_gc && used_after_gc <= capacity(),
+         err_msg("used: " SIZE_FORMAT " used_after_gc: " SIZE_FORMAT
+         " capacity: " SIZE_FORMAT, used(), used_after_gc, capacity()));
+}
+
+void ConcurrentMarkSweepGeneration::compute_new_size_free_list() {
+  assert_locked_or_safepoint(Heap_lock);
+
+  // If incremental collection failed, we just want to expand
+  // to the limit.
+  if (incremental_collection_failed()) {
+    clear_incremental_collection_failed();
+    grow_to_reserved();
+    return;
+  }
+
   double free_percentage = ((double) free()) / capacity();
   double desired_free_percentage = (double) MinHeapFreeRatio / 100;
   double maximum_free_percentage = (double) MaxHeapFreeRatio / 100;
@@ -925,9 +950,7 @@
   if (free_percentage < desired_free_percentage) {
     size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
     assert(desired_capacity >= capacity(), "invalid expansion size");
-    expand_bytes = MAX2(desired_capacity - capacity(), MinHeapDeltaBytes);
-  }
-  if (expand_bytes > 0) {
+    size_t expand_bytes = MAX2(desired_capacity - capacity(), MinHeapDeltaBytes);
     if (PrintGCDetails && Verbose) {
       size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
       gclog_or_tty->print_cr("\nFrom compute_new_size: ");
@@ -961,6 +984,14 @@
       gclog_or_tty->print_cr("  Expanded free fraction %f",
         ((double) free()) / capacity());
     }
+  } else {
+    size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
+    assert(desired_capacity <= capacity(), "invalid expansion size");
+    size_t shrink_bytes = capacity() - desired_capacity;
+    // Don't shrink unless the delta is greater than the minimum shrink we want
+    if (shrink_bytes >= MinHeapDeltaBytes) {
+      shrink_free_list_by(shrink_bytes);
+    }
   }
 }
 
@@ -1872,7 +1903,7 @@
   assert_locked_or_safepoint(Heap_lock);
   FreelistLocker z(this);
   MetaspaceGC::compute_new_size();
-  _cmsGen->compute_new_size();
+  _cmsGen->compute_new_size_free_list();
 }
 
 // A work method used by foreground collection to determine
@@ -2601,6 +2632,10 @@
 }
 
 void ConcurrentMarkSweepGeneration::gc_prologue(bool full) {
+
+  _capacity_at_prologue = capacity();
+  _used_at_prologue = used();
+
   // Delegate to CMScollector which knows how to coordinate between
   // this and any other CMS generations that it is responsible for
   // collecting.
@@ -2774,6 +2809,23 @@
   }
 }
 
+
+void
+CMSCollector::print_on_error(outputStream* st) {
+  CMSCollector* collector = ConcurrentMarkSweepGeneration::_collector;
+  if (collector != NULL) {
+    CMSBitMap* bitmap = &collector->_markBitMap;
+    st->print_cr("Marking Bits: (CMSBitMap*) " PTR_FORMAT, bitmap);
+    bitmap->print_on_error(st, " Bits: ");
+
+    st->cr();
+
+    CMSBitMap* mut_bitmap = &collector->_modUnionTable;
+    st->print_cr("Mod Union Table: (CMSBitMap*) " PTR_FORMAT, mut_bitmap);
+    mut_bitmap->print_on_error(st, " Bits: ");
+  }
+}
+
 ////////////////////////////////////////////////////////
 // CMS Verification Support
 ////////////////////////////////////////////////////////
@@ -3300,6 +3352,26 @@
 }
 
 
+void ConcurrentMarkSweepGeneration::shrink_by(size_t bytes) {
+  assert_locked_or_safepoint(ExpandHeap_lock);
+  // Shrink committed space
+  _virtual_space.shrink_by(bytes);
+  // Shrink space; this also shrinks the space's BOT
+  _cmsSpace->set_end((HeapWord*) _virtual_space.high());
+  size_t new_word_size = heap_word_size(_cmsSpace->capacity());
+  // Shrink the shared block offset array
+  _bts->resize(new_word_size);
+  MemRegion mr(_cmsSpace->bottom(), new_word_size);
+  // Shrink the card table
+  Universe::heap()->barrier_set()->resize_covered_region(mr);
+
+  if (Verbose && PrintGC) {
+    size_t new_mem_size = _virtual_space.committed_size();
+    size_t old_mem_size = new_mem_size + bytes;
+    gclog_or_tty->print_cr("Shrinking %s from " SIZE_FORMAT "K to " SIZE_FORMAT "K",
+                  name(), old_mem_size/K, new_mem_size/K);
+  }
+}
 
 void ConcurrentMarkSweepGeneration::shrink(size_t bytes) {
   assert_locked_or_safepoint(Heap_lock);
@@ -3351,7 +3423,7 @@
   return success;
 }
 
-void ConcurrentMarkSweepGeneration::shrink_by(size_t bytes) {
+void ConcurrentMarkSweepGeneration::shrink_free_list_by(size_t bytes) {
   assert_locked_or_safepoint(Heap_lock);
   assert_lock_strong(freelistLock());
   // XXX Fix when compaction is implemented.
@@ -6476,6 +6548,10 @@
   }
 }
 
+void CMSBitMap::print_on_error(outputStream* st, const char* prefix) const {
+  _bm.print_on_error(st, prefix);
+}
+
 #ifndef PRODUCT
 void CMSBitMap::assert_locked() const {
   CMSLockVerifier::assert_locked(lock());
@@ -9074,51 +9150,6 @@
   }
 }
 
-// The desired expansion delta is computed so that:
-// . desired free percentage or greater is used
-void ASConcurrentMarkSweepGeneration::compute_new_size() {
-  assert_locked_or_safepoint(Heap_lock);
-
-  GenCollectedHeap* gch = (GenCollectedHeap*) GenCollectedHeap::heap();
-
-  // If incremental collection failed, we just want to expand
-  // to the limit.
-  if (incremental_collection_failed()) {
-    clear_incremental_collection_failed();
-    grow_to_reserved();
-    return;
-  }
-
-  assert(UseAdaptiveSizePolicy, "Should be using adaptive sizing");
-
-  assert(gch->kind() == CollectedHeap::GenCollectedHeap,
-    "Wrong type of heap");
-  int prev_level = level() - 1;
-  assert(prev_level >= 0, "The cms generation is the lowest generation");
-  Generation* prev_gen = gch->get_gen(prev_level);
-  assert(prev_gen->kind() == Generation::ASParNew,
-    "Wrong type of young generation");
-  ParNewGeneration* younger_gen = (ParNewGeneration*) prev_gen;
-  size_t cur_eden = younger_gen->eden()->capacity();
-  CMSAdaptiveSizePolicy* size_policy = cms_size_policy();
-  size_t cur_promo = free();
-  size_policy->compute_tenured_generation_free_space(cur_promo,
-                                                       max_available(),
-                                                       cur_eden);
-  resize(cur_promo, size_policy->promo_size());
-
-  // Record the new size of the space in the cms generation
-  // that is available for promotions.  This is temporary.
-  // It should be the desired promo size.
-  size_policy->avg_cms_promo()->sample(free());
-  size_policy->avg_old_live()->sample(used());
-
-  if (UsePerfData) {
-    CMSGCAdaptivePolicyCounters* counters = gc_adaptive_policy_counters();
-    counters->update_cms_capacity_counter(capacity());
-  }
-}
-
 void ASConcurrentMarkSweepGeneration::shrink_by(size_t desired_bytes) {
   assert_locked_or_safepoint(Heap_lock);
   assert_lock_strong(freelistLock());
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -60,6 +60,7 @@
 class FreeChunk;
 class PromotionInfo;
 class ScanMarkedObjectsAgainCarefullyClosure;
+class TenuredGeneration;
 
 // A generic CMS bit map. It's the basis for both the CMS marking bit map
 // as well as for the mod union table (in each case only a subset of the
@@ -150,6 +151,8 @@
   size_t    heapWordToOffset(HeapWord* addr) const;
   size_t    heapWordDiffToOffsetDiff(size_t diff) const;
 
+  void print_on_error(outputStream* st, const char* prefix) const;
+
   // debugging
   // is this address range covered by the bit-map?
   NOT_PRODUCT(
@@ -810,9 +813,6 @@
   // used regions of each generation to limit the extent of sweep
   void save_sweep_limits();
 
-  // Resize the generations included in the collector.
-  void compute_new_size();
-
   // A work method used by foreground collection to determine
   // what type of collection (compacting or not, continuing or fresh)
   // it should do.
@@ -909,6 +909,9 @@
   void releaseFreelistLocks() const;
   bool haveFreelistLocks() const;
 
+  // Adjust size of underlying generation
+  void compute_new_size();
+
   // GC prologue and epilogue
   void gc_prologue(bool full);
   void gc_epilogue(bool full);
@@ -983,6 +986,8 @@
   CMSAdaptiveSizePolicy* size_policy();
   CMSGCAdaptivePolicyCounters* gc_adaptive_policy_counters();
 
+  static void print_on_error(outputStream* st);
+
   // debugging
   void verify();
   bool verify_after_remark();
@@ -1082,7 +1087,7 @@
 
  protected:
   // Shrink generation by specified size (returns false if unable to shrink)
-  virtual void shrink_by(size_t bytes);
+  void shrink_free_list_by(size_t bytes);
 
   // Update statistics for GC
   virtual void update_gc_stats(int level, bool full);
@@ -1233,6 +1238,7 @@
     CMSExpansionCause::Cause cause);
   virtual bool expand(size_t bytes, size_t expand_bytes);
   void shrink(size_t bytes);
+  void shrink_by(size_t bytes);
   HeapWord* expand_and_par_lab_allocate(CMSParGCThreadState* ps, size_t word_sz);
   bool expand_and_ensure_spooling_space(PromotionInfo* promo);
 
@@ -1293,7 +1299,13 @@
   bool must_be_youngest() const { return false; }
   bool must_be_oldest()   const { return true; }
 
-  void compute_new_size();
+  // Resize the generation after a compacting GC.  The
+  // generation can be treated as a contiguous space
+  // after the compaction.
+  virtual void compute_new_size();
+  // Resize the generation after a non-compacting
+  // collection.
+  void compute_new_size_free_list();
 
   CollectionTypes debug_collection_type() { return _debug_collection_type; }
   void rotate_debug_collection_type();
@@ -1315,7 +1327,6 @@
   virtual void shrink_by(size_t bytes);
 
  public:
-  virtual void compute_new_size();
   ASConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size,
                                   int level, CardTableRS* ct,
                                   bool use_adaptive_freelists,
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -101,6 +101,10 @@
 }
 #endif
 
+void CMBitMapRO::print_on_error(outputStream* st, const char* prefix) const {
+  _bm.print_on_error(st, prefix);
+}
+
 bool CMBitMap::allocate(ReservedSpace heap_rs) {
   _bmStartWord = (HeapWord*)(heap_rs.base());
   _bmWordSize  = heap_rs.size()/HeapWordSize;    // heap_rs.size() is in bytes
@@ -3277,6 +3281,13 @@
   }
 }
 
+void ConcurrentMark::print_on_error(outputStream* st) const {
+  st->print_cr("Marking Bits (Prev, Next): (CMBitMap*) " PTR_FORMAT ", (CMBitMap*) " PTR_FORMAT,
+      _prevMarkBitMap, _nextMarkBitMap);
+  _prevMarkBitMap->print_on_error(st, " Prev Bits: ");
+  _nextMarkBitMap->print_on_error(st, " Next Bits: ");
+}
+
 // We take a break if someone is trying to stop the world.
 bool ConcurrentMark::do_yield_check(uint worker_id) {
   if (should_yield()) {
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -113,6 +113,8 @@
     return res;
   }
 
+  void print_on_error(outputStream* st, const char* prefix) const;
+
   // debugging
   NOT_PRODUCT(bool covers(ReservedSpace rs) const;)
 };
@@ -829,6 +831,8 @@
 
   void print_worker_threads_on(outputStream* st) const;
 
+  void print_on_error(outputStream* st) const;
+
   // The following indicate whether a given verbose level has been
   // set. Notice that anything above stats is conditional to
   // _MARKING_VERBOSE_ having been set to 1
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -3427,6 +3427,15 @@
   heap_region_iterate(&blk);
 }
 
+void G1CollectedHeap::print_on_error(outputStream* st) const {
+  this->CollectedHeap::print_on_error(st);
+
+  if (_cm != NULL) {
+    st->cr();
+    _cm->print_on_error(st);
+  }
+}
+
 void G1CollectedHeap::print_gc_threads_on(outputStream* st) const {
   if (G1CollectedHeap::use_parallel_gc_threads()) {
     workers()->print_worker_threads_on(st);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1575,6 +1575,7 @@
   virtual void verify(bool silent);
   virtual void print_on(outputStream* st) const;
   virtual void print_extended_on(outputStream* st) const;
+  virtual void print_on_error(outputStream* st) const;
 
   virtual void print_gc_threads_on(outputStream* st) const;
   virtual void gc_threads_do(ThreadClosure* tc) const;
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1359,18 +1359,6 @@
 #endif // PRODUCT
 }
 
-#ifndef PRODUCT
-// for debugging, bit of a hack...
-static char*
-region_num_to_mbs(int length) {
-  static char buffer[64];
-  double bytes = (double) (length * HeapRegion::GrainBytes);
-  double mbs = bytes / (double) (1024 * 1024);
-  sprintf(buffer, "%7.2lfMB", mbs);
-  return buffer;
-}
-#endif // PRODUCT
-
 uint G1CollectorPolicy::max_regions(int purpose) {
   switch (purpose) {
     case GCAllocForSurvived:
--- a/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -53,15 +53,6 @@
 }
 
 
-static int byte_index_to_index(int ind) {
-  assert((ind % oopSize) == 0, "Invariant.");
-  return ind / oopSize;
-}
-
-static int index_to_byte_index(int byte_ind) {
-  return byte_ind * oopSize;
-}
-
 void PtrQueue::enqueue_known_active(void* ptr) {
   assert(0 <= _index && _index <= _sz, "Invariant.");
   assert(_index == 0 || _buf != NULL, "invariant");
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -173,6 +173,12 @@
   void reset_counters();
 #endif  // #ifndef PRODUCT
 
+  void print_on_error(outputStream* st) const {
+    st->print_cr("Marking Bits: (ParMarkBitMap*) " PTR_FORMAT, this);
+    _beg_bits.print_on_error(st, " Begin Bits: ");
+    _end_bits.print_on_error(st, " End Bits:   ");
+  }
+
 #ifdef  ASSERT
   void verify_clear() const;
   inline void verify_bit(idx_t bit) const;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -648,6 +648,15 @@
   MetaspaceAux::print_on(st);
 }
 
+void ParallelScavengeHeap::print_on_error(outputStream* st) const {
+  this->CollectedHeap::print_on_error(st);
+
+  if (UseParallelOldGC) {
+    st->cr();
+    PSParallelCompact::print_on_error(st);
+  }
+}
+
 void ParallelScavengeHeap::gc_threads_do(ThreadClosure* tc) const {
   PSScavenge::gc_task_manager()->threads_do(tc);
 }
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -220,6 +220,7 @@
 
   void prepare_for_verify();
   virtual void print_on(outputStream* st) const;
+  virtual void print_on_error(outputStream* st) const;
   virtual void print_gc_threads_on(outputStream* st) const;
   virtual void gc_threads_do(ThreadClosure* tc) const;
   virtual void print_tracing_info() const;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -165,6 +165,10 @@
 #endif  // #ifdef ASSERT
 
 
+void PSParallelCompact::print_on_error(outputStream* st) {
+  _mark_bitmap.print_on_error(st);
+}
+
 #ifndef PRODUCT
 const char* PSParallelCompact::space_names[] = {
   "old ", "eden", "from", "to  "
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1163,6 +1163,8 @@
   // Time since last full gc (in milliseconds).
   static jlong millis_since_last_gc();
 
+  static void print_on_error(outputStream* st);
+
 #ifndef PRODUCT
   // Debugging support.
   static const char* space_names[last_space_id];
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -567,6 +567,14 @@
     print_on(st);
   }
 
+  virtual void print_on_error(outputStream* st) const {
+    st->print_cr("Heap:");
+    print_extended_on(st);
+    st->cr();
+
+    _barrier_set->print_on(st);
+  }
+
   // Print all GC threads (other than the VM thread)
   // used by this heap.
   virtual void print_gc_threads_on(outputStream* st) const = 0;
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -557,11 +557,6 @@
 // be shared by method invocation and synchronized blocks.
 //%note synchronization_3
 
-static void trace_locking(Handle& h_locking_obj, bool is_locking) {
-  ObjectSynchronizer::trace_locking(h_locking_obj, false, true, is_locking);
-}
-
-
 //%note monitor_1
 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem))
 #ifdef ASSERT
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -217,6 +217,7 @@
                                              TRAPS) {
   vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name);
   if (TraceMethodHandles) {
+    ResourceMark rm(THREAD);
     tty->print_cr("lookup_polymorphic_method iid=%s %s.%s%s",
                   vmIntrinsics::name_at(iid), klass->external_name(),
                   name->as_C_string(), full_signature->as_C_string());
@@ -231,6 +232,7 @@
       TempNewSymbol basic_signature =
         MethodHandles::lookup_basic_type_signature(full_signature, keep_last_arg, CHECK);
       if (TraceMethodHandles) {
+        ResourceMark rm(THREAD);
         tty->print_cr("lookup_polymorphic_method %s %s => basic %s",
                       name->as_C_string(),
                       full_signature->as_C_string(),
@@ -283,6 +285,8 @@
       }
       if (result.not_null()) {
 #ifdef ASSERT
+        ResourceMark rm(THREAD);
+
         TempNewSymbol basic_signature =
           MethodHandles::lookup_basic_type_signature(full_signature, CHECK);
         int actual_size_of_params = result->size_of_parameters();
@@ -1222,8 +1226,10 @@
   Symbol* method_signature = NULL;
   KlassHandle  current_klass;
   resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
-  if (TraceMethodHandles)
+  if (TraceMethodHandles) {
+    ResourceMark rm(THREAD);
     tty->print_cr("resolve_invokehandle %s %s", method_name->as_C_string(), method_signature->as_C_string());
+  }
   resolve_handle_call(result, resolved_klass, method_name, method_signature, current_klass, CHECK);
 }
 
--- a/hotspot/src/share/vm/memory/allocation.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/memory/allocation.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -611,4 +611,23 @@
   void check()    PRODUCT_RETURN;
 };
 
+// Helper class to allocate arrays that may become large.
+// Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit
+// and uses mapped memory for larger allocations.
+// Most OS mallocs do something similar but Solaris malloc does not revert
+// to mapped memory for large allocations. By default ArrayAllocatorMallocLimit
+// is set so that we always use malloc except for Solaris where we set the
+// limit to get mapped memory.
+template <class E, MEMFLAGS F>
+class ArrayAllocator : StackObj {
+  char* _addr;
+  bool _use_malloc;
+  size_t _size;
+ public:
+  ArrayAllocator() : _addr(NULL), _use_malloc(false), _size(0) { }
+  ~ArrayAllocator() { free(); }
+  E* allocate(size_t length);
+  void free();
+};
+
 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP
--- a/hotspot/src/share/vm/memory/allocation.inline.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/memory/allocation.inline.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -108,5 +108,49 @@
    FreeHeap(p, F);
 }
 
+template <class E, MEMFLAGS F>
+E* ArrayAllocator<E, F>::allocate(size_t length) {
+  assert(_addr == NULL, "Already in use");
+
+  _size = sizeof(E) * length;
+  _use_malloc = _size < ArrayAllocatorMallocLimit;
+
+  if (_use_malloc) {
+    _addr = AllocateHeap(_size, F);
+    if (_addr == NULL && _size >=  (size_t)os::vm_allocation_granularity()) {
+      // malloc failed let's try with mmap instead
+      _use_malloc = false;
+    } else {
+      return (E*)_addr;
+    }
+  }
+
+  int alignment = os::vm_allocation_granularity();
+  _size = align_size_up(_size, alignment);
+
+  _addr = os::reserve_memory(_size, NULL, alignment);
+  if (_addr == NULL) {
+    vm_exit_out_of_memory(_size, "Allocator (reserve)");
+  }
+
+  bool success = os::commit_memory(_addr, _size, false /* executable */);
+  if (!success) {
+    vm_exit_out_of_memory(_size, "Allocator (commit)");
+  }
+
+  return (E*)_addr;
+}
+
+template<class E, MEMFLAGS F>
+void ArrayAllocator<E, F>::free() {
+  if (_addr != NULL) {
+    if (_use_malloc) {
+      FreeHeap(_addr, F);
+    } else {
+      os::release_memory(_addr, _size);
+    }
+    _addr = NULL;
+  }
+}
 
 #endif // SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -819,12 +819,13 @@
 // Returns "TRUE" iff "p" points into the committed areas of the heap.
 bool GenCollectedHeap::is_in(const void* p) const {
   #ifndef ASSERT
-  guarantee(VerifyBeforeGC   ||
-            VerifyDuringGC   ||
-            VerifyBeforeExit ||
-            PrintAssembly    ||
-            tty->count() != 0 ||   // already printing
-            VerifyAfterGC    ||
+  guarantee(VerifyBeforeGC      ||
+            VerifyDuringGC      ||
+            VerifyBeforeExit    ||
+            VerifyDuringStartup ||
+            PrintAssembly       ||
+            tty->count() != 0   ||   // already printing
+            VerifyAfterGC       ||
     VMError::fatal_error_in_progress(), "too expensive");
 
   #endif
@@ -1132,6 +1133,17 @@
 #endif // INCLUDE_ALL_GCS
 }
 
+void GenCollectedHeap::print_on_error(outputStream* st) const {
+  this->CollectedHeap::print_on_error(st);
+
+#if INCLUDE_ALL_GCS
+  if (UseConcMarkSweepGC) {
+    st->cr();
+    CMSCollector::print_on_error(st);
+  }
+#endif // INCLUDE_ALL_GCS
+}
+
 void GenCollectedHeap::print_tracing_info() const {
   if (TraceGen0Time) {
     get_gen(0)->print_summary_info();
--- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -344,6 +344,7 @@
   virtual void print_gc_threads_on(outputStream* st) const;
   virtual void gc_threads_do(ThreadClosure* tc) const;
   virtual void print_tracing_info() const;
+  virtual void print_on_error(outputStream* st) const;
 
   // PrintGC, PrintGCDetails support
   void print_heap_change(size_t prev_used) const;
--- a/hotspot/src/share/vm/memory/generation.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/memory/generation.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -382,7 +382,9 @@
 CardGeneration::CardGeneration(ReservedSpace rs, size_t initial_byte_size,
                                int level,
                                GenRemSet* remset) :
-  Generation(rs, initial_byte_size, level), _rs(remset)
+  Generation(rs, initial_byte_size, level), _rs(remset),
+  _shrink_factor(0), _min_heap_delta_bytes(), _capacity_at_prologue(),
+  _used_at_prologue()
 {
   HeapWord* start = (HeapWord*)rs.base();
   size_t reserved_byte_size = rs.size();
@@ -406,6 +408,9 @@
     // the end if we try.
     guarantee(_rs->is_aligned(reserved_mr.end()), "generation must be card aligned");
   }
+  _min_heap_delta_bytes = MinHeapDeltaBytes;
+  _capacity_at_prologue = initial_byte_size;
+  _used_at_prologue = 0;
 }
 
 bool CardGeneration::expand(size_t bytes, size_t expand_bytes) {
@@ -457,6 +462,160 @@
 }
 
 
+void CardGeneration::compute_new_size() {
+  assert(_shrink_factor <= 100, "invalid shrink factor");
+  size_t current_shrink_factor = _shrink_factor;
+  _shrink_factor = 0;
+
+  // We don't have floating point command-line arguments
+  // Note:  argument processing ensures that MinHeapFreeRatio < 100.
+  const double minimum_free_percentage = MinHeapFreeRatio / 100.0;
+  const double maximum_used_percentage = 1.0 - minimum_free_percentage;
+
+  // Compute some numbers about the state of the heap.
+  const size_t used_after_gc = used();
+  const size_t capacity_after_gc = capacity();
+
+  const double min_tmp = used_after_gc / maximum_used_percentage;
+  size_t minimum_desired_capacity = (size_t)MIN2(min_tmp, double(max_uintx));
+  // Don't shrink less than the initial generation size
+  minimum_desired_capacity = MAX2(minimum_desired_capacity,
+                                  spec()->init_size());
+  assert(used_after_gc <= minimum_desired_capacity, "sanity check");
+
+  if (PrintGC && Verbose) {
+    const size_t free_after_gc = free();
+    const double free_percentage = ((double)free_after_gc) / capacity_after_gc;
+    gclog_or_tty->print_cr("TenuredGeneration::compute_new_size: ");
+    gclog_or_tty->print_cr("  "
+                  "  minimum_free_percentage: %6.2f"
+                  "  maximum_used_percentage: %6.2f",
+                  minimum_free_percentage,
+                  maximum_used_percentage);
+    gclog_or_tty->print_cr("  "
+                  "   free_after_gc   : %6.1fK"
+                  "   used_after_gc   : %6.1fK"
+                  "   capacity_after_gc   : %6.1fK",
+                  free_after_gc / (double) K,
+                  used_after_gc / (double) K,
+                  capacity_after_gc / (double) K);
+    gclog_or_tty->print_cr("  "
+                  "   free_percentage: %6.2f",
+                  free_percentage);
+  }
+
+  if (capacity_after_gc < minimum_desired_capacity) {
+    // If we have less free space than we want then expand
+    size_t expand_bytes = minimum_desired_capacity - capacity_after_gc;
+    // Don't expand unless it's significant
+    if (expand_bytes >= _min_heap_delta_bytes) {
+      expand(expand_bytes, 0); // safe if expansion fails
+    }
+    if (PrintGC && Verbose) {
+      gclog_or_tty->print_cr("    expanding:"
+                    "  minimum_desired_capacity: %6.1fK"
+                    "  expand_bytes: %6.1fK"
+                    "  _min_heap_delta_bytes: %6.1fK",
+                    minimum_desired_capacity / (double) K,
+                    expand_bytes / (double) K,
+                    _min_heap_delta_bytes / (double) K);
+    }
+    return;
+  }
+
+  // No expansion, now see if we want to shrink
+  size_t shrink_bytes = 0;
+  // We would never want to shrink more than this
+  size_t max_shrink_bytes = capacity_after_gc - minimum_desired_capacity;
+
+  if (MaxHeapFreeRatio < 100) {
+    const double maximum_free_percentage = MaxHeapFreeRatio / 100.0;
+    const double minimum_used_percentage = 1.0 - maximum_free_percentage;
+    const double max_tmp = used_after_gc / minimum_used_percentage;
+    size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
+    maximum_desired_capacity = MAX2(maximum_desired_capacity,
+                                    spec()->init_size());
+    if (PrintGC && Verbose) {
+      gclog_or_tty->print_cr("  "
+                             "  maximum_free_percentage: %6.2f"
+                             "  minimum_used_percentage: %6.2f",
+                             maximum_free_percentage,
+                             minimum_used_percentage);
+      gclog_or_tty->print_cr("  "
+                             "  _capacity_at_prologue: %6.1fK"
+                             "  minimum_desired_capacity: %6.1fK"
+                             "  maximum_desired_capacity: %6.1fK",
+                             _capacity_at_prologue / (double) K,
+                             minimum_desired_capacity / (double) K,
+                             maximum_desired_capacity / (double) K);
+    }
+    assert(minimum_desired_capacity <= maximum_desired_capacity,
+           "sanity check");
+
+    if (capacity_after_gc > maximum_desired_capacity) {
+      // Capacity too large, compute shrinking size
+      shrink_bytes = capacity_after_gc - maximum_desired_capacity;
+      // We don't want shrink all the way back to initSize if people call
+      // System.gc(), because some programs do that between "phases" and then
+      // we'd just have to grow the heap up again for the next phase.  So we
+      // damp the shrinking: 0% on the first call, 10% on the second call, 40%
+      // on the third call, and 100% by the fourth call.  But if we recompute
+      // size without shrinking, it goes back to 0%.
+      shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
+      assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
+      if (current_shrink_factor == 0) {
+        _shrink_factor = 10;
+      } else {
+        _shrink_factor = MIN2(current_shrink_factor * 4, (size_t) 100);
+      }
+      if (PrintGC && Verbose) {
+        gclog_or_tty->print_cr("  "
+                      "  shrinking:"
+                      "  initSize: %.1fK"
+                      "  maximum_desired_capacity: %.1fK",
+                      spec()->init_size() / (double) K,
+                      maximum_desired_capacity / (double) K);
+        gclog_or_tty->print_cr("  "
+                      "  shrink_bytes: %.1fK"
+                      "  current_shrink_factor: %d"
+                      "  new shrink factor: %d"
+                      "  _min_heap_delta_bytes: %.1fK",
+                      shrink_bytes / (double) K,
+                      current_shrink_factor,
+                      _shrink_factor,
+                      _min_heap_delta_bytes / (double) K);
+      }
+    }
+  }
+
+  if (capacity_after_gc > _capacity_at_prologue) {
+    // We might have expanded for promotions, in which case we might want to
+    // take back that expansion if there's room after GC.  That keeps us from
+    // stretching the heap with promotions when there's plenty of room.
+    size_t expansion_for_promotion = capacity_after_gc - _capacity_at_prologue;
+    expansion_for_promotion = MIN2(expansion_for_promotion, max_shrink_bytes);
+    // We have two shrinking computations, take the largest
+    shrink_bytes = MAX2(shrink_bytes, expansion_for_promotion);
+    assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
+    if (PrintGC && Verbose) {
+      gclog_or_tty->print_cr("  "
+                             "  aggressive shrinking:"
+                             "  _capacity_at_prologue: %.1fK"
+                             "  capacity_after_gc: %.1fK"
+                             "  expansion_for_promotion: %.1fK"
+                             "  shrink_bytes: %.1fK",
+                             capacity_after_gc / (double) K,
+                             _capacity_at_prologue / (double) K,
+                             expansion_for_promotion / (double) K,
+                             shrink_bytes / (double) K);
+    }
+  }
+  // Don't shrink unless it's significant
+  if (shrink_bytes >= _min_heap_delta_bytes) {
+    shrink(shrink_bytes);
+  }
+}
+
 // Currently nothing to do.
 void CardGeneration::prepare_for_verify() {}
 
--- a/hotspot/src/share/vm/memory/generation.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/memory/generation.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -634,6 +634,17 @@
   // This is local to this generation.
   BlockOffsetSharedArray* _bts;
 
+  // current shrinking effect: this damps shrinking when the heap gets empty.
+  size_t _shrink_factor;
+
+  size_t _min_heap_delta_bytes;   // Minimum amount to expand.
+
+  // Some statistics from before gc started.
+  // These are gathered in the gc_prologue (and should_collect)
+  // to control growing/shrinking policy in spite of promotions.
+  size_t _capacity_at_prologue;
+  size_t _used_at_prologue;
+
   CardGeneration(ReservedSpace rs, size_t initial_byte_size, int level,
                  GenRemSet* remset);
 
@@ -644,6 +655,11 @@
   // necessarily the full "bytes") was done.
   virtual bool expand(size_t bytes, size_t expand_bytes);
 
+  // Shrink generation with specified size (returns false if unable to shrink)
+  virtual void shrink(size_t bytes) = 0;
+
+  virtual void compute_new_size();
+
   virtual void clear_remembered_set();
 
   virtual void invalidate_remembered_set();
@@ -667,7 +683,6 @@
   friend class VM_PopulateDumpSharedSpace;
 
  protected:
-  size_t     _min_heap_delta_bytes;   // Minimum amount to expand.
   ContiguousSpace*  _the_space;       // actual space holding objects
   WaterMark  _last_gc;                // watermark between objects allocated before
                                       // and after last GC.
@@ -688,11 +703,10 @@
 
  public:
   OneContigSpaceCardGeneration(ReservedSpace rs, size_t initial_byte_size,
-                               size_t min_heap_delta_bytes,
                                int level, GenRemSet* remset,
                                ContiguousSpace* space) :
     CardGeneration(rs, initial_byte_size, level, remset),
-    _the_space(space), _min_heap_delta_bytes(min_heap_delta_bytes)
+    _the_space(space)
   {}
 
   inline bool is_in(const void* p) const;
--- a/hotspot/src/share/vm/memory/heap.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/memory/heap.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -79,13 +79,6 @@
 }
 
 
-static size_t align_to_allocation_size(size_t size) {
-  const size_t alignment = (size_t)os::vm_allocation_granularity();
-  assert(is_power_of_2(alignment), "no kidding ???");
-  return (size + alignment - 1) & ~(alignment - 1);
-}
-
-
 void CodeHeap::on_code_mapping(char* base, size_t size) {
 #ifdef LINUX
   extern void linux_wrap_code(char* base, size_t size);
--- a/hotspot/src/share/vm/memory/tenuredGeneration.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/memory/tenuredGeneration.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -39,7 +39,7 @@
                                      size_t initial_byte_size, int level,
                                      GenRemSet* remset) :
   OneContigSpaceCardGeneration(rs, initial_byte_size,
-                               MinHeapDeltaBytes, level, remset, NULL)
+                               level, remset, NULL)
 {
   HeapWord* bottom = (HeapWord*) _virtual_space.low();
   HeapWord* end    = (HeapWord*) _virtual_space.high();
@@ -86,162 +86,6 @@
   return "tenured generation";
 }
 
-void TenuredGeneration::compute_new_size() {
-  assert(_shrink_factor <= 100, "invalid shrink factor");
-  size_t current_shrink_factor = _shrink_factor;
-  _shrink_factor = 0;
-
-  // We don't have floating point command-line arguments
-  // Note:  argument processing ensures that MinHeapFreeRatio < 100.
-  const double minimum_free_percentage = MinHeapFreeRatio / 100.0;
-  const double maximum_used_percentage = 1.0 - minimum_free_percentage;
-
-  // Compute some numbers about the state of the heap.
-  const size_t used_after_gc = used();
-  const size_t capacity_after_gc = capacity();
-
-  const double min_tmp = used_after_gc / maximum_used_percentage;
-  size_t minimum_desired_capacity = (size_t)MIN2(min_tmp, double(max_uintx));
-  // Don't shrink less than the initial generation size
-  minimum_desired_capacity = MAX2(minimum_desired_capacity,
-                                  spec()->init_size());
-  assert(used_after_gc <= minimum_desired_capacity, "sanity check");
-
-  if (PrintGC && Verbose) {
-    const size_t free_after_gc = free();
-    const double free_percentage = ((double)free_after_gc) / capacity_after_gc;
-    gclog_or_tty->print_cr("TenuredGeneration::compute_new_size: ");
-    gclog_or_tty->print_cr("  "
-                  "  minimum_free_percentage: %6.2f"
-                  "  maximum_used_percentage: %6.2f",
-                  minimum_free_percentage,
-                  maximum_used_percentage);
-    gclog_or_tty->print_cr("  "
-                  "   free_after_gc   : %6.1fK"
-                  "   used_after_gc   : %6.1fK"
-                  "   capacity_after_gc   : %6.1fK",
-                  free_after_gc / (double) K,
-                  used_after_gc / (double) K,
-                  capacity_after_gc / (double) K);
-    gclog_or_tty->print_cr("  "
-                  "   free_percentage: %6.2f",
-                  free_percentage);
-  }
-
-  if (capacity_after_gc < minimum_desired_capacity) {
-    // If we have less free space than we want then expand
-    size_t expand_bytes = minimum_desired_capacity - capacity_after_gc;
-    // Don't expand unless it's significant
-    if (expand_bytes >= _min_heap_delta_bytes) {
-      expand(expand_bytes, 0); // safe if expansion fails
-    }
-    if (PrintGC && Verbose) {
-      gclog_or_tty->print_cr("    expanding:"
-                    "  minimum_desired_capacity: %6.1fK"
-                    "  expand_bytes: %6.1fK"
-                    "  _min_heap_delta_bytes: %6.1fK",
-                    minimum_desired_capacity / (double) K,
-                    expand_bytes / (double) K,
-                    _min_heap_delta_bytes / (double) K);
-    }
-    return;
-  }
-
-  // No expansion, now see if we want to shrink
-  size_t shrink_bytes = 0;
-  // We would never want to shrink more than this
-  size_t max_shrink_bytes = capacity_after_gc - minimum_desired_capacity;
-
-  if (MaxHeapFreeRatio < 100) {
-    const double maximum_free_percentage = MaxHeapFreeRatio / 100.0;
-    const double minimum_used_percentage = 1.0 - maximum_free_percentage;
-    const double max_tmp = used_after_gc / minimum_used_percentage;
-    size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
-    maximum_desired_capacity = MAX2(maximum_desired_capacity,
-                                    spec()->init_size());
-    if (PrintGC && Verbose) {
-      gclog_or_tty->print_cr("  "
-                             "  maximum_free_percentage: %6.2f"
-                             "  minimum_used_percentage: %6.2f",
-                             maximum_free_percentage,
-                             minimum_used_percentage);
-      gclog_or_tty->print_cr("  "
-                             "  _capacity_at_prologue: %6.1fK"
-                             "  minimum_desired_capacity: %6.1fK"
-                             "  maximum_desired_capacity: %6.1fK",
-                             _capacity_at_prologue / (double) K,
-                             minimum_desired_capacity / (double) K,
-                             maximum_desired_capacity / (double) K);
-    }
-    assert(minimum_desired_capacity <= maximum_desired_capacity,
-           "sanity check");
-
-    if (capacity_after_gc > maximum_desired_capacity) {
-      // Capacity too large, compute shrinking size
-      shrink_bytes = capacity_after_gc - maximum_desired_capacity;
-      // We don't want shrink all the way back to initSize if people call
-      // System.gc(), because some programs do that between "phases" and then
-      // we'd just have to grow the heap up again for the next phase.  So we
-      // damp the shrinking: 0% on the first call, 10% on the second call, 40%
-      // on the third call, and 100% by the fourth call.  But if we recompute
-      // size without shrinking, it goes back to 0%.
-      shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
-      assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
-      if (current_shrink_factor == 0) {
-        _shrink_factor = 10;
-      } else {
-        _shrink_factor = MIN2(current_shrink_factor * 4, (size_t) 100);
-      }
-      if (PrintGC && Verbose) {
-        gclog_or_tty->print_cr("  "
-                      "  shrinking:"
-                      "  initSize: %.1fK"
-                      "  maximum_desired_capacity: %.1fK",
-                      spec()->init_size() / (double) K,
-                      maximum_desired_capacity / (double) K);
-        gclog_or_tty->print_cr("  "
-                      "  shrink_bytes: %.1fK"
-                      "  current_shrink_factor: %d"
-                      "  new shrink factor: %d"
-                      "  _min_heap_delta_bytes: %.1fK",
-                      shrink_bytes / (double) K,
-                      current_shrink_factor,
-                      _shrink_factor,
-                      _min_heap_delta_bytes / (double) K);
-      }
-    }
-  }
-
-  if (capacity_after_gc > _capacity_at_prologue) {
-    // We might have expanded for promotions, in which case we might want to
-    // take back that expansion if there's room after GC.  That keeps us from
-    // stretching the heap with promotions when there's plenty of room.
-    size_t expansion_for_promotion = capacity_after_gc - _capacity_at_prologue;
-    expansion_for_promotion = MIN2(expansion_for_promotion, max_shrink_bytes);
-    // We have two shrinking computations, take the largest
-    shrink_bytes = MAX2(shrink_bytes, expansion_for_promotion);
-    assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
-    if (PrintGC && Verbose) {
-      gclog_or_tty->print_cr("  "
-                             "  aggressive shrinking:"
-                             "  _capacity_at_prologue: %.1fK"
-                             "  capacity_after_gc: %.1fK"
-                             "  expansion_for_promotion: %.1fK"
-                             "  shrink_bytes: %.1fK",
-                             capacity_after_gc / (double) K,
-                             _capacity_at_prologue / (double) K,
-                             expansion_for_promotion / (double) K,
-                             shrink_bytes / (double) K);
-    }
-  }
-  // Don't shrink unless it's significant
-  if (shrink_bytes >= _min_heap_delta_bytes) {
-    shrink(shrink_bytes);
-  }
-  assert(used() == used_after_gc && used_after_gc <= capacity(),
-         "sanity check");
-}
-
 void TenuredGeneration::gc_prologue(bool full) {
   _capacity_at_prologue = capacity();
   _used_at_prologue = used();
@@ -312,6 +156,19 @@
                                         size, is_tlab);
 }
 
+void TenuredGeneration::compute_new_size() {
+  assert_locked_or_safepoint(Heap_lock);
+
+  // Compute some numbers about the state of the heap.
+  const size_t used_after_gc = used();
+  const size_t capacity_after_gc = capacity();
+
+  CardGeneration::compute_new_size();
+
+  assert(used() == used_after_gc && used_after_gc <= capacity(),
+         err_msg("used: " SIZE_FORMAT " used_after_gc: " SIZE_FORMAT
+         " capacity: " SIZE_FORMAT, used(), used_after_gc, capacity()));
+}
 void TenuredGeneration::update_gc_stats(int current_level,
                                         bool full) {
   // If the next lower level(s) has been collected, gather any statistics
--- a/hotspot/src/share/vm/memory/tenuredGeneration.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/memory/tenuredGeneration.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -38,13 +38,6 @@
 class TenuredGeneration: public OneContigSpaceCardGeneration {
   friend class VMStructs;
  protected:
-  // current shrinking effect: this damps shrinking when the heap gets empty.
-  size_t _shrink_factor;
-  // Some statistics from before gc started.
-  // These are gathered in the gc_prologue (and should_collect)
-  // to control growing/shrinking policy in spite of promotions.
-  size_t _capacity_at_prologue;
-  size_t _used_at_prologue;
 
 #if INCLUDE_ALL_GCS
   // To support parallel promotion: an array of parallel allocation
@@ -80,9 +73,6 @@
     return !CollectGen0First;
   }
 
-  // Mark sweep support
-  void compute_new_size();
-
   virtual void gc_prologue(bool full);
   virtual void gc_epilogue(bool full);
   bool should_collect(bool   full,
@@ -93,6 +83,7 @@
                        bool clear_all_soft_refs,
                        size_t size,
                        bool is_tlab);
+  virtual void compute_new_size();
 
 #if INCLUDE_ALL_GCS
   // Overrides.
--- a/hotspot/src/share/vm/memory/universe.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/memory/universe.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1326,6 +1326,8 @@
 static uintptr_t _verify_klass_data[2] = {0, (uintptr_t)-1};
 
 
+#ifndef PRODUCT
+
 static void calculate_verify_data(uintptr_t verify_data[2],
                                   HeapWord* low_boundary,
                                   HeapWord* high_boundary) {
@@ -1360,9 +1362,7 @@
   verify_data[1] = bits;
 }
 
-
 // Oop verification (see MacroAssembler::verify_oop)
-#ifndef PRODUCT
 
 uintptr_t Universe::verify_oop_mask() {
   MemRegion m = heap()->reserved_region();
--- a/hotspot/src/share/vm/oops/constantPool.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/oops/constantPool.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1378,12 +1378,13 @@
 
 // JVMTI GetConstantPool support
 
-// For temporary use until code is stable.
-#define DBG(code)
+// For debugging of constant pool
+const bool debug_cpool = false;
 
-static const char* WARN_MSG = "Must not be such entry!";
+#define DBG(code) do { if (debug_cpool) { (code); } } while(0)
 
 static void print_cpool_bytes(jint cnt, u1 *bytes) {
+  const char* WARN_MSG = "Must not be such entry!";
   jint size = 0;
   u2   idx1, idx2;
 
@@ -1669,8 +1670,7 @@
         idx1 = tbl->symbol_to_value(sym);
         assert(idx1 != 0, "Have not found a hashtable entry");
         Bytes::put_Java_u2((address) (bytes+1), idx1);
-        DBG(char *str = sym->as_utf8());
-        DBG(printf("JVM_CONSTANT_String: idx=#%03hd, %s", idx1, str));
+        DBG(printf("JVM_CONSTANT_String: idx=#%03hd, %s", idx1, sym->as_utf8()));
         break;
       }
       case JVM_CONSTANT_Fieldref:
@@ -1745,6 +1745,8 @@
   return (int)(bytes - start_bytes);
 } /* end copy_cpool_bytes */
 
+#undef DBG
+
 
 void ConstantPool::set_on_stack(const bool value) {
   if (value) {
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -3157,7 +3157,7 @@
     Array<int>* method_ordering = this->method_ordering();
     int length = method_ordering->length();
     if (JvmtiExport::can_maintain_original_method_order() ||
-        (UseSharedSpaces && length != 0)) {
+        ((UseSharedSpaces || DumpSharedSpaces) && length != 0)) {
       guarantee(length == methods()->length(), "invalid method ordering length");
       jlong sum = 0;
       for (int j = 0; j < length; j++) {
--- a/hotspot/src/share/vm/oops/method.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/oops/method.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -758,15 +758,19 @@
   void print_made_not_compilable(int comp_level, bool is_osr, bool report, const char* reason);
 
  public:
-  bool  is_not_c1_compilable() const          { return access_flags().is_not_c1_compilable(); }
-  void set_not_c1_compilable()                {       _access_flags.set_not_c1_compilable();  }
-  bool  is_not_c2_compilable() const          { return access_flags().is_not_c2_compilable(); }
-  void set_not_c2_compilable()                {       _access_flags.set_not_c2_compilable();  }
+  bool   is_not_c1_compilable() const         { return access_flags().is_not_c1_compilable();  }
+  void  set_not_c1_compilable()               {       _access_flags.set_not_c1_compilable();   }
+  void clear_not_c1_compilable()              {       _access_flags.clear_not_c1_compilable(); }
+  bool   is_not_c2_compilable() const         { return access_flags().is_not_c2_compilable();  }
+  void  set_not_c2_compilable()               {       _access_flags.set_not_c2_compilable();   }
+  void clear_not_c2_compilable()              {       _access_flags.clear_not_c2_compilable(); }
 
-  bool  is_not_c1_osr_compilable() const      { return is_not_c1_compilable(); }  // don't waste an accessFlags bit
-  void set_not_c1_osr_compilable()            {       set_not_c1_compilable(); }  // don't waste an accessFlags bit
-  bool  is_not_c2_osr_compilable() const      { return access_flags().is_not_c2_osr_compilable(); }
-  void set_not_c2_osr_compilable()            {       _access_flags.set_not_c2_osr_compilable();  }
+  bool    is_not_c1_osr_compilable() const    { return is_not_c1_compilable(); }  // don't waste an accessFlags bit
+  void   set_not_c1_osr_compilable()          {       set_not_c1_compilable(); }  // don't waste an accessFlags bit
+  void clear_not_c1_osr_compilable()          {     clear_not_c1_compilable(); }  // don't waste an accessFlags bit
+  bool   is_not_c2_osr_compilable() const     { return access_flags().is_not_c2_osr_compilable();  }
+  void  set_not_c2_osr_compilable()           {       _access_flags.set_not_c2_osr_compilable();   }
+  void clear_not_c2_osr_compilable()          {       _access_flags.clear_not_c2_osr_compilable(); }
 
   // Background compilation support
   bool queued_for_compilation() const  { return access_flags().queued_for_compilation(); }
--- a/hotspot/src/share/vm/oops/methodData.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/oops/methodData.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -660,29 +660,9 @@
   // Set the method back-pointer.
   _method = method();
 
-  _invocation_counter.init();
-  _backedge_counter.init();
-  _invocation_counter_start = 0;
-  _backedge_counter_start = 0;
-  _num_loops = 0;
-  _num_blocks = 0;
-  _highest_comp_level = 0;
-  _highest_osr_comp_level = 0;
-  _would_profile = true;
+  init();
   set_creation_mileage(mileage_of(method()));
 
-  // Initialize flags and trap history.
-  _nof_decompiles = 0;
-  _nof_overflow_recompiles = 0;
-  _nof_overflow_traps = 0;
-  _eflags = 0;
-  _arg_local = 0;
-  _arg_stack = 0;
-  _arg_returned = 0;
-  assert(sizeof(_trap_hist) % sizeof(HeapWord) == 0, "align");
-  Copy::zero_to_words((HeapWord*) &_trap_hist,
-                      sizeof(_trap_hist) / sizeof(HeapWord));
-
   // Go through the bytecodes and allocate and initialize the
   // corresponding data cells.
   int data_size = 0;
@@ -721,7 +701,27 @@
   post_initialize(&stream);
 
   set_size(object_size);
+}
 
+void MethodData::init() {
+  _invocation_counter.init();
+  _backedge_counter.init();
+  _invocation_counter_start = 0;
+  _backedge_counter_start = 0;
+  _num_loops = 0;
+  _num_blocks = 0;
+  _highest_comp_level = 0;
+  _highest_osr_comp_level = 0;
+  _would_profile = true;
+
+  // Initialize flags and trap history.
+  _nof_decompiles = 0;
+  _nof_overflow_recompiles = 0;
+  _nof_overflow_traps = 0;
+  clear_escape_info();
+  assert(sizeof(_trap_hist) % sizeof(HeapWord) == 0, "align");
+  Copy::zero_to_words((HeapWord*) &_trap_hist,
+                      sizeof(_trap_hist) / sizeof(HeapWord));
 }
 
 // Get a measure of how much mileage the method has on it.
--- a/hotspot/src/share/vm/oops/methodData.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/oops/methodData.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1284,8 +1284,8 @@
     return bytecode_cell_count(code) != no_profile_data;
   }
 
-  // Perform initialization of a new MethodData*
-  void initialize(methodHandle method);
+  // reset into original state
+  void init();
 
   // My size
   int size_in_bytes() const { return _size; }
@@ -1365,6 +1365,7 @@
   intx arg_stack()                               { return _arg_stack; }
   intx arg_returned()                            { return _arg_returned; }
   uint arg_modified(int a)                       { ArgInfoData *aid = arg_info();
+                                                   assert(aid != NULL, "arg_info must be not null");
                                                    assert(a >= 0 && a < aid->number_of_args(), "valid argument number");
                                                    return aid->arg_modified(a); }
 
@@ -1373,8 +1374,8 @@
   void set_arg_stack(intx v)                     { _arg_stack = v; }
   void set_arg_returned(intx v)                  { _arg_returned = v; }
   void set_arg_modified(int a, uint v)           { ArgInfoData *aid = arg_info();
+                                                   assert(aid != NULL, "arg_info must be not null");
                                                    assert(a >= 0 && a < aid->number_of_args(), "valid argument number");
-
                                                    aid->set_arg_modified(a, v); }
 
   void clear_escape_info()                       { _eflags = _arg_local = _arg_stack = _arg_returned = 0; }
--- a/hotspot/src/share/vm/opto/block.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/opto/block.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1028,26 +1028,6 @@
 }
 
 #ifndef PRODUCT
-static void edge_dump(GrowableArray<CFGEdge *> *edges) {
-  tty->print_cr("---- Edges ----");
-  for (int i = 0; i < edges->length(); i++) {
-    CFGEdge *e = edges->at(i);
-    if (e != NULL) {
-      edges->at(i)->dump();
-    }
-  }
-}
-
-static void trace_dump(Trace *traces[], int count) {
-  tty->print_cr("---- Traces ----");
-  for (int i = 0; i < count; i++) {
-    Trace *tr = traces[i];
-    if (tr != NULL) {
-      tr->dump();
-    }
-  }
-}
-
 void Trace::dump( ) const {
   tty->print_cr("Trace (freq %f)", first_block()->_freq);
   for (Block *b = first_block(); b != NULL; b = next(b)) {
--- a/hotspot/src/share/vm/opto/compile.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/opto/compile.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -2326,12 +2326,14 @@
   int  get_inner_loop_count() const { return _inner_loop_count; }
 };
 
+#ifdef ASSERT
 static bool oop_offset_is_sane(const TypeInstPtr* tp) {
   ciInstanceKlass *k = tp->klass()->as_instance_klass();
   // Make sure the offset goes inside the instance layout.
   return k->contains_field_offset(tp->offset());
   // Note that OffsetBot and OffsetTop are very negative.
 }
+#endif
 
 // Eliminate trivially redundant StoreCMs and accumulate their
 // precedence edges.
--- a/hotspot/src/share/vm/opto/connode.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/opto/connode.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -465,29 +465,6 @@
   return (phase->type(in(1)) == phase->type(this)) ? in(1) : this;
 }
 
-// Determine whether "n" is a node which can cause an alias of one of its inputs.  Node types
-// which can create aliases are: CheckCastPP, Phi, and any store (if there is also a load from
-// the location.)
-// Note:  this checks for aliases created in this compilation, not ones which may
-//        be potentially created at call sites.
-static bool can_cause_alias(Node *n, PhaseTransform *phase) {
-  bool possible_alias = false;
-
-  if (n->is_Store()) {
-    possible_alias = !n->as_Store()->value_never_loaded(phase);
-  } else {
-    int opc = n->Opcode();
-    possible_alias = n->is_Phi() ||
-        opc == Op_CheckCastPP ||
-        opc == Op_StorePConditional ||
-        opc == Op_CompareAndSwapP ||
-        opc == Op_CompareAndSwapN ||
-        opc == Op_GetAndSetP ||
-        opc == Op_GetAndSetN;
-  }
-  return possible_alias;
-}
-
 //------------------------------Value------------------------------------------
 // Take 'join' of input and cast-up type, unless working with an Interface
 const Type *CheckCastPPNode::Value( PhaseTransform *phase ) const {
--- a/hotspot/src/share/vm/opto/subnode.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/opto/subnode.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1078,16 +1078,6 @@
   return (_test._test == b->_test._test);
 }
 
-//------------------------------clone_cmp--------------------------------------
-// Clone a compare/bool tree
-static Node *clone_cmp( Node *cmp, Node *cmp1, Node *cmp2, PhaseGVN *gvn, BoolTest::mask test ) {
-  Node *ncmp = cmp->clone();
-  ncmp->set_req(1,cmp1);
-  ncmp->set_req(2,cmp2);
-  ncmp = gvn->transform( ncmp );
-  return new (gvn->C) BoolNode( ncmp, test );
-}
-
 //-------------------------------make_predicate--------------------------------
 Node* BoolNode::make_predicate(Node* test_value, PhaseGVN* phase) {
   if (test_value->is_Con())   return test_value;
--- a/hotspot/src/share/vm/prims/jni.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/prims/jni.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1289,32 +1289,6 @@
   JNI_NONVIRTUAL
 };
 
-static methodHandle jni_resolve_interface_call(Handle recv, methodHandle method, TRAPS) {
-  assert(!method.is_null() , "method should not be null");
-
-  KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc)
-  if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass());
-  KlassHandle spec_klass (THREAD, method->method_holder());
-  Symbol*  name  = method->name();
-  Symbol*  signature  = method->signature();
-  CallInfo info;
-  LinkResolver::resolve_interface_call(info, recv, recv_klass,  spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle()));
-  return info.selected_method();
-}
-
-static methodHandle jni_resolve_virtual_call(Handle recv, methodHandle method, TRAPS) {
-  assert(!method.is_null() , "method should not be null");
-
-  KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc)
-  if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass());
-  KlassHandle spec_klass (THREAD, method->method_holder());
-  Symbol*  name  = method->name();
-  Symbol*  signature  = method->signature();
-  CallInfo info;
-  LinkResolver::resolve_virtual_call(info, recv, recv_klass,  spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle()));
-  return info.selected_method();
-}
-
 
 
 static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) {
@@ -5053,6 +5027,7 @@
 void execute_internal_vm_tests() {
   if (ExecuteInternalVMTests) {
     tty->print_cr("Running internal VM tests");
+    run_unit_test(GlobalDefinitions::test_globals());
     run_unit_test(arrayOopDesc::test_max_array_length());
     run_unit_test(CollectedHeap::test_is_in());
     run_unit_test(QuickSort::test_quick_sort());
--- a/hotspot/src/share/vm/prims/jniCheck.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/prims/jniCheck.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -33,7 +33,7 @@
   // within IN_VM macro), one to be called when in NATIVE state.
 
   // When in VM state:
-  static void ReportJNIFatalError(JavaThread* thr, const char *msg) {
+  static inline void ReportJNIFatalError(JavaThread* thr, const char *msg) {
     tty->print_cr("FATAL ERROR in native method: %s", msg);
     thr->print_stack();
     os::abort(true);
--- a/hotspot/src/share/vm/prims/whitebox.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/prims/whitebox.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -49,6 +49,7 @@
 #endif // INCLUDE_NMT
 
 #include "compiler/compileBroker.hpp"
+#include "runtime/compilationPolicy.hpp"
 
 bool WhiteBox::_used = false;
 
@@ -118,45 +119,46 @@
 #endif // INCLUDE_ALL_GCS
 
 #ifdef INCLUDE_NMT
-// Keep track of the 3 allocations in NMTAllocTest so we can free them later
-// on and verify that they're not visible anymore
-static void* nmtMtTest1 = NULL, *nmtMtTest2 = NULL, *nmtMtTest3 = NULL;
-
 // Alloc memory using the test memory type so that we can use that to see if
 // NMT picks it up correctly
-WB_ENTRY(jboolean, WB_NMTAllocTest(JNIEnv* env))
-  void *mem;
+WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size))
+  jlong addr = 0;
 
-  if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) {
-    return false;
+  if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) {
+    addr = (jlong)(uintptr_t)os::malloc(size, mtTest);
   }
 
-  // Allocate 2 * 128k + 256k + 1024k and free the 1024k one to make sure we track
-  // everything correctly. Total should be 512k held alive.
-  nmtMtTest1 = os::malloc(128 * 1024, mtTest);
-  mem = os::malloc(1024 * 1024, mtTest);
-  nmtMtTest2 = os::malloc(256 * 1024, mtTest);
-  os::free(mem, mtTest);
-  nmtMtTest3 = os::malloc(128 * 1024, mtTest);
-
-  return true;
+  return addr;
 WB_END
 
 // Free the memory allocated by NMTAllocTest
-WB_ENTRY(jboolean, WB_NMTFreeTestMemory(JNIEnv* env))
+WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem))
+  os::free((void*)(uintptr_t)mem, mtTest);
+WB_END
 
-  if (nmtMtTest1 == NULL || nmtMtTest2 == NULL || nmtMtTest3 == NULL) {
-    return false;
+WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size))
+  jlong addr = 0;
+
+  if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) {
+    addr = (jlong)(uintptr_t)os::reserve_memory(size);
+    MemTracker::record_virtual_memory_type((address)addr, mtTest);
   }
 
-  os::free(nmtMtTest1, mtTest);
-  nmtMtTest1 = NULL;
-  os::free(nmtMtTest2, mtTest);
-  nmtMtTest2 = NULL;
-  os::free(nmtMtTest3, mtTest);
-  nmtMtTest3 = NULL;
+  return addr;
+WB_END
+
 
-  return true;
+WB_ENTRY(void, WB_NMTCommitMemory(JNIEnv* env, jobject o, jlong addr, jlong size))
+  os::commit_memory((char *)(uintptr_t)addr, size);
+  MemTracker::record_virtual_memory_type((address)(uintptr_t)addr, mtTest);
+WB_END
+
+WB_ENTRY(void, WB_NMTUncommitMemory(JNIEnv* env, jobject o, jlong addr, jlong size))
+  os::uncommit_memory((char *)(uintptr_t)addr, size);
+WB_END
+
+WB_ENTRY(void, WB_NMTReleaseMemory(JNIEnv* env, jobject o, jlong addr, jlong size))
+  os::release_memory((char *)(uintptr_t)addr, size);
 WB_END
 
 // Block until the current generation of NMT data to be merged, used to reliably test the NMT feature
@@ -213,11 +215,11 @@
   return (code->is_alive() && !code->is_marked_for_deoptimization());
 WB_END
 
-WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method))
+WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level))
   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
   MutexLockerEx mu(Compile_lock);
   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
-  return !mh->is_not_compilable();
+  return CompilationPolicy::can_be_compiled(mh, comp_level);
 WB_END
 
 WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method))
@@ -241,7 +243,7 @@
   mh->set_not_compilable();
 WB_END
 
-WB_ENTRY(jboolean, WB_SetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
+WB_ENTRY(jboolean, WB_TestSetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
   bool result = mh->dont_inline();
@@ -254,6 +256,54 @@
          CompileBroker::queue_size(CompLevel_full_profile) /* C1 */;
 WB_END
 
+
+WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
+  jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+  methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
+  bool result = mh->force_inline();
+  mh->set_force_inline(value == JNI_TRUE);
+  return result;
+WB_END
+
+WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level))
+  jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+  methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
+  nmethod* nm = CompileBroker::compile_method(mh, InvocationEntryBci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
+  MutexLockerEx mu(Compile_lock);
+  return (mh->queued_for_compilation() || nm != NULL);
+WB_END
+
+WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method))
+  jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+  methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
+  MutexLockerEx mu(Compile_lock);
+  MethodData* mdo = mh->method_data();
+
+  if (mdo != NULL) {
+    mdo->init();
+    ResourceMark rm;
+    int arg_count = mdo->method()->size_of_parameters();
+    for (int i = 0; i < arg_count; i++) {
+      mdo->set_arg_modified(i, 0);
+    }
+  }
+
+  mh->backedge_counter()->init();
+  mh->invocation_counter()->init();
+  mh->set_interpreter_invocation_count(0);
+  mh->set_interpreter_throwout_count(0);
+  mh->clear_not_c1_compilable();
+  mh->clear_not_c2_compilable();
+  mh->clear_not_c2_osr_compilable();
+  NOT_PRODUCT(mh->set_compiled_invocation_count(0));
+
+#ifdef TIERED
+  mh->set_rate(0.0F);
+  mh->set_prev_event_count(0);
+  mh->set_prev_time(0);
+#endif
+WB_END
+
 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
   ResourceMark rm(THREAD);
   int len;
@@ -271,7 +321,6 @@
   Universe::heap()->collect(GCCause::_last_ditch_collection);
 WB_END
 
-
 //Some convenience methods to deal with objects from java
 int WhiteBox::offset_for_field(const char* field_name, oop object,
     Symbol* signature_symbol) {
@@ -340,27 +389,37 @@
   {CC"g1RegionSize",       CC"()I",                   (void*)&WB_G1RegionSize      },
 #endif // INCLUDE_ALL_GCS
 #ifdef INCLUDE_NMT
-  {CC"NMTAllocTest",       CC"()Z",                   (void*)&WB_NMTAllocTest      },
-  {CC"NMTFreeTestMemory",  CC"()Z",                   (void*)&WB_NMTFreeTestMemory },
-  {CC"NMTWaitForDataMerge",CC"()Z",                   (void*)&WB_NMTWaitForDataMerge},
+  {CC"NMTMalloc",           CC"(J)J",                 (void*)&WB_NMTMalloc          },
+  {CC"NMTFree",             CC"(J)V",                 (void*)&WB_NMTFree            },
+  {CC"NMTReserveMemory",    CC"(J)J",                 (void*)&WB_NMTReserveMemory   },
+  {CC"NMTCommitMemory",     CC"(JJ)V",                (void*)&WB_NMTCommitMemory    },
+  {CC"NMTUncommitMemory",   CC"(JJ)V",                (void*)&WB_NMTUncommitMemory  },
+  {CC"NMTReleaseMemory",    CC"(JJ)V",                (void*)&WB_NMTReleaseMemory   },
+  {CC"NMTWaitForDataMerge", CC"()Z",                  (void*)&WB_NMTWaitForDataMerge},
 #endif // INCLUDE_NMT
   {CC"deoptimizeAll",      CC"()V",                   (void*)&WB_DeoptimizeAll     },
   {CC"deoptimizeMethod",   CC"(Ljava/lang/reflect/Method;)I",
                                                       (void*)&WB_DeoptimizeMethod  },
   {CC"isMethodCompiled",   CC"(Ljava/lang/reflect/Method;)Z",
                                                       (void*)&WB_IsMethodCompiled  },
-  {CC"isMethodCompilable", CC"(Ljava/lang/reflect/Method;)Z",
+  {CC"isMethodCompilable", CC"(Ljava/lang/reflect/Method;I)Z",
                                                       (void*)&WB_IsMethodCompilable},
   {CC"isMethodQueuedForCompilation",
       CC"(Ljava/lang/reflect/Method;)Z",              (void*)&WB_IsMethodQueuedForCompilation},
   {CC"makeMethodNotCompilable",
       CC"(Ljava/lang/reflect/Method;)V",              (void*)&WB_MakeMethodNotCompilable},
-  {CC"setDontInlineMethod",
-      CC"(Ljava/lang/reflect/Method;Z)Z",             (void*)&WB_SetDontInlineMethod},
+  {CC"testSetDontInlineMethod",
+      CC"(Ljava/lang/reflect/Method;Z)Z",             (void*)&WB_TestSetDontInlineMethod},
   {CC"getMethodCompilationLevel",
       CC"(Ljava/lang/reflect/Method;)I",              (void*)&WB_GetMethodCompilationLevel},
   {CC"getCompileQueuesSize",
       CC"()I",                                        (void*)&WB_GetCompileQueuesSize},
+  {CC"testSetForceInlineMethod",
+      CC"(Ljava/lang/reflect/Method;Z)Z",             (void*)&WB_TestSetForceInlineMethod},
+  {CC"enqueueMethodForCompilation",
+      CC"(Ljava/lang/reflect/Method;I)Z",             (void*)&WB_EnqueueMethodForCompilation},
+  {CC"clearMethodState",
+      CC"(Ljava/lang/reflect/Method;)V",              (void*)&WB_ClearMethodState},
   {CC"isInStringTable",   CC"(Ljava/lang/String;)Z",  (void*)&WB_IsInStringTable  },
   {CC"fullGC",   CC"()V",                             (void*)&WB_FullGC },
 };
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1754,11 +1754,15 @@
   return false;
 }
 
+#if !INCLUDE_ALL_GCS
+#ifdef ASSERT
 static bool verify_serial_gc_flags() {
   return (UseSerialGC &&
         !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
           UseParallelGC || UseParallelOldGC));
 }
+#endif // ASSERT
+#endif // INCLUDE_ALL_GCS
 
 // check if do gclog rotation
 // +UseGCLogFileRotation is a must,
@@ -2006,11 +2010,12 @@
   // than just disable the lock verification. This will be fixed under
   // bug 4788986.
   if (UseConcMarkSweepGC && FLSVerifyAllHeapReferences) {
-    if (VerifyGCStartAt == 0) {
+    if (VerifyDuringStartup) {
       warning("Heap verification at start-up disabled "
               "(due to current incompatibility with FLSVerifyAllHeapReferences)");
-      VerifyGCStartAt = 1;      // Disable verification at start-up
+      VerifyDuringStartup = false; // Disable verification at start-up
     }
+
     if (VerifyBeforeExit) {
       warning("Heap verification at shutdown disabled "
               "(due to current incompatibility with FLSVerifyAllHeapReferences)");
@@ -3092,6 +3097,7 @@
   }                                                                   \
 } while(0)
 
+#if !INCLUDE_ALL_GCS
 static void force_serial_gc() {
   FLAG_SET_DEFAULT(UseSerialGC, true);
   FLAG_SET_DEFAULT(CMSIncrementalMode, false);  // special CMS suboption
@@ -3101,6 +3107,7 @@
   UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
   UNSUPPORTED_GC_OPTION(UseParNewGC);
 }
+#endif // INCLUDE_ALL_GCS
 
 // Parse entry point called from JNI_CreateJavaVM
 
--- a/hotspot/src/share/vm/runtime/compilationPolicy.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/compilationPolicy.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -123,9 +123,10 @@
   }
   if (comp_level == CompLevel_all) {
     return !m->is_not_compilable(CompLevel_simple) && !m->is_not_compilable(CompLevel_full_optimization);
-  } else {
+  } else if (is_compile(comp_level)) {
     return !m->is_not_compilable(comp_level);
   }
+  return false;
 }
 
 bool CompilationPolicy::is_compilation_enabled() {
--- a/hotspot/src/share/vm/runtime/compilationPolicy.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/compilationPolicy.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -96,7 +96,7 @@
   void reset_counter_for_back_branch_event(methodHandle method);
 public:
   NonTieredCompPolicy() : _compiler_count(0) { }
-  virtual CompLevel initial_compile_level() { return CompLevel_initial_compile; }
+  virtual CompLevel initial_compile_level() { return CompLevel_highest_tier; }
   virtual int compiler_count(CompLevel comp_level);
   virtual void do_safepoint_work();
   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
--- a/hotspot/src/share/vm/runtime/globals.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -2123,6 +2123,10 @@
   product(intx, PrefetchFieldsAhead, -1,                                    \
           "How many fields ahead to prefetch in oop scan (<= 0 means off)") \
                                                                             \
+  diagnostic(bool, VerifyDuringStartup, false,                              \
+          "Verify memory system before executing any Java code "            \
+          "during VM initialization")                                       \
+                                                                            \
   diagnostic(bool, VerifyBeforeExit, trueInDebug,                           \
           "Verify system before exiting")                                   \
                                                                             \
@@ -3664,8 +3668,13 @@
   product(bool, PrintGCCause, true,                                         \
           "Include GC cause in GC logging")                                 \
                                                                             \
-  product(bool, AllowNonVirtualCalls, false,                                \
-          "Obey the ACC_SUPER flag and allow invokenonvirtual calls")
+  product(bool , AllowNonVirtualCalls, false,                               \
+          "Obey the ACC_SUPER flag and allow invokenonvirtual calls")       \
+                                                                            \
+  experimental(uintx, ArrayAllocatorMallocLimit,                            \
+          SOLARIS_ONLY(64*K) NOT_SOLARIS(max_uintx),                        \
+          "Allocation less than this value will be allocated "              \
+          "using malloc. Larger allocations will use mmap.")
 
 /*
  *  Macros for factoring of globals
--- a/hotspot/src/share/vm/runtime/safepoint.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -735,6 +735,9 @@
 // Exception handlers
 
 #ifndef PRODUCT
+
+#ifdef SPARC
+
 #ifdef _LP64
 #define PTR_PAD ""
 #else
@@ -755,7 +758,6 @@
                 newptr, is_oop?"oop":"   ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":"     "));
 }
 
-#ifdef SPARC
 static void print_me(intptr_t *new_sp, intptr_t *old_sp, bool *was_oops) {
 #ifdef _LP64
   tty->print_cr("--------+------address-----+------before-----------+-------after----------+");
--- a/hotspot/src/share/vm/runtime/synchronizer.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/synchronizer.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -449,8 +449,6 @@
 // and explicit fences (barriers) to control for architectural reordering performed
 // by the CPU(s) or platform.
 
-static int  MBFence (int x) { OrderAccess::fence(); return x; }
-
 struct SharedGlobals {
     // These are highly shared mostly-read variables.
     // To avoid false-sharing they need to be the sole occupants of a $ line.
@@ -1639,11 +1637,6 @@
 
 #ifndef PRODUCT
 
-void ObjectSynchronizer::trace_locking(Handle locking_obj, bool is_compiled,
-                                       bool is_method, bool is_locking) {
-  // Don't know what to do here
-}
-
 // Verify all monitors in the monitor cache, the verification is weak.
 void ObjectSynchronizer::verify() {
   ObjectMonitor* block = gBlockList;
--- a/hotspot/src/share/vm/runtime/synchronizer.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/synchronizer.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -121,7 +121,6 @@
   static void oops_do(OopClosure* f);
 
   // debugging
-  static void trace_locking(Handle obj, bool is_compiled, bool is_method, bool is_locking) PRODUCT_RETURN;
   static void verify() PRODUCT_RETURN;
   static int  verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
 
--- a/hotspot/src/share/vm/runtime/thread.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -3446,9 +3446,9 @@
   }
 
   assert (Universe::is_fully_initialized(), "not initialized");
-  if (VerifyBeforeGC && VerifyGCStartAt == 0) {
-    Universe::heap()->prepare_for_verify();
-    Universe::verify();   // make sure we're starting with a clean slate
+  if (VerifyDuringStartup) {
+    VM_Verify verify_op(false /* silent */);   // make sure we're starting with a clean slate
+    VMThread::execute(&verify_op);
   }
 
   EXCEPTION_MARK;
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -478,6 +478,9 @@
                                                                                                                                      \
   nonstatic_field(CardGeneration,              _rs,                                           GenRemSet*)                            \
   nonstatic_field(CardGeneration,              _bts,                                          BlockOffsetSharedArray*)               \
+  nonstatic_field(CardGeneration,              _shrink_factor,                                size_t)                                \
+  nonstatic_field(CardGeneration,              _capacity_at_prologue,                         size_t)                                \
+  nonstatic_field(CardGeneration,              _used_at_prologue,                             size_t)                                \
                                                                                                                                      \
   nonstatic_field(CardTableModRefBS,           _whole_heap,                                   const MemRegion)                       \
   nonstatic_field(CardTableModRefBS,           _guard_index,                                  const size_t)                          \
@@ -548,8 +551,6 @@
   nonstatic_field(Space,                       _bottom,                                       HeapWord*)                             \
   nonstatic_field(Space,                       _end,                                          HeapWord*)                             \
                                                                                                                                      \
-  nonstatic_field(TenuredGeneration,           _shrink_factor,                                size_t)                                \
-  nonstatic_field(TenuredGeneration,           _capacity_at_prologue,                         size_t)                                \
   nonstatic_field(ThreadLocalAllocBuffer,      _start,                                        HeapWord*)                             \
   nonstatic_field(ThreadLocalAllocBuffer,      _top,                                          HeapWord*)                             \
   nonstatic_field(ThreadLocalAllocBuffer,      _end,                                          HeapWord*)                             \
--- a/hotspot/src/share/vm/runtime/vm_operations.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/vm_operations.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -175,7 +175,8 @@
 }
 
 void VM_Verify::doit() {
-  Universe::verify();
+  Universe::heap()->prepare_for_verify();
+  Universe::verify(_silent);
 }
 
 bool VM_PrintThreads::doit_prologue() {
--- a/hotspot/src/share/vm/runtime/vm_operations.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/runtime/vm_operations.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -300,9 +300,9 @@
 
 class VM_Verify: public VM_Operation {
  private:
-  KlassHandle _dependee;
+  bool _silent;
  public:
-  VM_Verify() {}
+  VM_Verify(bool silent) : _silent(silent) {}
   VMOp_Type type() const { return VMOp_Verify; }
   void doit();
 };
--- a/hotspot/src/share/vm/services/diagnosticArgument.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/services/diagnosticArgument.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/services/memTracker.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/services/memTracker.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -127,12 +127,15 @@
   assert(_state == NMT_bootstrapping_multi_thread, "wrong state");
 
   _snapshot = new (std::nothrow)MemSnapshot();
-  if (_snapshot != NULL && !_snapshot->out_of_memory()) {
-    if (start_worker()) {
+  if (_snapshot != NULL) {
+    if (!_snapshot->out_of_memory() && start_worker()) {
       _state = NMT_started;
       NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack());
       return;
     }
+
+    delete _snapshot;
+    _snapshot = NULL;
   }
 
   // fail to start native memory tracking, shut it down
@@ -544,7 +547,10 @@
   assert(_worker_thread == NULL, "Just Check");
   _worker_thread = new (std::nothrow) MemTrackWorker();
   if (_worker_thread == NULL || _worker_thread->has_error()) {
-    shutdown(NMT_initialization);
+    if (_worker_thread != NULL) {
+      delete _worker_thread;
+      _worker_thread = NULL;
+    }
     return false;
   }
   _worker_thread->start();
--- a/hotspot/src/share/vm/utilities/accessFlags.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/utilities/accessFlags.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -194,6 +194,9 @@
   void set_is_obsolete()               { atomic_set_bits(JVM_ACC_IS_OBSOLETE);             }
   void set_is_prefixed_native()        { atomic_set_bits(JVM_ACC_IS_PREFIXED_NATIVE);      }
 
+  void clear_not_c1_compilable()       { atomic_clear_bits(JVM_ACC_NOT_C1_COMPILABLE);       }
+  void clear_not_c2_compilable()       { atomic_clear_bits(JVM_ACC_NOT_C2_COMPILABLE);       }
+  void clear_not_c2_osr_compilable()   { atomic_clear_bits(JVM_ACC_NOT_C2_OSR_COMPILABLE);   }
   // Klass* flags
   void set_has_vanilla_constructor()   { atomic_set_bits(JVM_ACC_HAS_VANILLA_CONSTRUCTOR); }
   void set_has_finalizer()             { atomic_set_bits(JVM_ACC_HAS_FINALIZER);           }
--- a/hotspot/src/share/vm/utilities/bitMap.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/utilities/bitMap.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -516,6 +516,10 @@
   return sum;
 }
 
+void BitMap::print_on_error(outputStream* st, const char* prefix) const {
+  st->print_cr("%s[" PTR_FORMAT ", " PTR_FORMAT ")",
+      prefix, map(), (char*)map() + (size() >> LogBitsPerByte));
+}
 
 #ifndef PRODUCT
 
--- a/hotspot/src/share/vm/utilities/bitMap.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/utilities/bitMap.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -262,6 +262,7 @@
   bool is_full() const;
   bool is_empty() const;
 
+  void print_on_error(outputStream* st, const char* prefix) const;
 
 #ifndef PRODUCT
  public:
--- a/hotspot/src/share/vm/utilities/debug.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/utilities/debug.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -608,18 +608,6 @@
   return  CodeCache::find_nmethod((address)addr);
 }
 
-static address same_page(address x, address y) {
-  intptr_t page_bits = -os::vm_page_size();
-  if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits)) {
-    return x;
-  } else if (x > y) {
-    return (address)(intptr_t(y) | ~page_bits) + 1;
-  } else {
-    return (address)(intptr_t(y) & page_bits);
-  }
-}
-
-
 // Another interface that isn't ambiguous in dbx.
 // Can we someday rename the other find to hsfind?
 extern "C" void hsfind(intptr_t x) {
--- a/hotspot/src/share/vm/utilities/globalDefinitions.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -355,3 +355,33 @@
 
     return size_t(result);
 }
+
+#ifndef PRODUCT
+
+void GlobalDefinitions::test_globals() {
+  intptr_t page_sizes[] = { os::vm_page_size(), 4096, 8192, 65536, 2*1024*1024 };
+  const int num_page_sizes = sizeof(page_sizes) / sizeof(page_sizes[0]);
+
+  for (int i = 0; i < num_page_sizes; i++) {
+    intptr_t page_size = page_sizes[i];
+
+    address a_page = (address)(10*page_size);
+
+    // Check that address within page is returned as is
+    assert(clamp_address_in_page(a_page, a_page, page_size) == a_page, "incorrect");
+    assert(clamp_address_in_page(a_page + 128, a_page, page_size) == a_page + 128, "incorrect");
+    assert(clamp_address_in_page(a_page + page_size - 1, a_page, page_size) == a_page + page_size - 1, "incorrect");
+
+    // Check that address above page returns start of next page
+    assert(clamp_address_in_page(a_page + page_size, a_page, page_size) == a_page + page_size, "incorrect");
+    assert(clamp_address_in_page(a_page + page_size + 1, a_page, page_size) == a_page + page_size, "incorrect");
+    assert(clamp_address_in_page(a_page + page_size*5 + 1, a_page, page_size) == a_page + page_size, "incorrect");
+
+    // Check that address below page returns start of page
+    assert(clamp_address_in_page(a_page - 1, a_page, page_size) == a_page, "incorrect");
+    assert(clamp_address_in_page(a_page - 2*page_size - 1, a_page, page_size) == a_page, "incorrect");
+    assert(clamp_address_in_page(a_page - 5*page_size - 1, a_page, page_size) == a_page, "incorrect");
+  }
+}
+
+#endif // PRODUCT
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -419,6 +419,24 @@
   return align_size_up(offset, HeapWordsPerLong);
 }
 
+// Clamp an address to be within a specific page
+// 1. If addr is on the page it is returned as is
+// 2. If addr is above the page_address the start of the *next* page will be returned
+// 3. Otherwise, if addr is below the page_address the start of the page will be returned
+inline address clamp_address_in_page(address addr, address page_address, intptr_t page_size) {
+  if (align_size_down(intptr_t(addr), page_size) == align_size_down(intptr_t(page_address), page_size)) {
+    // address is in the specified page, just return it as is
+    return addr;
+  } else if (addr > page_address) {
+    // address is above specified page, return start of next page
+    return (address)align_size_down(intptr_t(page_address), page_size) + page_size;
+  } else {
+    // address is below specified page, return start of page
+    return (address)align_size_down(intptr_t(page_address), page_size);
+  }
+}
+
+
 // The expected size in bytes of a cache line, used to pad data structures.
 #define DEFAULT_CACHE_LINE_SIZE 64
 
@@ -827,6 +845,10 @@
   return comp_level == CompLevel_highest_tier;
 }
 
+inline bool is_compile(int comp_level) {
+  return is_c1_compile(comp_level) || is_c2_compile(comp_level);
+}
+
 //----------------------------------------------------------------------------------------------------
 // 'Forward' declarations of frequently used classes
 // (in order to reduce interface dependencies & reduce
@@ -1296,4 +1318,15 @@
   return *(void**)addr;
 }
 
+
+#ifndef PRODUCT
+
+// For unit testing only
+class GlobalDefinitions {
+public:
+  static void test_globals();
+};
+
+#endif // PRODUCT
+
 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
--- a/hotspot/src/share/vm/utilities/taskqueue.hpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/utilities/taskqueue.hpp	Wed Jul 05 18:50:02 2017 +0200
@@ -253,6 +253,7 @@
 
 template <class E, MEMFLAGS F, unsigned int N = TASKQUEUE_SIZE>
 class GenericTaskQueue: public TaskQueueSuper<N, F> {
+  ArrayAllocator<E, F> _array_allocator;
 protected:
   typedef typename TaskQueueSuper<N, F>::Age Age;
   typedef typename TaskQueueSuper<N, F>::idx_t idx_t;
@@ -314,7 +315,7 @@
 
 template<class E, MEMFLAGS F, unsigned int N>
 void GenericTaskQueue<E, F, N>::initialize() {
-  _elems = NEW_C_HEAP_ARRAY(E, N, F);
+  _elems = _array_allocator.allocate(N);
 }
 
 template<class E, MEMFLAGS F, unsigned int N>
--- a/hotspot/src/share/vm/utilities/vmError.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/src/share/vm/utilities/vmError.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -685,13 +685,7 @@
   STEP(190, "(printing heap information)" )
 
      if (_verbose && Universe::is_fully_initialized()) {
-       // Print heap information before vm abort. As we'd like as much
-       // information as possible in the report we ask for the
-       // extended (i.e., more detailed) version.
-       Universe::print_on(st, true /* extended */);
-       st->cr();
-
-       Universe::heap()->barrier_set()->print_on(st);
+       Universe::heap()->print_on_error(st);
        st->cr();
 
        st->print_cr("Polling page: " INTPTR_FORMAT, os::get_polling_page());
--- a/hotspot/test/compiler/6863420/Test.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/compiler/6863420/Test.java	Wed Jul 05 18:50:02 2017 +0200
@@ -27,17 +27,35 @@
  * @bug 6863420
  * @summary os::javaTimeNanos() go backward on Solaris x86
  *
- * @run main/othervm Test
+ * Notice the internal timeout in timeout thread Test.TOT.
+ * @run main/othervm/timeout=300 Test
  */
 
 public class Test {
+
+    static final int INTERNAL_TIMEOUT=240;
+    static class TOT extends Thread {
+       public void run() {
+           try {
+               Thread.sleep(INTERNAL_TIMEOUT*1000);
+           } catch (InterruptedException ex) {
+           }
+           done = true;
+       }
+    }
+
     static long value = 0;
     static boolean got_backward_time = false;
+    static volatile boolean done = false;
 
     public static void main(String args[]) {
         final int count = 100000;
 
-        for (int numThreads = 1; numThreads <= 32; numThreads++) {
+        TOT tot = new TOT();
+        tot.setDaemon(true);
+        tot.start();
+
+        for (int numThreads = 1; !done && numThreads <= 32; numThreads++) {
             final int numRuns = 1;
             for (int t=1; t <= numRuns; t++) {
                 final int curRun = t;
@@ -48,7 +66,7 @@
                     Runnable thread =
                         new Runnable() {
                             public void run() {
-                                for (long l = 0; l < 100000; l++) {
+                                for (long l = 0; !done && l < 100000; l++) {
                                     final long start = System.nanoTime();
                                     if (value == 12345678) {
                                         System.out.println("Wow!");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/8011706/Test8011706.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact 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 8011706
+ * @summary loop invariant code motion may move load before store to the same field
+ * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation Test8011706
+ *
+ */
+
+public class Test8011706 {
+    int[] array;
+
+    void m(boolean test, int[] array1, int[] array2) {
+        int i = 0;
+        if (test) {
+            array = array1;
+        } else {
+            array = array2;
+        }
+
+        while(true) {
+            int v = array[i];
+            i++;
+            if (i >= 10) return;
+        }
+    }
+
+    static public void main(String[] args) {
+        int[] new_array = new int[10];
+        Test8011706 ti = new Test8011706();
+        boolean failed = false;
+        try {
+            for (int i = 0; i < 10000; i++) {
+                ti.array = null;
+                ti.m(true, new_array, new_array);
+            }
+        } catch(NullPointerException ex) {
+            throw new RuntimeException("TEST FAILED", ex);
+        }
+        System.out.println("TEST PASSED");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test ClearMethodStateTest
+ * @library /testlibrary /testlibrary/whitebox
+ * @build ClearMethodStateTest
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ClearMethodStateTest
+ * @author igor.ignatyev@oracle.com
+ */
+public class ClearMethodStateTest extends CompilerWhiteBoxTest {
+    public static void main(String[] args) throws Exception {
+        // to prevent inlining #method into #compile() and #test()
+        WHITE_BOX.testSetDontInlineMethod(METHOD, true);
+        new ClearMethodStateTest().runTest();
+    }
+
+    protected void test() throws Exception {
+        checkNotCompiled(METHOD);
+        compile();
+        checkCompiled(METHOD);
+        WHITE_BOX.clearMethodState(METHOD);
+        WHITE_BOX.deoptimizeMethod(METHOD);
+        checkNotCompiled(METHOD);
+
+
+        if (!TIERED_COMPILATION) {
+            WHITE_BOX.clearMethodState(METHOD);
+            compile(COMPILE_THRESHOLD);
+            checkCompiled(METHOD);
+
+            WHITE_BOX.deoptimizeMethod(METHOD);
+            checkNotCompiled(METHOD);
+            WHITE_BOX.clearMethodState(METHOD);
+
+            if (COMPILE_THRESHOLD > 1) {
+                compile(COMPILE_THRESHOLD - 1);
+                checkNotCompiled(METHOD);
+            } else {
+               System.err.println("Warning: 'CompileThreshold' <= 1");
+            }
+
+            method();
+            checkCompiled(METHOD);
+        } else {
+            System.err.println(
+                    "Warning: part of test is not applicable in Tiered");
+        }
+    }
+}
--- a/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -37,6 +37,8 @@
             = Integer.parseInt(getVMOption("CompileThreshold", "10000"));
     protected static final boolean BACKGROUND_COMPILATION
             = Boolean.valueOf(getVMOption("BackgroundCompilation", "true"));
+    protected static final boolean TIERED_COMPILATION
+            = Boolean.valueOf(getVMOption("TieredCompilation", "false"));
 
     protected static Method getMethod(String name) {
         try {
@@ -81,6 +83,9 @@
     }
 
     protected static void checkNotCompiled(Method method) {
+        if (WHITE_BOX.isMethodQueuedForCompilation(method)) {
+            throw new RuntimeException(method + " must not be in queue");
+        }
         if (WHITE_BOX.isMethodCompiled(method)) {
             throw new RuntimeException(method + " must be not compiled");
         }
@@ -139,8 +144,11 @@
     protected abstract void test() throws Exception;
 
     protected final int compile() {
+        return compile(Math.max(COMPILE_THRESHOLD, 150000));
+    }
+
+    protected final int compile(int count) {
         int result = 0;
-        int count = Math.max(COMPILE_THRESHOLD, 150000);
         for (int i = 0; i < count; ++i) {
             result += method();
         }
--- a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -33,7 +33,7 @@
 
     public static void main(String[] args) throws Exception {
         // to prevent inlining #method into #compile()
-        WHITE_BOX.setDontInlineMethod(METHOD, true);
+        WHITE_BOX.testSetDontInlineMethod(METHOD, true);
         new DeoptimizeAllTest().runTest();
     }
 
--- a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -33,7 +33,7 @@
 
     public static void main(String[] args) throws Exception {
         // to prevent inlining #method into #compile()
-        WHITE_BOX.setDontInlineMethod(METHOD, true);
+        WHITE_BOX.testSetDontInlineMethod(METHOD, true);
         new DeoptimizeMethodTest().runTest();
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test EnqueueMethodForCompilationTest
+ * @library /testlibrary /testlibrary/whitebox
+ * @build EnqueueMethodForCompilationTest
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI EnqueueMethodForCompilationTest
+ * @author igor.ignatyev@oracle.com
+ */
+public class EnqueueMethodForCompilationTest extends CompilerWhiteBoxTest {
+    public static void main(String[] args) throws Exception {
+        // to prevent inlining #method into #compile()
+        WHITE_BOX.testSetDontInlineMethod(METHOD, true);
+        new EnqueueMethodForCompilationTest().runTest();
+    }
+
+    protected void test() throws Exception {
+        checkNotCompiled(METHOD);
+
+        WHITE_BOX.enqueueMethodForCompilation(METHOD, 0);
+        if (WHITE_BOX.isMethodCompilable(METHOD, 0)) {
+          throw new RuntimeException(METHOD + " is compilable at level 0");
+        }
+        checkNotCompiled(METHOD);
+
+        WHITE_BOX.enqueueMethodForCompilation(METHOD, -1);
+        checkNotCompiled(METHOD);
+
+        WHITE_BOX.enqueueMethodForCompilation(METHOD, 5);
+        if (!WHITE_BOX.isMethodCompilable(METHOD, 5)) {
+          checkNotCompiled(METHOD);
+          compile();
+          checkCompiled(METHOD);
+        } else {
+          checkCompiled(METHOD);
+        }
+
+        int compLevel = WHITE_BOX.getMethodCompilationLevel(METHOD);
+        WHITE_BOX.deoptimizeMethod(METHOD);
+        checkNotCompiled(METHOD);
+
+        WHITE_BOX.enqueueMethodForCompilation(METHOD, compLevel);
+        checkCompiled(METHOD);
+        WHITE_BOX.deoptimizeMethod(METHOD);
+        checkNotCompiled(METHOD);
+
+        compile();
+        checkCompiled(METHOD);
+        WHITE_BOX.deoptimizeMethod(METHOD);
+        checkNotCompiled(METHOD);
+    }
+}
--- a/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -45,7 +45,7 @@
 
     public static void main(String[] args) throws Exception {
         // to prevent inlining #method into #compile()
-        WHITE_BOX.setDontInlineMethod(METHOD, true);
+        WHITE_BOX.testSetDontInlineMethod(METHOD, true);
         new IsMethodCompilableTest().runTest();
     }
 
@@ -60,26 +60,47 @@
                     "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf");
             return;
         }
-        boolean madeNotCompilable = false;
+
+        // deoptimze 'PerMethodRecompilationCutoff' times and clear state
+        for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) {
+            compileAndDeoptimaze();
+        }
+        if (!WHITE_BOX.isMethodCompilable(METHOD)) {
+            throw new RuntimeException(METHOD + " is not compilable after "
+                    + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations");
+        }
+        WHITE_BOX.clearMethodState(METHOD);
 
-        for (long i = 0; i < PER_METHOD_RECOMPILATION_CUTOFF; ++i) {
-            compile();
-            waitBackgroundCompilation(METHOD);
-            WHITE_BOX.deoptimizeMethod(METHOD);
-            if (!WHITE_BOX.isMethodCompilable(METHOD)) {
-                madeNotCompilable = true;
-                break;
-            }
+        // deoptimze 'PerMethodRecompilationCutoff' + 1 times
+        long i;
+        for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF
+                && WHITE_BOX.isMethodCompilable(METHOD); ++i) {
+            compileAndDeoptimaze();
         }
-        if (!madeNotCompilable) {
+        if (i != PER_METHOD_RECOMPILATION_CUTOFF) {
+           throw new RuntimeException(METHOD + " is not compilable after "
+                   + i + " iterations, but must only after "
+                   + PER_METHOD_RECOMPILATION_CUTOFF);
+        }
+        if (WHITE_BOX.isMethodCompilable(METHOD)) {
             throw new RuntimeException(METHOD + " is still compilable after "
                     + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
         }
         compile();
-        if (WHITE_BOX.isMethodCompiled(METHOD)) {
-            printInfo(METHOD);
-            throw new RuntimeException(
-                    METHOD + " is not compilable but compiled");
+        checkNotCompiled(METHOD);
+
+        WHITE_BOX.clearMethodState(METHOD);
+        if (!WHITE_BOX.isMethodCompilable(METHOD)) {
+            throw new RuntimeException(METHOD
+                    + " is compilable after clearMethodState()");
         }
+        compile();
+        checkCompiled(METHOD);
+    }
+
+    private void compileAndDeoptimaze() throws Exception {
+        compile();
+        waitBackgroundCompilation(METHOD);
+        WHITE_BOX.deoptimizeMethod(METHOD);
     }
 }
--- a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -33,7 +33,7 @@
 
     public static void main(String[] args) throws Exception {
         // to prevent inlining #method into #compile()
-        WHITE_BOX.setDontInlineMethod(METHOD, true);
+        WHITE_BOX.testSetDontInlineMethod(METHOD, true);
         new MakeMethodNotCompilableTest().runTest();
     }
 
@@ -46,9 +46,6 @@
             throw new RuntimeException(METHOD + " must be not compilable");
         }
         compile();
-        if (WHITE_BOX.isMethodQueuedForCompilation(METHOD)) {
-            throw new RuntimeException(METHOD + " must not be in queue");
-        }
         checkNotCompiled(METHOD);
         if (WHITE_BOX.isMethodCompilable(METHOD)) {
             throw new RuntimeException(METHOD + " must be not compilable");
--- a/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -36,23 +36,23 @@
     }
 
     protected void test() throws Exception {
-        if (WHITE_BOX.setDontInlineMethod(METHOD, true)) {
+        if (WHITE_BOX.testSetDontInlineMethod(METHOD, true)) {
             throw new RuntimeException("on start " + METHOD
                     + " must be inlineable");
         }
-        if (!WHITE_BOX.setDontInlineMethod(METHOD, true)) {
+        if (!WHITE_BOX.testSetDontInlineMethod(METHOD, true)) {
             throw new RuntimeException("after first change to true " + METHOD
                     + " must be not inlineable");
         }
-        if (!WHITE_BOX.setDontInlineMethod(METHOD, false)) {
+        if (!WHITE_BOX.testSetDontInlineMethod(METHOD, false)) {
             throw new RuntimeException("after second change to true " + METHOD
                     + " must be still not inlineable");
         }
-        if (WHITE_BOX.setDontInlineMethod(METHOD, false)) {
+        if (WHITE_BOX.testSetDontInlineMethod(METHOD, false)) {
             throw new RuntimeException("after first change to false" + METHOD
                     + " must be inlineable");
         }
-        if (WHITE_BOX.setDontInlineMethod(METHOD, false)) {
+        if (WHITE_BOX.testSetDontInlineMethod(METHOD, false)) {
             throw new RuntimeException("after second change to false " + METHOD
                     + " must be inlineable");
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test SetForceInlineMethodTest
+ * @library /testlibrary /testlibrary/whitebox
+ * @build SetForceInlineMethodTest
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SetForceInlineMethodTest
+ * @author igor.ignatyev@oracle.com
+ */
+public class SetForceInlineMethodTest extends CompilerWhiteBoxTest {
+
+    public static void main(String[] args) throws Exception {
+        new SetForceInlineMethodTest().runTest();
+    }
+
+    protected void test() throws Exception {
+        if (WHITE_BOX.testSetForceInlineMethod(METHOD, true)) {
+            throw new RuntimeException("on start " + METHOD
+                    + " must be not force inlineable");
+        }
+        if (!WHITE_BOX.testSetForceInlineMethod(METHOD, true)) {
+            throw new RuntimeException("after first change to true " + METHOD
+                    + " must be force inlineable");
+        }
+        if (!WHITE_BOX.testSetForceInlineMethod(METHOD, false)) {
+            throw new RuntimeException("after second change to true " + METHOD
+                    + " must be still force inlineable");
+        }
+        if (WHITE_BOX.testSetForceInlineMethod(METHOD, false)) {
+            throw new RuntimeException("after first change to false" + METHOD
+                    + " must be not force inlineable");
+        }
+        if (WHITE_BOX.testSetForceInlineMethod(METHOD, false)) {
+            throw new RuntimeException("after second change to false " + METHOD
+                    + " must be not force inlineable");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/6941923/Test6941923.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,121 @@
+/*
+ * 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 Test6941923.java
+ * @bug 6941923
+ * @summary test flags for gc log rotation
+ * @library /testlibrary
+ * @run main/othervm/timeout=600 Test6941923
+ *
+ */
+import com.oracle.java.testlibrary.*;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+class GCLoggingGenerator {
+
+    public static void main(String[] args) throws Exception {
+
+        long sizeOfLog = Long.parseLong(args[0]);
+        long lines = sizeOfLog / 80;
+        // full.GC generates ad least 1-line which is not shorter then 80 chars
+        // for some GC 2 shorter lines are generated
+        for (long i = 0; i < lines; i++) {
+            System.gc();
+        }
+    }
+}
+
+public class Test6941923 {
+
+    static final File currentDirectory = new File(".");
+    static final String logFileName = "test.log";
+    static final int logFileSizeK = 16;
+    static FilenameFilter logFilter = new FilenameFilter() {
+        @Override
+        public boolean accept(File dir, String name) {
+            return name.startsWith(logFileName);
+        }
+    };
+
+    public static void cleanLogs() {
+        for (File log : currentDirectory.listFiles(logFilter)) {
+            if (!log.delete()) {
+                throw new Error("Unable to delete " + log.getAbsolutePath());
+            }
+        }
+    }
+
+    public static void runTest(int numberOfFiles) throws Exception {
+
+        ArrayList<String> args = new ArrayList();
+        String[] logOpts = new String[]{
+            "-cp", System.getProperty("java.class.path"),
+            "-Xloggc:" + logFileName,
+            "-XX:-DisableExplicitGC", // to sure that System.gc() works
+            "-XX:+PrintGC", "-XX:+PrintGCDetails", "-XX:+UseGCLogFileRotation",
+            "-XX:NumberOfGCLogFiles=" + numberOfFiles,
+            "-XX:GCLogFileSize=" + logFileSizeK + "K", "-Xmx128M"};
+        // System.getProperty("test.java.opts") is '' if no options is set
+        // need to skip such empty
+        String[] externalVMopts = System.getProperty("test.java.opts").length() == 0
+                ? new String[0]
+                : System.getProperty("test.java.opts").split(" ");
+        args.addAll(Arrays.asList(externalVMopts));
+        args.addAll(Arrays.asList(logOpts));
+        args.add(GCLoggingGenerator.class.getName());
+        args.add(String.valueOf(numberOfFiles * logFileSizeK * 1024));
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[0]));
+        pb.redirectErrorStream(true);
+        pb.redirectOutput(new File(GCLoggingGenerator.class.getName() + ".log"));
+        Process process = pb.start();
+        int result = process.waitFor();
+        if (result != 0) {
+            throw new Error("Unexpected exit code = " + result);
+        }
+        File[] logs = currentDirectory.listFiles(logFilter);
+        int smallFilesNumber = 0;
+        for (File log : logs) {
+            if (log.length() < logFileSizeK * 1024) {
+                smallFilesNumber++;
+            }
+        }
+        if (logs.length != numberOfFiles) {
+            throw new Error("There are only " + logs.length + " logs instead " + numberOfFiles);
+        }
+        if (smallFilesNumber > 1) {
+            throw new Error("There should maximum one log with size < " + logFileSizeK + "K");
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        cleanLogs();
+        runTest(1);
+        cleanLogs();
+        runTest(3);
+        cleanLogs();
+    }
+}
--- a/hotspot/test/gc/6941923/test6941923.sh	Thu Apr 11 09:39:48 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-##
-## @test @(#)test6941923.sh
-## @bug 6941923 
-## @summary test new added flags for gc log rotation 
-## @author yqi 
-## @run shell test6941923.sh
-##
-## some tests require path to find test source dir
-if [ "${TESTSRC}" = "" ]
-then
-  TESTSRC=${PWD}
-  echo "TESTSRC not set.  Using "${TESTSRC}" as default"
-fi
-echo "TESTSRC=${TESTSRC}"
-## Adding common setup Variables for running shell tests.
-. ${TESTSRC}/../../test_env.sh
-
-## skip on windows
-OS=`uname -s`
-case "$OS" in
-  Windows_* | CYGWIN_* )
-    echo "Test skipped for Windows"
-    exit 0 
-    ;;
-esac
-
-# create a small test case
-testname="Test"
-if [ -e ${testname}.java ]; then
-  rm -rf ${testname}.*
-fi
-
-cat >> ${testname}.java << __EOF__
-import java.util.Vector;
-
-public class Test implements Runnable
-{
-  private boolean _should_stop = false;
-
-  public static void main(String[] args) throws Exception {
-
-    long limit = Long.parseLong(args[0]) * 60L * 1000L;   // minutes
-    Test t = new Test();
-    t.set_stop(false);
-    Thread thr = new Thread(t);
-    thr.start();
-
-    long time1 = System.currentTimeMillis();
-    long time2 = System.currentTimeMillis();
-    while (time2 - time1 < limit) {
-      try {
-        Thread.sleep(2000); // 2 seconds
-      }
-      catch(Exception e) {}
-      time2 = System.currentTimeMillis();
-      System.out.print("\r... " + (time2 - time1)/1000 + " seconds");
-    }
-    System.out.println();
-    t.set_stop(true);
-  }
-  public void set_stop(boolean value) { _should_stop = value; }
-  public void run() {
-    int cap = 20000;
-    int fix_size = 2048;
-    int loop = 0;
-    Vector< byte[] > v = new Vector< byte[] >(cap);
-    while(!_should_stop) {
-      byte[] g = new byte[fix_size];
-      v.add(g);
-      loop++;
-      if (loop > cap) {
-         v = null;
-         cap *= 2;
-         if (cap > 80000) cap = 80000;
-         v = new Vector< byte[] >(cap);
-      }
-    }
-  }
-}
-__EOF__
-
-msgsuccess="succeeded"
-msgfail="failed"
-gclogsize="16K"
-filesize=$((16*1024))
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${testname}.java > $NULL 2>&1
-
-if [ $? != 0 ]; then
-  echo "${COMPILEJAVA}/bin/javac ${testname}.java $fail"
-  exit -1
-fi
-
-# test for 2 minutes, it will complete circulation of gc log rotation
-tts=2
-logfile="test.log"
-hotspotlog="hotspot.log"
-
-if [ -e $logfile  ]; then
-  rm -rf $logfile
-fi
-
-#also delete $hotspotlog if it exists
-if [ -f $hotspotlog ]; then 
-  rm -rf $hotspotlog
-fi
-
-options="-Xloggc:$logfile -XX:+UseConcMarkSweepGC -XX:+PrintGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation  -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=$gclogsize"
-echo "Test gc log rotation in same file, wait for $tts minutes ...."
-${TESTJAVA}/bin/java $options $testname $tts
-if [ $? != 0 ]; then
-  echo "$msgfail"
-  exit -1
-fi
-
-# rotation file will be $logfile.0 
-if [ -f $logfile.0 ]; then
-  outfilesize=`ls -l $logfile.0 | awk '{print $5 }'`
-  if [ $((outfilesize)) -ge $((filesize)) ]; then
-    echo $msgsuccess
-  else
-    echo $msgfail
-  fi
-else 
-  echo $msgfail
-  exit -1
-fi
-
-# delete log file 
-rm -rf $logfile.0
-if [ -f $hotspotlog ]; then
-  rm -rf $hotspotlog
-fi
-
-#multiple log files
-numoffiles=3
-options="-Xloggc:$logfile -XX:+UseConcMarkSweepGC -XX:+PrintGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation  -XX:NumberOfGCLogFiles=$numoffiles -XX:GCLogFileSize=$gclogsize"
-echo "Test gc log rotation in $numoffiles files, wait for $tts minutes ...."
-${TESTJAVA}/bin/java $options $testname $tts
-if [ $? != 0 ]; then
-  echo "$msgfail"
-  exit -1
-fi
-
-atleast=0    # at least size of numoffile-1 files >= $gclogsize
-tk=0
-while [ $(($tk)) -lt $(($numoffiles)) ]
-do
-  if [ -f $logfile.$tk ]; then
-    outfilesize=`ls -l $logfile.$tk | awk '{ print $5 }'`
-    if [ $(($outfilesize)) -ge $(($filesize)) ]; then
-      atleast=$((atleast+1))
-    fi
-  fi
-  tk=$((tk+1))
-done
-
-rm -rf $logfile.*
-rm -rf $testname.*
-rm -rf $hotspotlog
-
-if [ $(($atleast)) -ge $(($numoffiles-1)) ]; then
-  echo $msgsuccess
-else
-  echo $msgfail
-  exit -1
-fi
--- a/hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java	Thu Apr 11 09:39:48 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test TestVerifyBeforeGCDuringStartup.java
- * @key gc
- * @bug 8010463
- * @summary Simple test run with -XX:+VerifyBeforeGC -XX:-UseTLAB to verify 8010463
- * @library /testlibrary
- */
-
-import com.oracle.java.testlibrary.OutputAnalyzer;
-import com.oracle.java.testlibrary.ProcessTools;
-
-public class TestVerifyBeforeGCDuringStartup {
-  public static void main(String args[]) throws Exception {
-    ProcessBuilder pb =
-      ProcessTools.createJavaProcessBuilder(System.getProperty("test.vm.opts"),
-                                            "-XX:-UseTLAB",
-                                            "-XX:+UnlockDiagnosticVMOptions",
-                                            "-XX:+VerifyBeforeGC", "-version");
-    OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldContain("[Verifying");
-    output.shouldHaveExitValue(0);
-  }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/TestVerifyDuringStartup.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test TestVerifyDuringStartup.java
+ * @key gc
+ * @bug 8010463
+ * @summary Simple test run with -XX:+VerifyDuringStartup -XX:-UseTLAB to verify 8010463
+ * @library /testlibrary
+ */
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+public class TestVerifyDuringStartup {
+  public static void main(String args[]) throws Exception {
+    ProcessBuilder pb =
+      ProcessTools.createJavaProcessBuilder(System.getProperty("test.vm.opts"),
+                                            "-XX:-UseTLAB",
+                                            "-XX:+UnlockDiagnosticVMOptions",
+                                            "-XX:+VerifyDuringStartup", "-version");
+    OutputAnalyzer output = new OutputAnalyzer(pb.start());
+    output.shouldContain("[Verifying");
+    output.shouldHaveExitValue(0);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/metaspace/G1AddMetaspaceDependency.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test G1AddMetaspaceDependency
+ * @bug 8010196
+ * @summary Checks that we don't get locking problems when adding metaspace dependencies with the G1 update buffer monitor
+ * @run main/othervm -XX:+UseG1GC -XX:G1UpdateBufferSize=1 G1AddMetaspaceDependency
+ */
+
+import java.io.InputStream;
+
+public class G1AddMetaspaceDependency {
+
+  static byte[] getClassBytes(String name) {
+    byte[] b = null;
+    try (InputStream is = ClassLoader.getSystemResourceAsStream(name)) {
+      byte[] tmp = new byte[is.available()];
+      is.read(tmp);
+      b = tmp;
+    } finally {
+      if (b == null) {
+        throw new RuntimeException("Unable to load class file");
+      }
+      return b;
+    }
+  }
+
+  static final String a_name = G1AddMetaspaceDependency.class.getName() + "$A";
+  static final String b_name = G1AddMetaspaceDependency.class.getName() + "$B";
+
+  public static void main(String... args) throws Exception {
+    final byte[] a_bytes = getClassBytes(a_name + ".class");
+    final byte[] b_bytes = getClassBytes(b_name + ".class");
+
+    for (int i = 0; i < 1000; i += 1) {
+      runTest(a_bytes, b_bytes);
+    }
+  }
+
+  static class Loader extends ClassLoader {
+    private final String myClass;
+    private final byte[] myBytes;
+    private final String friendClass;
+    private final ClassLoader friendLoader;
+
+    Loader(String myClass, byte[] myBytes,
+           String friendClass, ClassLoader friendLoader) {
+      this.myClass = myClass;
+      this.myBytes = myBytes;
+      this.friendClass = friendClass;
+      this.friendLoader = friendLoader;
+    }
+
+    Loader(String myClass, byte[] myBytes) {
+      this(myClass, myBytes, null, null);
+    }
+
+    @Override
+    public Class<?> loadClass(String name) throws ClassNotFoundException {
+      Class<?> c = findLoadedClass(name);
+      if (c != null) {
+        return c;
+      }
+
+      if (name.equals(friendClass)) {
+        return friendLoader.loadClass(name);
+      }
+
+      if (name.equals(myClass)) {
+        c = defineClass(name, myBytes, 0, myBytes.length);
+        resolveClass(c);
+        return c;
+      }
+
+      return findSystemClass(name);
+    }
+
+  }
+
+  private static void runTest(final byte[] a_bytes, final byte[] b_bytes) throws Exception {
+    Loader a_loader = new Loader(a_name, a_bytes);
+    Loader b_loader = new Loader(b_name, b_bytes, a_name, a_loader);
+    Loader c_loader = new Loader(b_name, b_bytes, a_name, a_loader);
+    Loader d_loader = new Loader(b_name, b_bytes, a_name, a_loader);
+    Loader e_loader = new Loader(b_name, b_bytes, a_name, a_loader);
+    Loader f_loader = new Loader(b_name, b_bytes, a_name, a_loader);
+    Loader g_loader = new Loader(b_name, b_bytes, a_name, a_loader);
+
+    byte[] b = new byte[20 * 2 << 20];
+    Class<?> c;
+    c = b_loader.loadClass(b_name);
+    c = c_loader.loadClass(b_name);
+    c = d_loader.loadClass(b_name);
+    c = e_loader.loadClass(b_name);
+    c = f_loader.loadClass(b_name);
+    c = g_loader.loadClass(b_name);
+  }
+  public class A {
+  }
+  class B extends A {
+  }
+}
--- a/hotspot/test/runtime/NMT/AllocTestType.java	Thu Apr 11 09:39:48 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @summary Test consistency of NMT by leaking a few select allocations of the Test type and then verify visibility with jcmd
- * @key nmt jcmd
- * @library /testlibrary /testlibrary/whitebox
- * @build AllocTestType
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail AllocTestType
- */
-
-import com.oracle.java.testlibrary.*;
-import sun.hotspot.WhiteBox;
-
-public class AllocTestType {
-
-  public static void main(String args[]) throws Exception {
-    OutputAnalyzer output;
-
-    // Grab my own PID
-    String pid = Integer.toString(ProcessTools.getProcessId());
-    ProcessBuilder pb = new ProcessBuilder();
-
-    // Use WB API to alloc with the mtTest type
-    if (!WhiteBox.getWhiteBox().NMTAllocTest()) {
-      throw new Exception("Call to WB API NMTAllocTest() failed");
-    }
-
-    // Use WB API to ensure that all data has been merged before we continue
-    if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
-      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
-    }
-
-    // Run 'jcmd <pid> VM.native_memory summary'
-    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
-    output = new OutputAnalyzer(pb.start());
-    output.shouldContain("Test (reserved=512KB, committed=512KB)");
-
-    // Free the memory allocated by NMTAllocTest
-    if (!WhiteBox.getWhiteBox().NMTFreeTestMemory()) {
-      throw new Exception("Call to WB API NMTFreeTestMemory() failed");
-    }
-
-    // Use WB API to ensure that all data has been merged before we continue
-    if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
-      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
-    }
-    output = new OutputAnalyzer(pb.start());
-    output.shouldNotContain("Test (reserved=");
-  }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/NMT/MallocTestType.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Test consistency of NMT by leaking a few select allocations of the Test type and then verify visibility with jcmd
+ * @key nmt jcmd
+ * @library /testlibrary /testlibrary/whitebox
+ * @build MallocTestType
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTestType
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.hotspot.WhiteBox;
+
+public class MallocTestType {
+
+  public static void main(String args[]) throws Exception {
+    OutputAnalyzer output;
+    WhiteBox wb = WhiteBox.getWhiteBox();
+
+    // Grab my own PID
+    String pid = Integer.toString(ProcessTools.getProcessId());
+    ProcessBuilder pb = new ProcessBuilder();
+
+    // Use WB API to alloc and free with the mtTest type
+    long memAlloc3 = wb.NMTMalloc(128 * 1024);
+    long memAlloc2 = wb.NMTMalloc(256 * 1024);
+    wb.NMTFree(memAlloc3);
+    long memAlloc1 = wb.NMTMalloc(512 * 1024);
+    wb.NMTFree(memAlloc2);
+
+    // Use WB API to ensure that all data has been merged before we continue
+    if (!wb.NMTWaitForDataMerge()) {
+      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
+    }
+
+    // Run 'jcmd <pid> VM.native_memory summary'
+    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
+    output = new OutputAnalyzer(pb.start());
+    output.shouldContain("Test (reserved=512KB, committed=512KB)");
+
+    // Free the memory allocated by NMTAllocTest
+    wb.NMTFree(memAlloc1);
+
+    // Use WB API to ensure that all data has been merged before we continue
+    if (!wb.NMTWaitForDataMerge()) {
+      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
+    }
+    output = new OutputAnalyzer(pb.start());
+    output.shouldNotContain("Test (reserved=");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/NMT/ThreadedMallocTestType.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @key nmt jcmd
+ * @library /testlibrary /testlibrary/whitebox
+ * @build ThreadedMallocTestType
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedMallocTestType
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.hotspot.WhiteBox;
+
+public class ThreadedMallocTestType {
+  public static long memAlloc1;
+  public static long memAlloc2;
+  public static long memAlloc3;
+
+  public static void main(String args[]) throws Exception {
+    OutputAnalyzer output;
+    final WhiteBox wb = WhiteBox.getWhiteBox();
+
+    // Grab my own PID
+    String pid = Integer.toString(ProcessTools.getProcessId());
+    ProcessBuilder pb = new ProcessBuilder();
+
+    Thread allocThread = new Thread() {
+      public void run() {
+        // Alloc memory using the WB api
+        memAlloc1 = wb.NMTMalloc(128 * 1024);
+        memAlloc2 = wb.NMTMalloc(256 * 1024);
+        memAlloc3 = wb.NMTMalloc(512 * 1024);
+      }
+    };
+
+    allocThread.start();
+    allocThread.join();
+
+    // Use WB API to ensure that all data has been merged before we continue
+    if (!wb.NMTWaitForDataMerge()) {
+      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
+    }
+
+    // Run 'jcmd <pid> VM.native_memory summary'
+    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
+    output = new OutputAnalyzer(pb.start());
+    output.shouldContain("Test (reserved=896KB, committed=896KB)");
+
+    Thread freeThread = new Thread() {
+      public void run() {
+        // Free the memory allocated by NMTMalloc
+        wb.NMTFree(memAlloc1);
+        wb.NMTFree(memAlloc2);
+        wb.NMTFree(memAlloc3);
+      }
+    };
+
+    freeThread.start();
+    freeThread.join();
+
+    // Use WB API to ensure that all data has been merged before we continue
+    if (!wb.NMTWaitForDataMerge()) {
+      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
+    }
+
+    output = new OutputAnalyzer(pb.start());
+    output.shouldNotContain("Test (reserved=");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @key nmt jcmd
+ * @library /testlibrary /testlibrary/whitebox
+ * @build ThreadedVirtualAllocTestType
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedVirtualAllocTestType
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.hotspot.WhiteBox;
+
+public class ThreadedVirtualAllocTestType {
+  public static long addr;
+  public static final WhiteBox wb = WhiteBox.getWhiteBox();
+  public static final long commitSize = 128 * 1024;
+  public static final long reserveSize = 512 * 1024;
+
+  public static void main(String args[]) throws Exception {
+    OutputAnalyzer output;
+
+    String pid = Integer.toString(ProcessTools.getProcessId());
+    ProcessBuilder pb = new ProcessBuilder();
+
+    Thread reserveThread = new Thread() {
+      public void run() {
+        addr = wb.NMTReserveMemory(reserveSize);
+      }
+    };
+    reserveThread.start();
+    reserveThread.join();
+
+    mergeData();
+
+    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"});
+    output = new OutputAnalyzer(pb.start());
+    output.shouldContain("Test (reserved=512KB, committed=0KB)");
+    output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 512KB for Test");
+
+    Thread commitThread = new Thread() {
+      public void run() {
+        wb.NMTCommitMemory(addr, commitSize);
+      }
+    };
+    commitThread.start();
+    commitThread.join();
+
+    mergeData();
+
+    output = new OutputAnalyzer(pb.start());
+    output.shouldContain("Test (reserved=512KB, committed=128KB)");
+    output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB");
+
+    Thread uncommitThread = new Thread() {
+      public void run() {
+        wb.NMTUncommitMemory(addr, commitSize);
+      }
+    };
+    uncommitThread.start();
+    uncommitThread.join();
+
+    mergeData();
+
+    output = new OutputAnalyzer(pb.start());
+    output.shouldContain("Test (reserved=512KB, committed=0KB)");
+    output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed");
+
+    Thread releaseThread = new Thread() {
+      public void run() {
+        wb.NMTReleaseMemory(addr, reserveSize);
+      }
+    };
+    releaseThread.start();
+    releaseThread.join();
+
+    mergeData();
+
+    output = new OutputAnalyzer(pb.start());
+    output.shouldNotContain("Test (reserved=");
+    output.shouldNotContain("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved");
+  }
+
+  public static void mergeData() throws Exception {
+    // Use WB API to ensure that all data has been merged before we continue
+    if (!wb.NMTWaitForDataMerge()) {
+      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/NMT/VirtualAllocTestType.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Test Reserve/Commit/Uncommit/Release of virtual memory and that we track it correctly
+ * @key nmt jcmd
+ * @library /testlibrary /testlibrary/whitebox
+ * @build VirtualAllocTestType
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocTestType
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.hotspot.WhiteBox;
+
+public class VirtualAllocTestType {
+
+  public static WhiteBox wb = WhiteBox.getWhiteBox();
+  public static void main(String args[]) throws Exception {
+    OutputAnalyzer output;
+    long commitSize = 128 * 1024;
+    long reserveSize = 256 * 1024;
+    long addr;
+
+    String pid = Integer.toString(ProcessTools.getProcessId());
+    ProcessBuilder pb = new ProcessBuilder();
+
+    addr = wb.NMTReserveMemory(reserveSize);
+    mergeData();
+
+    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"});
+    output = new OutputAnalyzer(pb.start());
+    output.shouldContain("Test (reserved=256KB, committed=0KB)");
+    output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 256KB for Test");
+
+    wb.NMTCommitMemory(addr, commitSize);
+
+    mergeData();
+
+    output = new OutputAnalyzer(pb.start());
+    output.shouldContain("Test (reserved=256KB, committed=128KB)");
+    output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB");
+
+    wb.NMTUncommitMemory(addr, commitSize);
+
+    mergeData();
+
+    output = new OutputAnalyzer(pb.start());
+    output.shouldContain("Test (reserved=256KB, committed=0KB)");
+    output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed");
+
+    wb.NMTReleaseMemory(addr, reserveSize);
+
+    mergeData();
+
+    output = new OutputAnalyzer(pb.start());
+    output.shouldNotContain("Test (reserved=");
+    output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved");
+  }
+
+  public static void mergeData() throws Exception {
+    // Use WB API to ensure that all data has been merged before we continue
+    if (!wb.NMTWaitForDataMerge()) {
+      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
+    }
+  }
+}
--- a/hotspot/test/sanity/WBApi.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/sanity/WBApi.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/hotspot/test/serviceability/ParserTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/serviceability/ParserTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/hotspot/test/testlibrary/OutputAnalyzerTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/testlibrary/OutputAnalyzerTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -36,6 +36,11 @@
     String stdout = "aaaaaa";
     String stderr = "bbbbbb";
 
+    // Regexps used for testing pattern matching of the test input
+    String stdoutPattern = "[a]";
+    String stderrPattern = "[b]";
+    String nonExistingPattern = "[c]";
+
     OutputAnalyzer output = new OutputAnalyzer(stdout, stderr);
 
     if (!stdout.equals(output.getStdout())) {
@@ -99,10 +104,73 @@
     }
 
     try {
-      output.stderrShouldNotContain(stderr);
-      throw new Exception("shouldContain() failed to throw exception");
+        output.stderrShouldNotContain(stderr);
+        throw new Exception("shouldContain() failed to throw exception");
+    } catch (RuntimeException e) {
+        // expected
+    }
+
+    // Should match
+    try {
+        output.shouldMatch(stdoutPattern);
+        output.stdoutShouldMatch(stdoutPattern);
+        output.shouldMatch(stderrPattern);
+        output.stderrShouldMatch(stderrPattern);
+    } catch (RuntimeException e) {
+        throw new Exception("shouldMatch() failed", e);
+    }
+
+    try {
+        output.shouldMatch(nonExistingPattern);
+        throw new Exception("shouldMatch() failed to throw exception");
+    } catch (RuntimeException e) {
+        // expected
+    }
+
+    try {
+        output.stdoutShouldMatch(stderrPattern);
+        throw new Exception(
+                "stdoutShouldMatch() failed to throw exception");
     } catch (RuntimeException e) {
-      // expected
+        // expected
+    }
+
+    try {
+        output.stderrShouldMatch(stdoutPattern);
+        throw new Exception(
+                "stderrShouldMatch() failed to throw exception");
+    } catch (RuntimeException e) {
+        // expected
+    }
+
+    // Should not match
+    try {
+        output.shouldNotMatch(nonExistingPattern);
+        output.stdoutShouldNotMatch(nonExistingPattern);
+        output.stderrShouldNotMatch(nonExistingPattern);
+    } catch (RuntimeException e) {
+        throw new Exception("shouldNotMatch() failed", e);
+    }
+
+    try {
+        output.shouldNotMatch(stdoutPattern);
+        throw new Exception("shouldNotMatch() failed to throw exception");
+    } catch (RuntimeException e) {
+        // expected
+    }
+
+    try {
+        output.stdoutShouldNotMatch(stdoutPattern);
+        throw new Exception("shouldNotMatch() failed to throw exception");
+    } catch (RuntimeException e) {
+        // expected
+    }
+
+    try {
+        output.stderrShouldNotMatch(stderrPattern);
+        throw new Exception("shouldNotMatch() failed to throw exception");
+    } catch (RuntimeException e) {
+        // expected
     }
   }
 }
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -24,6 +24,8 @@
 package com.oracle.java.testlibrary;
 
 import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public final class OutputAnalyzer {
 
@@ -142,15 +144,112 @@
   }
 
   /**
+   * Verify that the stdout and stderr contents of output buffer matches
+   * the pattern
+   *
+   * @param pattern
+   * @throws RuntimeException If the pattern was not found
+   */
+  public void shouldMatch(String pattern) {
+      Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
+      Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
+      if (!stdoutMatcher.find() && !stderrMatcher.find()) {
+          throw new RuntimeException("'" + pattern
+                  + "' missing from stdout/stderr: [" + stdout + stderr
+                  + "]\n");
+      }
+  }
+
+  /**
+   * Verify that the stdout contents of output buffer matches the
+   * pattern
+   *
+   * @param pattern
+   * @throws RuntimeException If the pattern was not found
+   */
+  public void stdoutShouldMatch(String pattern) {
+      Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
+      if (!matcher.find()) {
+          throw new RuntimeException("'" + pattern
+                  + "' missing from stdout: [" + stdout + "]\n");
+      }
+  }
+
+  /**
+   * Verify that the stderr contents of output buffer matches the
+   * pattern
+   *
+   * @param pattern
+   * @throws RuntimeException If the pattern was not found
+   */
+  public void stderrShouldMatch(String pattern) {
+      Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
+      if (!matcher.find()) {
+          throw new RuntimeException("'" + pattern
+                  + "' missing from stderr: [" + stderr + "]\n");
+      }
+  }
+
+  /**
+   * Verify that the stdout and stderr contents of output buffer does not
+   * match the pattern
+   *
+   * @param pattern
+   * @throws RuntimeException If the pattern was found
+   */
+  public void shouldNotMatch(String pattern) {
+      Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
+      if (matcher.find()) {
+          throw new RuntimeException("'" + pattern
+                  + "' found in stdout: [" + stdout + "]\n");
+      }
+      matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
+      if (matcher.find()) {
+          throw new RuntimeException("'" + pattern
+                  + "' found in stderr: [" + stderr + "]\n");
+      }
+  }
+
+  /**
+   * Verify that the stdout contents of output buffer does not match the
+   * pattern
+   *
+   * @param pattern
+   * @throws RuntimeException If the pattern was found
+   */
+  public void stdoutShouldNotMatch(String pattern) {
+      Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
+      if (matcher.find()) {
+          throw new RuntimeException("'" + pattern
+                  + "' found in stdout: [" + stdout + "]\n");
+      }
+  }
+
+  /**
+   * Verify that the stderr contents of output buffer does not match the
+   * pattern
+   *
+   * @param pattern
+   * @throws RuntimeException If the pattern was found
+   */
+  public void stderrShouldNotMatch(String pattern) {
+      Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
+      if (matcher.find()) {
+          throw new RuntimeException("'" + pattern
+                  + "' found in stderr: [" + stderr + "]\n");
+      }
+  }
+
+  /**
    * Verifiy the exit value of the process
    *
    * @param expectedExitValue Expected exit value from process
    * @throws RuntimeException If the exit value from the process did not match the expected value
    */
   public void shouldHaveExitValue(int expectedExitValue) {
-    if (getExitValue() != expectedExitValue) {
-      throw new RuntimeException("Exit value " + getExitValue() + " , expected to get " + expectedExitValue);
-    }
+      if (getExitValue() != expectedExitValue) {
+          throw new RuntimeException("Exit value " + getExitValue() + " , expected to get " + expectedExitValue);
+      }
   }
 
   /**
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -80,20 +80,30 @@
   public native Object[]    parseCommandLine(String commandline, DiagnosticCommand[] args);
 
   // NMT
-  public native boolean NMTAllocTest();
-  public native boolean NMTFreeTestMemory();
+  public native long NMTMalloc(long size);
+  public native void NMTFree(long mem);
+  public native long NMTReserveMemory(long size);
+  public native void NMTCommitMemory(long addr, long size);
+  public native void NMTUncommitMemory(long addr, long size);
+  public native void NMTReleaseMemory(long addr, long size);
   public native boolean NMTWaitForDataMerge();
 
   // Compiler
   public native void    deoptimizeAll();
   public native boolean isMethodCompiled(Method method);
-  public native boolean isMethodCompilable(Method method);
+  public boolean isMethodCompilable(Method method) {
+      return isMethodCompilable(method, -1 /*any*/);
+  }
+  public native boolean isMethodCompilable(Method method, int compLevel);
   public native boolean isMethodQueuedForCompilation(Method method);
   public native int     deoptimizeMethod(Method method);
   public native void    makeMethodNotCompilable(Method method);
   public native int     getMethodCompilationLevel(Method method);
-  public native boolean setDontInlineMethod(Method method, boolean value);
+  public native boolean testSetDontInlineMethod(Method method, boolean value);
   public native int     getCompileQueuesSize();
+  public native boolean testSetForceInlineMethod(Method method, boolean value);
+  public native boolean enqueueMethodForCompilation(Method method, int compLevel);
+  public native void    clearMethodState(Method method);
 
   //Intered strings
   public native boolean isInStringTable(String str);
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/parser/DiagnosticCommand.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/hotspot/test/testlibrary/whitebox/sun/hotspot/parser/DiagnosticCommand.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/.hgtags	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/.hgtags	Wed Jul 05 18:50:02 2017 +0200
@@ -206,3 +206,4 @@
 624bcb4800065c6656171948e31ebb2925f25c7a jdk8-b82
 ac519af51769e92c51b597a730974e8607357709 jdk8-b83
 7b4721e4edb4e1c65e9c839a70d7cc67f81c7632 jdk8-b84
+296676d534c52888c36e305a2bf7f345c4ca70f8 jdk8-b85
--- a/jdk/make/java/java/FILES_java.gmk	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/make/java/java/FILES_java.gmk	Wed Jul 05 18:50:02 2017 +0200
@@ -316,6 +316,8 @@
     java/util/concurrent/BrokenBarrierException.java \
     java/util/concurrent/Callable.java \
     java/util/concurrent/CancellationException.java \
+    java/util/concurrent/CompletableFuture.java \
+    java/util/concurrent/CompletionException.java \
     java/util/concurrent/CompletionService.java \
     java/util/concurrent/ConcurrentHashMap.java \
     java/util/concurrent/ConcurrentLinkedDeque.java \
--- a/jdk/src/macosx/classes/apple/laf/JRSUIConstants.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/apple/laf/JRSUIConstants.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,27 +28,25 @@
 import java.lang.reflect.Field;
 import java.nio.ByteBuffer;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 public final class JRSUIConstants {
     private static native long getPtrForConstant(final int constant);
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     static class Key {
-        protected static final int _value = 20;
+        @Native protected static final int _value = 20;
         public static final Key VALUE = new Key(_value);
 
-        protected static final int _thumbProportion = 24;
+        @Native protected static final int _thumbProportion = 24;
         public static final Key THUMB_PROPORTION = new Key(_thumbProportion);
 
-        protected static final int _thumbStart = 25;
+        @Native protected static final int _thumbStart = 25;
         public static final Key THUMB_START = new Key(_thumbStart);
 
-        protected static final int _windowTitleBarHeight = 28;
+        @Native protected static final int _windowTitleBarHeight = 28;
         public static final Key WINDOW_TITLE_BAR_HEIGHT = new Key(_windowTitleBarHeight);
 
-        protected static final int _animationFrame = 23;
+        @Native protected static final int _animationFrame = 23;
         public static final Key ANIMATION_FRAME = new Key(_animationFrame);
 
         final int constant;
@@ -70,10 +68,8 @@
         }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     static class DoubleValue {
-        protected static final byte TYPE_CODE = 1;
+        @Native protected static final byte TYPE_CODE = 1;
 
         final double doubleValue;
 
@@ -139,684 +135,634 @@
         }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class Size extends Property {
-        private static final byte SHIFT = 0;
-        private static final byte SIZE = 3;
-        private static final long MASK = (long)0x7 << SHIFT;
+        @Native private static final byte SHIFT = 0;
+        @Native private static final byte SIZE = 3;
+        @Native private static final long MASK = (long)0x7 << SHIFT;
         private static final PropertyEncoding size = new PropertyEncoding(MASK, SHIFT);
 
         Size(final byte value) {
             super(size, value);
         }
 
-        private static final byte _mini = 1;
+        @Native private static final byte _mini = 1;
         public static final Size MINI = new Size(_mini);
-        private static final byte _small = 2;
+        @Native private static final byte _small = 2;
         public static final Size SMALL = new Size(_small);
-        private static final byte _regular = 3;
+        @Native private static final byte _regular = 3;
         public static final Size REGULAR = new Size(_regular);
-        private static final byte _large = 4;
+        @Native private static final byte _large = 4;
         public static final Size LARGE = new Size(_large);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class State extends Property {
-        private static final byte SHIFT = Size.SHIFT + Size.SIZE;
-        private static final byte SIZE = 4;
-        private static final long MASK = (long)0xF << SHIFT;
+        @Native private static final byte SHIFT = Size.SHIFT + Size.SIZE;
+        @Native private static final byte SIZE = 4;
+        @Native private static final long MASK = (long)0xF << SHIFT;
         private static final PropertyEncoding state = new PropertyEncoding(MASK, SHIFT);
 
         State(final byte value) {
             super(state, value);
         }
 
-        private static final byte _active = 1;
+        @Native private static final byte _active = 1;
         public static final State ACTIVE = new State(_active);
-        private static final byte _inactive = 2;
+        @Native private static final byte _inactive = 2;
         public static final State INACTIVE = new State(_inactive);
-        private static final byte _disabled = 3;
+        @Native private static final byte _disabled = 3;
         public static final State DISABLED = new State(_disabled);
-        private static final byte _pressed = 4;
+        @Native private static final byte _pressed = 4;
         public static final State PRESSED = new State(_pressed);
-        private static final byte _pulsed = 5;
+        @Native private static final byte _pulsed = 5;
         public static final State PULSED = new State(_pulsed);
-        private static final byte _rollover = 6;
+        @Native private static final byte _rollover = 6;
         public static final State ROLLOVER = new State(_rollover);
-        private static final byte _drag = 7;
+        @Native private static final byte _drag = 7;
         public static final State DRAG = new State(_drag);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class Direction extends Property {
-        private static final byte SHIFT = State.SHIFT + State.SIZE;
-        private static final byte SIZE = 4;
-        private static final long MASK = (long)0xF << SHIFT;
+        @Native private static final byte SHIFT = State.SHIFT + State.SIZE;
+        @Native private static final byte SIZE = 4;
+        @Native private static final long MASK = (long)0xF << SHIFT;
         private static final PropertyEncoding direction = new PropertyEncoding(MASK, SHIFT);
 
         Direction(final byte value) {
             super(direction, value);
         }
 
-        private static final byte _none = 1;
+        @Native private static final byte _none = 1;
         public static final Direction NONE = new Direction(_none);
-        private static final byte _up = 2;
+        @Native private static final byte _up = 2;
         public static final Direction UP = new Direction(_up);
-        private static final byte _down = 3;
+        @Native private static final byte _down = 3;
         public static final Direction DOWN = new Direction(_down);
-        private static final byte _left = 4;
+        @Native private static final byte _left = 4;
         public static final Direction LEFT = new Direction(_left);
-        private static final byte _right = 5;
+        @Native private static final byte _right = 5;
         public static final Direction RIGHT = new Direction(_right);
-        private static final byte _north = 6;
+        @Native private static final byte _north = 6;
         public static final Direction NORTH = new Direction(_north);
-        private static final byte _south = 7;
+        @Native private static final byte _south = 7;
         public static final Direction SOUTH = new Direction(_south);
-        private static final byte _east = 8;
+        @Native private static final byte _east = 8;
         public static final Direction EAST = new Direction(_east);
-        private static final byte _west = 9;
+        @Native private static final byte _west = 9;
         public static final Direction WEST = new Direction(_west);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class Orientation extends Property {
-        private static final byte SHIFT = Direction.SHIFT + Direction.SIZE;
-        private static final byte SIZE = 2;
-        private static final long MASK = (long)0x3 << SHIFT;
+        @Native private static final byte SHIFT = Direction.SHIFT + Direction.SIZE;
+        @Native private static final byte SIZE = 2;
+        @Native private static final long MASK = (long)0x3 << SHIFT;
         private static final PropertyEncoding orientation = new PropertyEncoding(MASK, SHIFT);
 
         Orientation(final byte value) {
             super(orientation, value);
         }
 
-        private static final byte _horizontal = 1;
+        @Native private static final byte _horizontal = 1;
         public static final Orientation HORIZONTAL = new Orientation(_horizontal);
-        private static final byte _vertical = 2;
+        @Native private static final byte _vertical = 2;
         public static final Orientation VERTICAL = new Orientation(_vertical);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class AlignmentVertical extends Property {
-        private static final byte SHIFT = Orientation.SHIFT + Orientation.SIZE;
-        private static final byte SIZE = 2;
-        private static final long MASK = (long)0x3 << SHIFT;
+        @Native private static final byte SHIFT = Orientation.SHIFT + Orientation.SIZE;
+        @Native private static final byte SIZE = 2;
+        @Native private static final long MASK = (long)0x3 << SHIFT;
         private static final PropertyEncoding alignmentVertical = new PropertyEncoding(MASK, SHIFT);
 
         AlignmentVertical(final byte value){
             super(alignmentVertical, value);
         }
 
-        private static final byte _top = 1;
+        @Native private static final byte _top = 1;
         public static final AlignmentVertical TOP = new AlignmentVertical(_top);
-        private static final byte _center = 2;
+        @Native private static final byte _center = 2;
         public static final AlignmentVertical CENTER = new AlignmentVertical(_center);
-        private static final byte _bottom = 3;
+        @Native private static final byte _bottom = 3;
         public static final AlignmentVertical BOTTOM = new AlignmentVertical(_bottom);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class AlignmentHorizontal extends Property {
-        private static final byte SHIFT = AlignmentVertical.SHIFT + AlignmentVertical.SIZE;
-        private static final byte SIZE = 2;
-        private static final long MASK = (long)0x3 << SHIFT;
+        @Native private static final byte SHIFT = AlignmentVertical.SHIFT + AlignmentVertical.SIZE;
+        @Native private static final byte SIZE = 2;
+        @Native private static final long MASK = (long)0x3 << SHIFT;
         private static final PropertyEncoding alignmentHorizontal = new PropertyEncoding(MASK, SHIFT);
 
         AlignmentHorizontal(final byte value){
             super(alignmentHorizontal, value);
         }
 
-        private static final byte _left = 1;
+        @Native private static final byte _left = 1;
         public static final AlignmentHorizontal LEFT = new AlignmentHorizontal(_left);
-        private static final byte _center =  2;
+        @Native private static final byte _center =  2;
         public static final AlignmentHorizontal CENTER = new AlignmentHorizontal(_center);
-        private static final byte _right = 3;
+        @Native private static final byte _right = 3;
         public static final AlignmentHorizontal RIGHT = new AlignmentHorizontal(_right);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class SegmentPosition extends Property {
-        private static final byte SHIFT = AlignmentHorizontal.SHIFT + AlignmentHorizontal.SIZE;
-        private static final byte SIZE = 3;
-        private static final long MASK = (long)0x7 << SHIFT;
+        @Native private static final byte SHIFT = AlignmentHorizontal.SHIFT + AlignmentHorizontal.SIZE;
+        @Native private static final byte SIZE = 3;
+        @Native private static final long MASK = (long)0x7 << SHIFT;
         private static final PropertyEncoding segmentPosition = new PropertyEncoding(MASK, SHIFT);
 
         SegmentPosition(final byte value) {
             super(segmentPosition, value);
         }
 
-        private static final byte _first = 1;
+        @Native private static final byte _first = 1;
         public static final SegmentPosition FIRST = new SegmentPosition(_first);
-        private static final byte _middle = 2;
+        @Native private static final byte _middle = 2;
         public static final SegmentPosition MIDDLE = new SegmentPosition(_middle);
-        private static final byte _last = 3;
+        @Native private static final byte _last = 3;
         public static final SegmentPosition LAST = new SegmentPosition(_last);
-        private static final byte _only = 4;
+        @Native private static final byte _only = 4;
         public static final SegmentPosition ONLY = new SegmentPosition(_only);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class ScrollBarPart extends Property {
-        private static final byte SHIFT = SegmentPosition.SHIFT + SegmentPosition.SIZE;
-        private static final byte SIZE = 4;
-        private static final long MASK = (long)0xF << SHIFT;
+        @Native private static final byte SHIFT = SegmentPosition.SHIFT + SegmentPosition.SIZE;
+        @Native private static final byte SIZE = 4;
+        @Native private static final long MASK = (long)0xF << SHIFT;
         private static final PropertyEncoding scrollBarPart = new PropertyEncoding(MASK, SHIFT);
 
         ScrollBarPart(final byte value) {
             super(scrollBarPart, value);
         }
 
-        private static final byte _none = 1;
+        @Native private static final byte _none = 1;
         public static final ScrollBarPart NONE = new ScrollBarPart(_none);
-        private static final byte _thumb = 2;
+        @Native private static final byte _thumb = 2;
         public static final ScrollBarPart THUMB = new ScrollBarPart(_thumb);
-        private static final byte _arrowMin = 3;
+        @Native private static final byte _arrowMin = 3;
         public static final ScrollBarPart ARROW_MIN = new ScrollBarPart(_arrowMin);
-        private static final byte _arrowMax = 4;
+        @Native private static final byte _arrowMax = 4;
         public static final ScrollBarPart ARROW_MAX = new ScrollBarPart(_arrowMax);
-        private static final byte _arrowMaxInside = 5;
+        @Native private static final byte _arrowMaxInside = 5;
         public static final ScrollBarPart ARROW_MAX_INSIDE = new ScrollBarPart(_arrowMaxInside);
-        private static final byte _arrowMinInside = 6;
+        @Native private static final byte _arrowMinInside = 6;
         public static final ScrollBarPart ARROW_MIN_INSIDE = new ScrollBarPart(_arrowMinInside);
-        private static final byte _trackMin = 7;
+        @Native private static final byte _trackMin = 7;
         public static final ScrollBarPart TRACK_MIN = new ScrollBarPart(_trackMin);
-        private static final byte _trackMax = 8;
+        @Native private static final byte _trackMax = 8;
         public static final ScrollBarPart TRACK_MAX = new ScrollBarPart(_trackMax);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class Variant extends Property {
-        private static final byte SHIFT = ScrollBarPart.SHIFT + ScrollBarPart.SIZE;
-        private static final byte SIZE = 4;
-        private static final long MASK = (long)0xF << SHIFT;
+        @Native private static final byte SHIFT = ScrollBarPart.SHIFT + ScrollBarPart.SIZE;
+        @Native private static final byte SIZE = 4;
+        @Native private static final long MASK = (long)0xF << SHIFT;
         private static final PropertyEncoding variant = new PropertyEncoding(MASK, SHIFT);
 
         Variant(final byte value) {
             super(variant, value);
         }
 
-        private static final byte _menuGlyph = 1;
+        @Native private static final byte _menuGlyph = 1;
         public static final Variant MENU_GLYPH = new Variant(_menuGlyph);
-        private static final byte _menuPopup = Variant._menuGlyph + 1;
+        @Native private static final byte _menuPopup = Variant._menuGlyph + 1;
         public static final Variant MENU_POPUP = new Variant(_menuPopup);
-        private static final byte _menuPulldown = Variant._menuPopup + 1;
+        @Native private static final byte _menuPulldown = Variant._menuPopup + 1;
         public static final Variant MENU_PULLDOWN = new Variant(_menuPulldown);
-        private static final byte _menuHierarchical = Variant._menuPulldown + 1;
+        @Native private static final byte _menuHierarchical = Variant._menuPulldown + 1;
         public static final Variant MENU_HIERARCHICAL = new Variant(_menuHierarchical);
 
-        private static final byte _gradientListBackgroundEven = Variant._menuHierarchical + 1;
+        @Native private static final byte _gradientListBackgroundEven = Variant._menuHierarchical + 1;
         public static final Variant GRADIENT_LIST_BACKGROUND_EVEN = new Variant(_gradientListBackgroundEven);
-        private static final byte _gradientListBackgroundOdd = Variant._gradientListBackgroundEven + 1;
+        @Native private static final byte _gradientListBackgroundOdd = Variant._gradientListBackgroundEven + 1;
         public static final Variant GRADIENT_LIST_BACKGROUND_ODD = new Variant(_gradientListBackgroundOdd);
-        private static final byte _gradientSideBar = Variant._gradientListBackgroundOdd + 1;
+        @Native private static final byte _gradientSideBar = Variant._gradientListBackgroundOdd + 1;
         public static final Variant GRADIENT_SIDE_BAR = new Variant(_gradientSideBar);
-        private static final byte _gradientSideBarSelection = Variant._gradientSideBar + 1;
+        @Native private static final byte _gradientSideBarSelection = Variant._gradientSideBar + 1;
         public static final Variant GRADIENT_SIDE_BAR_SELECTION = new Variant(_gradientSideBarSelection);
-        private static final byte _gradientSideBarFocusedSelection = Variant._gradientSideBarSelection + 1;
+        @Native private static final byte _gradientSideBarFocusedSelection = Variant._gradientSideBarSelection + 1;
         public static final Variant GRADIENT_SIDE_BAR_FOCUSED_SELECTION = new Variant(_gradientSideBarFocusedSelection);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class WindowType extends Property {
-        private static final byte SHIFT = Variant.SHIFT + Variant.SIZE;
-        private static final byte SIZE = 2;
-        private static final long MASK = (long)0x3 << SHIFT;
+        @Native private static final byte SHIFT = Variant.SHIFT + Variant.SIZE;
+        @Native private static final byte SIZE = 2;
+        @Native private static final long MASK = (long)0x3 << SHIFT;
         private static final PropertyEncoding windowType = new PropertyEncoding(MASK, SHIFT);
 
         WindowType(final byte value){
             super(windowType, value);
         }
 
-        private static final byte _document = 1;
+        @Native private static final byte _document = 1;
         public static final WindowType DOCUMENT = new WindowType(_document);
-        private static final byte _utility = 2;
+        @Native private static final byte _utility = 2;
         public static final WindowType UTILITY = new WindowType(_utility);
-        private static final byte _titlelessUtility = 3;
+        @Native private static final byte _titlelessUtility = 3;
         public static final WindowType TITLELESS_UTILITY = new WindowType(_titlelessUtility);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class Focused extends Property {
-        private static final byte SHIFT = WindowType.SHIFT + WindowType.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = WindowType.SHIFT + WindowType.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
 
         Focused(final byte value) {
             super(focused, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final Focused NO = new Focused(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final Focused YES = new Focused(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class IndicatorOnly extends Property {
-        private static final byte SHIFT = Focused.SHIFT + Focused.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = Focused.SHIFT + Focused.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding indicatorOnly = new PropertyEncoding(MASK, SHIFT);
 
         IndicatorOnly(final byte value) {
             super(indicatorOnly, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final IndicatorOnly NO = new IndicatorOnly(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final IndicatorOnly YES = new IndicatorOnly(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class NoIndicator extends Property {
-        private static final byte SHIFT = IndicatorOnly.SHIFT + IndicatorOnly.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = IndicatorOnly.SHIFT + IndicatorOnly.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding noIndicator = new PropertyEncoding(MASK, SHIFT);
 
         NoIndicator(final byte value) {
             super(noIndicator, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final NoIndicator NO = new NoIndicator(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final NoIndicator YES = new NoIndicator(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class ArrowsOnly extends Property {
-        private static final byte SHIFT = NoIndicator.SHIFT + NoIndicator.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = NoIndicator.SHIFT + NoIndicator.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
 
         ArrowsOnly(final byte value) {
             super(focused, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final ArrowsOnly NO = new ArrowsOnly(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final ArrowsOnly YES = new ArrowsOnly(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class FrameOnly extends Property {
-        private static final byte SHIFT = ArrowsOnly.SHIFT + ArrowsOnly.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = ArrowsOnly.SHIFT + ArrowsOnly.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
 
         FrameOnly(final byte value) {
             super(focused, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final FrameOnly NO = new FrameOnly(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final FrameOnly YES = new FrameOnly(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class SegmentTrailingSeparator extends Property {
-        private static final byte SHIFT = FrameOnly.SHIFT + FrameOnly.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = FrameOnly.SHIFT + FrameOnly.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
 
         SegmentTrailingSeparator(final byte value) {
             super(focused, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final SegmentTrailingSeparator NO = new SegmentTrailingSeparator(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final SegmentTrailingSeparator YES = new SegmentTrailingSeparator(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class SegmentLeadingSeparator extends Property {
-        private static final byte SHIFT = SegmentTrailingSeparator.SHIFT + SegmentTrailingSeparator.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = SegmentTrailingSeparator.SHIFT + SegmentTrailingSeparator.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding leadingSeparator = new PropertyEncoding(MASK, SHIFT);
 
         SegmentLeadingSeparator(final byte value) {
             super(leadingSeparator, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final SegmentLeadingSeparator NO = new SegmentLeadingSeparator(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final SegmentLeadingSeparator YES = new SegmentLeadingSeparator(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class NothingToScroll extends Property {
-        private static final byte SHIFT = SegmentLeadingSeparator.SHIFT + SegmentLeadingSeparator.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = SegmentLeadingSeparator.SHIFT + SegmentLeadingSeparator.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
 
         NothingToScroll(final byte value) {
             super(focused, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final NothingToScroll NO = new NothingToScroll(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final NothingToScroll YES = new NothingToScroll(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class WindowTitleBarSeparator extends Property {
-        private static final byte SHIFT = NothingToScroll.SHIFT + NothingToScroll.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = NothingToScroll.SHIFT + NothingToScroll.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
 
         WindowTitleBarSeparator(final byte value) {
             super(focused, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final WindowTitleBarSeparator NO = new WindowTitleBarSeparator(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final WindowTitleBarSeparator YES = new WindowTitleBarSeparator(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class WindowClipCorners extends Property {
-        private static final byte SHIFT = WindowTitleBarSeparator.SHIFT + WindowTitleBarSeparator.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = WindowTitleBarSeparator.SHIFT + WindowTitleBarSeparator.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
 
         WindowClipCorners(final byte value) {
             super(focused, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final WindowClipCorners NO = new WindowClipCorners(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final WindowClipCorners YES = new WindowClipCorners(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class ShowArrows extends Property {
-        private static final byte SHIFT = WindowClipCorners.SHIFT + WindowClipCorners.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = WindowClipCorners.SHIFT + WindowClipCorners.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding showArrows = new PropertyEncoding(MASK, SHIFT);
 
         ShowArrows(final byte value) {
             super(showArrows, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final ShowArrows NO = new ShowArrows(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final ShowArrows YES = new ShowArrows(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class BooleanValue extends Property {
-        private static final byte SHIFT = ShowArrows.SHIFT + ShowArrows.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = ShowArrows.SHIFT + ShowArrows.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding booleanValue = new PropertyEncoding(MASK, SHIFT);
 
         BooleanValue(final byte value) {
             super(booleanValue, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final BooleanValue NO = new BooleanValue(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final BooleanValue YES = new BooleanValue(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class Animating extends Property {
-        private static final byte SHIFT = BooleanValue.SHIFT + BooleanValue.SIZE;
-        private static final byte SIZE = 1;
-        private static final long MASK = (long)0x1 << SHIFT;
+        @Native private static final byte SHIFT = BooleanValue.SHIFT + BooleanValue.SIZE;
+        @Native private static final byte SIZE = 1;
+        @Native private static final long MASK = (long)0x1 << SHIFT;
         private static final PropertyEncoding animating = new PropertyEncoding(MASK, SHIFT);
 
         Animating(final byte value) {
             super(animating, value);
         }
 
-        private static final byte _no = 0;
+        @Native private static final byte _no = 0;
         public static final Animating NO = new Animating(_no);
-        private static final byte _yes = 1;
+        @Native private static final byte _yes = 1;
         public static final Animating YES = new Animating(_yes);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class Widget extends Property {
-        private static final byte SHIFT = Animating.SHIFT + Animating.SIZE;
-        private static final byte SIZE = 7;
-        private static final long MASK = (long)0x7F << SHIFT;
+        @Native private static final byte SHIFT = Animating.SHIFT + Animating.SIZE;
+        @Native private static final byte SIZE = 7;
+        @Native private static final long MASK = (long)0x7F << SHIFT;
         private static final PropertyEncoding widget = new PropertyEncoding(MASK, SHIFT);
 
         Widget(final byte constant) {
             super(widget, constant);
         }
 
-        private static final byte _background = 1;
+        @Native private static final byte _background = 1;
         public static final Widget BACKGROUND = new Widget(_background);
 
-        private static final byte _buttonBevel = _background + 1;
+        @Native private static final byte _buttonBevel = _background + 1;
         public static final Widget BUTTON_BEVEL = new Widget(_buttonBevel);
-        private static final byte _buttonBevelInset = _buttonBevel + 1;
+        @Native private static final byte _buttonBevelInset = _buttonBevel + 1;
         public static final Widget BUTTON_BEVEL_INSET = new Widget(_buttonBevelInset);
-        private static final byte _buttonBevelRound = _buttonBevelInset + 1;
+        @Native private static final byte _buttonBevelRound = _buttonBevelInset + 1;
         public static final Widget BUTTON_BEVEL_ROUND = new Widget(_buttonBevelRound);
 
-        private static final byte _buttonCheckBox = _buttonBevelRound + 1;
+        @Native private static final byte _buttonCheckBox = _buttonBevelRound + 1;
         public static final Widget BUTTON_CHECK_BOX = new Widget(_buttonCheckBox);
 
-        private static final byte _buttonComboBox = _buttonCheckBox + 1;
+        @Native private static final byte _buttonComboBox = _buttonCheckBox + 1;
         public static final Widget BUTTON_COMBO_BOX = new Widget(_buttonComboBox);
-        private static final byte _buttonComboBoxInset = _buttonComboBox + 1;
+        @Native private static final byte _buttonComboBoxInset = _buttonComboBox + 1;
         public static final Widget BUTTON_COMBO_BOX_INSET = new Widget(_buttonComboBoxInset); // not hooked up in JRSUIConstants.m
 
-        private static final byte _buttonDisclosure = _buttonComboBoxInset + 1;
+        @Native private static final byte _buttonDisclosure = _buttonComboBoxInset + 1;
         public static final Widget BUTTON_DISCLOSURE = new Widget(_buttonDisclosure);
 
-        private static final byte _buttonListHeader = _buttonDisclosure + 1;
+        @Native private static final byte _buttonListHeader = _buttonDisclosure + 1;
         public static final Widget BUTTON_LIST_HEADER = new Widget(_buttonListHeader);
 
-        private static final byte _buttonLittleArrows = _buttonListHeader + 1;
+        @Native private static final byte _buttonLittleArrows = _buttonListHeader + 1;
         public static final Widget BUTTON_LITTLE_ARROWS = new Widget(_buttonLittleArrows);
 
-        private static final byte _buttonPopDown = _buttonLittleArrows + 1;
+        @Native private static final byte _buttonPopDown = _buttonLittleArrows + 1;
         public static final Widget BUTTON_POP_DOWN = new Widget(_buttonPopDown);
-        private static final byte _buttonPopDownInset = _buttonPopDown + 1;
+        @Native private static final byte _buttonPopDownInset = _buttonPopDown + 1;
         public static final Widget BUTTON_POP_DOWN_INSET = new Widget(_buttonPopDownInset);
-        private static final byte _buttonPopDownSquare = _buttonPopDownInset + 1;
+        @Native private static final byte _buttonPopDownSquare = _buttonPopDownInset + 1;
         public static final Widget BUTTON_POP_DOWN_SQUARE = new Widget(_buttonPopDownSquare);
 
-        private static final byte _buttonPopUp = _buttonPopDownSquare + 1;
+        @Native private static final byte _buttonPopUp = _buttonPopDownSquare + 1;
         public static final Widget BUTTON_POP_UP = new Widget(_buttonPopUp);
-        private static final byte _buttonPopUpInset = _buttonPopUp + 1;
+        @Native private static final byte _buttonPopUpInset = _buttonPopUp + 1;
         public static final Widget BUTTON_POP_UP_INSET = new Widget(_buttonPopUpInset);
-        private static final byte _buttonPopUpSquare = _buttonPopUpInset + 1;
+        @Native private static final byte _buttonPopUpSquare = _buttonPopUpInset + 1;
         public static final Widget BUTTON_POP_UP_SQUARE = new Widget(_buttonPopUpSquare);
 
-        private static final byte _buttonPush = _buttonPopUpSquare + 1;
+        @Native private static final byte _buttonPush = _buttonPopUpSquare + 1;
         public static final Widget BUTTON_PUSH = new Widget(_buttonPush);
-        private static final byte _buttonPushScope = _buttonPush + 1;
+        @Native private static final byte _buttonPushScope = _buttonPush + 1;
         public static final Widget BUTTON_PUSH_SCOPE = new Widget(_buttonPushScope);
-        private static final byte _buttonPushScope2 = _buttonPushScope + 1;
+        @Native private static final byte _buttonPushScope2 = _buttonPushScope + 1;
         public static final Widget BUTTON_PUSH_SCOPE2 = new Widget(_buttonPushScope2);
-        private static final byte _buttonPushTextured = _buttonPushScope2 + 1;
+        @Native private static final byte _buttonPushTextured = _buttonPushScope2 + 1;
         public static final Widget BUTTON_PUSH_TEXTURED = new Widget(_buttonPushTextured);
-        private static final byte _buttonPushInset = _buttonPushTextured + 1;
+        @Native private static final byte _buttonPushInset = _buttonPushTextured + 1;
         public static final Widget BUTTON_PUSH_INSET = new Widget(_buttonPushInset);
-        private static final byte _buttonPushInset2 = _buttonPushInset + 1;
+        @Native private static final byte _buttonPushInset2 = _buttonPushInset + 1;
         public static final Widget BUTTON_PUSH_INSET2 = new Widget(_buttonPushInset2);
 
-        private static final byte _buttonRadio = _buttonPushInset2 + 1;
+        @Native private static final byte _buttonRadio = _buttonPushInset2 + 1;
         public static final Widget BUTTON_RADIO = new Widget(_buttonRadio);
 
-        private static final byte _buttonRound = _buttonRadio + 1;
+        @Native private static final byte _buttonRound = _buttonRadio + 1;
         public static final Widget BUTTON_ROUND = new Widget(_buttonRound);
-        private static final byte _buttonRoundHelp = _buttonRound + 1;
+        @Native private static final byte _buttonRoundHelp = _buttonRound + 1;
         public static final Widget BUTTON_ROUND_HELP = new Widget(_buttonRoundHelp);
-        private static final byte _buttonRoundInset = _buttonRoundHelp + 1;
+        @Native private static final byte _buttonRoundInset = _buttonRoundHelp + 1;
         public static final Widget BUTTON_ROUND_INSET = new Widget(_buttonRoundInset);
-        private static final byte _buttonRoundInset2 =_buttonRoundInset + 1;
+        @Native private static final byte _buttonRoundInset2 =_buttonRoundInset + 1;
         public static final Widget BUTTON_ROUND_INSET2 = new Widget(_buttonRoundInset2);
 
-        private static final byte _buttonSearchFieldCancel = _buttonRoundInset2 + 1;
+        @Native private static final byte _buttonSearchFieldCancel = _buttonRoundInset2 + 1;
         public static final Widget BUTTON_SEARCH_FIELD_CANCEL = new Widget(_buttonSearchFieldCancel);
-        private static final byte _buttonSearchFieldFind = _buttonSearchFieldCancel + 1;
+        @Native private static final byte _buttonSearchFieldFind = _buttonSearchFieldCancel + 1;
         public static final Widget BUTTON_SEARCH_FIELD_FIND = new Widget(_buttonSearchFieldFind);
 
-        private static final byte _buttonSegmented = _buttonSearchFieldFind + 1;
+        @Native private static final byte _buttonSegmented = _buttonSearchFieldFind + 1;
         public static final Widget BUTTON_SEGMENTED = new Widget(_buttonSegmented);
-        private static final byte _buttonSegmentedInset = _buttonSegmented + 1;
+        @Native private static final byte _buttonSegmentedInset = _buttonSegmented + 1;
         public static final Widget BUTTON_SEGMENTED_INSET = new Widget(_buttonSegmentedInset);
-        private static final byte _buttonSegmentedInset2 = _buttonSegmentedInset + 1;
+        @Native private static final byte _buttonSegmentedInset2 = _buttonSegmentedInset + 1;
         public static final Widget BUTTON_SEGMENTED_INSET2 = new Widget(_buttonSegmentedInset2);
-        private static final byte _buttonSegmentedSCurve = _buttonSegmentedInset2 + 1;
+        @Native private static final byte _buttonSegmentedSCurve = _buttonSegmentedInset2 + 1;
         public static final Widget BUTTON_SEGMENTED_SCURVE = new Widget(_buttonSegmentedSCurve);
-        private static final byte _buttonSegmentedTextured = _buttonSegmentedSCurve + 1;
+        @Native private static final byte _buttonSegmentedTextured = _buttonSegmentedSCurve + 1;
         public static final Widget BUTTON_SEGMENTED_TEXTURED = new Widget(_buttonSegmentedTextured);
-        private static final byte _buttonSegmentedToolbar = _buttonSegmentedTextured + 1;
+        @Native private static final byte _buttonSegmentedToolbar = _buttonSegmentedTextured + 1;
         public static final Widget BUTTON_SEGMENTED_TOOLBAR = new Widget(_buttonSegmentedToolbar);
 
-        private static final byte _dial = _buttonSegmentedToolbar + 1;
+        @Native private static final byte _dial = _buttonSegmentedToolbar + 1;
         public static final Widget DIAL = new Widget(_dial);
 
-        private static final byte _disclosureTriangle = _dial + 1;
+        @Native private static final byte _disclosureTriangle = _dial + 1;
         public static final Widget DISCLOSURE_TRIANGLE = new Widget(_disclosureTriangle);
 
-        private static final byte _dividerGrabber = _disclosureTriangle + 1;
+        @Native private static final byte _dividerGrabber = _disclosureTriangle + 1;
         public static final Widget DIVIDER_GRABBER = new Widget(_dividerGrabber);
-        private static final byte _dividerSeparatorBar = _dividerGrabber + 1;
+        @Native private static final byte _dividerSeparatorBar = _dividerGrabber + 1;
         public static final Widget DIVIDER_SEPARATOR_BAR = new Widget(_dividerSeparatorBar);
-        private static final byte _dividerSplitter = _dividerSeparatorBar + 1;
+        @Native private static final byte _dividerSplitter = _dividerSeparatorBar + 1;
         public static final Widget DIVIDER_SPLITTER = new Widget(_dividerSplitter);
 
-        private static final byte _focus = _dividerSplitter + 1;
+        @Native private static final byte _focus = _dividerSplitter + 1;
         public static final Widget FOCUS = new Widget(_focus);
 
-        private static final byte _frameGroupBox = _focus + 1;
+        @Native private static final byte _frameGroupBox = _focus + 1;
         public static final Widget FRAME_GROUP_BOX = new Widget(_frameGroupBox);
-        private static final byte _frameGroupBoxSecondary = _frameGroupBox + 1;
+        @Native private static final byte _frameGroupBoxSecondary = _frameGroupBox + 1;
         public static final Widget FRAME_GROUP_BOX_SECONDARY = new Widget(_frameGroupBoxSecondary);
 
-        private static final byte _frameListBox = _frameGroupBoxSecondary + 1;
+        @Native private static final byte _frameListBox = _frameGroupBoxSecondary + 1;
         public static final Widget FRAME_LIST_BOX = new Widget(_frameListBox);
 
-        private static final byte _framePlacard = _frameListBox + 1;
+        @Native private static final byte _framePlacard = _frameListBox + 1;
         public static final Widget FRAME_PLACARD = new Widget(_framePlacard);
 
-        private static final byte _frameTextField = _framePlacard + 1;
+        @Native private static final byte _frameTextField = _framePlacard + 1;
         public static final Widget FRAME_TEXT_FIELD = new Widget(_frameTextField);
-        private static final byte _frameTextFieldRound = _frameTextField + 1;
+        @Native private static final byte _frameTextFieldRound = _frameTextField + 1;
         public static final Widget FRAME_TEXT_FIELD_ROUND = new Widget(_frameTextFieldRound);
 
-        private static final byte _frameWell = _frameTextFieldRound + 1;
+        @Native private static final byte _frameWell = _frameTextFieldRound + 1;
         public static final Widget FRAME_WELL = new Widget(_frameWell);
 
-        private static final byte _growBox = _frameWell + 1;
+        @Native private static final byte _growBox = _frameWell + 1;
         public static final Widget GROW_BOX = new Widget(_growBox);
-        private static final byte _growBoxTextured = _growBox + 1;
+        @Native private static final byte _growBoxTextured = _growBox + 1;
         public static final Widget GROW_BOX_TEXTURED = new Widget(_growBoxTextured);
 
-        private static final byte _gradient = _growBoxTextured + 1;
+        @Native private static final byte _gradient = _growBoxTextured + 1;
         public static final Widget GRADIENT = new Widget(_gradient);
 
-        private static final byte _menu = _gradient + 1;
+        @Native private static final byte _menu = _gradient + 1;
         public static final Widget MENU = new Widget(_menu);
-        private static final byte _menuItem = _menu + 1;
+        @Native private static final byte _menuItem = _menu + 1;
         public static final Widget MENU_ITEM = new Widget(_menuItem);
-        private static final byte _menuBar = _menuItem + 1;
+        @Native private static final byte _menuBar = _menuItem + 1;
         public static final Widget MENU_BAR = new Widget(_menuBar);
-        private static final byte _menuTitle = _menuBar + 1;
+        @Native private static final byte _menuTitle = _menuBar + 1;
         public static final Widget MENU_TITLE = new Widget(_menuTitle);
 
-        private static final byte _progressBar = _menuTitle + 1;
+        @Native private static final byte _progressBar = _menuTitle + 1;
         public static final Widget PROGRESS_BAR = new Widget(_progressBar);
-        private static final byte _progressIndeterminateBar = _progressBar + 1;
+        @Native private static final byte _progressIndeterminateBar = _progressBar + 1;
         public static final Widget PROGRESS_INDETERMINATE_BAR = new Widget(_progressIndeterminateBar);
-        private static final byte _progressRelevance = _progressIndeterminateBar + 1;
+        @Native private static final byte _progressRelevance = _progressIndeterminateBar + 1;
         public static final Widget PROGRESS_RELEVANCE = new Widget(_progressRelevance);
-        private static final byte _progressSpinner = _progressRelevance + 1;
+        @Native private static final byte _progressSpinner = _progressRelevance + 1;
         public static final Widget PROGRESS_SPINNER = new Widget(_progressSpinner);
 
-        private static final byte _scrollBar = _progressSpinner + 1;
+        @Native private static final byte _scrollBar = _progressSpinner + 1;
         public static final Widget SCROLL_BAR = new Widget(_scrollBar);
 
-        private static final byte _scrollColumnSizer = _scrollBar + 1;
+        @Native private static final byte _scrollColumnSizer = _scrollBar + 1;
         public static final Widget SCROLL_COLUMN_SIZER = new Widget(_scrollColumnSizer);
 
-        private static final byte _slider = _scrollColumnSizer + 1;
+        @Native private static final byte _slider = _scrollColumnSizer + 1;
         public static final Widget SLIDER = new Widget(_slider);
-        private static final byte _sliderThumb = _slider + 1;
+        @Native private static final byte _sliderThumb = _slider + 1;
         public static final Widget SLIDER_THUMB = new Widget(_sliderThumb);
 
-        private static final byte _synchronization = _sliderThumb + 1;
+        @Native private static final byte _synchronization = _sliderThumb + 1;
         public static final Widget SYNCHRONIZATION = new Widget(_synchronization);
 
-        private static final byte _tab = _synchronization + 1;
+        @Native private static final byte _tab = _synchronization + 1;
         public static final Widget TAB = new Widget(_tab);
 
-        private static final byte _titleBarCloseBox = _tab + 1;
+        @Native private static final byte _titleBarCloseBox = _tab + 1;
         public static final Widget TITLE_BAR_CLOSE_BOX = new Widget(_titleBarCloseBox);
-        private static final byte _titleBarCollapseBox = _titleBarCloseBox + 1;
+        @Native private static final byte _titleBarCollapseBox = _titleBarCloseBox + 1;
         public static final Widget TITLE_BAR_COLLAPSE_BOX = new Widget(_titleBarCollapseBox);
-        private static final byte _titleBarZoomBox = _titleBarCollapseBox + 1;
+        @Native private static final byte _titleBarZoomBox = _titleBarCollapseBox + 1;
         public static final Widget TITLE_BAR_ZOOM_BOX = new Widget(_titleBarZoomBox);
 
-        private static final byte _titleBarToolbarButton = _titleBarZoomBox + 1;
+        @Native private static final byte _titleBarToolbarButton = _titleBarZoomBox + 1;
         public static final Widget TITLE_BAR_TOOLBAR_BUTTON = new Widget(_titleBarToolbarButton);
 
-        private static final byte _toolbarItemWell = _titleBarToolbarButton + 1;
+        @Native private static final byte _toolbarItemWell = _titleBarToolbarButton + 1;
         public static final Widget TOOLBAR_ITEM_WELL = new Widget(_toolbarItemWell);
 
-        private static final byte _windowFrame = _toolbarItemWell + 1;
+        @Native private static final byte _windowFrame = _toolbarItemWell + 1;
         public static final Widget WINDOW_FRAME = new Widget(_windowFrame);
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class Hit {
-        private static final int _unknown = -1;
+        @Native private static final int _unknown = -1;
         public static final Hit UNKNOWN = new Hit(_unknown);
-        private static final int _none = 0;
+        @Native private static final int _none = 0;
         public static final Hit NONE = new Hit(_none);
-        private static final int _hit = 1;
+        @Native private static final int _hit = 1;
         public static final Hit HIT = new Hit(_hit);
 
         final int hit;
@@ -831,24 +777,22 @@
         }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class ScrollBarHit extends Hit {
-        private static final int _thumb = 2;
+        @Native private static final int _thumb = 2;
         public static final ScrollBarHit THUMB = new ScrollBarHit(_thumb);
 
-        private static final int _trackMin = 3;
+        @Native private static final int _trackMin = 3;
         public static final ScrollBarHit TRACK_MIN = new ScrollBarHit(_trackMin);
-        private static final int _trackMax = 4;
+        @Native private static final int _trackMax = 4;
         public static final ScrollBarHit TRACK_MAX = new ScrollBarHit(_trackMax);
 
-        private static final int _arrowMin = 5;
+        @Native private static final int _arrowMin = 5;
         public static final ScrollBarHit ARROW_MIN = new ScrollBarHit(_arrowMin);
-        private static final int _arrowMax = 6;
+        @Native private static final int _arrowMax = 6;
         public static final ScrollBarHit ARROW_MAX = new ScrollBarHit(_arrowMax);
-        private static final int _arrowMaxInside = 7;
+        @Native private static final int _arrowMaxInside = 7;
         public static final ScrollBarHit ARROW_MAX_INSIDE = new ScrollBarHit(_arrowMaxInside);
-        private static final int _arrowMinInside = 8;
+        @Native private static final int _arrowMinInside = 8;
         public static final ScrollBarHit ARROW_MIN_INSIDE = new ScrollBarHit(_arrowMinInside);
 
         ScrollBarHit(final int hit) { super(hit); }
--- a/jdk/src/macosx/classes/com/apple/eawt/FullScreenHandler.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/com/apple/eawt/FullScreenHandler.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,17 +33,15 @@
 
 import com.apple.eawt.AppEvent.FullScreenEvent;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 final class FullScreenHandler {
     private static final String CLIENT_PROPERTY = "com.apple.eawt.event.internalFullScreenHandler";
 
-    static final int FULLSCREEN_WILL_ENTER = 1;
-    static final int FULLSCREEN_DID_ENTER = 2;
-    static final int FULLSCREEN_WILL_EXIT = 3;
-    static final int FULLSCREEN_DID_EXIT = 4;
+    @Native static final int FULLSCREEN_WILL_ENTER = 1;
+    @Native static final int FULLSCREEN_DID_ENTER = 2;
+    @Native static final int FULLSCREEN_WILL_EXIT = 3;
+    @Native static final int FULLSCREEN_DID_EXIT = 4;
 
     // installs a private instance of the handler, if necessary
     static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
--- a/jdk/src/macosx/classes/com/apple/eawt/event/GestureHandler.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/com/apple/eawt/event/GestureHandler.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,18 +31,16 @@
 
 import javax.swing.*;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 final class GestureHandler {
     private static final String CLIENT_PROPERTY = "com.apple.eawt.event.internalGestureHandler";
 
     // native constants for the supported types of high-level gestures
-    static final int PHASE = 1;
-    static final int ROTATE = 2;
-    static final int MAGNIFY = 3;
-    static final int SWIPE = 4;
+    @Native static final int PHASE = 1;
+    @Native static final int ROTATE = 2;
+    @Native static final int MAGNIFY = 3;
+    @Native static final int SWIPE = 4;
 
     // installs a private instance of GestureHandler, if necessary
     static void addGestureListenerTo(final JComponent component, final GestureListener listener) {
--- a/jdk/src/macosx/classes/sun/java2d/OSXSurfaceData.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/sun/java2d/OSXSurfaceData.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,13 +37,11 @@
 import sun.java2d.pipe.*;
 import sun.lwawt.macosx.*;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /*
  * This is the SurfaceData for a CGContextRef.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class OSXSurfaceData extends BufImgSurfaceData {
     final static float UPPER_BND = Float.MAX_VALUE / 2.0f;
     final static float LOWER_BND = -UPPER_BND;
@@ -198,147 +196,147 @@
      // graphics primitives drawing implementation:
 
     // certain primitives don't care about all the states (ex. drawing an image needs not involve setting current paint)
-    static final int kPrimitive = 0;
-    static final int kImage = 1;
-    static final int kText = 2;
-    static final int kCopyArea = 3;
-    static final int kExternal = 4;
+    @Native static final int kPrimitive = 0;
+    @Native static final int kImage = 1;
+    @Native static final int kText = 2;
+    @Native static final int kCopyArea = 3;
+    @Native static final int kExternal = 4;
 
-    static final int kLine = 5; // belongs to kPrimitive
-    static final int kRect = 6; // belongs to kPrimitive
-    static final int kRoundRect = 7; // belongs to kPrimitive
-    static final int kOval = 8; // belongs to kPrimitive
-    static final int kArc = 9; // belongs to kPrimitive
-    static final int kPolygon = 10; // belongs to kPrimitive
-    static final int kShape = 11; // belongs to kPrimitive
+    @Native static final int kLine = 5; // belongs to kPrimitive
+    @Native static final int kRect = 6; // belongs to kPrimitive
+    @Native static final int kRoundRect = 7; // belongs to kPrimitive
+    @Native static final int kOval = 8; // belongs to kPrimitive
+    @Native static final int kArc = 9; // belongs to kPrimitive
+    @Native static final int kPolygon = 10; // belongs to kPrimitive
+    @Native static final int kShape = 11; // belongs to kPrimitive
     // static final int kImage = 12; // belongs to kImage
-    static final int kString = 13; // belongs to kText
-    static final int kGlyphs = 14; // belongs to kText
-    static final int kUnicodes = 15; // belongs to kText
+    @Native static final int kString = 13; // belongs to kText
+    @Native static final int kGlyphs = 14; // belongs to kText
+    @Native static final int kUnicodes = 15; // belongs to kText
     // static final int kCopyArea = 16; // belongs to kCopyArea
     // static final int kExternal = 17; // belongs to kExternal
 
-    static final int kCommonParameterCount = 1 + 1 + 4 + 4; // type + change flags + color info (type(1) align(1) and
+    @Native static final int kCommonParameterCount = 1 + 1 + 4 + 4; // type + change flags + color info (type(1) align(1) and
                                                             // value(2)) + parameters ((x1, y1, x2, y2) OR (x, y, w, h))
-    static final int kLineParametersCount = kCommonParameterCount; // kCommonParameterCount
-    static final int kRectParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill
-    static final int kRoundRectParametersCount = kCommonParameterCount + 2 + 1; // kCommonParameterCount + arcW + arcH +
+    @Native static final int kLineParametersCount = kCommonParameterCount; // kCommonParameterCount
+    @Native static final int kRectParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill
+    @Native static final int kRoundRectParametersCount = kCommonParameterCount + 2 + 1; // kCommonParameterCount + arcW + arcH +
                                                                                 // isfill
-    static final int kOvalParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill
-    static final int kArcParametersCount = kCommonParameterCount + 2 + 1 + 1;// kCommonParameterCount + startAngle +
+    @Native static final int kOvalParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill
+    @Native static final int kArcParametersCount = kCommonParameterCount + 2 + 1 + 1;// kCommonParameterCount + startAngle +
                                                                              // arcAngle + isfill + type
-    static final int kPolygonParametersCount = 0; // not supported
-    static final int kShapeParametersCount = 0; // not supported
-    static final int kImageParametersCount = kCommonParameterCount + 2 + 2 + 4 + 4; // flip horz vert + w&h + src + dst
-    static final int kStringParametersCount = 0; // not supported
-    static final int kGlyphsParametersCount = 0; // not supported
-    static final int kUnicodesParametersCount = 0; // not supported
-    static final int kPixelParametersCount = 0; // not supported
-    static final int kExternalParametersCount = 0; // not supported
+    @Native static final int kPolygonParametersCount = 0; // not supported
+    @Native static final int kShapeParametersCount = 0; // not supported
+    @Native static final int kImageParametersCount = kCommonParameterCount + 2 + 2 + 4 + 4; // flip horz vert + w&h + src + dst
+    @Native static final int kStringParametersCount = 0; // not supported
+    @Native static final int kGlyphsParametersCount = 0; // not supported
+    @Native static final int kUnicodesParametersCount = 0; // not supported
+    @Native static final int kPixelParametersCount = 0; // not supported
+    @Native static final int kExternalParametersCount = 0; // not supported
 
     // for intParameters
     // states info
-    static final int kChangeFlagIndex = 0; // kBoundsChangedBit | .. | kFontChangedBit
+    @Native static final int kChangeFlagIndex = 0; // kBoundsChangedBit | .. | kFontChangedBit
     // bounds info
-    static final int kBoundsXIndex = 1;
-    static final int kBoundsYIndex = 2;
-    static final int kBoundsWidthIndex = 3;
-    static final int kBoundsHeightIndex = 4;
+    @Native static final int kBoundsXIndex = 1;
+    @Native static final int kBoundsYIndex = 2;
+    @Native static final int kBoundsWidthIndex = 3;
+    @Native static final int kBoundsHeightIndex = 4;
     // clip info
-    static final int kClipStateIndex = 5;
-    static final int kClipNumTypesIndex = 6;
-    static final int kClipNumCoordsIndex = 7;
-    static final int kClipWindingRuleIndex = 8;
-    static final int kClipXIndex = 9;
-    static final int kClipYIndex = 10;
-    static final int kClipWidthIndex = 11;
-    static final int kClipHeightIndex = 12;
+    @Native static final int kClipStateIndex = 5;
+    @Native static final int kClipNumTypesIndex = 6;
+    @Native static final int kClipNumCoordsIndex = 7;
+    @Native static final int kClipWindingRuleIndex = 8;
+    @Native static final int kClipXIndex = 9;
+    @Native static final int kClipYIndex = 10;
+    @Native static final int kClipWidthIndex = 11;
+    @Native static final int kClipHeightIndex = 12;
     // ctm info
-    static final int kCTMaIndex = 13;
-    static final int kCTMbIndex = 14;
-    static final int kCTMcIndex = 15;
-    static final int kCTMdIndex = 16;
-    static final int kCTMtxIndex = 17;
-    static final int kCTMtyIndex = 18;
+    @Native static final int kCTMaIndex = 13;
+    @Native static final int kCTMbIndex = 14;
+    @Native static final int kCTMcIndex = 15;
+    @Native static final int kCTMdIndex = 16;
+    @Native static final int kCTMtxIndex = 17;
+    @Native static final int kCTMtyIndex = 18;
     // color info
-    static final int kColorStateIndex = 19; // kColorSimple or kColorGradient or kColorTexture
-    static final int kColorRGBValueIndex = 20; // if kColorSimple
-    static final int kColorIndexValueIndex = 21; // if kColorSystem
-    static final int kColorPointerIndex = 22; //
-    static final int kColorPointerIndex2 = 23; //
-    static final int kColorRGBValue1Index = 24; // if kColorGradient
-    static final int kColorWidthIndex = 25; // if kColorTexture
-    static final int kColorRGBValue2Index = 26; // if kColorGradient
-    static final int kColorHeightIndex = 27; // if kColorTexture
-    static final int kColorIsCyclicIndex = 28; // if kColorGradient (kColorNonCyclic or kColorCyclic)
-    static final int kColorx1Index = 29;
-    static final int kColortxIndex = 30;
-    static final int kColory1Index = 31;
-    static final int kColortyIndex = 32;
-    static final int kColorx2Index = 33;
-    static final int kColorsxIndex = 34;
-    static final int kColory2Index = 35;
-    static final int kColorsyIndex = 36;
+    @Native static final int kColorStateIndex = 19; // kColorSimple or kColorGradient or kColorTexture
+    @Native static final int kColorRGBValueIndex = 20; // if kColorSimple
+    @Native static final int kColorIndexValueIndex = 21; // if kColorSystem
+    @Native static final int kColorPointerIndex = 22; //
+    @Native static final int kColorPointerIndex2 = 23; //
+    @Native static final int kColorRGBValue1Index = 24; // if kColorGradient
+    @Native static final int kColorWidthIndex = 25; // if kColorTexture
+    @Native static final int kColorRGBValue2Index = 26; // if kColorGradient
+    @Native static final int kColorHeightIndex = 27; // if kColorTexture
+    @Native static final int kColorIsCyclicIndex = 28; // if kColorGradient (kColorNonCyclic or kColorCyclic)
+    @Native static final int kColorx1Index = 29;
+    @Native static final int kColortxIndex = 30;
+    @Native static final int kColory1Index = 31;
+    @Native static final int kColortyIndex = 32;
+    @Native static final int kColorx2Index = 33;
+    @Native static final int kColorsxIndex = 34;
+    @Native static final int kColory2Index = 35;
+    @Native static final int kColorsyIndex = 36;
     // composite info
-    static final int kCompositeRuleIndex = 37; // kCGCompositeClear or ... or kCGCompositeXor
-    static final int kCompositeValueIndex = 38;
+    @Native static final int kCompositeRuleIndex = 37; // kCGCompositeClear or ... or kCGCompositeXor
+    @Native static final int kCompositeValueIndex = 38;
     // stroke info
-    static final int kStrokeJoinIndex = 39; // see BasicStroke.java
-    static final int kStrokeCapIndex = 40; // see BasicStroke.java
-    static final int kStrokeWidthIndex = 41;
-    static final int kStrokeDashPhaseIndex = 42;
-    static final int kStrokeLimitIndex = 43;
+    @Native static final int kStrokeJoinIndex = 39; // see BasicStroke.java
+    @Native static final int kStrokeCapIndex = 40; // see BasicStroke.java
+    @Native static final int kStrokeWidthIndex = 41;
+    @Native static final int kStrokeDashPhaseIndex = 42;
+    @Native static final int kStrokeLimitIndex = 43;
     // hints info
-    static final int kHintsAntialiasIndex = 44;
-    static final int kHintsTextAntialiasIndex = 45;
-    static final int kHintsFractionalMetricsIndex = 46;
-    static final int kHintsRenderingIndex = 47;
-    static final int kHintsInterpolationIndex = 48;
+    @Native static final int kHintsAntialiasIndex = 44;
+    @Native static final int kHintsTextAntialiasIndex = 45;
+    @Native static final int kHintsFractionalMetricsIndex = 46;
+    @Native static final int kHintsRenderingIndex = 47;
+    @Native static final int kHintsInterpolationIndex = 48;
     // live resizing info
-    static final int kCanDrawDuringLiveResizeIndex = 49;
+    @Native static final int kCanDrawDuringLiveResizeIndex = 49;
 
-    static final int kSizeOfParameters = kCanDrawDuringLiveResizeIndex + 1;
+    @Native static final int kSizeOfParameters = kCanDrawDuringLiveResizeIndex + 1;
 
     // for objectParameters
-    static final int kClipCoordinatesIndex = 0;
-    static final int kClipTypesIndex = 1;
-    static final int kTextureImageIndex = 2;
-    static final int kStrokeDashArrayIndex = 3;
-    static final int kFontIndex = 4;
-    static final int kFontPaintIndex = 5;
+    @Native static final int kClipCoordinatesIndex = 0;
+    @Native static final int kClipTypesIndex = 1;
+    @Native static final int kTextureImageIndex = 2;
+    @Native static final int kStrokeDashArrayIndex = 3;
+    @Native static final int kFontIndex = 4;
+    @Native static final int kFontPaintIndex = 5;
 
     // possible state changes
-    static final int kBoundsChangedBit = 1 << 0;
-    static final int kBoundsNotChangedBit = ~kBoundsChangedBit;
-    static final int kClipChangedBit = 1 << 1;
-    static final int kClipNotChangedBit = ~kClipChangedBit;
-    static final int kCTMChangedBit = 1 << 2;
-    static final int kCTMNotChangedBit = ~kCTMChangedBit;
-    static final int kColorChangedBit = 1 << 3;
-    static final int kColorNotChangedBit = ~kColorChangedBit;
-    static final int kCompositeChangedBit = 1 << 4;
-    static final int kCompositeNotChangedBit = ~kCompositeChangedBit;
-    static final int kStrokeChangedBit = 1 << 5;
-    static final int kStrokeNotChangedBit = ~kStrokeChangedBit;
-    static final int kHintsChangedBit = 1 << 6;
-    static final int kHintsNotChangedBit = ~kHintsChangedBit;
-    static final int kFontChangedBit = 1 << 7;
-    static final int kFontNotChangedBit = ~kFontChangedBit;
-    static final int kEverythingChangedFlag = 0xffffffff;
+    @Native static final int kBoundsChangedBit = 1 << 0;
+    @Native static final int kBoundsNotChangedBit = ~kBoundsChangedBit;
+    @Native static final int kClipChangedBit = 1 << 1;
+    @Native static final int kClipNotChangedBit = ~kClipChangedBit;
+    @Native static final int kCTMChangedBit = 1 << 2;
+    @Native static final int kCTMNotChangedBit = ~kCTMChangedBit;
+    @Native static final int kColorChangedBit = 1 << 3;
+    @Native static final int kColorNotChangedBit = ~kColorChangedBit;
+    @Native static final int kCompositeChangedBit = 1 << 4;
+    @Native static final int kCompositeNotChangedBit = ~kCompositeChangedBit;
+    @Native static final int kStrokeChangedBit = 1 << 5;
+    @Native static final int kStrokeNotChangedBit = ~kStrokeChangedBit;
+    @Native static final int kHintsChangedBit = 1 << 6;
+    @Native static final int kHintsNotChangedBit = ~kHintsChangedBit;
+    @Native static final int kFontChangedBit = 1 << 7;
+    @Native static final int kFontNotChangedBit = ~kFontChangedBit;
+    @Native static final int kEverythingChangedFlag = 0xffffffff;
 
     // possible color states
-    static final int kColorSimple = 0;
-    static final int kColorSystem = 1;
-    static final int kColorGradient = 2;
-    static final int kColorTexture = 3;
+    @Native static final int kColorSimple = 0;
+    @Native static final int kColorSystem = 1;
+    @Native static final int kColorGradient = 2;
+    @Native static final int kColorTexture = 3;
 
     // possible gradient color states
-    static final int kColorNonCyclic = 0;
-    static final int kColorCyclic = 1;
+    @Native static final int kColorNonCyclic = 0;
+    @Native static final int kColorCyclic = 1;
 
     // possible clip states
-    static final int kClipRect = 0;
-    static final int kClipShape = 1;
+    @Native static final int kClipRect = 0;
+    @Native static final int kClipShape = 1;
 
     static int getRendererTypeForPrimitive(int primitiveType) {
         switch (primitiveType) {
--- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -336,7 +336,7 @@
         return peerTreeLock;
     }
 
-    final T getTarget() {
+    public final T getTarget() {
         return target;
     }
 
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CClipboard.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CClipboard.java	Wed Jul 05 18:50:02 2017 +0200
@@ -110,4 +110,12 @@
 
     public native void declareTypes(long[] formats, SunClipboard newOwner);
     public native void setData(byte[] data, long format);
+
+    /**
+     * Invokes native check whether a change count on the general pasteboard is different
+     * than when we set it. The different count value means the current owner lost
+     * pasteboard ownership and someone else put data on the clipboard.
+     * @since 1.7
+     */
+    public native void checkPasteboard();
 }
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java	Wed Jul 05 18:50:02 2017 +0200
@@ -51,15 +51,6 @@
 
     @Override
     protected Point getCursorPosition() {
-        synchronized(this) {
-            if (isDragging) {
-                // during the drag operation, the appkit thread is blocked,
-                // so nativeGetCursorPosition invocation may cause a deadlock.
-                // In order to avoid this, we returns last know cursor position.
-                return new Point(dragPos);
-            }
-        }
-
         final Point2D nativePosition = nativeGetCursorPosition();
         return new Point((int)nativePosition.getX(), (int)nativePosition.getY());
     }
@@ -101,31 +92,4 @@
         // do something special
         throw new RuntimeException("Unimplemented");
     }
-
-    // package private methods to handle cursor change during drag-and-drop
-    private boolean isDragging = false;
-    private Point dragPos = null;
-
-    synchronized void startDrag(int x, int y) {
-        if (isDragging) {
-            throw new RuntimeException("Invalid Drag state in CCursorManager!");
-        }
-        isDragging = true;
-        dragPos = new Point(x, y);
-    }
-
-    synchronized void updateDragPosition(int x, int y) {
-        if (!isDragging) {
-            throw new RuntimeException("Invalid Drag state in CCursorManager!");
-        }
-        dragPos.move(x, y);
-    }
-
-    synchronized void stopDrag() {
-        if (!isDragging) {
-            throw new RuntimeException("Invalid Drag state in CCursorManager!");
-        }
-        isDragging = false;
-        dragPos = null;
-    }
 }
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -174,7 +174,7 @@
                 bytes = Normalizer.normalize(new String(bytes, "UTF8"), Form.NFC).getBytes("UTF8");
             }
 
-            return super.translateBytesOrStream(stream, bytes, flavor, format, transferable);
+            return super.translateBytes(bytes, flavor, format, transferable);
         }
 
 
@@ -257,16 +257,13 @@
     private native byte[] imageDataToPlatformImageBytes(int[] rData, int nW, int nH);
 
     /**
-        * Translates either a byte array or an input stream which contain
+     * Translates a byte array which contains
      * platform-specific image data in the given format into an Image.
      */
-    protected Image platformImageBytesOrStreamToImage(InputStream stream, byte[] bytes, long format) throws IOException {
-        byte[] imageData = bytes;
-
-        if (imageData == null)
-            imageData = inputStreamToByteArray(stream);
-
-        return getImageForByteStream(imageData);
+    protected Image platformImageBytesToImage(byte[] bytes, long format)
+        throws IOException
+    {
+        return getImageForByteStream(bytes);
     }
 
     private native Image getImageForByteStream(byte[] bytes);
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -38,8 +38,12 @@
 import javax.accessibility.*;
 
 import java.util.Map;
+import java.util.concurrent.Callable;
+
 import sun.awt.dnd.*;
 import sun.lwawt.LWComponentPeer;
+import sun.lwawt.LWWindowPeer;
+import sun.lwawt.PlatformWindow;
 
 
 public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
@@ -104,13 +108,8 @@
         }
 
         //It sure will be LWComponentPeer instance as rootComponent is a Window
-        LWComponentPeer peer = (LWComponentPeer)rootComponent.getPeer();
-        //Get a pointer to a native window
-        CPlatformWindow platformWindow = (CPlatformWindow) peer.getPlatformWindow();
-        long nativeWindowPtr = platformWindow.getNSWindowPtr();
-
-        // Get drag cursor:
-        Cursor cursor = this.getCursor();
+        PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow();
+        long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow);
 
         // If there isn't any drag image make one of default appearance:
         if (fDragImage == null)
@@ -139,19 +138,15 @@
 
         try {
             // Create native dragging source:
-            final long nativeDragSource = createNativeDragSource(component, peer, nativeWindowPtr, transferable, triggerEvent,
+            final long nativeDragSource = createNativeDragSource(component, nativeViewPtr, transferable, triggerEvent,
                 (int) (dragOrigin.getX()), (int) (dragOrigin.getY()), extModifiers,
-                clickCount, timestamp, cursor, fDragCImage, dragImageOffset.x, dragImageOffset.y,
+                clickCount, timestamp, fDragCImage, dragImageOffset.x, dragImageOffset.y,
                 getDragSourceContext().getSourceActions(), formats, formatMap);
 
             if (nativeDragSource == 0)
                 throw new InvalidDnDOperationException("");
 
             setNativeContext(nativeDragSource);
-
-            CCursorManager.getInstance().startDrag(
-                    (int) (dragOrigin.getX()),
-                    (int) (dragOrigin.getY()));
         }
 
         catch (Exception e) {
@@ -160,6 +155,8 @@
 
         SunDropTargetContextPeer.setCurrentJVMLocalSourceTransferable(transferable);
 
+        CCursorManager.getInstance().setCursor(getCursor());
+
         // Create a new thread to run the dragging operation since it's synchronous, only coming back
         // after dragging is finished. This leaves the AWT event thread free to handle AWT events which
         // are posted during dragging by native event handlers.
@@ -173,8 +170,6 @@
                     } catch (Exception e) {
                         e.printStackTrace();
                     } finally {
-                        CCursorManager.getInstance().stopDrag();
-
                         releaseNativeDragSource(nativeDragSource);
                         fDragImage = null;
                         if (fDragCImage != null) {
@@ -189,8 +184,6 @@
         }
 
         catch (Exception e) {
-            CCursorManager.getInstance().stopDrag();
-
             final long nativeDragSource = getNativeContext();
             setNativeContext(0);
             releaseNativeDragSource(nativeDragSource);
@@ -416,13 +409,24 @@
                                 final int modifiers,
                                 final int x, final int y) {
 
-        CCursorManager.getInstance().updateDragPosition(x, y);
+        try {
+            Component componentAt = LWCToolkit.invokeAndWait(
+                    new Callable<Component>() {
+                        @Override
+                        public Component call() {
+                            LWWindowPeer mouseEventComponent = LWWindowPeer.getWindowUnderCursor();
+                            if (mouseEventComponent == null) {
+                                return null;
+                            }
+                            Component root = SwingUtilities.getRoot(mouseEventComponent.getTarget());
+                            if (root == null) {
+                                return null;
+                            }
+                            Point rootLocation = root.getLocationOnScreen();
+                            return getDropTargetAt(root, x - rootLocation.x, y - rootLocation.y);
+                        }
+                    }, getComponent());
 
-        Component rootComponent = SwingUtilities.getRoot(getComponent());
-        if(rootComponent != null) {
-            Point componentPoint = new Point(x, y);
-            SwingUtilities.convertPointFromScreen(componentPoint, rootComponent);
-            Component componentAt = SwingUtilities.getDeepestComponentAt(rootComponent, componentPoint.x, componentPoint.y);
             if(componentAt != hoveringComponent) {
                 if(hoveringComponent != null) {
                     dragExit(x, y);
@@ -432,20 +436,36 @@
                 }
                 hoveringComponent = componentAt;
             }
+
+            postDragSourceDragEvent(targetActions, modifiers, x, y,
+                    DISPATCH_MOUSE_MOVED);
+        } catch (Exception e) {
+            throw new InvalidDnDOperationException("Failed to handle DragMouseMoved event");
         }
-        postDragSourceDragEvent(targetActions, modifiers, x, y,
-                                DISPATCH_MOUSE_MOVED);
     }
 
-    /**
-     * upcall from native code
-     */
-    private void dragEnter(final int targetActions,
-                           final int modifiers,
-                           final int x, final int y) {
-        CCursorManager.getInstance().updateDragPosition(x, y);
+    //Returns the first lightweight or heavyweight Component which has a dropTarget ready to accept the drag
+    //Should be called from the EventDispatchThread
+    private static Component getDropTargetAt(Component root, int x, int y) {
+        if (!root.contains(x, y) || !root.isEnabled() || !root.isVisible()) {
+            return null;
+        }
+
+        if (root.getDropTarget() != null && root.getDropTarget().isActive()) {
+            return root;
+        }
 
-        postDragSourceDragEvent(targetActions, modifiers, x, y, DISPATCH_ENTER);
+        if (root instanceof Container) {
+            for (Component comp : ((Container) root).getComponents()) {
+                Point loc = comp.getLocation();
+                Component dropTarget = getDropTargetAt(comp, x - loc.x, y - loc.y);
+                if (dropTarget != null) {
+                    return dropTarget;
+                }
+            }
+        }
+
+        return null;
     }
 
     /**
@@ -455,19 +475,15 @@
         hoveringComponent = null;
     }
 
-    public void setCursor(Cursor c) throws InvalidDnDOperationException {
-        // TODO : BG
-        //AWTLockAccess.awtLock();
-        super.setCursor(c);
-        //AWTLockAccess.awtUnlock();
+    @Override
+    protected void setNativeCursor(long nativeCtxt, Cursor c, int cType) {
+        CCursorManager.getInstance().setCursor(c);
     }
 
-    protected native void setNativeCursor(long nativeCtxt, Cursor c, int cType);
-
     // Native support:
-    private native long createNativeDragSource(Component component, ComponentPeer peer, long nativePeer, Transferable transferable,
+    private native long createNativeDragSource(Component component, long nativePeer, Transferable transferable,
         InputEvent triggerEvent, int dragPosX, int dragPosY, int extModifiers, int clickCount, long timestamp,
-        Cursor cursor, CImage nsDragImage, int dragImageOffsetX, int dragImageOffsetY,
+        CImage nsDragImage, int dragImageOffsetX, int dragImageOffsetY,
         int sourceActions, long[] formats, Map formatMap);
 
     private native void doDragging(long nativeDragSource);
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java	Wed Jul 05 18:50:02 2017 +0200
@@ -30,6 +30,7 @@
 import java.awt.dnd.DropTarget;
 
 import sun.lwawt.LWComponentPeer;
+import sun.lwawt.PlatformWindow;
 
 
 public final class CDropTarget {
@@ -50,21 +51,11 @@
         fComponent = component;
         fPeer = peer;
 
-        // Make sure the drop target is a ComponentModel:
-        if (!(peer instanceof LWComponentPeer))
-            throw new IllegalArgumentException("CDropTarget's peer must be a LWComponentPeer.");
-
-        // Get model pointer (CButton.m and such) and its native peer:
-        LWComponentPeer model = (LWComponentPeer) peer;
-        if (model.getPlatformWindow() instanceof CPlatformWindow) {
-            CPlatformWindow platformWindow = (CPlatformWindow) model.getPlatformWindow();
-            long nativePeer = platformWindow.getNSWindowPtr();
-
-            // Create native dragging destination:
-            fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer);
-            if (fNativeDropTarget == 0) {
-                throw new IllegalStateException("CDropTarget.createNativeDropTarget() failed.");
-            }
+        long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow());
+        // Create native dragging destination:
+        fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer);
+        if (fNativeDropTarget == 0) {
+            throw new IllegalStateException("CDropTarget.createNativeDropTarget() failed.");
         }
     }
 
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Wed Jul 05 18:50:02 2017 +0200
@@ -112,6 +112,14 @@
 
     public void handleFocusEvent(boolean focused) {
         this.focused = focused;
+        if (focused) {
+            // see bug 8010925
+            // we can't put this to handleWindowFocusEvent because
+            // it won't be invoced if focuse is moved to a html element
+            // on the same page.
+            CClipboard clipboard = (CClipboard) Toolkit.getDefaultToolkit().getSystemClipboard();
+            clipboard.checkPasteboard();
+        }
         if (parentWindowActive) {
             responder.handleWindowFocusEvent(focused, null);
         }
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Jul 05 18:50:02 2017 +0200
@@ -875,6 +875,21 @@
         }
     }
 
+    /**
+     * Helper method to get a pointer to the native view from the PlatformWindow.
+     */
+    static long getNativeViewPtr(PlatformWindow platformWindow) {
+        long nativePeer = 0L;
+        if (platformWindow instanceof CPlatformWindow) {
+            nativePeer = ((CPlatformWindow) platformWindow).getContentView().getAWTView();
+        } else if (platformWindow instanceof CViewPlatformEmbeddedFrame){
+            nativePeer = ((CViewPlatformEmbeddedFrame) platformWindow).getNSViewPtr();
+        } else {
+            throw new IllegalArgumentException("Unsupported platformWindow implementation");
+        }
+        return nativePeer;
+    }
+
     /*************************************************************
      * Callbacks from the AWTWindow and AWTView objc classes.
      *************************************************************/
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CocoaConstants.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CocoaConstants.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,10 +25,7 @@
 
 package sun.lwawt.macosx;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public final class CocoaConstants {
     private CocoaConstants(){}
 
--- a/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs	Wed Jul 05 18:50:02 2017 +0200
@@ -2,7 +2,7 @@
 
 {-
 /*
- * Copyright (c) 2011,2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +34,7 @@
 
 import Data.List
 import Data.Maybe
-import Char
+import Data.Char
 
 data Width = W32 | W64
              deriving (Show, Eq, Bounded, Enum)
@@ -196,8 +196,6 @@
 c2java ntype =
     unlines [
  "// native " ++ ntypeS ++ " -> java " ++ jprimS,
- "/* No native methods here, but the constants are needed in the supporting JNI code */",
- "@GenerateNativeHeader",
  "public static final class " ++ className ++ " extends PrimitiveCoder<" ++ jclassS ++ ">{",
  "\tpublic static final " ++ className ++ " INST = new " ++ className ++ "();",
  "\tpublic " ++ className ++ "(){ super("++ffitypeVal ntype++", \"" ++ [encoding ntype] ++ "\", "++jclassS++".class, "++jprimS++".class); }",
@@ -248,13 +246,10 @@
   putStrLn "package com.apple.jobjc;"
 
   putStrLn "import com.apple.jobjc.JObjCRuntime.Width;"
-  putStrLn "import javax.tools.annotation.GenerateNativeHeader;"
 
   putStrLn "// Auto generated by PrimitiveCoder.hs"
   putStrLn "// Do not edit by hand."
 
-  putStrLn "/* No native methods here, but the constants are needed in the supporting JNI code */"
-  putStrLn "@GenerateNativeHeader"
   putStrLn "public abstract class PrimitiveCoder<T> extends Coder<T>{"
 
   putStrLn "\tpublic PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){"
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,7 @@
  */
 package com.apple.jobjc;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class CFType extends Pointer<Void> {
     protected CFType(long ptr) { super(ptr); }
     protected CFType(Pointer<?> ptr) { super(ptr.ptr); }
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
 import com.apple.jobjc.PrimitiveCoder.SIntCoder;
 import com.apple.jobjc.PrimitiveCoder.SLongLongCoder;
 import com.apple.jobjc.PrimitiveCoder.SShortCoder;
-import javax.tools.annotation.GenerateNativeHeader;
 
 public abstract class Coder<T> {
     private static native long getNativeFFITypePtrForCode(final int code);
@@ -143,8 +142,6 @@
 
     //
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static final class VoidCoder extends Coder<Object>{
         public static final VoidCoder INST = new VoidCoder();
         public VoidCoder(){ super(FFI_VOID, "v", Void.class, void.class); }
@@ -153,8 +150,6 @@
         @Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Trying to push a Void."); }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static final class UnknownCoder extends Coder<Object> {
         public static final UnknownCoder INST = new UnknownCoder();
         public UnknownCoder(){ super(-1, "?", null, null); }
@@ -163,8 +158,6 @@
         @Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Coder not implemented"); }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static final class PrimitivePointerCoder extends Coder<Long> {
         public static final PrimitivePointerCoder INST = new PrimitivePointerCoder();
         public PrimitivePointerCoder(){ super(Coder.FFI_PTR, "^?", Long.class, long.class); }
@@ -194,8 +187,6 @@
         @Override public void push(JObjCRuntime runtime, long addr, Long x) { push(runtime, addr, (long) x); }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static final class PointerCoder extends Coder<Pointer> {
         public static final PointerCoder INST = new PointerCoder();
         public PointerCoder(){ super(FFI_PTR, "^?", Pointer.class); }
@@ -209,8 +200,6 @@
         }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static final class SELCoder extends Coder<SEL> {
         public static final SELCoder INST = new SELCoder();
         public SELCoder(){ super(FFI_PTR, ":", SEL.class); }
@@ -224,8 +213,6 @@
         }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static abstract class StructCoder extends Coder<Struct> {
         private final FFIType ffiType;
         final int sizeof;
@@ -267,8 +254,6 @@
         }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static final class IDCoder extends Coder<ID>{
         public static final IDCoder INST = new IDCoder();
         public IDCoder(){ super(FFI_PTR, "@", ID.class); }
@@ -287,8 +272,6 @@
         }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static final class NSClassCoder extends Coder<NSClass>{
         public static final NSClassCoder INST = new NSClassCoder();
         public NSClassCoder(){ super(FFI_PTR, "#", NSClass.class); }
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,10 +26,7 @@
 
 import com.apple.jobjc.Coder.PrimitivePointerCoder;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 class FFIType{
     private static native void makeFFIType(long ffi_type_buf, long elements_buf);
     private static native int  getFFITypeSizeof();
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,7 @@
  */
 package com.apple.jobjc;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class Function {
     private static native long getFxnPtrForFunctionName(final String functionName);
     private static native long getFxnPtrForFunctionNameAndLib(final long libPtr, final String functionName);
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,10 +29,7 @@
 import java.util.LinkedHashMap;
 import java.util.Map;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class ID extends Pointer<Void>{
     static native String getNativeDescription(final long objPtr);
 
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,18 +30,13 @@
 import com.apple.jobjc.Coder.SELCoder;
 import com.apple.jobjc.Coder.StructCoder;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class Invoke {
     public abstract void invoke(NativeArgumentBuffer argBuf);
     public abstract void invoke(NativeArgumentBuffer buffer, Struct retvalStruct);
 
     //
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static final class FunCall extends Invoke{
         static native void invoke(long cifPtr, long fxnPtr, long retValPtr, long argsPtr);
 
@@ -78,8 +73,6 @@
         }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static final class MsgSend extends Invoke{
         static{ System.load("/usr/lib/libobjc.dylib"); }
 
@@ -165,8 +158,6 @@
         }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static final class MsgSendSuper extends Invoke{
         static{ System.load("/usr/lib/libobjc.dylib"); }
 
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,16 +31,11 @@
 
 import sun.misc.Unsafe;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public final class JObjCRuntime {
     static { System.loadLibrary("JObjC"); }
 
-    @GenerateNativeHeader
     public static enum Arch{ ppc, i386, x86_64 };
-    @GenerateNativeHeader
     public static enum Width{ W32, W64 };
 
     public static final Arch ARCH = getArch();
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,10 +25,7 @@
 package com.apple.jobjc;
 
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class MacOSXFramework {
     private static native long retainFramework(final String frameworkName);
     private static native void releaseFramework(final long frameworkPtr);
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,13 +27,8 @@
 import java.lang.ref.WeakReference;
 import java.lang.reflect.Constructor;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class NSClass<T extends ID> extends ID {
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class NSClassNotFoundException extends RuntimeException{
         public NSClassNotFoundException(String m){ super(m); }
         public NSClassNotFoundException(String m, Throwable cause){ super(m, cause); }
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,10 +28,7 @@
 
 import com.apple.jobjc.Coder.PrimitivePointerCoder;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public final class NativeArgumentBuffer{
     private static final ThreadLocal<NativeArgumentBuffer> threadLocal = new ThreadLocal<NativeArgumentBuffer>();
 
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,13 +27,10 @@
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * A wrapper around a direct ByteBuffer and its native pointer. For documentation, @see java.nio.ByteBuffer
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class NativeBuffer {
     static native long getPtrOfBuffer(final ByteBuffer byteBuffer);
 
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,7 @@
  */
 package com.apple.jobjc;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class NativeObjectLifecycleManager {
     private static native void retainNativeObject(final long ptr);
     private static native void releaseNativeObject(final long ptr);
@@ -37,8 +34,6 @@
     abstract void end(final long ptr);
     boolean shouldPreRetain() { return false; }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class CFRetainRelease extends NativeObjectLifecycleManager {
         public static final NativeObjectLifecycleManager INST = new CFRetainRelease();
         @Override void begin(final long ptr) { retainNativeObject(ptr); }
@@ -46,16 +41,12 @@
         @Override boolean shouldPreRetain() { return true; }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class Free extends NativeObjectLifecycleManager {
         public static final NativeObjectLifecycleManager INST = new Free();
         @Override void begin(final long ptr) { }
         @Override void end(final long ptr) { freeNativeObject(ptr); }
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     public static class Nothing extends NativeObjectLifecycleManager {
         public static final NativeObjectLifecycleManager INST = new Nothing();
         @Override void begin(final long ptr) { }
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,7 @@
  */
 package com.apple.jobjc;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class Opaque extends Pointer<Void> {
     protected Opaque(long ptr) { super(ptr); }
     protected Opaque(Pointer<?> ptr) { super(ptr.ptr); }
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,7 @@
  */
 package com.apple.jobjc;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class Pointer <T> implements Comparable<Pointer<T>>{
     long ptr;
 
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011,2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,11 +24,8 @@
  */
 package com.apple.jobjc;
 import com.apple.jobjc.JObjCRuntime.Width;
-import javax.tools.annotation.GenerateNativeHeader;
 // Auto generated by PrimitiveCoder.hs
 // Do not edit by hand.
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class PrimitiveCoder<T> extends Coder<T>{
     public PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){
         super(ffiTypeCode, objCEncoding, jclass, jprim);
@@ -130,8 +127,6 @@
 
 
 // native BOOL -> java boolean
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class BoolCoder extends PrimitiveCoder<Boolean>{
     public static final BoolCoder INST = new BoolCoder();
     public BoolCoder(){ super(FFI_SINT8, "B", Boolean.class, boolean.class); }
@@ -175,8 +170,6 @@
 }
 
 // native schar -> java byte
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class SCharCoder extends PrimitiveCoder<Byte>{
     public static final SCharCoder INST = new SCharCoder();
     public SCharCoder(){ super(FFI_SINT8, "c", Byte.class, byte.class); }
@@ -220,8 +213,6 @@
 }
 
 // native uchar -> java byte
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class UCharCoder extends PrimitiveCoder<Byte>{
     public static final UCharCoder INST = new UCharCoder();
     public UCharCoder(){ super(FFI_UINT8, "C", Byte.class, byte.class); }
@@ -265,8 +256,6 @@
 }
 
 // native sshort -> java short
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class SShortCoder extends PrimitiveCoder<Short>{
     public static final SShortCoder INST = new SShortCoder();
     public SShortCoder(){ super(FFI_SINT16, "s", Short.class, short.class); }
@@ -310,8 +299,6 @@
 }
 
 // native ushort -> java short
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class UShortCoder extends PrimitiveCoder<Short>{
     public static final UShortCoder INST = new UShortCoder();
     public UShortCoder(){ super(FFI_UINT16, "S", Short.class, short.class); }
@@ -355,8 +342,6 @@
 }
 
 // native sint -> java int
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class SIntCoder extends PrimitiveCoder<Integer>{
     public static final SIntCoder INST = new SIntCoder();
     public SIntCoder(){ super(FFI_SINT32, "i", Integer.class, int.class); }
@@ -400,8 +385,6 @@
 }
 
 // native uint -> java int
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class UIntCoder extends PrimitiveCoder<Integer>{
     public static final UIntCoder INST = new UIntCoder();
     public UIntCoder(){ super(FFI_UINT32, "I", Integer.class, int.class); }
@@ -445,8 +428,6 @@
 }
 
 // native slong -> java long
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class SLongCoder extends PrimitiveCoder<Long>{
     public static final SLongCoder INST = new SLongCoder();
     public SLongCoder(){ super((JObjCRuntime.IS64 ? (FFI_SINT64) : (FFI_SINT32)), "l", Long.class, long.class); }
@@ -496,8 +477,6 @@
 }
 
 // native ulong -> java long
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class ULongCoder extends PrimitiveCoder<Long>{
     public static final ULongCoder INST = new ULongCoder();
     public ULongCoder(){ super((JObjCRuntime.IS64 ? (FFI_UINT64) : (FFI_UINT32)), "L", Long.class, long.class); }
@@ -547,8 +526,6 @@
 }
 
 // native slonglong -> java long
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class SLongLongCoder extends PrimitiveCoder<Long>{
     public static final SLongLongCoder INST = new SLongLongCoder();
     public SLongLongCoder(){ super(FFI_SINT64, "q", Long.class, long.class); }
@@ -592,8 +569,6 @@
 }
 
 // native ulonglong -> java long
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class ULongLongCoder extends PrimitiveCoder<Long>{
     public static final ULongLongCoder INST = new ULongLongCoder();
     public ULongLongCoder(){ super(FFI_UINT64, "Q", Long.class, long.class); }
@@ -637,8 +612,6 @@
 }
 
 // native float -> java float
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class FloatCoder extends PrimitiveCoder<Float>{
     public static final FloatCoder INST = new FloatCoder();
     public FloatCoder(){ super(FFI_FLOAT, "f", Float.class, float.class); }
@@ -682,8 +655,6 @@
 }
 
 // native double -> java double
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public static final class DoubleCoder extends PrimitiveCoder<Double>{
     public static final DoubleCoder INST = new DoubleCoder();
     public DoubleCoder(){ super(FFI_DOUBLE, "d", Double.class, double.class); }
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,7 @@
  */
 package com.apple.jobjc;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class SEL {
     static native long getSelectorPtr(String selectorName);
     static native String getSelectorName(long ptr);
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,13 +24,10 @@
  */
 package com.apple.jobjc;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * A struct is malloced on the C heap and accessed in Java through a ByteBuffer.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class Struct{
     protected final NativeBuffer raw;
     private final JObjCRuntime runtime;
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,10 +33,7 @@
 import com.apple.jobjc.Coder.VoidCoder;
 import com.apple.jobjc.Invoke.MsgSend;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 final class Subclassing {
     static native long allocateClassPair(long superClass, String name);
     static native boolean addIVarForJObj(long clazz);
--- a/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,6 @@
  */
 
 #include "com_apple_jobjc_Invoke_FunCall.h"
-#include "com_apple_jobjc_Invoke_MsgSend.h"
-#include "com_apple_jobjc_Invoke_MsgSendSuper.h"
 #include <ffi/ffi.h>
 #include <objc/message.h>
 #include <JavaNativeFoundation/JavaNativeFoundation.h>
--- a/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,5 @@
  * questions.
  */
 
-#include "com_apple_jobjc_JObjCRuntime.h"
 #include "Cocoa/Cocoa.h"
 
--- a/jdk/src/macosx/native/sun/awt/CClipboard.m	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/CClipboard.m	Wed Jul 05 18:50:02 2017 +0200
@@ -189,18 +189,18 @@
 
 - (void) checkPasteboard:(id)application {
     AWT_ASSERT_APPKIT_THREAD;
-
+    
     //NSLog(@"CClipboard checkPasteboard oldCount %d newCount %d newTypes %@", fChangeCount, [[NSPasteboard generalPasteboard] changeCount], [[NSPasteboard generalPasteboard] types]);
-
+    
     // This is called via NSApplicationDidBecomeActiveNotification.
-
+    
     // If the change count on the general pasteboard is different than when we set it
     // someone else put data on the clipboard.  That means the current owner lost ownership.
     NSInteger newChangeCount = [[NSPasteboard generalPasteboard] changeCount];
-
+    
     if (fChangeCount != newChangeCount) {
         fChangeCount = newChangeCount;
-
+        
         [self pasteboardChangedOwner:[NSPasteboard generalPasteboard]];
     }
 }
@@ -371,4 +371,21 @@
     return returnValue;
 }
 
+/*
+ * Class:     sun_lwawt_macosx_CClipboard
+ * Method:    checkPasteboard
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CClipboard_checkPasteboard
+(JNIEnv *env, jobject inObject )
+{
+    JNF_COCOA_ENTER(env);
 
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
+        [[CClipboard sharedClipboard] checkPasteboard:nil];
+    }];
+        
+    JNF_COCOA_EXIT(env);
+}
+
+
--- a/jdk/src/macosx/native/sun/awt/CDragSource.h	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/CDragSource.h	Wed Jul 05 18:50:02 2017 +0200
@@ -33,7 +33,6 @@
 @private
     NSView*        fView;
     jobject            fComponent;
-    jobject            fComponentPeer;
     jobject            fDragSourceContextPeer;
 
     jobject            fTransferable;
@@ -43,8 +42,6 @@
     jint                fClickCount;
     jint                fModifiers;
 
-    jobject            fCursor;
-
     NSImage*        fDragImage;
     NSPoint            fDragImageOffset;
 
@@ -59,12 +56,22 @@
 + (CDragSource *) currentDragSource;
 
 // Common methods:
-- (id)init:(jobject)jdragsourcecontextpeer component:(jobject)jcomponent peer:(jobject)jpeer control:(id)control
-    transferable:(jobject)jtransferable triggerEvent:(jobject)jtrigger
-    dragPosX:(jint)dragPosX dragPosY:(jint)dragPosY modifiers:(jint)extModifiers clickCount:(jint)clickCount timeStamp:(jlong)timeStamp
-    cursor:(jobject)jcursor
-    dragImage:(jobject)jnsdragimage dragImageOffsetX:(jint)jdragimageoffsetx dragImageOffsetY:(jint)jdragimageoffsety
-    sourceActions:(jint)jsourceactions formats:(jlongArray)jformats formatMap:(jobject)jformatmap;
+- (id)        init:(jobject)jDragSourceContextPeer
+         component:(jobject)jComponent
+           control:(id)control
+      transferable:(jobject)jTransferable
+      triggerEvent:(jobject)jTrigger
+          dragPosX:(jint)dragPosX
+          dragPosY:(jint)dragPosY
+         modifiers:(jint)extModifiers
+        clickCount:(jint)clickCount
+         timeStamp:(jlong)timeStamp
+         dragImage:(jobject)jDragImage
+  dragImageOffsetX:(jint)jDragImageOffsetX
+  dragImageOffsetY:(jint)jDragImageOffsetY
+     sourceActions:(jint)jSourceActions
+           formats:(jlongArray)jFormats
+         formatMap:(jobject)jFormatMap;
 
 - (void)removeFromView:(JNIEnv *)env;
 
--- a/jdk/src/macosx/native/sun/awt/CDragSource.m	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/CDragSource.m	Wed Jul 05 18:50:02 2017 +0200
@@ -84,12 +84,22 @@
     return sCurrentDragSource;
 }
 
-- (id)init:(jobject)jdragsourcecontextpeer component:(jobject)jcomponent peer:(jobject)jpeer control:(id)control
-    transferable:(jobject)jtransferable triggerEvent:(jobject)jtrigger
-    dragPosX:(jint)dragPosX dragPosY:(jint)dragPosY modifiers:(jint)extModifiers clickCount:(jint)clickCount
-    timeStamp:(jlong)timeStamp cursor:(jobject)jcursor
-    dragImage:(jobject)jnsdragimage dragImageOffsetX:(jint)jdragimageoffsetx dragImageOffsetY:(jint)jdragimageoffsety
-    sourceActions:(jint)jsourceactions formats:(jlongArray)jformats formatMap:(jobject)jformatmap
+- (id)        init:(jobject)jDragSourceContextPeer
+         component:(jobject)jComponent
+           control:(id)control
+      transferable:(jobject)jTransferable
+      triggerEvent:(jobject)jTrigger
+          dragPosX:(jint)dragPosX
+          dragPosY:(jint)dragPosY
+         modifiers:(jint)extModifiers
+        clickCount:(jint)clickCount
+         timeStamp:(jlong)timeStamp
+         dragImage:(jobject)jDragImage
+  dragImageOffsetX:(jint)jDragImageOffsetX
+  dragImageOffsetY:(jint)jDragImageOffsetY
+     sourceActions:(jint)jSourceActions
+           formats:(jlongArray)jFormats
+         formatMap:(jobject)jFormatMap
 {
     self = [super init];
     DLog2(@"[CDragSource init]: %@\n", self);
@@ -100,27 +110,25 @@
     // Construct the object if we have a valid model for it:
     if (control != nil) {
         JNIEnv *env = [ThreadUtilities getJNIEnv];
-        fComponent = JNFNewGlobalRef(env, jcomponent);
-        fComponentPeer = JNFNewGlobalRef(env, jpeer);
-        fDragSourceContextPeer = JNFNewGlobalRef(env, jdragsourcecontextpeer);
+        fComponent = JNFNewGlobalRef(env, jComponent);
+        fDragSourceContextPeer = JNFNewGlobalRef(env, jDragSourceContextPeer);
 
-        fTransferable = JNFNewGlobalRef(env, jtransferable);
-        fTriggerEvent = JNFNewGlobalRef(env, jtrigger);
-        fCursor = JNFNewGlobalRef(env, jcursor);
+        fTransferable = JNFNewGlobalRef(env, jTransferable);
+        fTriggerEvent = JNFNewGlobalRef(env, jTrigger);
 
-        if (jnsdragimage) {
+        if (jDragImage) {
             JNF_MEMBER_CACHE(nsImagePtr, CImageClass, "ptr", "J");
-            jlong imgPtr = JNFGetLongField(env, jnsdragimage, nsImagePtr);
+            jlong imgPtr = JNFGetLongField(env, jDragImage, nsImagePtr);
             fDragImage = (NSImage*) jlong_to_ptr(imgPtr); // Double-casting prevents compiler 'd$|//
 
             [fDragImage retain];
         }
 
-        fDragImageOffset = NSMakePoint(jdragimageoffsetx, jdragimageoffsety);
+        fDragImageOffset = NSMakePoint(jDragImageOffsetX, jDragImageOffsetY);
 
-        fSourceActions = jsourceactions;
-        fFormats = JNFNewGlobalRef(env, jformats);
-        fFormatMap = JNFNewGlobalRef(env, jformatmap);
+        fSourceActions = jSourceActions;
+        fFormats = JNFNewGlobalRef(env, jFormats);
+        fFormatMap = JNFNewGlobalRef(env, jFormatMap);
 
         fTriggerEventTimeStamp = timeStamp;
         fDragPos = NSMakePoint(dragPosX, dragPosY);
@@ -129,9 +137,8 @@
 
         // Set this object as a dragging source:
 
-        AWTView *awtView = [((NSWindow *) control) contentView];
-        fView = [awtView retain];
-        [awtView setDragSource:self];
+        fView = [(AWTView *) control retain];
+        [fView setDragSource:self];
 
         // Let AWTEvent know Java drag is getting underway:
         [NSEvent javaDraggingBegin];
@@ -158,11 +165,6 @@
         fComponent = NULL;
     }
 
-    if (fComponentPeer != NULL) {
-        JNFDeleteGlobalRef(env, fComponentPeer);
-        fComponentPeer = NULL;
-    }
-
     if (fDragSourceContextPeer != NULL) {
         JNFDeleteGlobalRef(env, fDragSourceContextPeer);
         fDragSourceContextPeer = NULL;
@@ -178,11 +180,6 @@
         fTriggerEvent = NULL;
     }
 
-    if (fCursor != NULL) {
-        JNFDeleteGlobalRef(env, fCursor);
-        fCursor = NULL;
-    }
-
     if (fFormats != NULL) {
         JNFDeleteGlobalRef(env, fFormats);
         fFormats = NULL;
@@ -586,11 +583,6 @@
 {
     AWT_ASSERT_NOT_APPKIT_THREAD;
 
-    // Set the drag cursor (or not 3839999)
-    //JNIEnv *env = [ThreadUtilities getJNIEnv];
-    //jobject gCursor = JNFNewGlobalRef(env, fCursor);
-    //[EventFactory setJavaCursor:gCursor withEnv:env];
-
     [self performSelectorOnMainThread:@selector(doDrag) withObject:nil waitUntilDone:YES]; // AWT_THREADING Safe (called from unique asynchronous thread)
 }
 
--- a/jdk/src/macosx/native/sun/awt/CDragSourceContextPeer.m	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/CDragSourceContextPeer.m	Wed Jul 05 18:50:02 2017 +0200
@@ -34,12 +34,13 @@
 /*
  * Class:     sun_lwawt_macosx_CDragSourceContextPeer
  * Method:    createNativeDragSource
- * Signature: (Ljava/awt/Component;Ljava/awt/peer/ComponentPeer;JLjava/awt/datatransfer/Transferable;Ljava/awt/event/InputEvent;IIIIJLjava/awt/Cursor;IJIII[JLjava/util/Map;)J
+ * Signature: (Ljava/awt/Component;JLjava/awt/datatransfer/Transferable;
+               Ljava/awt/event/InputEvent;IIIIJIJIII[JLjava/util/Map;)J
  */
 JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_createNativeDragSource
-  (JNIEnv *env, jobject jthis, jobject jcomponent, jobject jpeer, jlong jnativepeer, jobject jtransferable,
+  (JNIEnv *env, jobject jthis, jobject jcomponent, jlong jnativepeer, jobject jtransferable,
    jobject jtrigger, jint jdragposx, jint jdragposy, jint jextmodifiers, jint jclickcount, jlong jtimestamp,
-   jobject jcursor, jobject jnsdragimage, jint jdragimageoffsetx, jint jdragimageoffsety,
+   jobject jnsdragimage, jint jdragimageoffsetx, jint jdragimageoffsety,
    jint jsourceactions, jlongArray jformats, jobject jformatmap)
 {
     id controlObj = (id) jlong_to_ptr(jnativepeer);
@@ -47,12 +48,22 @@
 
 JNF_COCOA_ENTER(env);
     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-        dragSource = [[CDragSource alloc] init:jthis component:jcomponent peer:jpeer control:controlObj
-            transferable:jtransferable triggerEvent:jtrigger dragPosX:jdragposx
-            dragPosY:jdragposy modifiers:jextmodifiers clickCount:jclickcount timeStamp:jtimestamp
-            cursor:jcursor dragImage:jnsdragimage dragImageOffsetX:jdragimageoffsetx
-            dragImageOffsetY:jdragimageoffsety sourceActions:jsourceactions
-            formats:jformats formatMap:jformatmap];
+        dragSource = [[CDragSource alloc] init:jthis
+                                     component:jcomponent
+                                       control:controlObj
+                                  transferable:jtransferable
+                                  triggerEvent:jtrigger
+                                      dragPosX:jdragposx
+                                      dragPosY:jdragposy
+                                     modifiers:jextmodifiers
+                                    clickCount:jclickcount
+                                     timeStamp:jtimestamp
+                                     dragImage:jnsdragimage
+                              dragImageOffsetX:jdragimageoffsetx
+                              dragImageOffsetY:jdragimageoffsety
+                                 sourceActions:jsourceactions
+                                       formats:jformats
+                                     formatMap:jformatmap];
     }];
 JNF_COCOA_EXIT(env);
 
@@ -94,19 +105,3 @@
     [dragSource removeFromView:env];
 JNF_COCOA_EXIT(env);
 }
-
-/*
- * Class:     sun_lwawt_macosx_CDragSourceContextPeer
- * Method:    setNativeCursor
- * Signature: (JLjava/awt/Cursor;I)V
- */
-JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_setNativeCursor
-  (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal, jobject jcursor, jint jcursortype)
-{
-   //AWT_ASSERT_NOT_APPKIT_THREAD;
-
-//JNF_COCOA_ENTER(env);
-//    jobject gCursor = JNFNewGlobalRef(env, jcursor);
-//    [EventFactory setJavaCursor:gCursor withEnv:env];
-//JNF_COCOA_EXIT(env);
-}
--- a/jdk/src/macosx/native/sun/awt/CDropTarget.m	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/CDropTarget.m	Wed Jul 05 18:50:02 2017 +0200
@@ -81,9 +81,8 @@
         fComponent = JNFNewGlobalRef(env, jcomponent);
         fDropTarget = JNFNewGlobalRef(env, jdropTarget);
 
-        AWTView *awtView = [((NSWindow *) control) contentView];
-        fView = [awtView retain];
-        [awtView setDropTarget:self];
+        fView = [((AWTView *) control) retain];
+        [fView setDropTarget:self];
 
 
     } else {
@@ -177,6 +176,10 @@
 {
     DLog2(@"[CDropTarget dealloc]: %@\n", self);
 
+    if(sCurrentDropTarget == self) {
+        sCurrentDropTarget = nil;
+    }
+
     [fView release];
     fView = nil;
 
@@ -490,7 +493,10 @@
         JNF_MEMBER_CACHE(handleEnterMessageMethod, jc_CDropTargetContextPeer, "handleEnterMessage", "(Ljava/awt/Component;IIII[JJ)I");
         if (sDraggingError == FALSE) {
             // Double-casting self gets rid of 'different size' compiler warning:
-            actions = JNFCallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
+            // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
+            actions = JNFCallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod,
+                                       fComponent, (jint) javaLocation.x, (jint) javaLocation.y,
+                                       dropAction, actions, formats, ptr_to_jlong(self));
         }
 
         if (sDraggingError == FALSE) {
@@ -510,11 +516,6 @@
             // Remember the dragOp for no-op'd update messages:
             sUpdateOperation = dragOp;
         }
-
-        // If we are in the same process as the sender, make the sender post the appropriate message
-        if (sender) {
-            [[CDragSource currentDragSource] postDragEnter];
-        }
     }
 
     // 9-11-02 Note: the native event thread would not handle an exception gracefully:
@@ -608,11 +609,9 @@
         JNF_MEMBER_CACHE(handleExitMessageMethod, jc_CDropTargetContextPeer, "handleExitMessage", "(Ljava/awt/Component;J)V");
         if (sDraggingError == FALSE) {
             DLog3(@"  - dragExit: loc native %f, %f\n", sDraggingLocation.x, sDraggingLocation.y);
-            JNFCallVoidMethod(env, fDropTargetContextPeer, handleExitMessageMethod, fComponent, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
-            // If we are in the same process as the sender, make the sender post the appropriate message
-            if (sender) {
-                [[CDragSource currentDragSource] postDragExit];
-            }
+             // AWT_THREADING Safe (CToolkitThreadBlockedHandler) 
+            JNFCallVoidMethod(env, fDropTargetContextPeer,
+                              handleExitMessageMethod, fComponent, ptr_to_jlong(self));
         }
 
         // 5-27-03 Note: [Radar 3270455]
--- a/jdk/src/macosx/native/sun/awt/CTextPipe.m	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/CTextPipe.m	Wed Jul 05 18:50:02 2017 +0200
@@ -501,10 +501,22 @@
         int *uniChars = (int *)malloc(sizeof(int) * length);
         CGSize *advances = (CGSize *)malloc(sizeof(CGSize) * length);
 
-        if (glyphs == NULL || advances == NULL)
+        if (glyphs == NULL || uniChars == NULL || advances == NULL)
         {
             (*env)->DeleteLocalRef(env, glyphsArray);
             [NSException raise:NSMallocException format:@"%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__];
+            if (glyphs)
+            {
+                free(glyphs);
+            }
+            if (uniChars)
+            {
+                free(uniChars);
+            }
+            if (advances)
+            {
+                free(advances);
+            }
             return;
         }
 
--- a/jdk/src/macosx/native/sun/awt/PrinterView.m	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/PrinterView.m	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +26,6 @@
 #import "PrinterView.h"
 
 #import "java_awt_print_Pageable.h"
-#import "java_awt_print_Printable.h"
 #import "java_awt_print_PageFormat.h"
 
 #import <JavaNativeFoundation/JavaNativeFoundation.h>
--- a/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Wed Jul 05 18:50:02 2017 +0200
@@ -32,8 +32,8 @@
 static CFDateFormatterStyle convertDateFormatterStyle(jint javaStyle);
 static CFNumberFormatterStyle convertNumberFormatterStyle(jint javaStyle);
 static void copyArrayElements(JNIEnv *env, CFArrayRef cfarray, jobjectArray jarray, CFIndex sindex, int dindex, int count);
-static jstring getNumberSymbolString(JNIEnv *env, jstring jdefault, CFStringRef type);
-static jchar getNumberSymbolChar(jchar jdefault, CFStringRef type);
+static jstring getNumberSymbolString(JNIEnv *env, jstring jlangtag, jstring jdefault, CFStringRef type);
+static jchar getNumberSymbolChar(JNIEnv *env, jstring jlangtag, jchar jdefault, CFStringRef type);
 
 // from java_props_macosx.c
 extern char * getMacOSXLocale(int cat);
@@ -322,7 +322,7 @@
  */
 JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCurrencySymbol
   (JNIEnv *env, jclass cls, jstring jlangtag, jstring currencySymbol) {
-    return getNumberSymbolString(env, currencySymbol, kCFNumberFormatterCurrencySymbol);
+    return getNumberSymbolString(env, jlangtag, currencySymbol, kCFNumberFormatterCurrencySymbol);
 }
 
 /*
@@ -332,7 +332,7 @@
  */
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDecimalSeparator
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar decimalSeparator) {
-    return getNumberSymbolChar(decimalSeparator, kCFNumberFormatterDecimalSeparator);
+    return getNumberSymbolChar(env, jlangtag, decimalSeparator, kCFNumberFormatterDecimalSeparator);
 }
 
 /*
@@ -342,7 +342,7 @@
  */
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getGroupingSeparator
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar groupingSeparator) {
-    return getNumberSymbolChar(groupingSeparator, kCFNumberFormatterGroupingSeparator);
+    return getNumberSymbolChar(env, jlangtag, groupingSeparator, kCFNumberFormatterGroupingSeparator);
 }
 
 /*
@@ -352,7 +352,7 @@
  */
 JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInfinity
   (JNIEnv *env, jclass cls, jstring jlangtag, jstring infinity) {
-    return getNumberSymbolString(env, infinity, kCFNumberFormatterInfinitySymbol);
+    return getNumberSymbolString(env, jlangtag, infinity, kCFNumberFormatterInfinitySymbol);
 }
 
 /*
@@ -362,7 +362,7 @@
  */
 JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInternationalCurrencySymbol
   (JNIEnv *env, jclass cls, jstring jlangtag, jstring internationalCurrencySymbol) {
-    return getNumberSymbolString(env, internationalCurrencySymbol, kCFNumberFormatterInternationalCurrencySymbol);
+    return getNumberSymbolString(env, jlangtag, internationalCurrencySymbol, kCFNumberFormatterInternationalCurrencySymbol);
 }
 
 /*
@@ -372,7 +372,7 @@
  */
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMinusSign
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar minusSign) {
-    return getNumberSymbolChar(minusSign, kCFNumberFormatterMinusSign);
+    return getNumberSymbolChar(env, jlangtag, minusSign, kCFNumberFormatterMinusSign);
 }
 
 /*
@@ -382,7 +382,7 @@
  */
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMonetaryDecimalSeparator
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar monetaryDecimalSeparator) {
-    return getNumberSymbolChar(monetaryDecimalSeparator, kCFNumberFormatterCurrencyDecimalSeparator);
+    return getNumberSymbolChar(env, jlangtag, monetaryDecimalSeparator, kCFNumberFormatterCurrencyDecimalSeparator);
 }
 
 /*
@@ -392,7 +392,7 @@
  */
 JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNaN
   (JNIEnv *env, jclass cls, jstring jlangtag, jstring nan) {
-    return getNumberSymbolString(env, nan, kCFNumberFormatterNaNSymbol);
+    return getNumberSymbolString(env, jlangtag, nan, kCFNumberFormatterNaNSymbol);
 }
 
 /*
@@ -402,7 +402,7 @@
  */
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPercent
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar percent) {
-    return getNumberSymbolChar(percent, kCFNumberFormatterPercentSymbol);
+    return getNumberSymbolChar(env, jlangtag, percent, kCFNumberFormatterPercentSymbol);
 }
 
 /*
@@ -412,7 +412,7 @@
  */
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPerMill
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar perMill) {
-    return getNumberSymbolChar(perMill, kCFNumberFormatterPerMillSymbol);
+    return getNumberSymbolChar(env, jlangtag, perMill, kCFNumberFormatterPerMillSymbol);
 }
 
 /*
@@ -422,7 +422,36 @@
  */
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getZeroDigit
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar zeroDigit) {
-    return getNumberSymbolChar(zeroDigit, kCFNumberFormatterZeroSymbol);
+    // The following code *should* work, but not for some reason :o
+    //
+    //return getNumberSymbolChar(env, jlangtag, zeroDigit, kCFNumberFormatterZeroSymbol);
+    //
+    // so here is a workaround.
+    jchar ret = zeroDigit;
+    CFLocaleRef cflocale = CFLocaleCopyCurrent();
+
+    if (cflocale != NULL) {
+        CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorDefault,
+                                                  cflocale,
+                                                  kCFNumberFormatterNoStyle);
+        if (nf != NULL) {
+            int zero = 0;
+            CFStringRef str = CFNumberFormatterCreateStringWithValue(kCFAllocatorDefault,
+                              nf, kCFNumberIntType, &zero);
+            if (str != NULL) {
+                if (CFStringGetLength(str) > 0) {
+                    ret = CFStringGetCharacterAtIndex(str, 0);
+                }
+                CFRelease(str);
+            }
+
+            CFRelease(nf);
+        }
+
+        CFRelease(cflocale);
+    }
+
+    return ret;
 }
 
 /*
@@ -432,7 +461,7 @@
  */
 JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getExponentSeparator
   (JNIEnv *env, jclass cls, jstring jlangtag, jstring exponent) {
-    return getNumberSymbolString(env, exponent, kCFNumberFormatterExponentSymbol);
+    return getNumberSymbolString(env, jlangtag, exponent, kCFNumberFormatterExponentSymbol);
 }
 
 /*
@@ -625,7 +654,7 @@
     }
 }
 
-static jstring getNumberSymbolString(JNIEnv *env, jstring jdefault, CFStringRef type) {
+static jstring getNumberSymbolString(JNIEnv *env, jstring jlangtag, jstring jdefault, CFStringRef type) {
     char buf[BUFLEN];
     jstring ret = jdefault;
     CFLocaleRef cflocale = CFLocaleCopyCurrent();
@@ -633,7 +662,7 @@
     if (cflocale != NULL) {
         CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorDefault,
                                                   cflocale,
-                                                  kCFNumberFormatterDecimalStyle);
+                                                  kCFNumberFormatterNoStyle);
         if (nf != NULL) {
             CFStringRef str = CFNumberFormatterCopyProperty(nf, type);
             if (str != NULL) {
@@ -651,21 +680,21 @@
     return ret;
 }
 
-static jchar getNumberSymbolChar(jchar jdefault, CFStringRef type) {
-    char buf[BUFLEN];
+static jchar getNumberSymbolChar(JNIEnv *env, jstring jlangtag, jchar jdefault, CFStringRef type) {
     jchar ret = jdefault;
     CFLocaleRef cflocale = CFLocaleCopyCurrent();
 
     if (cflocale != NULL) {
         CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorDefault,
                                                   cflocale,
-                                                  kCFNumberFormatterDecimalStyle);
+                                                  kCFNumberFormatterNoStyle);
         if (nf != NULL) {
             CFStringRef str = CFNumberFormatterCopyProperty(nf, type);
             if (str != NULL) {
-                CFStringGetCString(str, buf, BUFLEN, kCFStringEncodingUTF8);
+                if (CFStringGetLength(str) > 0) {
+                    ret = CFStringGetCharacterAtIndex(str, 0);
+                }
                 CFRelease(str);
-                ret = buf[0];
             }
 
             CFRelease(nf);
--- a/jdk/src/share/back/export/sys.h	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/back/export/sys.h	Wed Jul 05 18:50:02 2017 +0200
@@ -37,7 +37,7 @@
 
 /* Implemented in linker_md.c */
 
-void    dbgsysBuildLibName(char *, int, char *, char *);
+void    dbgsysBuildLibName(char *, int, const char *, const char *);
 void *  dbgsysLoadLibrary(const char *, char *err_buf, int err_buflen);
 void    dbgsysUnloadLibrary(void *);
 void *  dbgsysFindLibraryEntry(void *, const char *);
--- a/jdk/src/share/back/transport.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/back/transport.c	Wed Jul 05 18:50:02 2017 +0200
@@ -97,12 +97,12 @@
 
 /* Load transport library (directory=="" means do system search) */
 static void *
-loadTransportLibrary(char *libdir, char *name)
+loadTransportLibrary(const char *libdir, const char *name)
 {
     void *handle;
     char libname[MAXPATHLEN+2];
     char buf[MAXPATHLEN*2+100];
-    char *plibdir;
+    const char *plibdir;
 
     /* Convert libdir from UTF-8 to platform encoding */
     plibdir = NULL;
@@ -131,12 +131,12 @@
  * JDK 1.2 javai.c v1.61
  */
 static jdwpError
-loadTransport(char *name, jdwpTransportEnv **transportPtr)
+loadTransport(const char *name, jdwpTransportEnv **transportPtr)
 {
     JNIEnv                 *env;
     jdwpTransport_OnLoad_t  onLoad;
     void                   *handle;
-    char                   *libdir;
+    const char             *libdir;
 
     /* Make sure library name is not empty */
     if (name == NULL) {
--- a/jdk/src/share/classes/com/sun/crypto/provider/GaloisCounterMode.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/com/sun/crypto/provider/GaloisCounterMode.java	Wed Jul 05 18:50:02 2017 +0200
@@ -6,7 +6,7 @@
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this
  * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.S
+ * by Oracle in the LICENSE file that accompanied this code.
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
--- a/jdk/src/share/classes/java/awt/Adjustable.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/Adjustable.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 
 import java.awt.event.*;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * The interface for objects which have an adjustable numeric value
@@ -36,24 +36,22 @@
  * @author Amy Fowler
  * @author Tim Prinzing
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public interface Adjustable {
 
     /**
      * Indicates that the <code>Adjustable</code> has horizontal orientation.
      */
-    public static final int HORIZONTAL = 0;
+    @Native public static final int HORIZONTAL = 0;
 
     /**
      * Indicates that the <code>Adjustable</code> has vertical orientation.
      */
-    public static final int VERTICAL = 1;
+    @Native public static final int VERTICAL = 1;
 
     /**
      * Indicates that the <code>Adjustable</code> has no orientation.
      */
-    public static final int NO_ORIENTATION = 2;
+    @Native public static final int NO_ORIENTATION = 2;
 
     /**
      * Gets the orientation of the adjustable object.
--- a/jdk/src/share/classes/java/awt/AlphaComposite.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/AlphaComposite.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +26,7 @@
 package java.awt;
 
 import java.awt.image.ColorModel;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 import sun.java2d.SunCompositeContext;
 
 /**
@@ -350,8 +350,6 @@
  * @see CompositeContext
  */
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public final class AlphaComposite implements Composite {
     /**
      * Both the color and the alpha of the destination are cleared
@@ -364,7 +362,7 @@
      *  <em>C<sub>r</sub></em> = 0
      *</pre>
      */
-    public static final int     CLEAR           = 1;
+    @Native public static final int     CLEAR           = 1;
 
     /**
      * The source is copied to the destination
@@ -377,7 +375,7 @@
      *  <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em>
      *</pre>
      */
-    public static final int     SRC             = 2;
+    @Native public static final int     SRC             = 2;
 
     /**
      * The destination is left untouched
@@ -390,7 +388,7 @@
      *</pre>
      * @since 1.4
      */
-    public static final int     DST             = 9;
+    @Native public static final int     DST             = 9;
     // Note that DST was added in 1.4 so it is numbered out of order...
 
     /**
@@ -403,7 +401,7 @@
      *  <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em> + <em>C<sub>d</sub></em>*(1-<em>A<sub>s</sub></em>)
      *</pre>
      */
-    public static final int     SRC_OVER        = 3;
+    @Native public static final int     SRC_OVER        = 3;
 
     /**
      * The destination is composited over the source and
@@ -416,7 +414,7 @@
      *  <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em>*(1-<em>A<sub>d</sub></em>) + <em>C<sub>d</sub></em>
      *</pre>
      */
-    public static final int     DST_OVER        = 4;
+    @Native public static final int     DST_OVER        = 4;
 
     /**
      * The part of the source lying inside of the destination replaces
@@ -429,7 +427,7 @@
      *  <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em>*<em>A<sub>d</sub></em>
      *</pre>
      */
-    public static final int     SRC_IN          = 5;
+    @Native public static final int     SRC_IN          = 5;
 
     /**
      * The part of the destination lying inside of the source
@@ -442,7 +440,7 @@
      *  <em>C<sub>r</sub></em> = <em>C<sub>d</sub></em>*<em>A<sub>s</sub></em>
      *</pre>
      */
-    public static final int     DST_IN          = 6;
+    @Native public static final int     DST_IN          = 6;
 
     /**
      * The part of the source lying outside of the destination
@@ -455,7 +453,7 @@
      *  <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em>*(1-<em>A<sub>d</sub></em>)
      *</pre>
      */
-    public static final int     SRC_OUT         = 7;
+    @Native public static final int     SRC_OUT         = 7;
 
     /**
      * The part of the destination lying outside of the source
@@ -468,7 +466,7 @@
      *  <em>C<sub>r</sub></em> = <em>C<sub>d</sub></em>*(1-<em>A<sub>s</sub></em>)
      *</pre>
      */
-    public static final int     DST_OUT         = 8;
+    @Native public static final int     DST_OUT         = 8;
 
     // Rule 9 is DST which is defined above where it fits into the
     // list logically, rather than numerically
@@ -487,7 +485,7 @@
      *</pre>
      * @since 1.4
      */
-    public static final int     SRC_ATOP        = 10;
+    @Native public static final int     SRC_ATOP        = 10;
 
     /**
      * The part of the destination lying inside of the source
@@ -501,7 +499,7 @@
      *</pre>
      * @since 1.4
      */
-    public static final int     DST_ATOP        = 11;
+    @Native public static final int     DST_ATOP        = 11;
 
     /**
      * The part of the source that lies outside of the destination
@@ -516,7 +514,7 @@
      *</pre>
      * @since 1.4
      */
-    public static final int     XOR             = 12;
+    @Native public static final int     XOR             = 12;
 
     /**
      * <code>AlphaComposite</code> object that implements the opaque CLEAR rule
@@ -606,8 +604,8 @@
      */
     public static final AlphaComposite Xor      = new AlphaComposite(XOR);
 
-    private static final int MIN_RULE = CLEAR;
-    private static final int MAX_RULE = XOR;
+    @Native private static final int MIN_RULE = CLEAR;
+    @Native private static final int MAX_RULE = XOR;
 
     float extraAlpha;
     int rule;
--- a/jdk/src/share/classes/java/awt/BasicStroke.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/BasicStroke.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 
 import java.beans.ConstructorProperties;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * The <code>BasicStroke</code> class defines a basic set of rendering
@@ -111,47 +111,45 @@
  * @see Graphics2D
  * @author Jim Graham
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class BasicStroke implements Stroke {
 
     /**
      * Joins path segments by extending their outside edges until
      * they meet.
      */
-    public final static int JOIN_MITER = 0;
+    @Native public final static int JOIN_MITER = 0;
 
     /**
      * Joins path segments by rounding off the corner at a radius
      * of half the line width.
      */
-    public final static int JOIN_ROUND = 1;
+    @Native public final static int JOIN_ROUND = 1;
 
     /**
      * Joins path segments by connecting the outer corners of their
      * wide outlines with a straight segment.
      */
-    public final static int JOIN_BEVEL = 2;
+    @Native public final static int JOIN_BEVEL = 2;
 
     /**
      * Ends unclosed subpaths and dash segments with no added
      * decoration.
      */
-    public final static int CAP_BUTT = 0;
+    @Native public final static int CAP_BUTT = 0;
 
     /**
      * Ends unclosed subpaths and dash segments with a round
      * decoration that has a radius equal to half of the width
      * of the pen.
      */
-    public final static int CAP_ROUND = 1;
+    @Native public final static int CAP_ROUND = 1;
 
     /**
      * Ends unclosed subpaths and dash segments with a square
      * projection that extends beyond the end of the segment
      * to a distance equal to half of the line width.
      */
-    public final static int CAP_SQUARE = 2;
+    @Native public final static int CAP_SQUARE = 2;
 
     float width;
 
--- a/jdk/src/share/classes/java/awt/Choice.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/Choice.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +34,6 @@
 
 import javax.accessibility.*;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * The <code>Choice</code> class presents a pop-up menu of choices.
@@ -71,8 +70,6 @@
  * @author      Arthur van Hoff
  * @since       JDK1.0
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class Choice extends Component implements ItemSelectable, Accessible {
     /**
      * The items for the <code>Choice</code>.
--- a/jdk/src/share/classes/java/awt/DisplayMode.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/DisplayMode.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 package java.awt;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * The <code>DisplayMode</code> class encapsulates the bit depth, height,
@@ -46,8 +46,6 @@
  * @since 1.4
  */
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public final class DisplayMode {
 
     private Dimension size;
@@ -94,7 +92,7 @@
      * display mode.
      * @see #getBitDepth
      */
-    public final static int BIT_DEPTH_MULTI = -1;
+    @Native public final static int BIT_DEPTH_MULTI = -1;
 
     /**
      * Returns the bit depth of the display, in bits per pixel.  This may be
@@ -112,7 +110,7 @@
      * Value of the refresh rate if not known.
      * @see #getRefreshRate
      */
-    public final static int REFRESH_RATE_UNKNOWN = 0;
+    @Native public final static int REFRESH_RATE_UNKNOWN = 0;
 
     /**
      * Returns the refresh rate of the display, in hertz.  This may be
--- a/jdk/src/share/classes/java/awt/Image.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/Image.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +33,6 @@
 
 import sun.awt.image.SurfaceManager;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * The abstract class <code>Image</code> is the superclass of all
@@ -44,8 +43,6 @@
  * @author      Arthur van Hoff
  * @since       JDK1.0
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class Image {
 
     /**
--- a/jdk/src/share/classes/java/awt/List.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/List.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +33,6 @@
 import java.io.ObjectInputStream;
 import java.io.IOException;
 import javax.accessibility.*;
-import javax.tools.annotation.GenerateNativeHeader;
 
 
 /**
@@ -107,8 +106,6 @@
  * @see         java.awt.event.ActionListener
  * @since       JDK1.0
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class List extends Component implements ItemSelectable, Accessible {
     /**
      * A vector created to contain items which will become
--- a/jdk/src/share/classes/java/awt/PopupMenu.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/PopupMenu.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +28,6 @@
 import java.awt.peer.PopupMenuPeer;
 import javax.accessibility.*;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 import sun.awt.AWTAccessor;
 
@@ -44,8 +43,6 @@
  *
  * @author      Amy Fowler
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class PopupMenu extends Menu {
 
     private static final String base = "popup";
--- a/jdk/src/share/classes/java/awt/SystemColor.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/SystemColor.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +26,7 @@
 
 import java.io.ObjectStreamException;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * A class to encapsulate symbolic colors representing the color of
@@ -49,8 +49,6 @@
  * @author      Carl Quinn
  * @author      Amy Fowler
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public final class SystemColor extends Color implements java.io.Serializable {
 
    /**
@@ -58,187 +56,187 @@
      * {@link #desktop} system color.
      * @see SystemColor#desktop
      */
-    public final static int DESKTOP = 0;
+    @Native public final static int DESKTOP = 0;
 
     /**
      * The array index for the
      * {@link #activeCaption} system color.
      * @see SystemColor#activeCaption
      */
-    public final static int ACTIVE_CAPTION = 1;
+    @Native public final static int ACTIVE_CAPTION = 1;
 
     /**
      * The array index for the
      * {@link #activeCaptionText} system color.
      * @see SystemColor#activeCaptionText
      */
-    public final static int ACTIVE_CAPTION_TEXT = 2;
+    @Native public final static int ACTIVE_CAPTION_TEXT = 2;
 
     /**
      * The array index for the
      * {@link #activeCaptionBorder} system color.
      * @see SystemColor#activeCaptionBorder
      */
-    public final static int ACTIVE_CAPTION_BORDER = 3;
+    @Native public final static int ACTIVE_CAPTION_BORDER = 3;
 
     /**
      * The array index for the
      * {@link #inactiveCaption} system color.
      * @see SystemColor#inactiveCaption
      */
-    public final static int INACTIVE_CAPTION = 4;
+    @Native public final static int INACTIVE_CAPTION = 4;
 
     /**
      * The array index for the
      * {@link #inactiveCaptionText} system color.
      * @see SystemColor#inactiveCaptionText
      */
-    public final static int INACTIVE_CAPTION_TEXT = 5;
+    @Native public final static int INACTIVE_CAPTION_TEXT = 5;
 
     /**
      * The array index for the
      * {@link #inactiveCaptionBorder} system color.
      * @see SystemColor#inactiveCaptionBorder
      */
-    public final static int INACTIVE_CAPTION_BORDER = 6;
+    @Native public final static int INACTIVE_CAPTION_BORDER = 6;
 
     /**
      * The array index for the
      * {@link #window} system color.
      * @see SystemColor#window
      */
-    public final static int WINDOW = 7;
+    @Native public final static int WINDOW = 7;
 
     /**
      * The array index for the
      * {@link #windowBorder} system color.
      * @see SystemColor#windowBorder
      */
-    public final static int WINDOW_BORDER = 8;
+    @Native public final static int WINDOW_BORDER = 8;
 
     /**
      * The array index for the
      * {@link #windowText} system color.
      * @see SystemColor#windowText
      */
-    public final static int WINDOW_TEXT = 9;
+    @Native public final static int WINDOW_TEXT = 9;
 
     /**
      * The array index for the
      * {@link #menu} system color.
      * @see SystemColor#menu
      */
-    public final static int MENU = 10;
+    @Native public final static int MENU = 10;
 
     /**
      * The array index for the
      * {@link #menuText} system color.
      * @see SystemColor#menuText
      */
-    public final static int MENU_TEXT = 11;
+    @Native public final static int MENU_TEXT = 11;
 
     /**
      * The array index for the
      * {@link #text} system color.
      * @see SystemColor#text
      */
-    public final static int TEXT = 12;
+    @Native public final static int TEXT = 12;
 
     /**
      * The array index for the
      * {@link #textText} system color.
      * @see SystemColor#textText
      */
-    public final static int TEXT_TEXT = 13;
+    @Native public final static int TEXT_TEXT = 13;
 
     /**
      * The array index for the
      * {@link #textHighlight} system color.
      * @see SystemColor#textHighlight
      */
-    public final static int TEXT_HIGHLIGHT = 14;
+    @Native public final static int TEXT_HIGHLIGHT = 14;
 
     /**
      * The array index for the
      * {@link #textHighlightText} system color.
      * @see SystemColor#textHighlightText
      */
-    public final static int TEXT_HIGHLIGHT_TEXT = 15;
+    @Native public final static int TEXT_HIGHLIGHT_TEXT = 15;
 
     /**
      * The array index for the
      * {@link #textInactiveText} system color.
      * @see SystemColor#textInactiveText
      */
-    public final static int TEXT_INACTIVE_TEXT = 16;
+    @Native public final static int TEXT_INACTIVE_TEXT = 16;
 
     /**
      * The array index for the
      * {@link #control} system color.
      * @see SystemColor#control
      */
-    public final static int CONTROL = 17;
+    @Native public final static int CONTROL = 17;
 
     /**
      * The array index for the
      * {@link #controlText} system color.
      * @see SystemColor#controlText
      */
-    public final static int CONTROL_TEXT = 18;
+    @Native public final static int CONTROL_TEXT = 18;
 
     /**
      * The array index for the
      * {@link #controlHighlight} system color.
      * @see SystemColor#controlHighlight
      */
-    public final static int CONTROL_HIGHLIGHT = 19;
+    @Native public final static int CONTROL_HIGHLIGHT = 19;
 
     /**
      * The array index for the
      * {@link #controlLtHighlight} system color.
      * @see SystemColor#controlLtHighlight
      */
-    public final static int CONTROL_LT_HIGHLIGHT = 20;
+    @Native public final static int CONTROL_LT_HIGHLIGHT = 20;
 
     /**
      * The array index for the
      * {@link #controlShadow} system color.
      * @see SystemColor#controlShadow
      */
-    public final static int CONTROL_SHADOW = 21;
+    @Native public final static int CONTROL_SHADOW = 21;
 
     /**
      * The array index for the
      * {@link #controlDkShadow} system color.
      * @see SystemColor#controlDkShadow
      */
-    public final static int CONTROL_DK_SHADOW = 22;
+    @Native public final static int CONTROL_DK_SHADOW = 22;
 
     /**
      * The array index for the
      * {@link #scrollbar} system color.
      * @see SystemColor#scrollbar
      */
-    public final static int SCROLLBAR = 23;
+    @Native public final static int SCROLLBAR = 23;
 
     /**
      * The array index for the
      * {@link #info} system color.
      * @see SystemColor#info
      */
-    public final static int INFO = 24;
+    @Native public final static int INFO = 24;
 
     /**
      * The array index for the
      * {@link #infoText} system color.
      * @see SystemColor#infoText
      */
-    public final static int INFO_TEXT = 25;
+    @Native public final static int INFO_TEXT = 25;
 
     /**
      * The number of system colors in the array.
      */
-    public final static int NUM_COLORS = 26;
+    @Native public final static int NUM_COLORS = 26;
 
     /******************************************************************************************/
 
--- a/jdk/src/share/classes/java/awt/TextComponent.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/TextComponent.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
 import javax.swing.text.AttributeSet;
 import javax.accessibility.*;
 import java.awt.im.InputMethodRequests;
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * The <code>TextComponent</code> class is the superclass of
@@ -57,8 +56,6 @@
  * @author      Arthur van Hoff
  * @since       JDK1.0
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class TextComponent extends Component implements Accessible {
 
     /**
--- a/jdk/src/share/classes/java/awt/Transparency.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/Transparency.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,34 +25,32 @@
 
 package java.awt;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * The <code>Transparency</code> interface defines the common transparency
  * modes for implementing classes.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public interface Transparency {
 
     /**
      * Represents image data that is guaranteed to be completely opaque,
      * meaning that all pixels have an alpha value of 1.0.
      */
-    public final static int OPAQUE            = 1;
+    @Native public final static int OPAQUE            = 1;
 
     /**
      * Represents image data that is guaranteed to be either completely
      * opaque, with an alpha value of 1.0, or completely transparent,
      * with an alpha value of 0.0.
      */
-    public final static int BITMASK = 2;
+    @Native public final static int BITMASK = 2;
 
     /**
      * Represents image data that contains or might contain arbitrary
      * alpha values between and including 0.0 and 1.0.
      */
-    public final static int TRANSLUCENT        = 3;
+    @Native public final static int TRANSLUCENT        = 3;
 
     /**
      * Returns the type of this <code>Transparency</code>.
--- a/jdk/src/share/classes/java/awt/color/ColorSpace.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/color/ColorSpace.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 
 package java.awt.color;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 import sun.java2d.cmm.PCMM;
 import sun.java2d.cmm.CMSManager;
@@ -95,8 +95,6 @@
  * @see ICC_ColorSpace
  */
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class ColorSpace implements java.io.Serializable {
 
     static final long serialVersionUID = -409452704308689724L;
@@ -115,127 +113,127 @@
     /**
      * Any of the family of XYZ color spaces.
      */
-    public static final int TYPE_XYZ = 0;
+    @Native public static final int TYPE_XYZ = 0;
 
     /**
      * Any of the family of Lab color spaces.
      */
-    public static final int TYPE_Lab = 1;
+    @Native public static final int TYPE_Lab = 1;
 
     /**
      * Any of the family of Luv color spaces.
      */
-    public static final int TYPE_Luv = 2;
+    @Native public static final int TYPE_Luv = 2;
 
     /**
      * Any of the family of YCbCr color spaces.
      */
-    public static final int TYPE_YCbCr = 3;
+    @Native public static final int TYPE_YCbCr = 3;
 
     /**
      * Any of the family of Yxy color spaces.
      */
-    public static final int TYPE_Yxy = 4;
+    @Native public static final int TYPE_Yxy = 4;
 
     /**
      * Any of the family of RGB color spaces.
      */
-    public static final int TYPE_RGB = 5;
+    @Native public static final int TYPE_RGB = 5;
 
     /**
      * Any of the family of GRAY color spaces.
      */
-    public static final int TYPE_GRAY = 6;
+    @Native public static final int TYPE_GRAY = 6;
 
     /**
      * Any of the family of HSV color spaces.
      */
-    public static final int TYPE_HSV = 7;
+    @Native public static final int TYPE_HSV = 7;
 
     /**
      * Any of the family of HLS color spaces.
      */
-    public static final int TYPE_HLS = 8;
+    @Native public static final int TYPE_HLS = 8;
 
     /**
      * Any of the family of CMYK color spaces.
      */
-    public static final int TYPE_CMYK = 9;
+    @Native public static final int TYPE_CMYK = 9;
 
     /**
      * Any of the family of CMY color spaces.
      */
-    public static final int TYPE_CMY = 11;
+    @Native public static final int TYPE_CMY = 11;
 
     /**
      * Generic 2 component color spaces.
      */
-    public static final int TYPE_2CLR = 12;
+    @Native public static final int TYPE_2CLR = 12;
 
     /**
      * Generic 3 component color spaces.
      */
-    public static final int TYPE_3CLR = 13;
+    @Native public static final int TYPE_3CLR = 13;
 
     /**
      * Generic 4 component color spaces.
      */
-    public static final int TYPE_4CLR = 14;
+    @Native public static final int TYPE_4CLR = 14;
 
     /**
      * Generic 5 component color spaces.
      */
-    public static final int TYPE_5CLR = 15;
+    @Native public static final int TYPE_5CLR = 15;
 
     /**
      * Generic 6 component color spaces.
      */
-    public static final int TYPE_6CLR = 16;
+    @Native public static final int TYPE_6CLR = 16;
 
     /**
      * Generic 7 component color spaces.
      */
-    public static final int TYPE_7CLR = 17;
+    @Native public static final int TYPE_7CLR = 17;
 
     /**
      * Generic 8 component color spaces.
      */
-    public static final int TYPE_8CLR = 18;
+    @Native public static final int TYPE_8CLR = 18;
 
     /**
      * Generic 9 component color spaces.
      */
-    public static final int TYPE_9CLR = 19;
+    @Native public static final int TYPE_9CLR = 19;
 
     /**
      * Generic 10 component color spaces.
      */
-    public static final int TYPE_ACLR = 20;
+    @Native public static final int TYPE_ACLR = 20;
 
     /**
      * Generic 11 component color spaces.
      */
-    public static final int TYPE_BCLR = 21;
+    @Native public static final int TYPE_BCLR = 21;
 
     /**
      * Generic 12 component color spaces.
      */
-    public static final int TYPE_CCLR = 22;
+    @Native public static final int TYPE_CCLR = 22;
 
     /**
      * Generic 13 component color spaces.
      */
-    public static final int TYPE_DCLR = 23;
+    @Native public static final int TYPE_DCLR = 23;
 
     /**
      * Generic 14 component color spaces.
      */
-    public static final int TYPE_ECLR = 24;
+    @Native public static final int TYPE_ECLR = 24;
 
     /**
      * Generic 15 component color spaces.
      */
-    public static final int TYPE_FCLR = 25;
+    @Native public static final int TYPE_FCLR = 25;
 
     /**
      * The sRGB color space defined at
@@ -243,28 +241,28 @@
      * http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html
      * </A>.
      */
-    public static final int CS_sRGB = 1000;
+    @Native public static final int CS_sRGB = 1000;
 
     /**
      * A built-in linear RGB color space.  This space is based on the
      * same RGB primaries as CS_sRGB, but has a linear tone reproduction curve.
      */
-    public static final int CS_LINEAR_RGB = 1004;
+    @Native public static final int CS_LINEAR_RGB = 1004;
 
     /**
      * The CIEXYZ conversion color space defined above.
      */
-    public static final int CS_CIEXYZ = 1001;
+    @Native public static final int CS_CIEXYZ = 1001;
 
     /**
      * The Photo YCC conversion color space.
      */
-    public static final int CS_PYCC = 1002;
+    @Native public static final int CS_PYCC = 1002;
 
     /**
      * The built-in linear gray scale color space.
      */
-    public static final int CS_GRAY = 1003;
+    @Native public static final int CS_GRAY = 1003;
 
 
     /**
--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,6 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * A representation of color profile data for device independent and
@@ -90,8 +89,6 @@
  */
 
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class ICC_Profile implements Serializable {
 
     private static final long serialVersionUID = -3938515861990936766L;
--- a/jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java	Wed Jul 05 18:50:02 2017 +0200
@@ -25,7 +25,6 @@
 
 package java.awt.datatransfer;
 
-import java.awt.Toolkit;
 import java.io.*;
 import java.nio.*;
 import java.util.*;
@@ -162,6 +161,18 @@
         }
     }
 
+    /*
+     * private initializer
+     */
+    static private DataFlavor initHtmlDataFlavor(String htmlFlavorType) {
+        try {
+            return new DataFlavor ("text/html; class=java.lang.String;document=" +
+                                       htmlFlavorType + ";charset=Unicode");
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
     /**
      * The <code>DataFlavor</code> representing a Java Unicode String class,
      * where:
@@ -246,6 +257,46 @@
     public static final String javaRemoteObjectMimeType = "application/x-java-remote-object";
 
     /**
+     * Represents a piece of an HTML markup. The markup consists of the part
+     * selected on the source side. Therefore some tags in the markup may be
+     * unpaired. If the flavor is used to represent the data in
+     * a {@link Transferable} instance, no additional changes will be made.
+     * This DataFlavor instance represents the same HTML markup as DataFlavor
+     * instances which content MIME type does not contain document parameter
+     * and representation class is the String class.
+     * <pre>
+     *     representationClass = String
+     *     mimeType           = "text/html"
+     * </pre>
+     */
+    public static DataFlavor selectionHtmlFlavor = initHtmlDataFlavor("selection");
+
+    /**
+     * Represents a piece of an HTML markup. If possible, the markup received
+     * from a native system is supplemented with pair tags to be
+     * a well-formed HTML markup. If the flavor is used to represent the data in
+     * a {@link Transferable} instance, no additional changes will be made.
+     * <pre>
+     *     representationClass = String
+     *     mimeType           = "text/html"
+     * </pre>
+     */
+    public static DataFlavor fragmentHtmlFlavor = initHtmlDataFlavor("fragment");
+
+    /**
+     * Represents a piece of an HTML markup. If possible, the markup
+     * received from a native system is supplemented with additional
+     * tags to make up a well-formed HTML document. If the flavor is used to
+     * represent the data in a {@link Transferable} instance,
+     * no additional changes will be made.
+     * <pre>
+     *     representationClass = String
+     *     mimeType           = "text/html"
+     * </pre>
+     */
+    public static  DataFlavor allHtmlFlavor = initHtmlDataFlavor("all");
+
+    /**
      * Constructs a new <code>DataFlavor</code>.  This constructor is
      * provided only for the purpose of supporting the
      * <code>Externalizable</code> interface.  It is not
@@ -949,24 +1000,35 @@
                 return false;
             }
 
-            if ("text".equals(getPrimaryType()) &&
-                DataTransferer.doesSubtypeSupportCharset(this) &&
-                representationClass != null &&
-                !(isRepresentationClassReader() ||
-                  String.class.equals(representationClass) ||
-                  isRepresentationClassCharBuffer() ||
-                  DataTransferer.charArrayClass.equals(representationClass)))
-            {
-                String thisCharset =
-                    DataTransferer.canonicalName(getParameter("charset"));
-                String thatCharset =
-                    DataTransferer.canonicalName(that.getParameter("charset"));
-                if (thisCharset == null) {
-                    if (thatCharset != null) {
-                        return false;
+            if ("text".equals(getPrimaryType())) {
+                if (DataTransferer.doesSubtypeSupportCharset(this) &&
+                    representationClass != null &&
+                    !(isRepresentationClassReader() ||
+                        String.class.equals(representationClass) ||
+                        isRepresentationClassCharBuffer() ||
+                        DataTransferer.charArrayClass.equals(representationClass)))
+                {
+                    String thisCharset =
+                        DataTransferer.canonicalName(getParameter("charset"));
+                    String thatCharset =
+                        DataTransferer.canonicalName(that.getParameter("charset"));
+                    if (thisCharset == null) {
+                        if (thatCharset != null) {
+                            return false;
+                        }
+                    } else {
+                        if (!thisCharset.equals(thatCharset)) {
+                            return false;
+                        }
                     }
-                } else {
-                    if (!thisCharset.equals(thatCharset)) {
+                }
+
+                if ("html".equals(getSubType()) &&
+                        this.getParameter("document") != null )
+                {
+                   if (!this.getParameter("document").
+                            equals(that.getParameter("document")))
+                    {
                         return false;
                     }
                 }
--- a/jdk/src/share/classes/java/awt/datatransfer/StringSelection.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/datatransfer/StringSelection.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 import java.io.*;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * A <code>Transferable</code> which implements the capability required
@@ -43,8 +42,6 @@
  * @see java.awt.datatransfer.DataFlavor#stringFlavor
  * @see java.awt.datatransfer.DataFlavor#plainTextFlavor
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class StringSelection implements Transferable, ClipboardOwner {
 
     private static final int STRING = 0;
--- a/jdk/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java	Wed Jul 05 18:50:02 2017 +0200
@@ -41,7 +41,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -101,6 +101,11 @@
     private static final String TEXT_PLAIN_BASE_TYPE = "text/plain";
 
     /**
+     * A String representing text/html MIME type.
+     */
+    private static final String HTML_TEXT_BASE_TYPE = "text/html";
+
+    /**
      * This constant is passed to flavorToNativeLookup() to indicate that a
      * a native should be synthesized, stored, and returned by encoding the
      * DataFlavor's MIME type in case if the DataFlavor is not found in
@@ -113,7 +118,7 @@
      * text DataFlavors).
      * Do not use the field directly, use getNativeToFlavor() instead.
      */
-    private Map nativeToFlavor = new HashMap();
+    private final Map<String, List<DataFlavor>> nativeToFlavor = new HashMap<>();
 
     /**
      * Accessor to nativeToFlavor map.  Since we use lazy initialization we must
@@ -122,7 +127,7 @@
      *
      * @return nativeToFlavor
      */
-    private Map getNativeToFlavor() {
+    private Map<String, List<DataFlavor>> getNativeToFlavor() {
         if (!isMapInitialized) {
             initSystemFlavorMap();
         }
@@ -134,7 +139,7 @@
      * native Strings.
      * Do not use the field directly, use getFlavorToNative() instead.
      */
-    private Map flavorToNative = new HashMap();
+    private final Map flavorToNative = new HashMap();
 
     /**
      * Accessor to flavorToNative map.  Since we use lazy initialization we must
@@ -421,14 +426,17 @@
                         }
                     }
 
-                    // For text/* flavors, store mappings in separate maps to
-                    // enable dynamic mapping generation at a run-time.
+                    final LinkedHashSet<DataFlavor> dfs = new LinkedHashSet<>();
+
+                    dfs.add(flavor);
+
                     if ("text".equals(flavor.getPrimaryType())) {
-                        store(value, key, getFlavorToNative());
-                        store(key, value, getNativeToFlavor());
-                    } else {
-                        store(flavor, key, getFlavorToNative());
-                        store(key, flavor, getNativeToFlavor());
+                        dfs.addAll(convertMimeTypeToDataFlavors(value));
+                    }
+
+                    for (DataFlavor df : dfs) {
+                        store(df, key, getFlavorToNative());
+                        store(key, df, getNativeToFlavor());
                     }
                 }
             }
@@ -530,7 +538,7 @@
      * only if the specified native is encoded as a Java MIME type.
      */
     private List nativeToFlavorLookup(String nat) {
-        List flavors = (List)getNativeToFlavor().get(nat);
+        List<DataFlavor> flavors = getNativeToFlavor().get(nat);
 
         if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
             DataTransferer transferer = DataTransferer.getInstance();
@@ -625,7 +633,7 @@
                 getNativesForFlavorCache.remove(flav);
                 getNativesForFlavorCache.remove(null);
 
-                List flavors = (List)getNativeToFlavor().get(encoded);
+                List<DataFlavor> flavors = getNativeToFlavor().get(encoded);
                 if (flavors == null) {
                     flavors = new ArrayList(1);
                     getNativeToFlavor().put(encoded, flavors);
@@ -681,7 +689,7 @@
         }
 
         if (flav == null) {
-            retval = new ArrayList(getNativeToFlavor().keySet());
+            retval = new ArrayList<String>(getNativeToFlavor().keySet());
         } else if (disabledMappingGenerationKeys.contains(flav)) {
             // In this case we shouldn't synthesize a native for this flavor,
             // since its mappings were explicitly specified.
@@ -809,140 +817,162 @@
             }
         }
 
-        LinkedList retval = new LinkedList();
+        final LinkedHashSet <DataFlavor> returnValue =
+            new LinkedHashSet<>();
 
         if (nat == null) {
-            List natives = getNativesForFlavor(null);
-            HashSet dups = new HashSet(natives.size());
+            final List<String> natives = getNativesForFlavor(null);
 
-            for (Iterator natives_iter = natives.iterator();
-                 natives_iter.hasNext(); )
+            for (String n : natives)
             {
-                List flavors =
-                    getFlavorsForNative((String)natives_iter.next());
-                for (Iterator flavors_iter = flavors.iterator();
-                     flavors_iter.hasNext(); )
+                final List<DataFlavor> flavors = getFlavorsForNative(n);
+
+                for (DataFlavor df : flavors)
                 {
-                    Object flavor = flavors_iter.next();
-                    if (dups.add(flavor)) {
-                        retval.add(flavor);
-                    }
+                    returnValue.add(df);
                 }
             }
         } else {
-            List flavors = nativeToFlavorLookup(nat);
+
+            final List<DataFlavor> flavors = nativeToFlavorLookup(nat);
 
             if (disabledMappingGenerationKeys.contains(nat)) {
                 return flavors;
             }
 
-            HashSet dups = new HashSet(flavors.size());
-
-            List flavorsAndbaseTypes = nativeToFlavorLookup(nat);
-
-            for (Iterator flavorsAndbaseTypes_iter =
-                     flavorsAndbaseTypes.iterator();
-                 flavorsAndbaseTypes_iter.hasNext(); )
-            {
-                Object value = flavorsAndbaseTypes_iter.next();
-                if (value instanceof String) {
-                    String baseType = (String)value;
-                    String subType = null;
-                    try {
-                        MimeType mimeType = new MimeType(baseType);
-                        subType = mimeType.getSubType();
-                    } catch (MimeTypeParseException mtpe) {
-                        // Cannot happen, since we checked all mappings
-                        // on load from flavormap.properties.
-                        assert(false);
-                    }
-                    if (DataTransferer.doesSubtypeSupportCharset(subType,
-                                                                 null)) {
-                        if (TEXT_PLAIN_BASE_TYPE.equals(baseType) &&
-                            dups.add(DataFlavor.stringFlavor))
-                        {
-                            retval.add(DataFlavor.stringFlavor);
-                        }
-
-                        for (int i = 0; i < UNICODE_TEXT_CLASSES.length; i++) {
-                            DataFlavor toAdd = null;
-                            try {
-                                toAdd = new DataFlavor
-                                    (baseType + ";charset=Unicode;class=" +
-                                     UNICODE_TEXT_CLASSES[i]);
-                            } catch (ClassNotFoundException cannotHappen) {
-                            }
-                            if (dups.add(toAdd)) {
-                                retval.add(toAdd);
-                            }
-                        }
-
-                        for (Iterator charset_iter =
-                                 DataTransferer.standardEncodings();
-                             charset_iter.hasNext(); )
-                        {
-                            String charset = (String)charset_iter.next();
+            final List<DataFlavor> flavorsAndBaseTypes =
+                nativeToFlavorLookup(nat);
 
-                            for (int i = 0; i < ENCODED_TEXT_CLASSES.length;
-                                 i++)
-                            {
-                                DataFlavor toAdd = null;
-                                try {
-                                    toAdd = new DataFlavor
-                                        (baseType + ";charset=" + charset +
-                                         ";class=" + ENCODED_TEXT_CLASSES[i]);
-                                } catch (ClassNotFoundException cannotHappen) {
-                                }
-
-                                // Check for equality to plainTextFlavor so
-                                // that we can ensure that the exact charset of
-                                // plainTextFlavor, not the canonical charset
-                                // or another equivalent charset with a
-                                // different name, is used.
-                                if (toAdd.equals(DataFlavor.plainTextFlavor)) {
-                                    toAdd = DataFlavor.plainTextFlavor;
-                                }
-
-                                if (dups.add(toAdd)) {
-                                    retval.add(toAdd);
-                                }
-                            }
-                        }
-
-                        if (TEXT_PLAIN_BASE_TYPE.equals(baseType) &&
-                            dups.add(DataFlavor.plainTextFlavor))
-                        {
-                            retval.add(DataFlavor.plainTextFlavor);
-                        }
-                    } else {
-                        // Non-charset text natives should be treated as
-                        // opaque, 8-bit data in any of its various
-                        // representations.
-                        for (int i = 0; i < ENCODED_TEXT_CLASSES.length; i++) {
-                            DataFlavor toAdd = null;
-                            try {
-                                toAdd = new DataFlavor(baseType +
-                                     ";class=" + ENCODED_TEXT_CLASSES[i]);
-                            } catch (ClassNotFoundException cannotHappen) {
-                            }
-
-                            if (dups.add(toAdd)) {
-                                retval.add(toAdd);
-                            }
-                        }
-                    }
-                } else {
-                    DataFlavor flavor = (DataFlavor)value;
-                    if (dups.add(flavor)) {
-                        retval.add(flavor);
+            for (DataFlavor df : flavorsAndBaseTypes) {
+                returnValue.add(df);
+                if ("text".equals(df.getPrimaryType())) {
+                    try {
+                        returnValue.addAll(
+                                convertMimeTypeToDataFlavors(
+                                        new MimeType(df.getMimeType()
+                                        ).getBaseType()));
+                    } catch (MimeTypeParseException e) {
+                        e.printStackTrace();
                     }
                 }
             }
+
+        }
+
+        final ArrayList arrayList = new ArrayList(returnValue);
+        getFlavorsForNativeCache.put(nat, new SoftReference(arrayList));
+        return (List)arrayList.clone();
+    }
+
+    private static LinkedHashSet<DataFlavor> convertMimeTypeToDataFlavors(
+        final String baseType) {
+
+        final LinkedHashSet<DataFlavor> returnValue =
+            new LinkedHashSet<DataFlavor>();
+
+        String subType = null;
+
+        try {
+            final MimeType mimeType = new MimeType(baseType);
+            subType = mimeType.getSubType();
+        } catch (MimeTypeParseException mtpe) {
+            // Cannot happen, since we checked all mappings
+            // on load from flavormap.properties.
+            assert(false);
         }
 
-        ArrayList arrayList = new ArrayList(retval);
-        getFlavorsForNativeCache.put(nat, new SoftReference(arrayList));
-        return (List)arrayList.clone();
+        if (DataTransferer.doesSubtypeSupportCharset(subType, null)) {
+            if (TEXT_PLAIN_BASE_TYPE.equals(baseType))
+            {
+                returnValue.add(DataFlavor.stringFlavor);
+            }
+
+            for (String unicodeClassName : UNICODE_TEXT_CLASSES) {
+                final String mimeType = baseType + ";charset=Unicode;class=" +
+                                            unicodeClassName;
+
+                final LinkedHashSet<String> mimeTypes =
+                    handleHtmlMimeTypes(baseType, mimeType);
+                for (String mt : mimeTypes) {
+                    DataFlavor toAdd = null;
+                    try {
+                        toAdd = new DataFlavor(mt);
+                    } catch (ClassNotFoundException cannotHappen) {
+                    }
+                    returnValue.add(toAdd);
+                }
+            }
+
+            for (String charset : DataTransferer.standardEncodings()) {
+
+                for (String encodedTextClass : ENCODED_TEXT_CLASSES) {
+                    final String mimeType =
+                            baseType + ";charset=" + charset +
+                            ";class=" + encodedTextClass;
+
+                    final LinkedHashSet<String> mimeTypes =
+                        handleHtmlMimeTypes(baseType, mimeType);
+
+                    for (String mt : mimeTypes) {
+
+                        DataFlavor df = null;
+
+                        try {
+                            df = new DataFlavor(mt);
+                            // Check for equality to plainTextFlavor so
+                            // that we can ensure that the exact charset of
+                            // plainTextFlavor, not the canonical charset
+                            // or another equivalent charset with a
+                            // different name, is used.
+                            if (df.equals(DataFlavor.plainTextFlavor)) {
+                                df = DataFlavor.plainTextFlavor;
+                            }
+                        } catch (ClassNotFoundException cannotHappen) {
+                        }
+
+                        returnValue.add(df);
+                    }
+                }
+            }
+
+            if (TEXT_PLAIN_BASE_TYPE.equals(baseType))
+            {
+                returnValue.add(DataFlavor.plainTextFlavor);
+            }
+        } else {
+            // Non-charset text natives should be treated as
+            // opaque, 8-bit data in any of its various
+            // representations.
+            for (String encodedTextClassName : ENCODED_TEXT_CLASSES) {
+                DataFlavor toAdd = null;
+                try {
+                    toAdd = new DataFlavor(baseType +
+                         ";class=" + encodedTextClassName);
+                } catch (ClassNotFoundException cannotHappen) {
+                }
+                returnValue.add(toAdd);
+            }
+        }
+        return returnValue;
+    }
+
+    private static final String [] htmlDocumntTypes =
+        new String [] {"all", "selection", "fragment"};
+
+    private static LinkedHashSet<String> handleHtmlMimeTypes(
+        String baseType, String mimeType) {
+
+        LinkedHashSet<String> returnValues = new LinkedHashSet<>();
+
+        if (HTML_TEXT_BASE_TYPE.equals(baseType)) {
+            for (String documentType : htmlDocumntTypes) {
+                returnValues.add(mimeType + ";document=" + documentType);
+            }
+        } else {
+            returnValues.add(mimeType);
+        }
+
+        return returnValues;
     }
 
     /**
--- a/jdk/src/share/classes/java/awt/dnd/DnDConstants.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/dnd/DnDConstants.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,15 +25,13 @@
 
 package java.awt.dnd;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * This class contains constant values representing
  * the type of action(s) to be performed by a Drag and Drop operation.
  * @since 1.2
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public final class DnDConstants {
 
     private DnDConstants() {} // define null private constructor.
@@ -41,23 +39,23 @@
     /**
      * An <code>int</code> representing no action.
      */
-    public static final int ACTION_NONE         = 0x0;
+    @Native public static final int ACTION_NONE         = 0x0;
 
     /**
      * An <code>int</code> representing a &quot;copy&quot; action.
      */
-    public static final int ACTION_COPY         = 0x1;
+    @Native public static final int ACTION_COPY         = 0x1;
 
     /**
      * An <code>int</code> representing a &quot;move&quot; action.
      */
-    public static final int ACTION_MOVE         = 0x2;
+    @Native public static final int ACTION_MOVE         = 0x2;
 
     /**
      * An <code>int</code> representing a &quot;copy&quot; or
      * &quot;move&quot; action.
      */
-    public static final int ACTION_COPY_OR_MOVE = ACTION_COPY | ACTION_MOVE;
+    @Native public static final int ACTION_COPY_OR_MOVE = ACTION_COPY | ACTION_MOVE;
 
     /**
      * An <code>int</code> representing a &quot;link&quot; action.
@@ -75,12 +73,12 @@
      * results for the user.
      */
 
-    public static final int ACTION_LINK         = 0x40000000;
+    @Native public static final int ACTION_LINK         = 0x40000000;
 
     /**
      * An <code>int</code> representing a &quot;reference&quot;
      * action (synonym for ACTION_LINK).
      */
-    public static final int ACTION_REFERENCE    = ACTION_LINK;
+    @Native public static final int ACTION_REFERENCE    = ACTION_LINK;
 
 }
--- a/jdk/src/share/classes/java/awt/dnd/InvalidDnDOperationException.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/dnd/InvalidDnDOperationException.java	Wed Jul 05 18:50:02 2017 +0200
@@ -36,7 +36,7 @@
 
 public class InvalidDnDOperationException extends IllegalStateException {
 
-    private static final long serialVersionUID = 5156676500247816278L;
+    private static final long serialVersionUID = -6062568741193956678L;
 
     static private String dft_msg = "The operation requested cannot be performed by the DnD system since it is not in the appropriate state";
 
--- a/jdk/src/share/classes/java/awt/event/ActionEvent.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/event/ActionEvent.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 
 import java.awt.AWTEvent;
 import java.awt.Event;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * A semantic event which indicates that a component-defined action occurred.
@@ -57,8 +57,6 @@
  * @author Carl Quinn
  * @since 1.1
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class ActionEvent extends AWTEvent {
 
     /**
@@ -99,7 +97,7 @@
     /**
      * This event id indicates that a meaningful action occured.
      */
-    public static final int ACTION_PERFORMED    = ACTION_FIRST; //Event.ACTION_EVENT
+    @Native public static final int ACTION_PERFORMED    = ACTION_FIRST; //Event.ACTION_EVENT
 
     /**
      * The nonlocalized string that gives more details
--- a/jdk/src/share/classes/java/awt/event/AdjustmentEvent.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/event/AdjustmentEvent.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,9 +27,8 @@
 
 import java.awt.Adjustable;
 import java.awt.AWTEvent;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * The adjustment event emitted by Adjustable objects like
@@ -57,8 +56,6 @@
  * @author Amy Fowler
  * @since 1.1
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class AdjustmentEvent extends AWTEvent {
 
     /**
@@ -79,27 +76,27 @@
     /**
      * The unit increment adjustment type.
      */
-    public static final int UNIT_INCREMENT      = 1;
+    @Native public static final int UNIT_INCREMENT      = 1;
 
     /**
      * The unit decrement adjustment type.
      */
-    public static final int UNIT_DECREMENT      = 2;
+    @Native public static final int UNIT_DECREMENT      = 2;
 
     /**
      * The block decrement adjustment type.
      */
-    public static final int BLOCK_DECREMENT     = 3;
+    @Native public static final int BLOCK_DECREMENT     = 3;
 
     /**
      * The block increment adjustment type.
      */
-    public static final int BLOCK_INCREMENT     = 4;
+    @Native public static final int BLOCK_INCREMENT     = 4;
 
     /**
      * The absolute tracking adjustment type.
      */
-    public static final int TRACK               = 5;
+    @Native public static final int TRACK               = 5;
 
     /**
      * The adjustable object that fired the event.
--- a/jdk/src/share/classes/java/awt/event/ComponentEvent.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/event/ComponentEvent.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +28,7 @@
 import java.awt.AWTEvent;
 import java.awt.Component;
 import java.awt.Rectangle;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * A low-level event which indicates that a component moved, changed
@@ -65,8 +65,6 @@
  * @author Carl Quinn
  * @since 1.1
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class ComponentEvent extends AWTEvent {
 
     /**
@@ -82,22 +80,22 @@
    /**
      * This event indicates that the component's position changed.
      */
-    public static final int COMPONENT_MOVED     = COMPONENT_FIRST;
+    @Native public static final int COMPONENT_MOVED     = COMPONENT_FIRST;
 
     /**
      * This event indicates that the component's size changed.
      */
-    public static final int COMPONENT_RESIZED   = 1 + COMPONENT_FIRST;
+    @Native public static final int COMPONENT_RESIZED   = 1 + COMPONENT_FIRST;
 
     /**
      * This event indicates that the component was made visible.
      */
-    public static final int COMPONENT_SHOWN     = 2 + COMPONENT_FIRST;
+    @Native public static final int COMPONENT_SHOWN     = 2 + COMPONENT_FIRST;
 
     /**
      * This event indicates that the component was rendered invisible.
      */
-    public static final int COMPONENT_HIDDEN    = 3 + COMPONENT_FIRST;
+    @Native public static final int COMPONENT_HIDDEN    = 3 + COMPONENT_FIRST;
 
     /*
      * JDK 1.1 serialVersionUID
--- a/jdk/src/share/classes/java/awt/event/FocusEvent.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/event/FocusEvent.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +26,6 @@
 package java.awt.event;
 
 import java.awt.Component;
-import javax.tools.annotation.GenerateNativeHeader;
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
 
@@ -64,8 +63,6 @@
  * @author Amy Fowler
  * @since 1.1
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class FocusEvent extends ComponentEvent {
 
     /**
--- a/jdk/src/share/classes/java/awt/event/InputMethodEvent.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/event/InputMethodEvent.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +33,7 @@
 import java.io.ObjectInputStream;
 import java.text.AttributedCharacterIterator;
 import java.text.CharacterIterator;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * Input method events contain information about text that is being
@@ -56,8 +56,6 @@
  * @author JavaSoft Asia/Pacific
  * @since 1.2
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class InputMethodEvent extends AWTEvent {
 
     /**
@@ -68,25 +66,25 @@
     /**
      * Marks the first integer id for the range of input method event ids.
      */
-    public static final int INPUT_METHOD_FIRST = 1100;
+    @Native public static final int INPUT_METHOD_FIRST = 1100;
 
     /**
      * The event type indicating changed input method text. This event is
      * generated by input methods while processing input.
      */
-    public static final int INPUT_METHOD_TEXT_CHANGED = INPUT_METHOD_FIRST;
+    @Native public static final int INPUT_METHOD_TEXT_CHANGED = INPUT_METHOD_FIRST;
 
     /**
      * The event type indicating a changed insertion point in input method text.
      * This event is
      * generated by input methods while processing input if only the caret changed.
      */
-    public static final int CARET_POSITION_CHANGED = INPUT_METHOD_FIRST + 1;
+    @Native public static final int CARET_POSITION_CHANGED = INPUT_METHOD_FIRST + 1;
 
     /**
      * Marks the last integer id for the range of input method event ids.
      */
-    public static final int INPUT_METHOD_LAST = INPUT_METHOD_FIRST + 1;
+    @Native public static final int INPUT_METHOD_LAST = INPUT_METHOD_FIRST + 1;
 
     /**
      * The time stamp that indicates when the event was created.
--- a/jdk/src/share/classes/java/awt/event/MouseWheelEvent.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/event/MouseWheelEvent.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 
 import java.awt.Component;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * An event which indicates that the mouse wheel was rotated in a component.
@@ -99,8 +99,6 @@
  * @since 1.4
  */
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class MouseWheelEvent extends MouseEvent {
 
     /**
@@ -109,7 +107,7 @@
      *
      * @see #getScrollType
      */
-    public static final int WHEEL_UNIT_SCROLL = 0;
+    @Native public static final int WHEEL_UNIT_SCROLL = 0;
 
     /**
      * Constant representing scrolling by a "block" (like scrolling
@@ -117,7 +115,7 @@
      *
      * @see #getScrollType
      */
-    public static final int WHEEL_BLOCK_SCROLL = 1;
+    @Native public static final int WHEEL_BLOCK_SCROLL = 1;
 
     /**
      * Indicates what sort of scrolling should take place in response to this
--- a/jdk/src/share/classes/java/awt/event/WindowEvent.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/event/WindowEvent.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +26,7 @@
 package java.awt.event;
 
 import java.awt.Window;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
 
@@ -56,8 +56,6 @@
  *
  * @since JDK1.1
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class WindowEvent extends ComponentEvent {
 
     /**
@@ -69,7 +67,7 @@
      * The window opened event.  This event is delivered only
      * the first time a window is made visible.
      */
-    public static final int WINDOW_OPENED       = WINDOW_FIRST; // 200
+    @Native public static final int WINDOW_OPENED       = WINDOW_FIRST; // 200
 
     /**
      * The "window is closing" event. This event is delivered when
@@ -78,13 +76,13 @@
      * while processing this event, the window close operation will be
      * cancelled.
      */
-    public static final int WINDOW_CLOSING      = 1 + WINDOW_FIRST; //Event.WINDOW_DESTROY
+    @Native public static final int WINDOW_CLOSING      = 1 + WINDOW_FIRST; //Event.WINDOW_DESTROY
 
     /**
      * The window closed event. This event is delivered after
      * the window has been closed as the result of a call to dispose.
      */
-    public static final int WINDOW_CLOSED       = 2 + WINDOW_FIRST;
+    @Native public static final int WINDOW_CLOSED       = 2 + WINDOW_FIRST;
 
     /**
      * The window iconified event. This event is delivered when
@@ -93,13 +91,13 @@
      * the icon specified in the window's iconImage property.
      * @see java.awt.Frame#setIconImage
      */
-    public static final int WINDOW_ICONIFIED    = 3 + WINDOW_FIRST; //Event.WINDOW_ICONIFY
+    @Native public static final int WINDOW_ICONIFIED    = 3 + WINDOW_FIRST; //Event.WINDOW_ICONIFY
 
     /**
      * The window deiconified event type. This event is delivered when
      * the window has been changed from a minimized to a normal state.
      */
-    public static final int WINDOW_DEICONIFIED  = 4 + WINDOW_FIRST; //Event.WINDOW_DEICONIFY
+    @Native public static final int WINDOW_DEICONIFIED  = 4 + WINDOW_FIRST; //Event.WINDOW_DEICONIFY
 
     /**
      * The window-activated event type. This event is delivered when the Window
@@ -109,7 +107,7 @@
      * active Window is always either the focused Window, or the first Frame or
      * Dialog that is an owner of the focused Window.
      */
-    public static final int WINDOW_ACTIVATED    = 5 + WINDOW_FIRST;
+    @Native public static final int WINDOW_ACTIVATED    = 5 + WINDOW_FIRST;
 
     /**
      * The window-deactivated event type. This event is delivered when the
@@ -119,21 +117,21 @@
      * title bar. The active Window is always either the focused Window, or the
      * first Frame or Dialog that is an owner of the focused Window.
      */
-    public static final int WINDOW_DEACTIVATED  = 6 + WINDOW_FIRST;
+    @Native public static final int WINDOW_DEACTIVATED  = 6 + WINDOW_FIRST;
 
     /**
      * The window-gained-focus event type. This event is delivered when the
      * Window becomes the focused Window, which means that the Window, or one
      * of its subcomponents, will receive keyboard events.
      */
-    public static final int WINDOW_GAINED_FOCUS = 7 + WINDOW_FIRST;
+    @Native public static final int WINDOW_GAINED_FOCUS = 7 + WINDOW_FIRST;
 
     /**
      * The window-lost-focus event type. This event is delivered when a Window
      * is no longer the focused Window, which means keyboard events will no
      * longer be delivered to the Window or any of its subcomponents.
      */
-    public static final int WINDOW_LOST_FOCUS   = 8 + WINDOW_FIRST;
+    @Native public static final int WINDOW_LOST_FOCUS   = 8 + WINDOW_FIRST;
 
     /**
      * The window-state-changed event type.  This event is delivered
@@ -141,7 +139,7 @@
      * iconified, maximized etc.
      * @since 1.4
      */
-    public static final int WINDOW_STATE_CHANGED = 9 + WINDOW_FIRST;
+    @Native public static final int WINDOW_STATE_CHANGED = 9 + WINDOW_FIRST;
 
     /**
      * The last number in the range of ids used for window events.
--- a/jdk/src/share/classes/java/awt/geom/PathIterator.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/geom/PathIterator.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 package java.awt.geom;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * The <code>PathIterator</code> interface provides the mechanism
@@ -59,8 +59,6 @@
  *
  * @author Jim Graham
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public interface PathIterator {
     /**
      * The winding rule constant for specifying an even-odd rule
@@ -69,7 +67,7 @@
      * path if a ray drawn in any direction from that point to
      * infinity is crossed by path segments an odd number of times.
      */
-    public static final int WIND_EVEN_ODD       = 0;
+    @Native public static final int WIND_EVEN_ODD       = 0;
 
     /**
      * The winding rule constant for specifying a non-zero rule
@@ -80,20 +78,20 @@
      * of times in the counter-clockwise direction than the
      * clockwise direction.
      */
-    public static final int WIND_NON_ZERO       = 1;
+    @Native public static final int WIND_NON_ZERO       = 1;
 
     /**
      * The segment type constant for a point that specifies the
      * starting location for a new subpath.
      */
-    public static final int SEG_MOVETO          = 0;
+    @Native public static final int SEG_MOVETO          = 0;
 
     /**
      * The segment type constant for a point that specifies the
      * end point of a line to be drawn from the most recently
      * specified point.
      */
-    public static final int SEG_LINETO          = 1;
+    @Native public static final int SEG_LINETO          = 1;
 
     /**
      * The segment type constant for the pair of points that specify
@@ -115,7 +113,7 @@
      *               = n! / (m! * (n-m)!)
      * </pre>
      */
-    public static final int SEG_QUADTO          = 2;
+    @Native public static final int SEG_QUADTO          = 2;
 
     /**
      * The segment type constant for the set of 3 points that specify
@@ -139,14 +137,14 @@
      * </pre>
      * This form of curve is commonly known as a B&eacute;zier curve.
      */
-    public static final int SEG_CUBICTO         = 3;
+    @Native public static final int SEG_CUBICTO         = 3;
 
     /**
      * The segment type constant that specifies that
      * the preceding subpath should be closed by appending a line segment
      * back to the point corresponding to the most recent SEG_MOVETO.
      */
-    public static final int SEG_CLOSE           = 4;
+    @Native public static final int SEG_CLOSE           = 4;
 
     /**
      * Returns the winding rule for determining the interior of the
--- a/jdk/src/share/classes/java/awt/image/AffineTransformOp.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/image/AffineTransformOp.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +34,7 @@
 import java.awt.Rectangle;
 import java.awt.RenderingHints;
 import java.awt.Transparency;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 import sun.awt.image.ImagingLib;
 
 /**
@@ -63,8 +63,6 @@
  * @see java.awt.RenderingHints#KEY_COLOR_RENDERING
  * @see java.awt.RenderingHints#KEY_DITHERING
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class AffineTransformOp implements BufferedImageOp, RasterOp {
     private AffineTransform xform;
     RenderingHints hints;
@@ -72,17 +70,17 @@
     /**
      * Nearest-neighbor interpolation type.
      */
-    public static final int TYPE_NEAREST_NEIGHBOR = 1;
+    @Native public static final int TYPE_NEAREST_NEIGHBOR = 1;
 
     /**
      * Bilinear interpolation type.
      */
-    public static final int TYPE_BILINEAR = 2;
+    @Native public static final int TYPE_BILINEAR = 2;
 
     /**
      * Bicubic interpolation type.
      */
-    public static final int TYPE_BICUBIC = 3;
+    @Native public static final int TYPE_BICUBIC = 3;
 
     int interpolationType = TYPE_NEAREST_NEIGHBOR;
 
--- a/jdk/src/share/classes/java/awt/image/ConvolveOp.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/image/ConvolveOp.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 import java.awt.Rectangle;
 import java.awt.RenderingHints;
 import java.awt.geom.Point2D;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 import sun.awt.image.ImagingLib;
 
 /**
@@ -66,8 +66,6 @@
  * @see java.awt.RenderingHints#KEY_COLOR_RENDERING
  * @see java.awt.RenderingHints#KEY_DITHERING
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class ConvolveOp implements BufferedImageOp, RasterOp {
     Kernel kernel;
     int edgeHint;
@@ -81,13 +79,13 @@
      * is the default.
      */
 
-    public static final int EDGE_ZERO_FILL = 0;
+    @Native public static final int EDGE_ZERO_FILL = 0;
 
     /**
      * Pixels at the edge of the source image are copied to
      * the corresponding pixels in the destination without modification.
      */
-    public static final int EDGE_NO_OP     = 1;
+    @Native public static final int EDGE_NO_OP     = 1;
 
     /**
      * Constructs a ConvolveOp given a Kernel, an edge condition, and a
--- a/jdk/src/share/classes/java/awt/image/DataBuffer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/image/DataBuffer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
 
 import sun.awt.image.SunWritableRaster;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * This class exists to wrap one or more data arrays.  Each data array in
@@ -67,30 +67,28 @@
  * @see java.awt.image.Raster
  * @see java.awt.image.SampleModel
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class DataBuffer {
 
     /** Tag for unsigned byte data. */
-    public static final int TYPE_BYTE  = 0;
+    @Native public static final int TYPE_BYTE  = 0;
 
     /** Tag for unsigned short data. */
-    public static final int TYPE_USHORT = 1;
+    @Native public static final int TYPE_USHORT = 1;
 
     /** Tag for signed short data.  Placeholder for future use. */
-    public static final int TYPE_SHORT = 2;
+    @Native public static final int TYPE_SHORT = 2;
 
     /** Tag for int data. */
-    public static final int TYPE_INT   = 3;
+    @Native public static final int TYPE_INT   = 3;
 
     /** Tag for float data.  Placeholder for future use. */
-    public static final int TYPE_FLOAT  = 4;
+    @Native public static final int TYPE_FLOAT  = 4;
 
     /** Tag for double data.  Placeholder for future use. */
-    public static final int TYPE_DOUBLE  = 5;
+    @Native public static final int TYPE_DOUBLE  = 5;
 
     /** Tag for undefined data. */
-    public static final int TYPE_UNDEFINED = 32;
+    @Native public static final int TYPE_UNDEFINED = 32;
 
     /** The data type of this DataBuffer. */
     protected int dataType;
--- a/jdk/src/share/classes/java/awt/image/ImageConsumer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/image/ImageConsumer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 import java.util.Hashtable;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * The interface for objects expressing interest in image data through
@@ -39,8 +38,6 @@
  *
  * @author      Jim Graham
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public interface ImageConsumer {
     /**
      * The dimensions of the source image are reported using the
--- a/jdk/src/share/classes/java/awt/image/ImageObserver.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/image/ImageObserver.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 import java.awt.Image;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * An asynchronous update interface for receiving notifications about
@@ -35,8 +34,6 @@
  *
  * @author      Jim Graham
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public interface ImageObserver {
     /**
      * This method is called when information about an image which was
--- a/jdk/src/share/classes/java/awt/peer/ComponentPeer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/peer/ComponentPeer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
 import java.awt.image.ColorModel;
 import java.awt.image.VolatileImage;
 import java.awt.GraphicsConfiguration;
-import javax.tools.annotation.GenerateNativeHeader;
 import sun.awt.CausedFocusEvent;
 import sun.java2d.pipe.Region;
 
@@ -50,8 +49,6 @@
  * nor invoke any of the peer methods directly on the peer
  * instances.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public interface ComponentPeer {
 
     /**
--- a/jdk/src/share/classes/java/awt/print/PageFormat.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/print/PageFormat.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,14 +29,12 @@
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * The <code>PageFormat</code> class describes the size and
  * orientation of a page to be printed.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class PageFormat implements Cloneable
 {
 
@@ -48,21 +46,21 @@
      *  Note that this is not the Macintosh landscape but
      *  is the Window's and PostScript landscape.
      */
-    public static final int LANDSCAPE = 0;
+    @Native public static final int LANDSCAPE = 0;
 
     /**
      *  The origin is at the top left of the paper with
      *  x running to the right and y running down the
      *  paper.
      */
-    public static final int PORTRAIT = 1;
+    @Native public static final int PORTRAIT = 1;
 
     /**
      *  The origin is at the top right of the paper with x
      *  running top to bottom and y running right to left.
      *  Note that this is the Macintosh landscape.
      */
-    public static final int REVERSE_LANDSCAPE = 2;
+    @Native public static final int REVERSE_LANDSCAPE = 2;
 
  /* Instance Variables */
 
--- a/jdk/src/share/classes/java/awt/print/Pageable.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/print/Pageable.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 package java.awt.print;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * The <code>Pageable</code> implementation represents a set of
@@ -35,8 +35,6 @@
  * @see java.awt.print.PageFormat
  * @see java.awt.print.Printable
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public interface Pageable {
 
     /**
@@ -45,7 +43,7 @@
      * method if a <code>Pageable</code> implementation does not know
      * the number of pages in its set.
      */
-    int UNKNOWN_NUMBER_OF_PAGES = -1;
+    @Native int UNKNOWN_NUMBER_OF_PAGES = -1;
 
     /**
      * Returns the number of pages in the set.
--- a/jdk/src/share/classes/java/awt/print/Printable.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/awt/print/Printable.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 import java.awt.Graphics;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * The <code>Printable</code> interface is implemented
@@ -100,8 +99,6 @@
  * @see java.awt.print.PageFormat
  * @see java.awt.print.PrinterJob
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public interface Printable {
 
     /**
--- a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java	Wed Jul 05 18:50:02 2017 +0200
@@ -236,7 +236,7 @@
         if ((index < 0) || (index >= count)) {
             throw new StringIndexOutOfBoundsException(index);
         }
-        return Character.codePointAt(value, index);
+        return Character.codePointAtImpl(value, index, count);
     }
 
     /**
@@ -265,7 +265,7 @@
         if ((i < 0) || (i >= count)) {
             throw new StringIndexOutOfBoundsException(index);
         }
-        return Character.codePointBefore(value, index);
+        return Character.codePointBeforeImpl(value, index, 0);
     }
 
     /**
@@ -415,7 +415,8 @@
      * @return  a reference to this object.
      */
     public AbstractStringBuilder append(String str) {
-        if (str == null) str = "null";
+        if (str == null)
+            return appendNull();
         int len = str.length();
         ensureCapacityInternal(count + len);
         str.getChars(0, len, value, count);
@@ -426,7 +427,7 @@
     // Documentation in subclasses because of synchro difference
     public AbstractStringBuilder append(StringBuffer sb) {
         if (sb == null)
-            return append("null");
+            return appendNull();
         int len = sb.length();
         ensureCapacityInternal(count + len);
         sb.getChars(0, len, value, count);
@@ -439,7 +440,7 @@
      */
     AbstractStringBuilder append(AbstractStringBuilder asb) {
         if (asb == null)
-            return append("null");
+            return appendNull();
         int len = asb.length();
         ensureCapacityInternal(count + len);
         asb.getChars(0, len, value, count);
@@ -451,7 +452,7 @@
     @Override
     public AbstractStringBuilder append(CharSequence s) {
         if (s == null)
-            s = "null";
+            return appendNull();
         if (s instanceof String)
             return this.append((String)s);
         if (s instanceof AbstractStringBuilder)
@@ -460,6 +461,18 @@
         return this.append(s, 0, s.length());
     }
 
+    private AbstractStringBuilder appendNull() {
+        int c = count;
+        ensureCapacityInternal(c + 4);
+        final char[] value = this.value;
+        value[c++] = 'n';
+        value[c++] = 'u';
+        value[c++] = 'l';
+        value[c++] = 'l';
+        count = c;
+        return this;
+    }
+
     /**
      * Appends a subsequence of the specified {@code CharSequence} to this
      * sequence.
@@ -1370,32 +1383,37 @@
      * @return  a reference to this object.
      */
     public AbstractStringBuilder reverse() {
-        boolean hasSurrogate = false;
+        boolean hasSurrogates = false;
         int n = count - 1;
-        for (int j = (n-1) >> 1; j >= 0; --j) {
-            char temp = value[j];
-            char temp2 = value[n - j];
-            if (!hasSurrogate) {
-                hasSurrogate = (temp >= Character.MIN_SURROGATE && temp <= Character.MAX_SURROGATE)
-                    || (temp2 >= Character.MIN_SURROGATE && temp2 <= Character.MAX_SURROGATE);
+        for (int j = (n-1) >> 1; j >= 0; j--) {
+            int k = n - j;
+            char cj = value[j];
+            char ck = value[k];
+            value[j] = ck;
+            value[k] = cj;
+            if (Character.isSurrogate(cj) ||
+                Character.isSurrogate(ck)) {
+                hasSurrogates = true;
             }
-            value[j] = temp2;
-            value[n - j] = temp;
+        }
+        if (hasSurrogates) {
+            reverseAllValidSurrogatePairs();
         }
-        if (hasSurrogate) {
-            // Reverse back all valid surrogate pairs
-            for (int i = 0; i < count - 1; i++) {
-                char c2 = value[i];
-                if (Character.isLowSurrogate(c2)) {
-                    char c1 = value[i + 1];
-                    if (Character.isHighSurrogate(c1)) {
-                        value[i++] = c1;
-                        value[i] = c2;
-                    }
+        return this;
+    }
+
+    /** Outlined helper method for reverse() */
+    private void reverseAllValidSurrogatePairs() {
+        for (int i = 0; i < count - 1; i++) {
+            char c2 = value[i];
+            if (Character.isLowSurrogate(c2)) {
+                char c1 = value[i + 1];
+                if (Character.isHighSurrogate(c1)) {
+                    value[i++] = c1;
+                    value[i] = c2;
                 }
             }
         }
-        return this;
     }
 
     /**
--- a/jdk/src/share/classes/java/lang/Character.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/lang/Character.java	Wed Jul 05 18:50:02 2017 +0200
@@ -4862,13 +4862,11 @@
      * @since  1.5
      */
     public static int codePointAt(CharSequence seq, int index) {
-        char c1 = seq.charAt(index++);
-        if (isHighSurrogate(c1)) {
-            if (index < seq.length()) {
-                char c2 = seq.charAt(index);
-                if (isLowSurrogate(c2)) {
-                    return toCodePoint(c1, c2);
-                }
+        char c1 = seq.charAt(index);
+        if (isHighSurrogate(c1) && ++index < seq.length()) {
+            char c2 = seq.charAt(index);
+            if (isLowSurrogate(c2)) {
+                return toCodePoint(c1, c2);
             }
         }
         return c1;
@@ -4931,15 +4929,13 @@
         return codePointAtImpl(a, index, limit);
     }
 
-    // throws ArrayIndexOutofBoundsException if index out of bounds
+    // throws ArrayIndexOutOfBoundsException if index out of bounds
     static int codePointAtImpl(char[] a, int index, int limit) {
-        char c1 = a[index++];
-        if (isHighSurrogate(c1)) {
-            if (index < limit) {
-                char c2 = a[index];
-                if (isLowSurrogate(c2)) {
-                    return toCodePoint(c1, c2);
-                }
+        char c1 = a[index];
+        if (isHighSurrogate(c1) && ++index < limit) {
+            char c2 = a[index];
+            if (isLowSurrogate(c2)) {
+                return toCodePoint(c1, c2);
             }
         }
         return c1;
@@ -4968,12 +4964,10 @@
      */
     public static int codePointBefore(CharSequence seq, int index) {
         char c2 = seq.charAt(--index);
-        if (isLowSurrogate(c2)) {
-            if (index > 0) {
-                char c1 = seq.charAt(--index);
-                if (isHighSurrogate(c1)) {
-                    return toCodePoint(c1, c2);
-                }
+        if (isLowSurrogate(c2) && index > 0) {
+            char c1 = seq.charAt(--index);
+            if (isHighSurrogate(c1)) {
+                return toCodePoint(c1, c2);
             }
         }
         return c2;
@@ -5038,15 +5032,13 @@
         return codePointBeforeImpl(a, index, start);
     }
 
-    // throws ArrayIndexOutofBoundsException if index-1 out of bounds
+    // throws ArrayIndexOutOfBoundsException if index-1 out of bounds
     static int codePointBeforeImpl(char[] a, int index, int start) {
         char c2 = a[--index];
-        if (isLowSurrogate(c2)) {
-            if (index > start) {
-                char c1 = a[--index];
-                if (isHighSurrogate(c1)) {
-                    return toCodePoint(c1, c2);
-                }
+        if (isLowSurrogate(c2) && index > start) {
+            char c1 = a[--index];
+            if (isHighSurrogate(c1)) {
+                return toCodePoint(c1, c2);
             }
         }
         return c2;
--- a/jdk/src/share/classes/java/lang/Class.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/lang/Class.java	Wed Jul 05 18:50:02 2017 +0200
@@ -113,8 +113,7 @@
  * @see     java.lang.ClassLoader#defineClass(byte[], int, int)
  * @since   JDK1.0
  */
-public final
-    class Class<T> implements java.io.Serializable,
+public final class Class<T> implements java.io.Serializable,
                               java.lang.reflect.GenericDeclaration,
                               java.lang.reflect.Type,
                               java.lang.reflect.AnnotatedElement {
@@ -150,6 +149,75 @@
             + getName();
     }
 
+    /**
+     * Returns a string describing this {@code Class}, including
+     * information about modifiers and type parameters.
+     *
+     * The string is formatted as a list of type modifiers, if any,
+     * followed by the kind of type (empty string for primitive types
+     * and {@code class}, {@code enum}, {@code interface}, or {@code
+     * &#64;interface}, as appropriate), followed by the type's name,
+     * followed by an angle-bracketed comma-separated list of the
+     * type's type parameters, if any.
+     *
+     * A space is used to separate modifiers from one another and to
+     * separate any modifiers from the kind of type. The modifiers
+     * occur in canonical order. If there are no type parameters, the
+     * type parameter list is elided.
+     *
+     * <p>Note that since information about the runtime representation
+     * of a type is being generated, modifiers not present on the
+     * originating source code or illegal on the originating source
+     * code may be present.
+     *
+     * @return a string describing this {@code Class}, including
+     * information about modifiers and type parameters
+     *
+     * @since 1.8
+     */
+    public String toGenericString() {
+        if (isPrimitive()) {
+            return toString();
+        } else {
+            StringBuilder sb = new StringBuilder();
+
+            // Class modifiers are a superset of interface modifiers
+            int modifiers = getModifiers() & Modifier.classModifiers();
+            if (modifiers != 0) {
+                sb.append(Modifier.toString(modifiers));
+                sb.append(' ');
+            }
+
+            if (isAnnotation()) {
+                sb.append('@');
+            }
+            if (isInterface()) { // Note: all annotation types are interfaces
+                sb.append("interface");
+            } else {
+                if (isEnum())
+                    sb.append("enum");
+                else
+                    sb.append("class");
+            }
+            sb.append(' ');
+            sb.append(getName());
+
+            TypeVariable<?>[] typeparms = getTypeParameters();
+            if (typeparms.length > 0) {
+                boolean first = true;
+                sb.append('<');
+                for(TypeVariable<?> typeparm: typeparms) {
+                    if (!first)
+                        sb.append(',');
+                    sb.append(typeparm.getTypeName());
+                    first = false;
+                }
+                sb.append('>');
+            }
+
+            return sb.toString();
+        }
+    }
 
     /**
      * Returns the {@code Class} object associated with the class or
@@ -1164,6 +1232,32 @@
     }
 
     /**
+     * Return an informative string for the name of this type.
+     *
+     * @return an informative string for the name of this type
+     * @since 1.8
+     */
+    public String getTypeName() {
+        if (isArray()) {
+            try {
+                Class<?> cl = this;
+                int dimensions = 0;
+                while (cl.isArray()) {
+                    dimensions++;
+                    cl = cl.getComponentType();
+                }
+                StringBuilder sb = new StringBuilder();
+                sb.append(cl.getName());
+                for (int i = 0; i < dimensions; i++) {
+                    sb.append("[]");
+                }
+                return sb.toString();
+            } catch (Throwable e) { /*FALLTHRU*/ }
+        }
+        return getName();
+    }
+
+    /**
      * Character.isDigit answers {@code true} to some non-ascii
      * digits.  This one does not.
      */
--- a/jdk/src/share/classes/java/lang/reflect/Constructor.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/Constructor.java	Wed Jul 05 18:50:02 2017 +0200
@@ -284,16 +284,20 @@
      * modifiers {@code public}, {@code protected} or
      * {@code private}.  Only one of these may appear, or none if the
      * constructor has default (package) access.
+     *
+     * @return a string describing this {@code Constructor}
+     * @jls 8.8.3. Constructor Modifiers
      */
     public String toString() {
         return sharedToString(Modifier.constructorModifiers(),
+                              false,
                               parameterTypes,
                               exceptionTypes);
     }
 
     @Override
     void specificToStringHeader(StringBuilder sb) {
-        sb.append(Field.getTypeName(getDeclaringClass()));
+        sb.append(getDeclaringClass().getTypeName());
     }
 
     /**
@@ -328,10 +332,11 @@
      * include type parameters
      *
      * @since 1.5
+     * @jls 8.8.3. Constructor Modifiers
      */
     @Override
     public String toGenericString() {
-        return sharedToGenericString(Modifier.constructorModifiers());
+        return sharedToGenericString(Modifier.constructorModifiers(), false);
     }
 
     @Override
--- a/jdk/src/share/classes/java/lang/reflect/Executable.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/Executable.java	Wed Jul 05 18:50:02 2017 +0200
@@ -82,27 +82,38 @@
 
     void separateWithCommas(Class<?>[] types, StringBuilder sb) {
         for (int j = 0; j < types.length; j++) {
-            sb.append(Field.getTypeName(types[j]));
+            sb.append(types[j].getTypeName());
             if (j < (types.length - 1))
                 sb.append(",");
         }
 
     }
 
-    void printModifiersIfNonzero(StringBuilder sb, int mask) {
+    void printModifiersIfNonzero(StringBuilder sb, int mask, boolean isDefault) {
         int mod = getModifiers() & mask;
-        if (mod != 0) {
+
+        if (mod != 0 && !isDefault) {
             sb.append(Modifier.toString(mod)).append(' ');
+        } else {
+            int access_mod = mod & Modifier.ACCESS_MODIFIERS;
+            if (access_mod != 0)
+                sb.append(Modifier.toString(access_mod)).append(' ');
+            if (isDefault)
+                sb.append("default ");
+            mod = (mod & ~Modifier.ACCESS_MODIFIERS);
+            if (mod != 0)
+                sb.append(Modifier.toString(mod)).append(' ');
         }
     }
 
     String sharedToString(int modifierMask,
+                          boolean isDefault,
                           Class<?>[] parameterTypes,
                           Class<?>[] exceptionTypes) {
         try {
             StringBuilder sb = new StringBuilder();
 
-            printModifiersIfNonzero(sb, modifierMask);
+            printModifiersIfNonzero(sb, modifierMask, isDefault);
             specificToStringHeader(sb);
 
             sb.append('(');
@@ -124,11 +135,11 @@
      */
     abstract void specificToStringHeader(StringBuilder sb);
 
-    String sharedToGenericString(int modifierMask) {
+    String sharedToGenericString(int modifierMask, boolean isDefault) {
         try {
             StringBuilder sb = new StringBuilder();
 
-            printModifiersIfNonzero(sb, modifierMask);
+            printModifiersIfNonzero(sb, modifierMask, isDefault);
 
             TypeVariable<?>[] typeparms = getTypeParameters();
             if (typeparms.length > 0) {
@@ -150,9 +161,7 @@
             sb.append('(');
             Type[] params = getGenericParameterTypes();
             for (int j = 0; j < params.length; j++) {
-                String param = (params[j] instanceof Class)?
-                    Field.getTypeName((Class)params[j]):
-                    (params[j].toString());
+                String param = params[j].getTypeName();
                 if (isVarArgs() && (j == params.length - 1)) // replace T[] with T...
                     param = param.replaceFirst("\\[\\]$", "...");
                 sb.append(param);
--- a/jdk/src/share/classes/java/lang/reflect/Field.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/Field.java	Wed Jul 05 18:50:02 2017 +0200
@@ -288,12 +288,15 @@
      * {@code protected} or {@code private} first, and then other
      * modifiers in the following order: {@code static}, {@code final},
      * {@code transient}, {@code volatile}.
+     *
+     * @return a string describing this {@code Field}
+     * @jls 8.3.1 Field Modifiers
      */
     public String toString() {
         int mod = getModifiers();
         return (((mod == 0) ? "" : (Modifier.toString(mod) + " "))
-            + getTypeName(getType()) + " "
-            + getTypeName(getDeclaringClass()) + "."
+            + getType().getTypeName() + " "
+            + getDeclaringClass().getTypeName() + "."
             + getName());
     }
 
@@ -315,14 +318,14 @@
      * its generic type
      *
      * @since 1.5
+     * @jls 8.3.1 Field Modifiers
      */
     public String toGenericString() {
         int mod = getModifiers();
         Type fieldType = getGenericType();
         return (((mod == 0) ? "" : (Modifier.toString(mod) + " "))
-            +  ((fieldType instanceof Class) ?
-                getTypeName((Class)fieldType): fieldType.toString())+ " "
-            + getTypeName(getDeclaringClass()) + "."
+            + fieldType.getTypeName() + " "
+            + getDeclaringClass().getTypeName() + "."
             + getName());
     }
 
@@ -992,29 +995,6 @@
         }
     }
 
-    /*
-     * Utility routine to paper over array type names
-     */
-    static String getTypeName(Class<?> type) {
-        if (type.isArray()) {
-            try {
-                Class<?> cl = type;
-                int dimensions = 0;
-                while (cl.isArray()) {
-                    dimensions++;
-                    cl = cl.getComponentType();
-                }
-                StringBuffer sb = new StringBuffer();
-                sb.append(cl.getName());
-                for (int i = 0; i < dimensions; i++) {
-                    sb.append("[]");
-                }
-                return sb.toString();
-            } catch (Throwable e) { /*FALLTHRU*/ }
-        }
-        return type.getName();
-    }
-
     /**
      * @throws NullPointerException {@inheritDoc}
      * @since 1.5
--- a/jdk/src/share/classes/java/lang/reflect/Method.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/Method.java	Wed Jul 05 18:50:02 2017 +0200
@@ -342,19 +342,24 @@
      * specified by "The Java Language Specification".  This is
      * {@code public}, {@code protected} or {@code private} first,
      * and then other modifiers in the following order:
-     * {@code abstract}, {@code static}, {@code final},
+     * {@code abstract}, {@code default}, {@code static}, {@code final},
      * {@code synchronized}, {@code native}, {@code strictfp}.
+     *
+     * @return a string describing this {@code Method}
+     *
+     * @jls 8.4.3 Method Modifiers
      */
     public String toString() {
         return sharedToString(Modifier.methodModifiers(),
+                              isDefault(),
                               parameterTypes,
                               exceptionTypes);
     }
 
     @Override
     void specificToStringHeader(StringBuilder sb) {
-        sb.append(Field.getTypeName(getReturnType())).append(' ');
-        sb.append(Field.getTypeName(getDeclaringClass())).append('.');
+        sb.append(getReturnType().getTypeName()).append(' ');
+        sb.append(getDeclaringClass().getTypeName()).append('.');
         sb.append(getName());
     }
 
@@ -381,34 +386,32 @@
      * class name.  If the method is declared to throw exceptions, the
      * parameter list is followed by a space, followed by the word
      * throws followed by a comma-separated list of the generic thrown
-     * exception types.  If there are no type parameters, the type
-     * parameter list is elided.
+     * exception types.
      *
      * <p>The access modifiers are placed in canonical order as
      * specified by "The Java Language Specification".  This is
      * {@code public}, {@code protected} or {@code private} first,
      * and then other modifiers in the following order:
-     * {@code abstract}, {@code static}, {@code final},
+     * {@code abstract}, {@code default}, {@code static}, {@code final},
      * {@code synchronized}, {@code native}, {@code strictfp}.
      *
      * @return a string describing this {@code Method},
      * include type parameters
      *
      * @since 1.5
+     *
+     * @jls 8.4.3 Method Modifiers
      */
     @Override
     public String toGenericString() {
-        return sharedToGenericString(Modifier.methodModifiers());
+        return sharedToGenericString(Modifier.methodModifiers(), isDefault());
     }
 
     @Override
     void specificToGenericStringHeader(StringBuilder sb) {
         Type genRetType = getGenericReturnType();
-        sb.append( ((genRetType instanceof Class<?>)?
-                    Field.getTypeName((Class<?>)genRetType):genRetType.toString()))
-            .append(' ');
-
-        sb.append(Field.getTypeName(getDeclaringClass())).append('.');
+        sb.append(genRetType.getTypeName()).append(' ');
+        sb.append(getDeclaringClass().getTypeName()).append('.');
         sb.append(getName());
     }
 
--- a/jdk/src/share/classes/java/lang/reflect/Modifier.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/Modifier.java	Wed Jul 05 18:50:02 2017 +0200
@@ -43,8 +43,7 @@
  * @author Nakul Saraiya
  * @author Kenneth Russell
  */
-public
-class Modifier {
+public class Modifier {
 
     /*
      * Bootstrapping protocol between java.lang and java.lang.reflect
@@ -233,7 +232,7 @@
      * represented by {@code mod}
      */
     public static String toString(int mod) {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         int len;
 
         if ((mod & PUBLIC) != 0)        sb.append("public ");
@@ -390,6 +389,12 @@
         Modifier.VOLATILE;
 
     /**
+     *
+     */
+    static final int ACCESS_MODIFIERS =
+        Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
+
+    /**
      * Return an {@code int} value OR-ing together the source language
      * modifiers that can be applied to a class.
      * @return an {@code int} value OR-ing together the source language
--- a/jdk/src/share/classes/java/lang/reflect/Parameter.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/Parameter.java	Wed Jul 05 18:50:02 2017 +0200
@@ -110,21 +110,19 @@
     public String toString() {
         final StringBuilder sb = new StringBuilder();
         final Type type = getParameterizedType();
-        final String typename = (type instanceof Class)?
-            Field.getTypeName((Class)type):
-            (type.toString());
+        final String typename = type.getTypeName();
 
         sb.append(Modifier.toString(getModifiers()));
 
         if(0 != modifiers)
-            sb.append(" ");
+            sb.append(' ');
 
         if(isVarArgs())
             sb.append(typename.replaceFirst("\\[\\]$", "..."));
         else
             sb.append(typename);
 
-        sb.append(" ");
+        sb.append(' ');
         sb.append(getName());
 
         return sb.toString();
--- a/jdk/src/share/classes/java/lang/reflect/Type.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/Type.java	Wed Jul 05 18:50:02 2017 +0200
@@ -32,6 +32,17 @@
  *
  * @since 1.5
  */
-
 public interface Type {
+    /**
+     * Returns a string describing this type, including information
+     * about any type parameters.
+     *
+     * @implSpec The default implementation calls {@code toString}.
+     *
+     * @return a string describing this type
+     * @since 1.8
+     */
+    default String getTypeName() {
+        return toString();
+    }
 }
--- a/jdk/src/share/classes/java/util/Base64.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/util/Base64.java	Wed Jul 05 18:50:02 2017 +0200
@@ -620,7 +620,10 @@
      * required. So if the final unit of the encoded byte data only has
      * two or three Base64 characters (without the corresponding padding
      * character(s) padded), they are decoded as if followed by padding
-     * character(s).
+     * character(s). If there is padding character present in the
+     * final unit, the correct number of padding character(s) must be
+     * present, otherwise {@code IllegalArgumentException} is thrown
+     * during decoding.
      *
      * <p> Instances of {@link Decoder} class are safe for use by
      * multiple concurrent threads.
@@ -1034,23 +1037,26 @@
                 throw new IllegalArgumentException(
                     "Input byte[] should at least have 2 bytes for base64 bytes");
             }
-            if (src[sl - 1] == '=') {
-                paddings++;
-                if (src[sl - 2] == '=')
-                    paddings++;
-            }
             if (isMIME) {
                 // scan all bytes to fill out all non-alphabet. a performance
                 // trade-off of pre-scan or Arrays.copyOf
                 int n = 0;
                 while (sp < sl) {
                     int b = src[sp++] & 0xff;
-                    if (b == '=')
+                    if (b == '=') {
+                        len -= (sl - sp + 1);
                         break;
+                    }
                     if ((b = base64[b]) == -1)
                         n++;
                 }
                 len -= n;
+            } else {
+                if (src[sl - 1] == '=') {
+                    paddings++;
+                    if (src[sl - 2] == '=')
+                        paddings++;
+                }
             }
             if (paddings == 0 && (len & 0x3) !=  0)
                 paddings = 4 - (len & 0x3);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/concurrent/CompletableFuture.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,3305 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+package java.util.concurrent;
+import java.util.function.Supplier;
+import java.util.function.Consumer;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.function.BiFunction;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ForkJoinTask;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.LockSupport;
+
+/**
+ * A {@link Future} that may be explicitly completed (setting its
+ * value and status), and may include dependent functions and actions
+ * that trigger upon its completion.
+ *
+ * <p>When two or more threads attempt to
+ * {@link #complete complete},
+ * {@link #completeExceptionally completeExceptionally}, or
+ * {@link #cancel cancel}
+ * a CompletableFuture, only one of them succeeds.
+ *
+ * <p>Methods are available for adding dependents based on
+ * user-provided Functions, Consumers, or Runnables. The appropriate
+ * form to use depends on whether actions require arguments and/or
+ * produce results.  Completion of a dependent action will trigger the
+ * completion of another CompletableFuture.  Actions may also be
+ * triggered after either or both the current and another
+ * CompletableFuture complete.  Multiple CompletableFutures may also
+ * be grouped as one using {@link #anyOf(CompletableFuture...)} and
+ * {@link #allOf(CompletableFuture...)}.
+ *
+ * <p>CompletableFutures themselves do not execute asynchronously.
+ * However, actions supplied for dependent completions of another
+ * CompletableFuture may do so, depending on whether they are provided
+ * via one of the <em>async</em> methods (that is, methods with names
+ * of the form <tt><var>xxx</var>Async</tt>).  The <em>async</em>
+ * methods provide a way to commence asynchronous processing of an
+ * action using either a given {@link Executor} or by default the
+ * {@link ForkJoinPool#commonPool()}. To simplify monitoring,
+ * debugging, and tracking, all generated asynchronous tasks are
+ * instances of the marker interface {@link AsynchronousCompletionTask}.
+ *
+ * <p>Actions supplied for dependent completions of <em>non-async</em>
+ * methods may be performed by the thread that completes the current
+ * CompletableFuture, or by any other caller of these methods.  There
+ * are no guarantees about the order of processing completions unless
+ * constrained by these methods.
+ *
+ * <p>Since (unlike {@link FutureTask}) this class has no direct
+ * control over the computation that causes it to be completed,
+ * cancellation is treated as just another form of exceptional completion.
+ * Method {@link #cancel cancel} has the same effect as
+ * {@code completeExceptionally(new CancellationException())}.
+ *
+ * <p>Upon exceptional completion (including cancellation), or when a
+ * completion entails an additional computation which terminates
+ * abruptly with an (unchecked) exception or error, then all of their
+ * dependent completions (and their dependents in turn) generally act
+ * as {@code completeExceptionally} with a {@link CompletionException}
+ * holding that exception as its cause.  However, the {@link
+ * #exceptionally exceptionally} and {@link #handle handle}
+ * completions <em>are</em> able to handle exceptional completions of
+ * the CompletableFutures they depend on.
+ *
+ * <p>In case of exceptional completion with a CompletionException,
+ * methods {@link #get()} and {@link #get(long, TimeUnit)} throw an
+ * {@link ExecutionException} with the same cause as held in the
+ * corresponding CompletionException.  However, in these cases,
+ * methods {@link #join()} and {@link #getNow} throw the
+ * CompletionException, which simplifies usage.
+ *
+ * <p>Arguments used to pass a completion result (that is, for parameters
+ * of type {@code T}) may be null, but passing a null value for any other
+ * parameter will result in a {@link NullPointerException} being thrown.
+ *
+ * @author Doug Lea
+ * @since 1.8
+ */
+public class CompletableFuture<T> implements Future<T> {
+
+    /*
+     * Overview:
+     *
+     * 1. Non-nullness of field result (set via CAS) indicates done.
+     * An AltResult is used to box null as a result, as well as to
+     * hold exceptions.  Using a single field makes completion fast
+     * and simple to detect and trigger, at the expense of a lot of
+     * encoding and decoding that infiltrates many methods. One minor
+     * simplification relies on the (static) NIL (to box null results)
+     * being the only AltResult with a null exception field, so we
+     * don't usually need explicit comparisons with NIL. The CF
+     * exception propagation mechanics surrounding decoding rely on
+     * unchecked casts of decoded results really being unchecked,
+     * where user type errors are caught at point of use, as is
+     * currently the case in Java. These are highlighted by using
+     * SuppressWarnings-annotated temporaries.
+     *
+     * 2. Waiters are held in a Treiber stack similar to the one used
+     * in FutureTask, Phaser, and SynchronousQueue. See their
+     * internal documentation for algorithmic details.
+     *
+     * 3. Completions are also kept in a list/stack, and pulled off
+     * and run when completion is triggered. (We could even use the
+     * same stack as for waiters, but would give up the potential
+     * parallelism obtained because woken waiters help release/run
+     * others -- see method postComplete).  Because post-processing
+     * may race with direct calls, class Completion opportunistically
+     * extends AtomicInteger so callers can claim the action via
+     * compareAndSet(0, 1).  The Completion.run methods are all
+     * written a boringly similar uniform way (that sometimes includes
+     * unnecessary-looking checks, kept to maintain uniformity).
+     * There are enough dimensions upon which they differ that
+     * attempts to factor commonalities while maintaining efficiency
+     * require more lines of code than they would save.
+     *
+     * 4. The exported then/and/or methods do support a bit of
+     * factoring (see doThenApply etc). They must cope with the
+     * intrinsic races surrounding addition of a dependent action
+     * versus performing the action directly because the task is
+     * already complete.  For example, a CF may not be complete upon
+     * entry, so a dependent completion is added, but by the time it
+     * is added, the target CF is complete, so must be directly
+     * executed. This is all done while avoiding unnecessary object
+     * construction in safe-bypass cases.
+     */
+
+    // preliminaries
+
+    static final class AltResult {
+        final Throwable ex; // null only for NIL
+        AltResult(Throwable ex) { this.ex = ex; }
+    }
+
+    static final AltResult NIL = new AltResult(null);
+
+    // Fields
+
+    volatile Object result;    // Either the result or boxed AltResult
+    volatile WaitNode waiters; // Treiber stack of threads blocked on get()
+    volatile CompletionNode completions; // list (Treiber stack) of completions
+
+    // Basic utilities for triggering and processing completions
+
+    /**
+     * Removes and signals all waiting threads and runs all completions.
+     */
+    final void postComplete() {
+        WaitNode q; Thread t;
+        while ((q = waiters) != null) {
+            if (UNSAFE.compareAndSwapObject(this, WAITERS, q, q.next) &&
+                (t = q.thread) != null) {
+                q.thread = null;
+                LockSupport.unpark(t);
+            }
+        }
+
+        CompletionNode h; Completion c;
+        while ((h = completions) != null) {
+            if (UNSAFE.compareAndSwapObject(this, COMPLETIONS, h, h.next) &&
+                (c = h.completion) != null)
+                c.run();
+        }
+    }
+
+    /**
+     * Triggers completion with the encoding of the given arguments:
+     * if the exception is non-null, encodes it as a wrapped
+     * CompletionException unless it is one already.  Otherwise uses
+     * the given result, boxed as NIL if null.
+     */
+    final void internalComplete(T v, Throwable ex) {
+        if (result == null)
+            UNSAFE.compareAndSwapObject
+                (this, RESULT, null,
+                 (ex == null) ? (v == null) ? NIL : v :
+                 new AltResult((ex instanceof CompletionException) ? ex :
+                               new CompletionException(ex)));
+        postComplete(); // help out even if not triggered
+    }
+
+    /**
+     * If triggered, helps release and/or process completions.
+     */
+    final void helpPostComplete() {
+        if (result != null)
+            postComplete();
+    }
+
+    /* ------------- waiting for completions -------------- */
+
+    /** Number of processors, for spin control */
+    static final int NCPU = Runtime.getRuntime().availableProcessors();
+
+    /**
+     * Heuristic spin value for waitingGet() before blocking on
+     * multiprocessors
+     */
+    static final int SPINS = (NCPU > 1) ? 1 << 8 : 0;
+
+    /**
+     * Linked nodes to record waiting threads in a Treiber stack.  See
+     * other classes such as Phaser and SynchronousQueue for more
+     * detailed explanation. This class implements ManagedBlocker to
+     * avoid starvation when blocking actions pile up in
+     * ForkJoinPools.
+     */
+    static final class WaitNode implements ForkJoinPool.ManagedBlocker {
+        long nanos;          // wait time if timed
+        final long deadline; // non-zero if timed
+        volatile int interruptControl; // > 0: interruptible, < 0: interrupted
+        volatile Thread thread;
+        volatile WaitNode next;
+        WaitNode(boolean interruptible, long nanos, long deadline) {
+            this.thread = Thread.currentThread();
+            this.interruptControl = interruptible ? 1 : 0;
+            this.nanos = nanos;
+            this.deadline = deadline;
+        }
+        public boolean isReleasable() {
+            if (thread == null)
+                return true;
+            if (Thread.interrupted()) {
+                int i = interruptControl;
+                interruptControl = -1;
+                if (i > 0)
+                    return true;
+            }
+            if (deadline != 0L &&
+                (nanos <= 0L || (nanos = deadline - System.nanoTime()) <= 0L)) {
+                thread = null;
+                return true;
+            }
+            return false;
+        }
+        public boolean block() {
+            if (isReleasable())
+                return true;
+            else if (deadline == 0L)
+                LockSupport.park(this);
+            else if (nanos > 0L)
+                LockSupport.parkNanos(this, nanos);
+            return isReleasable();
+        }
+    }
+
+    /**
+     * Returns raw result after waiting, or null if interruptible and
+     * interrupted.
+     */
+    private Object waitingGet(boolean interruptible) {
+        WaitNode q = null;
+        boolean queued = false;
+        int spins = SPINS;
+        for (Object r;;) {
+            if ((r = result) != null) {
+                if (q != null) { // suppress unpark
+                    q.thread = null;
+                    if (q.interruptControl < 0) {
+                        if (interruptible) {
+                            removeWaiter(q);
+                            return null;
+                        }
+                        Thread.currentThread().interrupt();
+                    }
+                }
+                postComplete(); // help release others
+                return r;
+            }
+            else if (spins > 0) {
+                int rnd = ThreadLocalRandom.nextSecondarySeed();
+                if (rnd == 0)
+                    rnd = ThreadLocalRandom.current().nextInt();
+                if (rnd >= 0)
+                    --spins;
+            }
+            else if (q == null)
+                q = new WaitNode(interruptible, 0L, 0L);
+            else if (!queued)
+                queued = UNSAFE.compareAndSwapObject(this, WAITERS,
+                                                     q.next = waiters, q);
+            else if (interruptible && q.interruptControl < 0) {
+                removeWaiter(q);
+                return null;
+            }
+            else if (q.thread != null && result == null) {
+                try {
+                    ForkJoinPool.managedBlock(q);
+                } catch (InterruptedException ex) {
+                    q.interruptControl = -1;
+                }
+            }
+        }
+    }
+
+    /**
+     * Awaits completion or aborts on interrupt or timeout.
+     *
+     * @param nanos time to wait
+     * @return raw result
+     */
+    private Object timedAwaitDone(long nanos)
+        throws InterruptedException, TimeoutException {
+        WaitNode q = null;
+        boolean queued = false;
+        for (Object r;;) {
+            if ((r = result) != null) {
+                if (q != null) {
+                    q.thread = null;
+                    if (q.interruptControl < 0) {
+                        removeWaiter(q);
+                        throw new InterruptedException();
+                    }
+                }
+                postComplete();
+                return r;
+            }
+            else if (q == null) {
+                if (nanos <= 0L)
+                    throw new TimeoutException();
+                long d = System.nanoTime() + nanos;
+                q = new WaitNode(true, nanos, d == 0L ? 1L : d); // avoid 0
+            }
+            else if (!queued)
+                queued = UNSAFE.compareAndSwapObject(this, WAITERS,
+                                                     q.next = waiters, q);
+            else if (q.interruptControl < 0) {
+                removeWaiter(q);
+                throw new InterruptedException();
+            }
+            else if (q.nanos <= 0L) {
+                if (result == null) {
+                    removeWaiter(q);
+                    throw new TimeoutException();
+                }
+            }
+            else if (q.thread != null && result == null) {
+                try {
+                    ForkJoinPool.managedBlock(q);
+                } catch (InterruptedException ex) {
+                    q.interruptControl = -1;
+                }
+            }
+        }
+    }
+
+    /**
+     * Tries to unlink a timed-out or interrupted wait node to avoid
+     * accumulating garbage.  Internal nodes are simply unspliced
+     * without CAS since it is harmless if they are traversed anyway
+     * by releasers.  To avoid effects of unsplicing from already
+     * removed nodes, the list is retraversed in case of an apparent
+     * race.  This is slow when there are a lot of nodes, but we don't
+     * expect lists to be long enough to outweigh higher-overhead
+     * schemes.
+     */
+    private void removeWaiter(WaitNode node) {
+        if (node != null) {
+            node.thread = null;
+            retry:
+            for (;;) {          // restart on removeWaiter race
+                for (WaitNode pred = null, q = waiters, s; q != null; q = s) {
+                    s = q.next;
+                    if (q.thread != null)
+                        pred = q;
+                    else if (pred != null) {
+                        pred.next = s;
+                        if (pred.thread == null) // check for race
+                            continue retry;
+                    }
+                    else if (!UNSAFE.compareAndSwapObject(this, WAITERS, q, s))
+                        continue retry;
+                }
+                break;
+            }
+        }
+    }
+
+    /* ------------- Async tasks -------------- */
+
+    /**
+     * A marker interface identifying asynchronous tasks produced by
+     * {@code async} methods. This may be useful for monitoring,
+     * debugging, and tracking asynchronous activities.
+     *
+     * @since 1.8
+     */
+    public static interface AsynchronousCompletionTask {
+    }
+
+    /** Base class can act as either FJ or plain Runnable */
+    abstract static class Async extends ForkJoinTask<Void>
+        implements Runnable, AsynchronousCompletionTask {
+        public final Void getRawResult() { return null; }
+        public final void setRawResult(Void v) { }
+        public final void run() { exec(); }
+    }
+
+    static final class AsyncRun extends Async {
+        final Runnable fn;
+        final CompletableFuture<Void> dst;
+        AsyncRun(Runnable fn, CompletableFuture<Void> dst) {
+            this.fn = fn; this.dst = dst;
+        }
+        public final boolean exec() {
+            CompletableFuture<Void> d; Throwable ex;
+            if ((d = this.dst) != null && d.result == null) {
+                try {
+                    fn.run();
+                    ex = null;
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+                d.internalComplete(null, ex);
+            }
+            return true;
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class AsyncSupply<U> extends Async {
+        final Supplier<U> fn;
+        final CompletableFuture<U> dst;
+        AsyncSupply(Supplier<U> fn, CompletableFuture<U> dst) {
+            this.fn = fn; this.dst = dst;
+        }
+        public final boolean exec() {
+            CompletableFuture<U> d; U u; Throwable ex;
+            if ((d = this.dst) != null && d.result == null) {
+                try {
+                    u = fn.get();
+                    ex = null;
+                } catch (Throwable rex) {
+                    ex = rex;
+                    u = null;
+                }
+                d.internalComplete(u, ex);
+            }
+            return true;
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class AsyncApply<T,U> extends Async {
+        final T arg;
+        final Function<? super T,? extends U> fn;
+        final CompletableFuture<U> dst;
+        AsyncApply(T arg, Function<? super T,? extends U> fn,
+                   CompletableFuture<U> dst) {
+            this.arg = arg; this.fn = fn; this.dst = dst;
+        }
+        public final boolean exec() {
+            CompletableFuture<U> d; U u; Throwable ex;
+            if ((d = this.dst) != null && d.result == null) {
+                try {
+                    u = fn.apply(arg);
+                    ex = null;
+                } catch (Throwable rex) {
+                    ex = rex;
+                    u = null;
+                }
+                d.internalComplete(u, ex);
+            }
+            return true;
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class AsyncCombine<T,U,V> extends Async {
+        final T arg1;
+        final U arg2;
+        final BiFunction<? super T,? super U,? extends V> fn;
+        final CompletableFuture<V> dst;
+        AsyncCombine(T arg1, U arg2,
+                     BiFunction<? super T,? super U,? extends V> fn,
+                     CompletableFuture<V> dst) {
+            this.arg1 = arg1; this.arg2 = arg2; this.fn = fn; this.dst = dst;
+        }
+        public final boolean exec() {
+            CompletableFuture<V> d; V v; Throwable ex;
+            if ((d = this.dst) != null && d.result == null) {
+                try {
+                    v = fn.apply(arg1, arg2);
+                    ex = null;
+                } catch (Throwable rex) {
+                    ex = rex;
+                    v = null;
+                }
+                d.internalComplete(v, ex);
+            }
+            return true;
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class AsyncAccept<T> extends Async {
+        final T arg;
+        final Consumer<? super T> fn;
+        final CompletableFuture<Void> dst;
+        AsyncAccept(T arg, Consumer<? super T> fn,
+                    CompletableFuture<Void> dst) {
+            this.arg = arg; this.fn = fn; this.dst = dst;
+        }
+        public final boolean exec() {
+            CompletableFuture<Void> d; Throwable ex;
+            if ((d = this.dst) != null && d.result == null) {
+                try {
+                    fn.accept(arg);
+                    ex = null;
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+                d.internalComplete(null, ex);
+            }
+            return true;
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class AsyncAcceptBoth<T,U> extends Async {
+        final T arg1;
+        final U arg2;
+        final BiConsumer<? super T,? super U> fn;
+        final CompletableFuture<Void> dst;
+        AsyncAcceptBoth(T arg1, U arg2,
+                        BiConsumer<? super T,? super U> fn,
+                        CompletableFuture<Void> dst) {
+            this.arg1 = arg1; this.arg2 = arg2; this.fn = fn; this.dst = dst;
+        }
+        public final boolean exec() {
+            CompletableFuture<Void> d; Throwable ex;
+            if ((d = this.dst) != null && d.result == null) {
+                try {
+                    fn.accept(arg1, arg2);
+                    ex = null;
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+                d.internalComplete(null, ex);
+            }
+            return true;
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class AsyncCompose<T,U> extends Async {
+        final T arg;
+        final Function<? super T, CompletableFuture<U>> fn;
+        final CompletableFuture<U> dst;
+        AsyncCompose(T arg,
+                     Function<? super T, CompletableFuture<U>> fn,
+                     CompletableFuture<U> dst) {
+            this.arg = arg; this.fn = fn; this.dst = dst;
+        }
+        public final boolean exec() {
+            CompletableFuture<U> d, fr; U u; Throwable ex;
+            if ((d = this.dst) != null && d.result == null) {
+                try {
+                    fr = fn.apply(arg);
+                    ex = (fr == null) ? new NullPointerException() : null;
+                } catch (Throwable rex) {
+                    ex = rex;
+                    fr = null;
+                }
+                if (ex != null)
+                    u = null;
+                else {
+                    Object r = fr.result;
+                    if (r == null)
+                        r = fr.waitingGet(false);
+                    if (r instanceof AltResult) {
+                        ex = ((AltResult)r).ex;
+                        u = null;
+                    }
+                    else {
+                        @SuppressWarnings("unchecked") U ur = (U) r;
+                        u = ur;
+                    }
+                }
+                d.internalComplete(u, ex);
+            }
+            return true;
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    /* ------------- Completions -------------- */
+
+    /**
+     * Simple linked list nodes to record completions, used in
+     * basically the same way as WaitNodes. (We separate nodes from
+     * the Completions themselves mainly because for the And and Or
+     * methods, the same Completion object resides in two lists.)
+     */
+    static final class CompletionNode {
+        final Completion completion;
+        volatile CompletionNode next;
+        CompletionNode(Completion completion) { this.completion = completion; }
+    }
+
+    // Opportunistically subclass AtomicInteger to use compareAndSet to claim.
+    abstract static class Completion extends AtomicInteger implements Runnable {
+    }
+
+    static final class ThenApply<T,U> extends Completion {
+        final CompletableFuture<? extends T> src;
+        final Function<? super T,? extends U> fn;
+        final CompletableFuture<U> dst;
+        final Executor executor;
+        ThenApply(CompletableFuture<? extends T> src,
+                  Function<? super T,? extends U> fn,
+                  CompletableFuture<U> dst,
+                  Executor executor) {
+            this.src = src; this.fn = fn; this.dst = dst;
+            this.executor = executor;
+        }
+        public final void run() {
+            final CompletableFuture<? extends T> a;
+            final Function<? super T,? extends U> fn;
+            final CompletableFuture<U> dst;
+            Object r; T t; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult) {
+                    ex = ((AltResult)r).ex;
+                    t = null;
+                }
+                else {
+                    ex = null;
+                    @SuppressWarnings("unchecked") T tr = (T) r;
+                    t = tr;
+                }
+                Executor e = executor;
+                U u = null;
+                if (ex == null) {
+                    try {
+                        if (e != null)
+                            e.execute(new AsyncApply<T,U>(t, fn, dst));
+                        else
+                            u = fn.apply(t);
+                    } catch (Throwable rex) {
+                        ex = rex;
+                    }
+                }
+                if (e == null || ex != null)
+                    dst.internalComplete(u, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class ThenAccept<T> extends Completion {
+        final CompletableFuture<? extends T> src;
+        final Consumer<? super T> fn;
+        final CompletableFuture<Void> dst;
+        final Executor executor;
+        ThenAccept(CompletableFuture<? extends T> src,
+                   Consumer<? super T> fn,
+                   CompletableFuture<Void> dst,
+                   Executor executor) {
+            this.src = src; this.fn = fn; this.dst = dst;
+            this.executor = executor;
+        }
+        public final void run() {
+            final CompletableFuture<? extends T> a;
+            final Consumer<? super T> fn;
+            final CompletableFuture<Void> dst;
+            Object r; T t; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult) {
+                    ex = ((AltResult)r).ex;
+                    t = null;
+                }
+                else {
+                    ex = null;
+                    @SuppressWarnings("unchecked") T tr = (T) r;
+                    t = tr;
+                }
+                Executor e = executor;
+                if (ex == null) {
+                    try {
+                        if (e != null)
+                            e.execute(new AsyncAccept<T>(t, fn, dst));
+                        else
+                            fn.accept(t);
+                    } catch (Throwable rex) {
+                        ex = rex;
+                    }
+                }
+                if (e == null || ex != null)
+                    dst.internalComplete(null, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class ThenRun extends Completion {
+        final CompletableFuture<?> src;
+        final Runnable fn;
+        final CompletableFuture<Void> dst;
+        final Executor executor;
+        ThenRun(CompletableFuture<?> src,
+                Runnable fn,
+                CompletableFuture<Void> dst,
+                Executor executor) {
+            this.src = src; this.fn = fn; this.dst = dst;
+            this.executor = executor;
+        }
+        public final void run() {
+            final CompletableFuture<?> a;
+            final Runnable fn;
+            final CompletableFuture<Void> dst;
+            Object r; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult)
+                    ex = ((AltResult)r).ex;
+                else
+                    ex = null;
+                Executor e = executor;
+                if (ex == null) {
+                    try {
+                        if (e != null)
+                            e.execute(new AsyncRun(fn, dst));
+                        else
+                            fn.run();
+                    } catch (Throwable rex) {
+                        ex = rex;
+                    }
+                }
+                if (e == null || ex != null)
+                    dst.internalComplete(null, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class ThenCombine<T,U,V> extends Completion {
+        final CompletableFuture<? extends T> src;
+        final CompletableFuture<? extends U> snd;
+        final BiFunction<? super T,? super U,? extends V> fn;
+        final CompletableFuture<V> dst;
+        final Executor executor;
+        ThenCombine(CompletableFuture<? extends T> src,
+                    CompletableFuture<? extends U> snd,
+                    BiFunction<? super T,? super U,? extends V> fn,
+                    CompletableFuture<V> dst,
+                    Executor executor) {
+            this.src = src; this.snd = snd;
+            this.fn = fn; this.dst = dst;
+            this.executor = executor;
+        }
+        public final void run() {
+            final CompletableFuture<? extends T> a;
+            final CompletableFuture<? extends U> b;
+            final BiFunction<? super T,? super U,? extends V> fn;
+            final CompletableFuture<V> dst;
+            Object r, s; T t; U u; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                (b = this.snd) != null &&
+                (s = b.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult) {
+                    ex = ((AltResult)r).ex;
+                    t = null;
+                }
+                else {
+                    ex = null;
+                    @SuppressWarnings("unchecked") T tr = (T) r;
+                    t = tr;
+                }
+                if (ex != null)
+                    u = null;
+                else if (s instanceof AltResult) {
+                    ex = ((AltResult)s).ex;
+                    u = null;
+                }
+                else {
+                    @SuppressWarnings("unchecked") U us = (U) s;
+                    u = us;
+                }
+                Executor e = executor;
+                V v = null;
+                if (ex == null) {
+                    try {
+                        if (e != null)
+                            e.execute(new AsyncCombine<T,U,V>(t, u, fn, dst));
+                        else
+                            v = fn.apply(t, u);
+                    } catch (Throwable rex) {
+                        ex = rex;
+                    }
+                }
+                if (e == null || ex != null)
+                    dst.internalComplete(v, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class ThenAcceptBoth<T,U> extends Completion {
+        final CompletableFuture<? extends T> src;
+        final CompletableFuture<? extends U> snd;
+        final BiConsumer<? super T,? super U> fn;
+        final CompletableFuture<Void> dst;
+        final Executor executor;
+        ThenAcceptBoth(CompletableFuture<? extends T> src,
+                       CompletableFuture<? extends U> snd,
+                       BiConsumer<? super T,? super U> fn,
+                       CompletableFuture<Void> dst,
+                       Executor executor) {
+            this.src = src; this.snd = snd;
+            this.fn = fn; this.dst = dst;
+            this.executor = executor;
+        }
+        public final void run() {
+            final CompletableFuture<? extends T> a;
+            final CompletableFuture<? extends U> b;
+            final BiConsumer<? super T,? super U> fn;
+            final CompletableFuture<Void> dst;
+            Object r, s; T t; U u; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                (b = this.snd) != null &&
+                (s = b.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult) {
+                    ex = ((AltResult)r).ex;
+                    t = null;
+                }
+                else {
+                    ex = null;
+                    @SuppressWarnings("unchecked") T tr = (T) r;
+                    t = tr;
+                }
+                if (ex != null)
+                    u = null;
+                else if (s instanceof AltResult) {
+                    ex = ((AltResult)s).ex;
+                    u = null;
+                }
+                else {
+                    @SuppressWarnings("unchecked") U us = (U) s;
+                    u = us;
+                }
+                Executor e = executor;
+                if (ex == null) {
+                    try {
+                        if (e != null)
+                            e.execute(new AsyncAcceptBoth<T,U>(t, u, fn, dst));
+                        else
+                            fn.accept(t, u);
+                    } catch (Throwable rex) {
+                        ex = rex;
+                    }
+                }
+                if (e == null || ex != null)
+                    dst.internalComplete(null, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class RunAfterBoth extends Completion {
+        final CompletableFuture<?> src;
+        final CompletableFuture<?> snd;
+        final Runnable fn;
+        final CompletableFuture<Void> dst;
+        final Executor executor;
+        RunAfterBoth(CompletableFuture<?> src,
+                     CompletableFuture<?> snd,
+                     Runnable fn,
+                     CompletableFuture<Void> dst,
+                     Executor executor) {
+            this.src = src; this.snd = snd;
+            this.fn = fn; this.dst = dst;
+            this.executor = executor;
+        }
+        public final void run() {
+            final CompletableFuture<?> a;
+            final CompletableFuture<?> b;
+            final Runnable fn;
+            final CompletableFuture<Void> dst;
+            Object r, s; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                (b = this.snd) != null &&
+                (s = b.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult)
+                    ex = ((AltResult)r).ex;
+                else
+                    ex = null;
+                if (ex == null && (s instanceof AltResult))
+                    ex = ((AltResult)s).ex;
+                Executor e = executor;
+                if (ex == null) {
+                    try {
+                        if (e != null)
+                            e.execute(new AsyncRun(fn, dst));
+                        else
+                            fn.run();
+                    } catch (Throwable rex) {
+                        ex = rex;
+                    }
+                }
+                if (e == null || ex != null)
+                    dst.internalComplete(null, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class AndCompletion extends Completion {
+        final CompletableFuture<?> src;
+        final CompletableFuture<?> snd;
+        final CompletableFuture<Void> dst;
+        AndCompletion(CompletableFuture<?> src,
+                      CompletableFuture<?> snd,
+                      CompletableFuture<Void> dst) {
+            this.src = src; this.snd = snd; this.dst = dst;
+        }
+        public final void run() {
+            final CompletableFuture<?> a;
+            final CompletableFuture<?> b;
+            final CompletableFuture<Void> dst;
+            Object r, s; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                (b = this.snd) != null &&
+                (s = b.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult)
+                    ex = ((AltResult)r).ex;
+                else
+                    ex = null;
+                if (ex == null && (s instanceof AltResult))
+                    ex = ((AltResult)s).ex;
+                dst.internalComplete(null, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class ApplyToEither<T,U> extends Completion {
+        final CompletableFuture<? extends T> src;
+        final CompletableFuture<? extends T> snd;
+        final Function<? super T,? extends U> fn;
+        final CompletableFuture<U> dst;
+        final Executor executor;
+        ApplyToEither(CompletableFuture<? extends T> src,
+                      CompletableFuture<? extends T> snd,
+                      Function<? super T,? extends U> fn,
+                      CompletableFuture<U> dst,
+                      Executor executor) {
+            this.src = src; this.snd = snd;
+            this.fn = fn; this.dst = dst;
+            this.executor = executor;
+        }
+        public final void run() {
+            final CompletableFuture<? extends T> a;
+            final CompletableFuture<? extends T> b;
+            final Function<? super T,? extends U> fn;
+            final CompletableFuture<U> dst;
+            Object r; T t; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (((a = this.src) != null && (r = a.result) != null) ||
+                 ((b = this.snd) != null && (r = b.result) != null)) &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult) {
+                    ex = ((AltResult)r).ex;
+                    t = null;
+                }
+                else {
+                    ex = null;
+                    @SuppressWarnings("unchecked") T tr = (T) r;
+                    t = tr;
+                }
+                Executor e = executor;
+                U u = null;
+                if (ex == null) {
+                    try {
+                        if (e != null)
+                            e.execute(new AsyncApply<T,U>(t, fn, dst));
+                        else
+                            u = fn.apply(t);
+                    } catch (Throwable rex) {
+                        ex = rex;
+                    }
+                }
+                if (e == null || ex != null)
+                    dst.internalComplete(u, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class AcceptEither<T> extends Completion {
+        final CompletableFuture<? extends T> src;
+        final CompletableFuture<? extends T> snd;
+        final Consumer<? super T> fn;
+        final CompletableFuture<Void> dst;
+        final Executor executor;
+        AcceptEither(CompletableFuture<? extends T> src,
+                     CompletableFuture<? extends T> snd,
+                     Consumer<? super T> fn,
+                     CompletableFuture<Void> dst,
+                     Executor executor) {
+            this.src = src; this.snd = snd;
+            this.fn = fn; this.dst = dst;
+            this.executor = executor;
+        }
+        public final void run() {
+            final CompletableFuture<? extends T> a;
+            final CompletableFuture<? extends T> b;
+            final Consumer<? super T> fn;
+            final CompletableFuture<Void> dst;
+            Object r; T t; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (((a = this.src) != null && (r = a.result) != null) ||
+                 ((b = this.snd) != null && (r = b.result) != null)) &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult) {
+                    ex = ((AltResult)r).ex;
+                    t = null;
+                }
+                else {
+                    ex = null;
+                    @SuppressWarnings("unchecked") T tr = (T) r;
+                    t = tr;
+                }
+                Executor e = executor;
+                if (ex == null) {
+                    try {
+                        if (e != null)
+                            e.execute(new AsyncAccept<T>(t, fn, dst));
+                        else
+                            fn.accept(t);
+                    } catch (Throwable rex) {
+                        ex = rex;
+                    }
+                }
+                if (e == null || ex != null)
+                    dst.internalComplete(null, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class RunAfterEither extends Completion {
+        final CompletableFuture<?> src;
+        final CompletableFuture<?> snd;
+        final Runnable fn;
+        final CompletableFuture<Void> dst;
+        final Executor executor;
+        RunAfterEither(CompletableFuture<?> src,
+                       CompletableFuture<?> snd,
+                       Runnable fn,
+                       CompletableFuture<Void> dst,
+                       Executor executor) {
+            this.src = src; this.snd = snd;
+            this.fn = fn; this.dst = dst;
+            this.executor = executor;
+        }
+        public final void run() {
+            final CompletableFuture<?> a;
+            final CompletableFuture<?> b;
+            final Runnable fn;
+            final CompletableFuture<Void> dst;
+            Object r; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (((a = this.src) != null && (r = a.result) != null) ||
+                 ((b = this.snd) != null && (r = b.result) != null)) &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult)
+                    ex = ((AltResult)r).ex;
+                else
+                    ex = null;
+                Executor e = executor;
+                if (ex == null) {
+                    try {
+                        if (e != null)
+                            e.execute(new AsyncRun(fn, dst));
+                        else
+                            fn.run();
+                    } catch (Throwable rex) {
+                        ex = rex;
+                    }
+                }
+                if (e == null || ex != null)
+                    dst.internalComplete(null, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class OrCompletion extends Completion {
+        final CompletableFuture<?> src;
+        final CompletableFuture<?> snd;
+        final CompletableFuture<Object> dst;
+        OrCompletion(CompletableFuture<?> src,
+                     CompletableFuture<?> snd,
+                     CompletableFuture<Object> dst) {
+            this.src = src; this.snd = snd; this.dst = dst;
+        }
+        public final void run() {
+            final CompletableFuture<?> a;
+            final CompletableFuture<?> b;
+            final CompletableFuture<Object> dst;
+            Object r, t; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (((a = this.src) != null && (r = a.result) != null) ||
+                 ((b = this.snd) != null && (r = b.result) != null)) &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult) {
+                    ex = ((AltResult)r).ex;
+                    t = null;
+                }
+                else {
+                    ex = null;
+                    t = r;
+                }
+                dst.internalComplete(t, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class ExceptionCompletion<T> extends Completion {
+        final CompletableFuture<? extends T> src;
+        final Function<? super Throwable, ? extends T> fn;
+        final CompletableFuture<T> dst;
+        ExceptionCompletion(CompletableFuture<? extends T> src,
+                            Function<? super Throwable, ? extends T> fn,
+                            CompletableFuture<T> dst) {
+            this.src = src; this.fn = fn; this.dst = dst;
+        }
+        public final void run() {
+            final CompletableFuture<? extends T> a;
+            final Function<? super Throwable, ? extends T> fn;
+            final CompletableFuture<T> dst;
+            Object r; T t = null; Throwable ex, dx = null;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                compareAndSet(0, 1)) {
+                if ((r instanceof AltResult) &&
+                    (ex = ((AltResult)r).ex) != null)  {
+                    try {
+                        t = fn.apply(ex);
+                    } catch (Throwable rex) {
+                        dx = rex;
+                    }
+                }
+                else {
+                    @SuppressWarnings("unchecked") T tr = (T) r;
+                    t = tr;
+                }
+                dst.internalComplete(t, dx);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class ThenCopy<T> extends Completion {
+        final CompletableFuture<?> src;
+        final CompletableFuture<T> dst;
+        ThenCopy(CompletableFuture<?> src,
+                 CompletableFuture<T> dst) {
+            this.src = src; this.dst = dst;
+        }
+        public final void run() {
+            final CompletableFuture<?> a;
+            final CompletableFuture<T> dst;
+            Object r; T t; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult) {
+                    ex = ((AltResult)r).ex;
+                    t = null;
+                }
+                else {
+                    ex = null;
+                    @SuppressWarnings("unchecked") T tr = (T) r;
+                    t = tr;
+                }
+                dst.internalComplete(t, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    // version of ThenCopy for CompletableFuture<Void> dst
+    static final class ThenPropagate extends Completion {
+        final CompletableFuture<?> src;
+        final CompletableFuture<Void> dst;
+        ThenPropagate(CompletableFuture<?> src,
+                      CompletableFuture<Void> dst) {
+            this.src = src; this.dst = dst;
+        }
+        public final void run() {
+            final CompletableFuture<?> a;
+            final CompletableFuture<Void> dst;
+            Object r; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult)
+                    ex = ((AltResult)r).ex;
+                else
+                    ex = null;
+                dst.internalComplete(null, ex);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class HandleCompletion<T,U> extends Completion {
+        final CompletableFuture<? extends T> src;
+        final BiFunction<? super T, Throwable, ? extends U> fn;
+        final CompletableFuture<U> dst;
+        HandleCompletion(CompletableFuture<? extends T> src,
+                         BiFunction<? super T, Throwable, ? extends U> fn,
+                         CompletableFuture<U> dst) {
+            this.src = src; this.fn = fn; this.dst = dst;
+        }
+        public final void run() {
+            final CompletableFuture<? extends T> a;
+            final BiFunction<? super T, Throwable, ? extends U> fn;
+            final CompletableFuture<U> dst;
+            Object r; T t; Throwable ex;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult) {
+                    ex = ((AltResult)r).ex;
+                    t = null;
+                }
+                else {
+                    ex = null;
+                    @SuppressWarnings("unchecked") T tr = (T) r;
+                    t = tr;
+                }
+                U u = null; Throwable dx = null;
+                try {
+                    u = fn.apply(t, ex);
+                } catch (Throwable rex) {
+                    dx = rex;
+                }
+                dst.internalComplete(u, dx);
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    static final class ThenCompose<T,U> extends Completion {
+        final CompletableFuture<? extends T> src;
+        final Function<? super T, CompletableFuture<U>> fn;
+        final CompletableFuture<U> dst;
+        final Executor executor;
+        ThenCompose(CompletableFuture<? extends T> src,
+                    Function<? super T, CompletableFuture<U>> fn,
+                    CompletableFuture<U> dst,
+                    Executor executor) {
+            this.src = src; this.fn = fn; this.dst = dst;
+            this.executor = executor;
+        }
+        public final void run() {
+            final CompletableFuture<? extends T> a;
+            final Function<? super T, CompletableFuture<U>> fn;
+            final CompletableFuture<U> dst;
+            Object r; T t; Throwable ex; Executor e;
+            if ((dst = this.dst) != null &&
+                (fn = this.fn) != null &&
+                (a = this.src) != null &&
+                (r = a.result) != null &&
+                compareAndSet(0, 1)) {
+                if (r instanceof AltResult) {
+                    ex = ((AltResult)r).ex;
+                    t = null;
+                }
+                else {
+                    ex = null;
+                    @SuppressWarnings("unchecked") T tr = (T) r;
+                    t = tr;
+                }
+                CompletableFuture<U> c = null;
+                U u = null;
+                boolean complete = false;
+                if (ex == null) {
+                    if ((e = executor) != null)
+                        e.execute(new AsyncCompose<T,U>(t, fn, dst));
+                    else {
+                        try {
+                            if ((c = fn.apply(t)) == null)
+                                ex = new NullPointerException();
+                        } catch (Throwable rex) {
+                            ex = rex;
+                        }
+                    }
+                }
+                if (c != null) {
+                    ThenCopy<U> d = null;
+                    Object s;
+                    if ((s = c.result) == null) {
+                        CompletionNode p = new CompletionNode
+                            (d = new ThenCopy<U>(c, dst));
+                        while ((s = c.result) == null) {
+                            if (UNSAFE.compareAndSwapObject
+                                (c, COMPLETIONS, p.next = c.completions, p))
+                                break;
+                        }
+                    }
+                    if (s != null && (d == null || d.compareAndSet(0, 1))) {
+                        complete = true;
+                        if (s instanceof AltResult) {
+                            ex = ((AltResult)s).ex;  // no rewrap
+                            u = null;
+                        }
+                        else {
+                            @SuppressWarnings("unchecked") U us = (U) s;
+                            u = us;
+                        }
+                    }
+                }
+                if (complete || ex != null)
+                    dst.internalComplete(u, ex);
+                if (c != null)
+                    c.helpPostComplete();
+            }
+        }
+        private static final long serialVersionUID = 5232453952276885070L;
+    }
+
+    // public methods
+
+    /**
+     * Creates a new incomplete CompletableFuture.
+     */
+    public CompletableFuture() {
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * by a task running in the {@link ForkJoinPool#commonPool()} with
+     * the value obtained by calling the given Supplier.
+     *
+     * @param supplier a function returning the value to be used
+     * to complete the returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier) {
+        if (supplier == null) throw new NullPointerException();
+        CompletableFuture<U> f = new CompletableFuture<U>();
+        ForkJoinPool.commonPool().
+            execute((ForkJoinTask<?>)new AsyncSupply<U>(supplier, f));
+        return f;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * by a task running in the given executor with the value obtained
+     * by calling the given Supplier.
+     *
+     * @param supplier a function returning the value to be used
+     * to complete the returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier,
+                                                       Executor executor) {
+        if (executor == null || supplier == null)
+            throw new NullPointerException();
+        CompletableFuture<U> f = new CompletableFuture<U>();
+        executor.execute(new AsyncSupply<U>(supplier, f));
+        return f;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * by a task running in the {@link ForkJoinPool#commonPool()} after
+     * it runs the given action.
+     *
+     * @param runnable the action to run before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public static CompletableFuture<Void> runAsync(Runnable runnable) {
+        if (runnable == null) throw new NullPointerException();
+        CompletableFuture<Void> f = new CompletableFuture<Void>();
+        ForkJoinPool.commonPool().
+            execute((ForkJoinTask<?>)new AsyncRun(runnable, f));
+        return f;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * by a task running in the given executor after it runs the given
+     * action.
+     *
+     * @param runnable the action to run before completing the
+     * returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public static CompletableFuture<Void> runAsync(Runnable runnable,
+                                                   Executor executor) {
+        if (executor == null || runnable == null)
+            throw new NullPointerException();
+        CompletableFuture<Void> f = new CompletableFuture<Void>();
+        executor.execute(new AsyncRun(runnable, f));
+        return f;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is already completed with
+     * the given value.
+     *
+     * @param value the value
+     * @return the completed CompletableFuture
+     */
+    public static <U> CompletableFuture<U> completedFuture(U value) {
+        CompletableFuture<U> f = new CompletableFuture<U>();
+        f.result = (value == null) ? NIL : value;
+        return f;
+    }
+
+    /**
+     * Returns {@code true} if completed in any fashion: normally,
+     * exceptionally, or via cancellation.
+     *
+     * @return {@code true} if completed
+     */
+    public boolean isDone() {
+        return result != null;
+    }
+
+    /**
+     * Waits if necessary for this future to complete, and then
+     * returns its result.
+     *
+     * @return the result value
+     * @throws CancellationException if this future was cancelled
+     * @throws ExecutionException if this future completed exceptionally
+     * @throws InterruptedException if the current thread was interrupted
+     * while waiting
+     */
+    public T get() throws InterruptedException, ExecutionException {
+        Object r; Throwable ex, cause;
+        if ((r = result) == null && (r = waitingGet(true)) == null)
+            throw new InterruptedException();
+        if (!(r instanceof AltResult)) {
+            @SuppressWarnings("unchecked") T tr = (T) r;
+            return tr;
+        }
+        if ((ex = ((AltResult)r).ex) == null)
+            return null;
+        if (ex instanceof CancellationException)
+            throw (CancellationException)ex;
+        if ((ex instanceof CompletionException) &&
+            (cause = ex.getCause()) != null)
+            ex = cause;
+        throw new ExecutionException(ex);
+    }
+
+    /**
+     * Waits if necessary for at most the given time for this future
+     * to complete, and then returns its result, if available.
+     *
+     * @param timeout the maximum time to wait
+     * @param unit the time unit of the timeout argument
+     * @return the result value
+     * @throws CancellationException if this future was cancelled
+     * @throws ExecutionException if this future completed exceptionally
+     * @throws InterruptedException if the current thread was interrupted
+     * while waiting
+     * @throws TimeoutException if the wait timed out
+     */
+    public T get(long timeout, TimeUnit unit)
+        throws InterruptedException, ExecutionException, TimeoutException {
+        Object r; Throwable ex, cause;
+        long nanos = unit.toNanos(timeout);
+        if (Thread.interrupted())
+            throw new InterruptedException();
+        if ((r = result) == null)
+            r = timedAwaitDone(nanos);
+        if (!(r instanceof AltResult)) {
+            @SuppressWarnings("unchecked") T tr = (T) r;
+            return tr;
+        }
+        if ((ex = ((AltResult)r).ex) == null)
+            return null;
+        if (ex instanceof CancellationException)
+            throw (CancellationException)ex;
+        if ((ex instanceof CompletionException) &&
+            (cause = ex.getCause()) != null)
+            ex = cause;
+        throw new ExecutionException(ex);
+    }
+
+    /**
+     * Returns the result value when complete, or throws an
+     * (unchecked) exception if completed exceptionally. To better
+     * conform with the use of common functional forms, if a
+     * computation involved in the completion of this
+     * CompletableFuture threw an exception, this method throws an
+     * (unchecked) {@link CompletionException} with the underlying
+     * exception as its cause.
+     *
+     * @return the result value
+     * @throws CancellationException if the computation was cancelled
+     * @throws CompletionException if this future completed
+     * exceptionally or a completion computation threw an exception
+     */
+    public T join() {
+        Object r; Throwable ex;
+        if ((r = result) == null)
+            r = waitingGet(false);
+        if (!(r instanceof AltResult)) {
+            @SuppressWarnings("unchecked") T tr = (T) r;
+            return tr;
+        }
+        if ((ex = ((AltResult)r).ex) == null)
+            return null;
+        if (ex instanceof CancellationException)
+            throw (CancellationException)ex;
+        if (ex instanceof CompletionException)
+            throw (CompletionException)ex;
+        throw new CompletionException(ex);
+    }
+
+    /**
+     * Returns the result value (or throws any encountered exception)
+     * if completed, else returns the given valueIfAbsent.
+     *
+     * @param valueIfAbsent the value to return if not completed
+     * @return the result value, if completed, else the given valueIfAbsent
+     * @throws CancellationException if the computation was cancelled
+     * @throws CompletionException if this future completed
+     * exceptionally or a completion computation threw an exception
+     */
+    public T getNow(T valueIfAbsent) {
+        Object r; Throwable ex;
+        if ((r = result) == null)
+            return valueIfAbsent;
+        if (!(r instanceof AltResult)) {
+            @SuppressWarnings("unchecked") T tr = (T) r;
+            return tr;
+        }
+        if ((ex = ((AltResult)r).ex) == null)
+            return null;
+        if (ex instanceof CancellationException)
+            throw (CancellationException)ex;
+        if (ex instanceof CompletionException)
+            throw (CompletionException)ex;
+        throw new CompletionException(ex);
+    }
+
+    /**
+     * If not already completed, sets the value returned by {@link
+     * #get()} and related methods to the given value.
+     *
+     * @param value the result value
+     * @return {@code true} if this invocation caused this CompletableFuture
+     * to transition to a completed state, else {@code false}
+     */
+    public boolean complete(T value) {
+        boolean triggered = result == null &&
+            UNSAFE.compareAndSwapObject(this, RESULT, null,
+                                        value == null ? NIL : value);
+        postComplete();
+        return triggered;
+    }
+
+    /**
+     * If not already completed, causes invocations of {@link #get()}
+     * and related methods to throw the given exception.
+     *
+     * @param ex the exception
+     * @return {@code true} if this invocation caused this CompletableFuture
+     * to transition to a completed state, else {@code false}
+     */
+    public boolean completeExceptionally(Throwable ex) {
+        if (ex == null) throw new NullPointerException();
+        boolean triggered = result == null &&
+            UNSAFE.compareAndSwapObject(this, RESULT, null, new AltResult(ex));
+        postComplete();
+        return triggered;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed
+     * when this CompletableFuture completes, with the result of the
+     * given function of this CompletableFuture's result.
+     *
+     * <p>If this CompletableFuture completes exceptionally, or the
+     * supplied function throws an exception, then the returned
+     * CompletableFuture completes exceptionally with a
+     * CompletionException holding the exception as its cause.
+     *
+     * @param fn the function to use to compute the value of
+     * the returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public <U> CompletableFuture<U> thenApply(Function<? super T,? extends U> fn) {
+        return doThenApply(fn, null);
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when this CompletableFuture completes, with the result of the
+     * given function of this CompletableFuture's result from a
+     * task running in the {@link ForkJoinPool#commonPool()}.
+     *
+     * <p>If this CompletableFuture completes exceptionally, or the
+     * supplied function throws an exception, then the returned
+     * CompletableFuture completes exceptionally with a
+     * CompletionException holding the exception as its cause.
+     *
+     * @param fn the function to use to compute the value of
+     * the returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public <U> CompletableFuture<U> thenApplyAsync
+        (Function<? super T,? extends U> fn) {
+        return doThenApply(fn, ForkJoinPool.commonPool());
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when this CompletableFuture completes, with the result of the
+     * given function of this CompletableFuture's result from a
+     * task running in the given executor.
+     *
+     * <p>If this CompletableFuture completes exceptionally, or the
+     * supplied function throws an exception, then the returned
+     * CompletableFuture completes exceptionally with a
+     * CompletionException holding the exception as its cause.
+     *
+     * @param fn the function to use to compute the value of
+     * the returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public <U> CompletableFuture<U> thenApplyAsync
+        (Function<? super T,? extends U> fn,
+         Executor executor) {
+        if (executor == null) throw new NullPointerException();
+        return doThenApply(fn, executor);
+    }
+
+    private <U> CompletableFuture<U> doThenApply
+        (Function<? super T,? extends U> fn,
+         Executor e) {
+        if (fn == null) throw new NullPointerException();
+        CompletableFuture<U> dst = new CompletableFuture<U>();
+        ThenApply<T,U> d = null;
+        Object r;
+        if ((r = result) == null) {
+            CompletionNode p = new CompletionNode
+                (d = new ThenApply<T,U>(this, fn, dst, e));
+            while ((r = result) == null) {
+                if (UNSAFE.compareAndSwapObject
+                    (this, COMPLETIONS, p.next = completions, p))
+                    break;
+            }
+        }
+        if (r != null && (d == null || d.compareAndSet(0, 1))) {
+            T t; Throwable ex;
+            if (r instanceof AltResult) {
+                ex = ((AltResult)r).ex;
+                t = null;
+            }
+            else {
+                ex = null;
+                @SuppressWarnings("unchecked") T tr = (T) r;
+                t = tr;
+            }
+            U u = null;
+            if (ex == null) {
+                try {
+                    if (e != null)
+                        e.execute(new AsyncApply<T,U>(t, fn, dst));
+                    else
+                        u = fn.apply(t);
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+            }
+            if (e == null || ex != null)
+                dst.internalComplete(u, ex);
+        }
+        helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed
+     * when this CompletableFuture completes, after performing the given
+     * action with this CompletableFuture's result.
+     *
+     * <p>If this CompletableFuture completes exceptionally, or the
+     * supplied action throws an exception, then the returned
+     * CompletableFuture completes exceptionally with a
+     * CompletionException holding the exception as its cause.
+     *
+     * @param block the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> thenAccept(Consumer<? super T> block) {
+        return doThenAccept(block, null);
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when this CompletableFuture completes, after performing the given
+     * action with this CompletableFuture's result from a task running
+     * in the {@link ForkJoinPool#commonPool()}.
+     *
+     * <p>If this CompletableFuture completes exceptionally, or the
+     * supplied action throws an exception, then the returned
+     * CompletableFuture completes exceptionally with a
+     * CompletionException holding the exception as its cause.
+     *
+     * @param block the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> block) {
+        return doThenAccept(block, ForkJoinPool.commonPool());
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when this CompletableFuture completes, after performing the given
+     * action with this CompletableFuture's result from a task running
+     * in the given executor.
+     *
+     * <p>If this CompletableFuture completes exceptionally, or the
+     * supplied action throws an exception, then the returned
+     * CompletableFuture completes exceptionally with a
+     * CompletionException holding the exception as its cause.
+     *
+     * @param block the action to perform before completing the
+     * returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> block,
+                                                   Executor executor) {
+        if (executor == null) throw new NullPointerException();
+        return doThenAccept(block, executor);
+    }
+
+    private CompletableFuture<Void> doThenAccept(Consumer<? super T> fn,
+                                                 Executor e) {
+        if (fn == null) throw new NullPointerException();
+        CompletableFuture<Void> dst = new CompletableFuture<Void>();
+        ThenAccept<T> d = null;
+        Object r;
+        if ((r = result) == null) {
+            CompletionNode p = new CompletionNode
+                (d = new ThenAccept<T>(this, fn, dst, e));
+            while ((r = result) == null) {
+                if (UNSAFE.compareAndSwapObject
+                    (this, COMPLETIONS, p.next = completions, p))
+                    break;
+            }
+        }
+        if (r != null && (d == null || d.compareAndSet(0, 1))) {
+            T t; Throwable ex;
+            if (r instanceof AltResult) {
+                ex = ((AltResult)r).ex;
+                t = null;
+            }
+            else {
+                ex = null;
+                @SuppressWarnings("unchecked") T tr = (T) r;
+                t = tr;
+            }
+            if (ex == null) {
+                try {
+                    if (e != null)
+                        e.execute(new AsyncAccept<T>(t, fn, dst));
+                    else
+                        fn.accept(t);
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+            }
+            if (e == null || ex != null)
+                dst.internalComplete(null, ex);
+        }
+        helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed
+     * when this CompletableFuture completes, after performing the given
+     * action.
+     *
+     * <p>If this CompletableFuture completes exceptionally, or the
+     * supplied action throws an exception, then the returned
+     * CompletableFuture completes exceptionally with a
+     * CompletionException holding the exception as its cause.
+     *
+     * @param action the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> thenRun(Runnable action) {
+        return doThenRun(action, null);
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when this CompletableFuture completes, after performing the given
+     * action from a task running in the {@link ForkJoinPool#commonPool()}.
+     *
+     * <p>If this CompletableFuture completes exceptionally, or the
+     * supplied action throws an exception, then the returned
+     * CompletableFuture completes exceptionally with a
+     * CompletionException holding the exception as its cause.
+     *
+     * @param action the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> thenRunAsync(Runnable action) {
+        return doThenRun(action, ForkJoinPool.commonPool());
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when this CompletableFuture completes, after performing the given
+     * action from a task running in the given executor.
+     *
+     * <p>If this CompletableFuture completes exceptionally, or the
+     * supplied action throws an exception, then the returned
+     * CompletableFuture completes exceptionally with a
+     * CompletionException holding the exception as its cause.
+     *
+     * @param action the action to perform before completing the
+     * returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> thenRunAsync(Runnable action,
+                                                Executor executor) {
+        if (executor == null) throw new NullPointerException();
+        return doThenRun(action, executor);
+    }
+
+    private CompletableFuture<Void> doThenRun(Runnable action,
+                                              Executor e) {
+        if (action == null) throw new NullPointerException();
+        CompletableFuture<Void> dst = new CompletableFuture<Void>();
+        ThenRun d = null;
+        Object r;
+        if ((r = result) == null) {
+            CompletionNode p = new CompletionNode
+                (d = new ThenRun(this, action, dst, e));
+            while ((r = result) == null) {
+                if (UNSAFE.compareAndSwapObject
+                    (this, COMPLETIONS, p.next = completions, p))
+                    break;
+            }
+        }
+        if (r != null && (d == null || d.compareAndSet(0, 1))) {
+            Throwable ex;
+            if (r instanceof AltResult)
+                ex = ((AltResult)r).ex;
+            else
+                ex = null;
+            if (ex == null) {
+                try {
+                    if (e != null)
+                        e.execute(new AsyncRun(action, dst));
+                    else
+                        action.run();
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+            }
+            if (e == null || ex != null)
+                dst.internalComplete(null, ex);
+        }
+        helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed
+     * when both this and the other given CompletableFuture complete,
+     * with the result of the given function of the results of the two
+     * CompletableFutures.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, or the supplied function throws an exception,
+     * then the returned CompletableFuture completes exceptionally
+     * with a CompletionException holding the exception as its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param fn the function to use to compute the value of
+     * the returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public <U,V> CompletableFuture<V> thenCombine
+        (CompletableFuture<? extends U> other,
+         BiFunction<? super T,? super U,? extends V> fn) {
+        return doThenCombine(other, fn, null);
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when both this and the other given CompletableFuture complete,
+     * with the result of the given function of the results of the two
+     * CompletableFutures from a task running in the
+     * {@link ForkJoinPool#commonPool()}.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, or the supplied function throws an exception,
+     * then the returned CompletableFuture completes exceptionally
+     * with a CompletionException holding the exception as its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param fn the function to use to compute the value of
+     * the returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public <U,V> CompletableFuture<V> thenCombineAsync
+        (CompletableFuture<? extends U> other,
+         BiFunction<? super T,? super U,? extends V> fn) {
+        return doThenCombine(other, fn, ForkJoinPool.commonPool());
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when both this and the other given CompletableFuture complete,
+     * with the result of the given function of the results of the two
+     * CompletableFutures from a task running in the given executor.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, or the supplied function throws an exception,
+     * then the returned CompletableFuture completes exceptionally
+     * with a CompletionException holding the exception as its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param fn the function to use to compute the value of
+     * the returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public <U,V> CompletableFuture<V> thenCombineAsync
+        (CompletableFuture<? extends U> other,
+         BiFunction<? super T,? super U,? extends V> fn,
+         Executor executor) {
+        if (executor == null) throw new NullPointerException();
+        return doThenCombine(other, fn, executor);
+    }
+
+    private <U,V> CompletableFuture<V> doThenCombine
+        (CompletableFuture<? extends U> other,
+         BiFunction<? super T,? super U,? extends V> fn,
+         Executor e) {
+        if (other == null || fn == null) throw new NullPointerException();
+        CompletableFuture<V> dst = new CompletableFuture<V>();
+        ThenCombine<T,U,V> d = null;
+        Object r, s = null;
+        if ((r = result) == null || (s = other.result) == null) {
+            d = new ThenCombine<T,U,V>(this, other, fn, dst, e);
+            CompletionNode q = null, p = new CompletionNode(d);
+            while ((r == null && (r = result) == null) ||
+                   (s == null && (s = other.result) == null)) {
+                if (q != null) {
+                    if (s != null ||
+                        UNSAFE.compareAndSwapObject
+                        (other, COMPLETIONS, q.next = other.completions, q))
+                        break;
+                }
+                else if (r != null ||
+                         UNSAFE.compareAndSwapObject
+                         (this, COMPLETIONS, p.next = completions, p)) {
+                    if (s != null)
+                        break;
+                    q = new CompletionNode(d);
+                }
+            }
+        }
+        if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) {
+            T t; U u; Throwable ex;
+            if (r instanceof AltResult) {
+                ex = ((AltResult)r).ex;
+                t = null;
+            }
+            else {
+                ex = null;
+                @SuppressWarnings("unchecked") T tr = (T) r;
+                t = tr;
+            }
+            if (ex != null)
+                u = null;
+            else if (s instanceof AltResult) {
+                ex = ((AltResult)s).ex;
+                u = null;
+            }
+            else {
+                @SuppressWarnings("unchecked") U us = (U) s;
+                u = us;
+            }
+            V v = null;
+            if (ex == null) {
+                try {
+                    if (e != null)
+                        e.execute(new AsyncCombine<T,U,V>(t, u, fn, dst));
+                    else
+                        v = fn.apply(t, u);
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+            }
+            if (e == null || ex != null)
+                dst.internalComplete(v, ex);
+        }
+        helpPostComplete();
+        other.helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed
+     * when both this and the other given CompletableFuture complete,
+     * after performing the given action with the results of the two
+     * CompletableFutures.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, or the supplied action throws an exception,
+     * then the returned CompletableFuture completes exceptionally
+     * with a CompletionException holding the exception as its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param block the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public <U> CompletableFuture<Void> thenAcceptBoth
+        (CompletableFuture<? extends U> other,
+         BiConsumer<? super T, ? super U> block) {
+        return doThenAcceptBoth(other, block, null);
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when both this and the other given CompletableFuture complete,
+     * after performing the given action with the results of the two
+     * CompletableFutures from a task running in the {@link
+     * ForkJoinPool#commonPool()}.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, or the supplied action throws an exception,
+     * then the returned CompletableFuture completes exceptionally
+     * with a CompletionException holding the exception as its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param block the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public <U> CompletableFuture<Void> thenAcceptBothAsync
+        (CompletableFuture<? extends U> other,
+         BiConsumer<? super T, ? super U> block) {
+        return doThenAcceptBoth(other, block, ForkJoinPool.commonPool());
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when both this and the other given CompletableFuture complete,
+     * after performing the given action with the results of the two
+     * CompletableFutures from a task running in the given executor.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, or the supplied action throws an exception,
+     * then the returned CompletableFuture completes exceptionally
+     * with a CompletionException holding the exception as its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param block the action to perform before completing the
+     * returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public <U> CompletableFuture<Void> thenAcceptBothAsync
+        (CompletableFuture<? extends U> other,
+         BiConsumer<? super T, ? super U> block,
+         Executor executor) {
+        if (executor == null) throw new NullPointerException();
+        return doThenAcceptBoth(other, block, executor);
+    }
+
+    private <U> CompletableFuture<Void> doThenAcceptBoth
+        (CompletableFuture<? extends U> other,
+         BiConsumer<? super T,? super U> fn,
+         Executor e) {
+        if (other == null || fn == null) throw new NullPointerException();
+        CompletableFuture<Void> dst = new CompletableFuture<Void>();
+        ThenAcceptBoth<T,U> d = null;
+        Object r, s = null;
+        if ((r = result) == null || (s = other.result) == null) {
+            d = new ThenAcceptBoth<T,U>(this, other, fn, dst, e);
+            CompletionNode q = null, p = new CompletionNode(d);
+            while ((r == null && (r = result) == null) ||
+                   (s == null && (s = other.result) == null)) {
+                if (q != null) {
+                    if (s != null ||
+                        UNSAFE.compareAndSwapObject
+                        (other, COMPLETIONS, q.next = other.completions, q))
+                        break;
+                }
+                else if (r != null ||
+                         UNSAFE.compareAndSwapObject
+                         (this, COMPLETIONS, p.next = completions, p)) {
+                    if (s != null)
+                        break;
+                    q = new CompletionNode(d);
+                }
+            }
+        }
+        if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) {
+            T t; U u; Throwable ex;
+            if (r instanceof AltResult) {
+                ex = ((AltResult)r).ex;
+                t = null;
+            }
+            else {
+                ex = null;
+                @SuppressWarnings("unchecked") T tr = (T) r;
+                t = tr;
+            }
+            if (ex != null)
+                u = null;
+            else if (s instanceof AltResult) {
+                ex = ((AltResult)s).ex;
+                u = null;
+            }
+            else {
+                @SuppressWarnings("unchecked") U us = (U) s;
+                u = us;
+            }
+            if (ex == null) {
+                try {
+                    if (e != null)
+                        e.execute(new AsyncAcceptBoth<T,U>(t, u, fn, dst));
+                    else
+                        fn.accept(t, u);
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+            }
+            if (e == null || ex != null)
+                dst.internalComplete(null, ex);
+        }
+        helpPostComplete();
+        other.helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed
+     * when both this and the other given CompletableFuture complete,
+     * after performing the given action.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, or the supplied action throws an exception,
+     * then the returned CompletableFuture completes exceptionally
+     * with a CompletionException holding the exception as its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param action the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> runAfterBoth(CompletableFuture<?> other,
+                                                Runnable action) {
+        return doRunAfterBoth(other, action, null);
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when both this and the other given CompletableFuture complete,
+     * after performing the given action from a task running in the
+     * {@link ForkJoinPool#commonPool()}.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, or the supplied action throws an exception,
+     * then the returned CompletableFuture completes exceptionally
+     * with a CompletionException holding the exception as its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param action the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> runAfterBothAsync(CompletableFuture<?> other,
+                                                     Runnable action) {
+        return doRunAfterBoth(other, action, ForkJoinPool.commonPool());
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when both this and the other given CompletableFuture complete,
+     * after performing the given action from a task running in the
+     * given executor.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, or the supplied action throws an exception,
+     * then the returned CompletableFuture completes exceptionally
+     * with a CompletionException holding the exception as its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param action the action to perform before completing the
+     * returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> runAfterBothAsync(CompletableFuture<?> other,
+                                                     Runnable action,
+                                                     Executor executor) {
+        if (executor == null) throw new NullPointerException();
+        return doRunAfterBoth(other, action, executor);
+    }
+
+    private CompletableFuture<Void> doRunAfterBoth(CompletableFuture<?> other,
+                                                   Runnable action,
+                                                   Executor e) {
+        if (other == null || action == null) throw new NullPointerException();
+        CompletableFuture<Void> dst = new CompletableFuture<Void>();
+        RunAfterBoth d = null;
+        Object r, s = null;
+        if ((r = result) == null || (s = other.result) == null) {
+            d = new RunAfterBoth(this, other, action, dst, e);
+            CompletionNode q = null, p = new CompletionNode(d);
+            while ((r == null && (r = result) == null) ||
+                   (s == null && (s = other.result) == null)) {
+                if (q != null) {
+                    if (s != null ||
+                        UNSAFE.compareAndSwapObject
+                        (other, COMPLETIONS, q.next = other.completions, q))
+                        break;
+                }
+                else if (r != null ||
+                         UNSAFE.compareAndSwapObject
+                         (this, COMPLETIONS, p.next = completions, p)) {
+                    if (s != null)
+                        break;
+                    q = new CompletionNode(d);
+                }
+            }
+        }
+        if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) {
+            Throwable ex;
+            if (r instanceof AltResult)
+                ex = ((AltResult)r).ex;
+            else
+                ex = null;
+            if (ex == null && (s instanceof AltResult))
+                ex = ((AltResult)s).ex;
+            if (ex == null) {
+                try {
+                    if (e != null)
+                        e.execute(new AsyncRun(action, dst));
+                    else
+                        action.run();
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+            }
+            if (e == null || ex != null)
+                dst.internalComplete(null, ex);
+        }
+        helpPostComplete();
+        other.helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed
+     * when either this or the other given CompletableFuture completes,
+     * with the result of the given function of either this or the other
+     * CompletableFuture's result.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, then the returned CompletableFuture may also do so,
+     * with a CompletionException holding one of these exceptions as its
+     * cause.  No guarantees are made about which result or exception is
+     * used in the returned CompletableFuture.  If the supplied function
+     * throws an exception, then the returned CompletableFuture completes
+     * exceptionally with a CompletionException holding the exception as
+     * its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param fn the function to use to compute the value of
+     * the returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public <U> CompletableFuture<U> applyToEither
+        (CompletableFuture<? extends T> other,
+         Function<? super T, U> fn) {
+        return doApplyToEither(other, fn, null);
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when either this or the other given CompletableFuture completes,
+     * with the result of the given function of either this or the other
+     * CompletableFuture's result from a task running in the
+     * {@link ForkJoinPool#commonPool()}.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, then the returned CompletableFuture may also do so,
+     * with a CompletionException holding one of these exceptions as its
+     * cause.  No guarantees are made about which result or exception is
+     * used in the returned CompletableFuture.  If the supplied function
+     * throws an exception, then the returned CompletableFuture completes
+     * exceptionally with a CompletionException holding the exception as
+     * its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param fn the function to use to compute the value of
+     * the returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public <U> CompletableFuture<U> applyToEitherAsync
+        (CompletableFuture<? extends T> other,
+         Function<? super T, U> fn) {
+        return doApplyToEither(other, fn, ForkJoinPool.commonPool());
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when either this or the other given CompletableFuture completes,
+     * with the result of the given function of either this or the other
+     * CompletableFuture's result from a task running in the
+     * given executor.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, then the returned CompletableFuture may also do so,
+     * with a CompletionException holding one of these exceptions as its
+     * cause.  No guarantees are made about which result or exception is
+     * used in the returned CompletableFuture.  If the supplied function
+     * throws an exception, then the returned CompletableFuture completes
+     * exceptionally with a CompletionException holding the exception as
+     * its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param fn the function to use to compute the value of
+     * the returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public <U> CompletableFuture<U> applyToEitherAsync
+        (CompletableFuture<? extends T> other,
+         Function<? super T, U> fn,
+         Executor executor) {
+        if (executor == null) throw new NullPointerException();
+        return doApplyToEither(other, fn, executor);
+    }
+
+    private <U> CompletableFuture<U> doApplyToEither
+        (CompletableFuture<? extends T> other,
+         Function<? super T, U> fn,
+         Executor e) {
+        if (other == null || fn == null) throw new NullPointerException();
+        CompletableFuture<U> dst = new CompletableFuture<U>();
+        ApplyToEither<T,U> d = null;
+        Object r;
+        if ((r = result) == null && (r = other.result) == null) {
+            d = new ApplyToEither<T,U>(this, other, fn, dst, e);
+            CompletionNode q = null, p = new CompletionNode(d);
+            while ((r = result) == null && (r = other.result) == null) {
+                if (q != null) {
+                    if (UNSAFE.compareAndSwapObject
+                        (other, COMPLETIONS, q.next = other.completions, q))
+                        break;
+                }
+                else if (UNSAFE.compareAndSwapObject
+                         (this, COMPLETIONS, p.next = completions, p))
+                    q = new CompletionNode(d);
+            }
+        }
+        if (r != null && (d == null || d.compareAndSet(0, 1))) {
+            T t; Throwable ex;
+            if (r instanceof AltResult) {
+                ex = ((AltResult)r).ex;
+                t = null;
+            }
+            else {
+                ex = null;
+                @SuppressWarnings("unchecked") T tr = (T) r;
+                t = tr;
+            }
+            U u = null;
+            if (ex == null) {
+                try {
+                    if (e != null)
+                        e.execute(new AsyncApply<T,U>(t, fn, dst));
+                    else
+                        u = fn.apply(t);
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+            }
+            if (e == null || ex != null)
+                dst.internalComplete(u, ex);
+        }
+        helpPostComplete();
+        other.helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed
+     * when either this or the other given CompletableFuture completes,
+     * after performing the given action with the result of either this
+     * or the other CompletableFuture's result.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, then the returned CompletableFuture may also do so,
+     * with a CompletionException holding one of these exceptions as its
+     * cause.  No guarantees are made about which result or exception is
+     * used in the returned CompletableFuture.  If the supplied action
+     * throws an exception, then the returned CompletableFuture completes
+     * exceptionally with a CompletionException holding the exception as
+     * its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param block the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> acceptEither
+        (CompletableFuture<? extends T> other,
+         Consumer<? super T> block) {
+        return doAcceptEither(other, block, null);
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when either this or the other given CompletableFuture completes,
+     * after performing the given action with the result of either this
+     * or the other CompletableFuture's result from a task running in
+     * the {@link ForkJoinPool#commonPool()}.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, then the returned CompletableFuture may also do so,
+     * with a CompletionException holding one of these exceptions as its
+     * cause.  No guarantees are made about which result or exception is
+     * used in the returned CompletableFuture.  If the supplied action
+     * throws an exception, then the returned CompletableFuture completes
+     * exceptionally with a CompletionException holding the exception as
+     * its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param block the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> acceptEitherAsync
+        (CompletableFuture<? extends T> other,
+         Consumer<? super T> block) {
+        return doAcceptEither(other, block, ForkJoinPool.commonPool());
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when either this or the other given CompletableFuture completes,
+     * after performing the given action with the result of either this
+     * or the other CompletableFuture's result from a task running in
+     * the given executor.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, then the returned CompletableFuture may also do so,
+     * with a CompletionException holding one of these exceptions as its
+     * cause.  No guarantees are made about which result or exception is
+     * used in the returned CompletableFuture.  If the supplied action
+     * throws an exception, then the returned CompletableFuture completes
+     * exceptionally with a CompletionException holding the exception as
+     * its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param block the action to perform before completing the
+     * returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> acceptEitherAsync
+        (CompletableFuture<? extends T> other,
+         Consumer<? super T> block,
+         Executor executor) {
+        if (executor == null) throw new NullPointerException();
+        return doAcceptEither(other, block, executor);
+    }
+
+    private CompletableFuture<Void> doAcceptEither
+        (CompletableFuture<? extends T> other,
+         Consumer<? super T> fn,
+         Executor e) {
+        if (other == null || fn == null) throw new NullPointerException();
+        CompletableFuture<Void> dst = new CompletableFuture<Void>();
+        AcceptEither<T> d = null;
+        Object r;
+        if ((r = result) == null && (r = other.result) == null) {
+            d = new AcceptEither<T>(this, other, fn, dst, e);
+            CompletionNode q = null, p = new CompletionNode(d);
+            while ((r = result) == null && (r = other.result) == null) {
+                if (q != null) {
+                    if (UNSAFE.compareAndSwapObject
+                        (other, COMPLETIONS, q.next = other.completions, q))
+                        break;
+                }
+                else if (UNSAFE.compareAndSwapObject
+                         (this, COMPLETIONS, p.next = completions, p))
+                    q = new CompletionNode(d);
+            }
+        }
+        if (r != null && (d == null || d.compareAndSet(0, 1))) {
+            T t; Throwable ex;
+            if (r instanceof AltResult) {
+                ex = ((AltResult)r).ex;
+                t = null;
+            }
+            else {
+                ex = null;
+                @SuppressWarnings("unchecked") T tr = (T) r;
+                t = tr;
+            }
+            if (ex == null) {
+                try {
+                    if (e != null)
+                        e.execute(new AsyncAccept<T>(t, fn, dst));
+                    else
+                        fn.accept(t);
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+            }
+            if (e == null || ex != null)
+                dst.internalComplete(null, ex);
+        }
+        helpPostComplete();
+        other.helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed
+     * when either this or the other given CompletableFuture completes,
+     * after performing the given action.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, then the returned CompletableFuture may also do so,
+     * with a CompletionException holding one of these exceptions as its
+     * cause.  No guarantees are made about which result or exception is
+     * used in the returned CompletableFuture.  If the supplied action
+     * throws an exception, then the returned CompletableFuture completes
+     * exceptionally with a CompletionException holding the exception as
+     * its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param action the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> runAfterEither(CompletableFuture<?> other,
+                                                  Runnable action) {
+        return doRunAfterEither(other, action, null);
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when either this or the other given CompletableFuture completes,
+     * after performing the given action from a task running in the
+     * {@link ForkJoinPool#commonPool()}.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, then the returned CompletableFuture may also do so,
+     * with a CompletionException holding one of these exceptions as its
+     * cause.  No guarantees are made about which result or exception is
+     * used in the returned CompletableFuture.  If the supplied action
+     * throws an exception, then the returned CompletableFuture completes
+     * exceptionally with a CompletionException holding the exception as
+     * its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param action the action to perform before completing the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> runAfterEitherAsync
+        (CompletableFuture<?> other,
+         Runnable action) {
+        return doRunAfterEither(other, action, ForkJoinPool.commonPool());
+    }
+
+    /**
+     * Returns a new CompletableFuture that is asynchronously completed
+     * when either this or the other given CompletableFuture completes,
+     * after performing the given action from a task running in the
+     * given executor.
+     *
+     * <p>If this and/or the other CompletableFuture complete
+     * exceptionally, then the returned CompletableFuture may also do so,
+     * with a CompletionException holding one of these exceptions as its
+     * cause.  No guarantees are made about which result or exception is
+     * used in the returned CompletableFuture.  If the supplied action
+     * throws an exception, then the returned CompletableFuture completes
+     * exceptionally with a CompletionException holding the exception as
+     * its cause.
+     *
+     * @param other the other CompletableFuture
+     * @param action the action to perform before completing the
+     * returned CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<Void> runAfterEitherAsync
+        (CompletableFuture<?> other,
+         Runnable action,
+         Executor executor) {
+        if (executor == null) throw new NullPointerException();
+        return doRunAfterEither(other, action, executor);
+    }
+
+    private CompletableFuture<Void> doRunAfterEither
+        (CompletableFuture<?> other,
+         Runnable action,
+         Executor e) {
+        if (other == null || action == null) throw new NullPointerException();
+        CompletableFuture<Void> dst = new CompletableFuture<Void>();
+        RunAfterEither d = null;
+        Object r;
+        if ((r = result) == null && (r = other.result) == null) {
+            d = new RunAfterEither(this, other, action, dst, e);
+            CompletionNode q = null, p = new CompletionNode(d);
+            while ((r = result) == null && (r = other.result) == null) {
+                if (q != null) {
+                    if (UNSAFE.compareAndSwapObject
+                        (other, COMPLETIONS, q.next = other.completions, q))
+                        break;
+                }
+                else if (UNSAFE.compareAndSwapObject
+                         (this, COMPLETIONS, p.next = completions, p))
+                    q = new CompletionNode(d);
+            }
+        }
+        if (r != null && (d == null || d.compareAndSet(0, 1))) {
+            Throwable ex;
+            if (r instanceof AltResult)
+                ex = ((AltResult)r).ex;
+            else
+                ex = null;
+            if (ex == null) {
+                try {
+                    if (e != null)
+                        e.execute(new AsyncRun(action, dst));
+                    else
+                        action.run();
+                } catch (Throwable rex) {
+                    ex = rex;
+                }
+            }
+            if (e == null || ex != null)
+                dst.internalComplete(null, ex);
+        }
+        helpPostComplete();
+        other.helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a CompletableFuture that upon completion, has the same
+     * value as produced by the given function of the result of this
+     * CompletableFuture.
+     *
+     * <p>If this CompletableFuture completes exceptionally, then the
+     * returned CompletableFuture also does so, with a
+     * CompletionException holding this exception as its cause.
+     * Similarly, if the computed CompletableFuture completes
+     * exceptionally, then so does the returned CompletableFuture.
+     *
+     * @param fn the function returning a new CompletableFuture
+     * @return the CompletableFuture
+     */
+    public <U> CompletableFuture<U> thenCompose
+        (Function<? super T, CompletableFuture<U>> fn) {
+        return doThenCompose(fn, null);
+    }
+
+    /**
+     * Returns a CompletableFuture that upon completion, has the same
+     * value as that produced asynchronously using the {@link
+     * ForkJoinPool#commonPool()} by the given function of the result
+     * of this CompletableFuture.
+     *
+     * <p>If this CompletableFuture completes exceptionally, then the
+     * returned CompletableFuture also does so, with a
+     * CompletionException holding this exception as its cause.
+     * Similarly, if the computed CompletableFuture completes
+     * exceptionally, then so does the returned CompletableFuture.
+     *
+     * @param fn the function returning a new CompletableFuture
+     * @return the CompletableFuture
+     */
+    public <U> CompletableFuture<U> thenComposeAsync
+        (Function<? super T, CompletableFuture<U>> fn) {
+        return doThenCompose(fn, ForkJoinPool.commonPool());
+    }
+
+    /**
+     * Returns a CompletableFuture that upon completion, has the same
+     * value as that produced asynchronously using the given executor
+     * by the given function of this CompletableFuture.
+     *
+     * <p>If this CompletableFuture completes exceptionally, then the
+     * returned CompletableFuture also does so, with a
+     * CompletionException holding this exception as its cause.
+     * Similarly, if the computed CompletableFuture completes
+     * exceptionally, then so does the returned CompletableFuture.
+     *
+     * @param fn the function returning a new CompletableFuture
+     * @param executor the executor to use for asynchronous execution
+     * @return the CompletableFuture
+     */
+    public <U> CompletableFuture<U> thenComposeAsync
+        (Function<? super T, CompletableFuture<U>> fn,
+         Executor executor) {
+        if (executor == null) throw new NullPointerException();
+        return doThenCompose(fn, executor);
+    }
+
+    private <U> CompletableFuture<U> doThenCompose
+        (Function<? super T, CompletableFuture<U>> fn,
+         Executor e) {
+        if (fn == null) throw new NullPointerException();
+        CompletableFuture<U> dst = null;
+        ThenCompose<T,U> d = null;
+        Object r;
+        if ((r = result) == null) {
+            dst = new CompletableFuture<U>();
+            CompletionNode p = new CompletionNode
+                (d = new ThenCompose<T,U>(this, fn, dst, e));
+            while ((r = result) == null) {
+                if (UNSAFE.compareAndSwapObject
+                    (this, COMPLETIONS, p.next = completions, p))
+                    break;
+            }
+        }
+        if (r != null && (d == null || d.compareAndSet(0, 1))) {
+            T t; Throwable ex;
+            if (r instanceof AltResult) {
+                ex = ((AltResult)r).ex;
+                t = null;
+            }
+            else {
+                ex = null;
+                @SuppressWarnings("unchecked") T tr = (T) r;
+                t = tr;
+            }
+            if (ex == null) {
+                if (e != null) {
+                    if (dst == null)
+                        dst = new CompletableFuture<U>();
+                    e.execute(new AsyncCompose<T,U>(t, fn, dst));
+                }
+                else {
+                    try {
+                        if ((dst = fn.apply(t)) == null)
+                            ex = new NullPointerException();
+                    } catch (Throwable rex) {
+                        ex = rex;
+                    }
+                }
+            }
+            if (dst == null)
+                dst = new CompletableFuture<U>();
+            if (e == null || ex != null)
+                dst.internalComplete(null, ex);
+        }
+        helpPostComplete();
+        dst.helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed when this
+     * CompletableFuture completes, with the result of the given
+     * function of the exception triggering this CompletableFuture's
+     * completion when it completes exceptionally; otherwise, if this
+     * CompletableFuture completes normally, then the returned
+     * CompletableFuture also completes normally with the same value.
+     *
+     * @param fn the function to use to compute the value of the
+     * returned CompletableFuture if this CompletableFuture completed
+     * exceptionally
+     * @return the new CompletableFuture
+     */
+    public CompletableFuture<T> exceptionally
+        (Function<Throwable, ? extends T> fn) {
+        if (fn == null) throw new NullPointerException();
+        CompletableFuture<T> dst = new CompletableFuture<T>();
+        ExceptionCompletion<T> d = null;
+        Object r;
+        if ((r = result) == null) {
+            CompletionNode p =
+                new CompletionNode(d = new ExceptionCompletion<T>(this, fn, dst));
+            while ((r = result) == null) {
+                if (UNSAFE.compareAndSwapObject(this, COMPLETIONS,
+                                                p.next = completions, p))
+                    break;
+            }
+        }
+        if (r != null && (d == null || d.compareAndSet(0, 1))) {
+            T t = null; Throwable ex, dx = null;
+            if (r instanceof AltResult) {
+                if ((ex = ((AltResult)r).ex) != null)  {
+                    try {
+                        t = fn.apply(ex);
+                    } catch (Throwable rex) {
+                        dx = rex;
+                    }
+                }
+            }
+            else {
+                @SuppressWarnings("unchecked") T tr = (T) r;
+                t = tr;
+            }
+            dst.internalComplete(t, dx);
+        }
+        helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed when this
+     * CompletableFuture completes, with the result of the given
+     * function of the result and exception of this CompletableFuture's
+     * completion.  The given function is invoked with the result (or
+     * {@code null} if none) and the exception (or {@code null} if none)
+     * of this CompletableFuture when complete.
+     *
+     * @param fn the function to use to compute the value of the
+     * returned CompletableFuture
+     * @return the new CompletableFuture
+     */
+    public <U> CompletableFuture<U> handle
+        (BiFunction<? super T, Throwable, ? extends U> fn) {
+        if (fn == null) throw new NullPointerException();
+        CompletableFuture<U> dst = new CompletableFuture<U>();
+        HandleCompletion<T,U> d = null;
+        Object r;
+        if ((r = result) == null) {
+            CompletionNode p =
+                new CompletionNode(d = new HandleCompletion<T,U>(this, fn, dst));
+            while ((r = result) == null) {
+                if (UNSAFE.compareAndSwapObject(this, COMPLETIONS,
+                                                p.next = completions, p))
+                    break;
+            }
+        }
+        if (r != null && (d == null || d.compareAndSet(0, 1))) {
+            T t; Throwable ex;
+            if (r instanceof AltResult) {
+                ex = ((AltResult)r).ex;
+                t = null;
+            }
+            else {
+                ex = null;
+                @SuppressWarnings("unchecked") T tr = (T) r;
+                t = tr;
+            }
+            U u; Throwable dx;
+            try {
+                u = fn.apply(t, ex);
+                dx = null;
+            } catch (Throwable rex) {
+                dx = rex;
+                u = null;
+            }
+            dst.internalComplete(u, dx);
+        }
+        helpPostComplete();
+        return dst;
+    }
+
+
+    /* ------------- Arbitrary-arity constructions -------------- */
+
+    /*
+     * The basic plan of attack is to recursively form binary
+     * completion trees of elements. This can be overkill for small
+     * sets, but scales nicely. The And/All vs Or/Any forms use the
+     * same idea, but details differ.
+     */
+
+    /**
+     * Returns a new CompletableFuture that is completed when all of
+     * the given CompletableFutures complete.  If any of the given
+     * CompletableFutures complete exceptionally, then the returned
+     * CompletableFuture also does so, with a CompletionException
+     * holding this exception as its cause.  Otherwise, the results,
+     * if any, of the given CompletableFutures are not reflected in
+     * the returned CompletableFuture, but may be obtained by
+     * inspecting them individually. If no CompletableFutures are
+     * provided, returns a CompletableFuture completed with the value
+     * {@code null}.
+     *
+     * <p>Among the applications of this method is to await completion
+     * of a set of independent CompletableFutures before continuing a
+     * program, as in: {@code CompletableFuture.allOf(c1, c2,
+     * c3).join();}.
+     *
+     * @param cfs the CompletableFutures
+     * @return a new CompletableFuture that is completed when all of the
+     * given CompletableFutures complete
+     * @throws NullPointerException if the array or any of its elements are
+     * {@code null}
+     */
+    public static CompletableFuture<Void> allOf(CompletableFuture<?>... cfs) {
+        int len = cfs.length; // Directly handle empty and singleton cases
+        if (len > 1)
+            return allTree(cfs, 0, len - 1);
+        else {
+            CompletableFuture<Void> dst = new CompletableFuture<Void>();
+            CompletableFuture<?> f;
+            if (len == 0)
+                dst.result = NIL;
+            else if ((f = cfs[0]) == null)
+                throw new NullPointerException();
+            else {
+                ThenPropagate d = null;
+                CompletionNode p = null;
+                Object r;
+                while ((r = f.result) == null) {
+                    if (d == null)
+                        d = new ThenPropagate(f, dst);
+                    else if (p == null)
+                        p = new CompletionNode(d);
+                    else if (UNSAFE.compareAndSwapObject
+                             (f, COMPLETIONS, p.next = f.completions, p))
+                        break;
+                }
+                if (r != null && (d == null || d.compareAndSet(0, 1)))
+                    dst.internalComplete(null, (r instanceof AltResult) ?
+                                         ((AltResult)r).ex : null);
+                f.helpPostComplete();
+            }
+            return dst;
+        }
+    }
+
+    /**
+     * Recursively constructs an And'ed tree of CompletableFutures.
+     * Called only when array known to have at least two elements.
+     */
+    private static CompletableFuture<Void> allTree(CompletableFuture<?>[] cfs,
+                                                   int lo, int hi) {
+        CompletableFuture<?> fst, snd;
+        int mid = (lo + hi) >>> 1;
+        if ((fst = (lo == mid   ? cfs[lo] : allTree(cfs, lo,    mid))) == null ||
+            (snd = (hi == mid+1 ? cfs[hi] : allTree(cfs, mid+1, hi))) == null)
+            throw new NullPointerException();
+        CompletableFuture<Void> dst = new CompletableFuture<Void>();
+        AndCompletion d = null;
+        CompletionNode p = null, q = null;
+        Object r = null, s = null;
+        while ((r = fst.result) == null || (s = snd.result) == null) {
+            if (d == null)
+                d = new AndCompletion(fst, snd, dst);
+            else if (p == null)
+                p = new CompletionNode(d);
+            else if (q == null) {
+                if (UNSAFE.compareAndSwapObject
+                    (fst, COMPLETIONS, p.next = fst.completions, p))
+                    q = new CompletionNode(d);
+            }
+            else if (UNSAFE.compareAndSwapObject
+                     (snd, COMPLETIONS, q.next = snd.completions, q))
+                break;
+        }
+        if ((r != null || (r = fst.result) != null) &&
+            (s != null || (s = snd.result) != null) &&
+            (d == null || d.compareAndSet(0, 1))) {
+            Throwable ex;
+            if (r instanceof AltResult)
+                ex = ((AltResult)r).ex;
+            else
+                ex = null;
+            if (ex == null && (s instanceof AltResult))
+                ex = ((AltResult)s).ex;
+            dst.internalComplete(null, ex);
+        }
+        fst.helpPostComplete();
+        snd.helpPostComplete();
+        return dst;
+    }
+
+    /**
+     * Returns a new CompletableFuture that is completed when any of
+     * the given CompletableFutures complete, with the same result.
+     * Otherwise, if it completed exceptionally, the returned
+     * CompletableFuture also does so, with a CompletionException
+     * holding this exception as its cause.  If no CompletableFutures
+     * are provided, returns an incomplete CompletableFuture.
+     *
+     * @param cfs the CompletableFutures
+     * @return a new CompletableFuture that is completed with the
+     * result or exception of any of the given CompletableFutures when
+     * one completes
+     * @throws NullPointerException if the array or any of its elements are
+     * {@code null}
+     */
+    public static CompletableFuture<Object> anyOf(CompletableFuture<?>... cfs) {
+        int len = cfs.length; // Same idea as allOf
+        if (len > 1)
+            return anyTree(cfs, 0, len - 1);
+        else {
+            CompletableFuture<Object> dst = new CompletableFuture<Object>();
+            CompletableFuture<?> f;
+            if (len == 0)
+                ; // skip
+            else if ((f = cfs[0]) == null)
+                throw new NullPointerException();
+            else {
+                ThenCopy<Object> d = null;
+                CompletionNode p = null;
+                Object r;
+                while ((r = f.result) == null) {
+                    if (d == null)
+                        d = new ThenCopy<Object>(f, dst);
+                    else if (p == null)
+                        p = new CompletionNode(d);
+                    else if (UNSAFE.compareAndSwapObject
+                             (f, COMPLETIONS, p.next = f.completions, p))
+                        break;
+                }
+                if (r != null && (d == null || d.compareAndSet(0, 1))) {
+                    Throwable ex; Object t;
+                    if (r instanceof AltResult) {
+                        ex = ((AltResult)r).ex;
+                        t = null;
+                    }
+                    else {
+                        ex = null;
+                        t = r;
+                    }
+                    dst.internalComplete(t, ex);
+                }
+                f.helpPostComplete();
+            }
+            return dst;
+        }
+    }
+
+    /**
+     * Recursively constructs an Or'ed tree of CompletableFutures.
+     */
+    private static CompletableFuture<Object> anyTree(CompletableFuture<?>[] cfs,
+                                                     int lo, int hi) {
+        CompletableFuture<?> fst, snd;
+        int mid = (lo + hi) >>> 1;
+        if ((fst = (lo == mid   ? cfs[lo] : anyTree(cfs, lo,    mid))) == null ||
+            (snd = (hi == mid+1 ? cfs[hi] : anyTree(cfs, mid+1, hi))) == null)
+            throw new NullPointerException();
+        CompletableFuture<Object> dst = new CompletableFuture<Object>();
+        OrCompletion d = null;
+        CompletionNode p = null, q = null;
+        Object r;
+        while ((r = fst.result) == null && (r = snd.result) == null) {
+            if (d == null)
+                d = new OrCompletion(fst, snd, dst);
+            else if (p == null)
+                p = new CompletionNode(d);
+            else if (q == null) {
+                if (UNSAFE.compareAndSwapObject
+                    (fst, COMPLETIONS, p.next = fst.completions, p))
+                    q = new CompletionNode(d);
+            }
+            else if (UNSAFE.compareAndSwapObject
+                     (snd, COMPLETIONS, q.next = snd.completions, q))
+                break;
+        }
+        if ((r != null || (r = fst.result) != null ||
+             (r = snd.result) != null) &&
+            (d == null || d.compareAndSet(0, 1))) {
+            Throwable ex; Object t;
+            if (r instanceof AltResult) {
+                ex = ((AltResult)r).ex;
+                t = null;
+            }
+            else {
+                ex = null;
+                t = r;
+            }
+            dst.internalComplete(t, ex);
+        }
+        fst.helpPostComplete();
+        snd.helpPostComplete();
+        return dst;
+    }
+
+    /* ------------- Control and status methods -------------- */
+
+    /**
+     * If not already completed, completes this CompletableFuture with
+     * a {@link CancellationException}. Dependent CompletableFutures
+     * that have not already completed will also complete
+     * exceptionally, with a {@link CompletionException} caused by
+     * this {@code CancellationException}.
+     *
+     * @param mayInterruptIfRunning this value has no effect in this
+     * implementation because interrupts are not used to control
+     * processing.
+     *
+     * @return {@code true} if this task is now cancelled
+     */
+    public boolean cancel(boolean mayInterruptIfRunning) {
+        boolean cancelled = (result == null) &&
+            UNSAFE.compareAndSwapObject
+            (this, RESULT, null, new AltResult(new CancellationException()));
+        postComplete();
+        return cancelled || isCancelled();
+    }
+
+    /**
+     * Returns {@code true} if this CompletableFuture was cancelled
+     * before it completed normally.
+     *
+     * @return {@code true} if this CompletableFuture was cancelled
+     * before it completed normally
+     */
+    public boolean isCancelled() {
+        Object r;
+        return ((r = result) instanceof AltResult) &&
+            (((AltResult)r).ex instanceof CancellationException);
+    }
+
+    /**
+     * Forcibly sets or resets the value subsequently returned by
+     * method {@link #get()} and related methods, whether or not
+     * already completed. This method is designed for use only in
+     * error recovery actions, and even in such situations may result
+     * in ongoing dependent completions using established versus
+     * overwritten outcomes.
+     *
+     * @param value the completion value
+     */
+    public void obtrudeValue(T value) {
+        result = (value == null) ? NIL : value;
+        postComplete();
+    }
+
+    /**
+     * Forcibly causes subsequent invocations of method {@link #get()}
+     * and related methods to throw the given exception, whether or
+     * not already completed. This method is designed for use only in
+     * recovery actions, and even in such situations may result in
+     * ongoing dependent completions using established versus
+     * overwritten outcomes.
+     *
+     * @param ex the exception
+     */
+    public void obtrudeException(Throwable ex) {
+        if (ex == null) throw new NullPointerException();
+        result = new AltResult(ex);
+        postComplete();
+    }
+
+    /**
+     * Returns the estimated number of CompletableFutures whose
+     * completions are awaiting completion of this CompletableFuture.
+     * This method is designed for use in monitoring system state, not
+     * for synchronization control.
+     *
+     * @return the number of dependent CompletableFutures
+     */
+    public int getNumberOfDependents() {
+        int count = 0;
+        for (CompletionNode p = completions; p != null; p = p.next)
+            ++count;
+        return count;
+    }
+
+    /**
+     * Returns a string identifying this CompletableFuture, as well as
+     * its completion state.  The state, in brackets, contains the
+     * String {@code "Completed Normally"} or the String {@code
+     * "Completed Exceptionally"}, or the String {@code "Not
+     * completed"} followed by the number of CompletableFutures
+     * dependent upon its completion, if any.
+     *
+     * @return a string identifying this CompletableFuture, as well as its state
+     */
+    public String toString() {
+        Object r = result;
+        int count;
+        return super.toString() +
+            ((r == null) ?
+             (((count = getNumberOfDependents()) == 0) ?
+              "[Not completed]" :
+              "[Not completed, " + count + " dependents]") :
+             (((r instanceof AltResult) && ((AltResult)r).ex != null) ?
+              "[Completed exceptionally]" :
+              "[Completed normally]"));
+    }
+
+    // Unsafe mechanics
+    private static final sun.misc.Unsafe UNSAFE;
+    private static final long RESULT;
+    private static final long WAITERS;
+    private static final long COMPLETIONS;
+    static {
+        try {
+            UNSAFE = sun.misc.Unsafe.getUnsafe();
+            Class<?> k = CompletableFuture.class;
+            RESULT = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("result"));
+            WAITERS = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("waiters"));
+            COMPLETIONS = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("completions"));
+        } catch (Exception e) {
+            throw new Error(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/concurrent/CompletionException.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,90 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+package java.util.concurrent;
+
+/**
+ * Exception thrown when an error or other exception is encountered
+ * in the course of completing a result or task.
+ *
+ * @since 1.8
+ * @author Doug Lea
+ */
+public class CompletionException extends RuntimeException {
+    private static final long serialVersionUID = 7830266012832686185L;
+
+    /**
+     * Constructs a {@code CompletionException} with no detail message.
+     * The cause is not initialized, and may subsequently be
+     * initialized by a call to {@link #initCause(Throwable) initCause}.
+     */
+    protected CompletionException() { }
+
+    /**
+     * Constructs a {@code CompletionException} with the specified detail
+     * message. The cause is not initialized, and may subsequently be
+     * initialized by a call to {@link #initCause(Throwable) initCause}.
+     *
+     * @param message the detail message
+     */
+    protected CompletionException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a {@code CompletionException} with the specified detail
+     * message and cause.
+     *
+     * @param  message the detail message
+     * @param  cause the cause (which is saved for later retrieval by the
+     *         {@link #getCause()} method)
+     */
+    public CompletionException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * Constructs a {@code CompletionException} with the specified cause.
+     * The detail message is set to {@code (cause == null ? null :
+     * cause.toString())} (which typically contains the class and
+     * detail message of {@code cause}).
+     *
+     * @param  cause the cause (which is saved for later retrieval by the
+     *         {@link #getCause()} method)
+     */
+    public CompletionException(Throwable cause) {
+        super(cause);
+    }
+}
--- a/jdk/src/share/classes/java/util/function/DoublePredicate.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/util/function/DoublePredicate.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/util/function/IntPredicate.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/util/function/IntPredicate.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/util/function/LongPredicate.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/util/function/LongPredicate.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/util/function/ObjIntConsumer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/util/function/ObjIntConsumer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/util/function/ToDoubleBiFunction.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/util/function/ToDoubleBiFunction.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/util/logging/LoggingProxyImpl.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/util/logging/LoggingProxyImpl.java	Wed Jul 05 18:50:02 2017 +0200
@@ -106,6 +106,11 @@
     }
 
     @Override
+    public int getLevelValue(Object level) {
+        return ((Level) level).intValue();
+    }
+
+    @Override
     public String getProperty(String key) {
         return LogManager.getLogManager().getProperty(key);
     }
--- a/jdk/src/share/classes/java/util/zip/ZipOutputStream.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/java/util/zip/ZipOutputStream.java	Wed Jul 05 18:50:02 2017 +0200
@@ -43,6 +43,20 @@
 public
 class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
 
+    /**
+     * Whether to use ZIP64 for zip files with more than 64k entries.
+     * Until ZIP64 support in zip implementations is ubiquitous, this
+     * system property allows the creation of zip files which can be
+     * read by legacy zip implementations which tolerate "incorrect"
+     * total entry count fields, such as the ones in jdk6, and even
+     * some in jdk7.
+     */
+    private static final boolean inhibitZip64 =
+        Boolean.parseBoolean(
+            java.security.AccessController.doPrivileged(
+                new sun.security.action.GetPropertyAction(
+                    "jdk.util.zip.inhibitZip64", "false")));
+
     private static class XEntry {
         public final ZipEntry entry;
         public final long offset;
@@ -534,8 +548,10 @@
         }
         int count = xentries.size();
         if (count >= ZIP64_MAGICCOUNT) {
-            count = ZIP64_MAGICCOUNT;
-            hasZip64 = true;
+            hasZip64 |= !inhibitZip64;
+            if (hasZip64) {
+                count = ZIP64_MAGICCOUNT;
+            }
         }
         if (hasZip64) {
             long off64 = written;
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java	Wed Jul 05 18:50:02 2017 +0200
@@ -508,7 +508,7 @@
      *
      * @param length the length, in bytes, to which the <code>CLOB</code>
      *        value should be truncated
-     * @throws SerialLException if there is an error accessing the
+     * @throws SerialException if there is an error accessing the
      *        <code>CLOB</code> value;
      * if the {@code free} method had been previously called on this object
      */
--- a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +34,6 @@
 import java.util.Set;
 import java.awt.AWTKeyStroke;
 import java.applet.Applet;
-import javax.tools.annotation.GenerateNativeHeader;
 import sun.applet.AppletPanel;
 
 /**
@@ -54,8 +53,6 @@
  *
  * @author      Thomas Ball
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class EmbeddedFrame extends Frame
                           implements KeyEventDispatcher, PropertyChangeListener {
 
--- a/jdk/src/share/classes/sun/awt/SunHints.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/awt/SunHints.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +26,7 @@
 package sun.awt;
 
 import java.awt.RenderingHints;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * This class contains rendering hints that can be used by the
@@ -34,8 +34,6 @@
  * {@link java.awt.image.BufferedImageOp} and
  * {@link java.awt.image.Raster}.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class SunHints {
     /**
      * Defines the type of all keys used to control various
@@ -180,86 +178,86 @@
     /**
      * Rendering hint key and values
      */
-    public static final int INTKEY_RENDERING = 0;
-    public static final int INTVAL_RENDER_DEFAULT = 0;
-    public static final int INTVAL_RENDER_SPEED = 1;
-    public static final int INTVAL_RENDER_QUALITY = 2;
+    @Native public static final int INTKEY_RENDERING = 0;
+    @Native public static final int INTVAL_RENDER_DEFAULT = 0;
+    @Native public static final int INTVAL_RENDER_SPEED = 1;
+    @Native public static final int INTVAL_RENDER_QUALITY = 2;
 
     /**
      * Antialiasing hint key and values
      */
-    public static final int INTKEY_ANTIALIASING = 1;
-    public static final int INTVAL_ANTIALIAS_DEFAULT = 0;
-    public static final int INTVAL_ANTIALIAS_OFF = 1;
-    public static final int INTVAL_ANTIALIAS_ON = 2;
+    @Native public static final int INTKEY_ANTIALIASING = 1;
+    @Native public static final int INTVAL_ANTIALIAS_DEFAULT = 0;
+    @Native public static final int INTVAL_ANTIALIAS_OFF = 1;
+    @Native public static final int INTVAL_ANTIALIAS_ON = 2;
 
     /**
      * Text antialiasing hint key and values
      */
-    public static final int INTKEY_TEXT_ANTIALIASING = 2;
-    public static final int INTVAL_TEXT_ANTIALIAS_DEFAULT = 0;
-    public static final int INTVAL_TEXT_ANTIALIAS_OFF = 1;
-    public static final int INTVAL_TEXT_ANTIALIAS_ON = 2;
-    public static final int INTVAL_TEXT_ANTIALIAS_GASP = 3;
-    public static final int INTVAL_TEXT_ANTIALIAS_LCD_HRGB = 4;
-    public static final int INTVAL_TEXT_ANTIALIAS_LCD_HBGR = 5;
-    public static final int INTVAL_TEXT_ANTIALIAS_LCD_VRGB = 6;
-    public static final int INTVAL_TEXT_ANTIALIAS_LCD_VBGR = 7;
+    @Native public static final int INTKEY_TEXT_ANTIALIASING = 2;
+    @Native public static final int INTVAL_TEXT_ANTIALIAS_DEFAULT = 0;
+    @Native public static final int INTVAL_TEXT_ANTIALIAS_OFF = 1;
+    @Native public static final int INTVAL_TEXT_ANTIALIAS_ON = 2;
+    @Native public static final int INTVAL_TEXT_ANTIALIAS_GASP = 3;
+    @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_HRGB = 4;
+    @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_HBGR = 5;
+    @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_VRGB = 6;
+    @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_VBGR = 7;
 
     /**
      * Font fractional metrics hint key and values
      */
-    public static final int INTKEY_FRACTIONALMETRICS = 3;
-    public static final int INTVAL_FRACTIONALMETRICS_DEFAULT = 0;
-    public static final int INTVAL_FRACTIONALMETRICS_OFF = 1;
-    public static final int INTVAL_FRACTIONALMETRICS_ON = 2;
+    @Native public static final int INTKEY_FRACTIONALMETRICS = 3;
+    @Native public static final int INTVAL_FRACTIONALMETRICS_DEFAULT = 0;
+    @Native public static final int INTVAL_FRACTIONALMETRICS_OFF = 1;
+    @Native public static final int INTVAL_FRACTIONALMETRICS_ON = 2;
 
     /**
      * Dithering hint key and values
      */
-    public static final int INTKEY_DITHERING = 4;
-    public static final int INTVAL_DITHER_DEFAULT = 0;
-    public static final int INTVAL_DITHER_DISABLE = 1;
-    public static final int INTVAL_DITHER_ENABLE = 2;
+    @Native public static final int INTKEY_DITHERING = 4;
+    @Native public static final int INTVAL_DITHER_DEFAULT = 0;
+    @Native public static final int INTVAL_DITHER_DISABLE = 1;
+    @Native public static final int INTVAL_DITHER_ENABLE = 2;
 
     /**
      * Interpolation hint key and values
      */
-    public static final int INTKEY_INTERPOLATION = 5;
-    public static final int INTVAL_INTERPOLATION_NEAREST_NEIGHBOR = 0;
-    public static final int INTVAL_INTERPOLATION_BILINEAR = 1;
-    public static final int INTVAL_INTERPOLATION_BICUBIC = 2;
+    @Native public static final int INTKEY_INTERPOLATION = 5;
+    @Native public static final int INTVAL_INTERPOLATION_NEAREST_NEIGHBOR = 0;
+    @Native public static final int INTVAL_INTERPOLATION_BILINEAR = 1;
+    @Native public static final int INTVAL_INTERPOLATION_BICUBIC = 2;
 
     /**
      * Alpha interpolation hint key and values
      */
-    public static final int INTKEY_ALPHA_INTERPOLATION = 6;
-    public static final int INTVAL_ALPHA_INTERPOLATION_DEFAULT = 0;
-    public static final int INTVAL_ALPHA_INTERPOLATION_SPEED = 1;
-    public static final int INTVAL_ALPHA_INTERPOLATION_QUALITY = 2;
+    @Native public static final int INTKEY_ALPHA_INTERPOLATION = 6;
+    @Native public static final int INTVAL_ALPHA_INTERPOLATION_DEFAULT = 0;
+    @Native public static final int INTVAL_ALPHA_INTERPOLATION_SPEED = 1;
+    @Native public static final int INTVAL_ALPHA_INTERPOLATION_QUALITY = 2;
 
     /**
      * Color rendering hint key and values
      */
-    public static final int INTKEY_COLOR_RENDERING = 7;
-    public static final int INTVAL_COLOR_RENDER_DEFAULT = 0;
-    public static final int INTVAL_COLOR_RENDER_SPEED = 1;
-    public static final int INTVAL_COLOR_RENDER_QUALITY = 2;
+    @Native public static final int INTKEY_COLOR_RENDERING = 7;
+    @Native public static final int INTVAL_COLOR_RENDER_DEFAULT = 0;
+    @Native public static final int INTVAL_COLOR_RENDER_SPEED = 1;
+    @Native public static final int INTVAL_COLOR_RENDER_QUALITY = 2;
 
     /**
      * Stroke normalization control hint key and values
      */
-    public static final int INTKEY_STROKE_CONTROL = 8;
-    public static final int INTVAL_STROKE_DEFAULT = 0;
-    public static final int INTVAL_STROKE_NORMALIZE = 1;
-    public static final int INTVAL_STROKE_PURE = 2;
+    @Native public static final int INTKEY_STROKE_CONTROL = 8;
+    @Native public static final int INTVAL_STROKE_DEFAULT = 0;
+    @Native public static final int INTVAL_STROKE_NORMALIZE = 1;
+    @Native public static final int INTVAL_STROKE_PURE = 2;
 
     /**
      * LCD text contrast control hint key.
      * Value is "100" to make discontiguous with the others which
      * are all enumerative and are of a different class.
      */
-    public static final int INTKEY_AATEXT_LCD_CONTRAST = 100;
+    @Native public static final int INTKEY_AATEXT_LCD_CONTRAST = 100;
 
     /**
      * Rendering hint key and value objects
--- a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -171,12 +171,12 @@
      * Lazy initialization of Standard Encodings.
      */
     private static class StandardEncodingsHolder {
-        private static final SortedSet standardEncodings = load();
-
-        private static SortedSet load() {
+        private static final SortedSet<String> standardEncodings = load();
+
+        private static SortedSet<String> load() {
             final Comparator comparator =
                     new CharsetComparator(IndexedComparator.SELECT_WORST);
-            final SortedSet tempSet = new TreeSet(comparator);
+            final SortedSet<String> tempSet = new TreeSet<String>(comparator);
             tempSet.add("US-ASCII");
             tempSet.add("ISO-8859-1");
             tempSet.add("UTF-8");
@@ -523,8 +523,8 @@
      * So as to avoid loading all available character converters, optional,
      * non-standard, character sets are not included.
      */
-    public static Iterator standardEncodings() {
-        return StandardEncodingsHolder.standardEncodings.iterator();
+    public static Set <String> standardEncodings() {
+        return StandardEncodingsHolder.standardEncodings;
     }
 
     /**
@@ -1068,17 +1068,10 @@
      *
      * Native to Java string conversion
      */
-    private String translateBytesOrStreamToString(InputStream str,  byte[] bytes,
-                                                    long format,
-                                                    Transferable localeTransferable)
+    private String translateBytesToString(byte[] bytes, long format,
+                                          Transferable localeTransferable)
             throws IOException
     {
-        // A String holds all of its data in memory at one time, so
-        // we can't avoid reading the entire InputStream at this point.
-        if (bytes == null) {
-            bytes = inputStreamToByteArray(str);
-        }
-        str.close();
 
         Long lFormat = Long.valueOf(format);
         String charset = getBestCharsetForTextFormat(lFormat, localeTransferable);
@@ -1221,13 +1214,13 @@
                     ("cannot transfer non-text data as Reader");
             }
 
-            Reader r = (Reader)obj;
             StringBuffer buf = new StringBuffer();
-            int c;
-            while ((c = r.read()) != -1) {
-                buf.append((char)c);
+            try (Reader r = (Reader)obj) {
+                int c;
+                while ((c = r.read()) != -1) {
+                    buf.append((char)c);
+                }
             }
-            r.close();
 
             return translateTransferableString(
                 buf.toString(),
@@ -1309,7 +1302,7 @@
             return bytes;
         }
 
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        byte[] theByteArray = null;
 
         // Target data is a file list. Source data must be a
         // java.util.List which contains java.io.File or String instances.
@@ -1324,8 +1317,9 @@
 
             final ArrayList<String> fileList = castToFiles(list, userProtectionDomain);
 
-            bos = convertFileListToBytes(fileList);
-
+            try (ByteArrayOutputStream bos = convertFileListToBytes(fileList)) {
+                theByteArray = bos.toByteArray();
+            }
 
         // Target data is a URI list. Source data must be a
         // java.util.List which contains java.io.File or String instances.
@@ -1360,57 +1354,72 @@
               }
 
             byte[] eoln = "\r\n".getBytes(targetCharset);
-            for (int i = 0; i < uriList.size(); i++) {
-                byte[] bytes = uriList.get(i).getBytes(targetCharset);
-                bos.write(bytes, 0, bytes.length);
-                bos.write(eoln, 0, eoln.length);
+
+            try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
+                for (int i = 0; i < uriList.size(); i++) {
+                    byte[] bytes = uriList.get(i).getBytes(targetCharset);
+                    bos.write(bytes, 0, bytes.length);
+                    bos.write(eoln, 0, eoln.length);
+                }
+                theByteArray = bos.toByteArray();
             }
 
         // Source data is an InputStream. For arbitrary flavors, just grab the
         // bytes and dump them into a byte array. For text flavors, decode back
         // to a String and recur to reencode according to the requested format.
         } else if (flavor.isRepresentationClassInputStream()) {
-            InputStream is = (InputStream)obj;
-            boolean eof = false;
-            int avail = is.available();
-            byte[] tmp = new byte[avail > 8192 ? avail : 8192];
-            do {
-                int ret;
-                if (!(eof = (ret = is.read(tmp, 0, tmp.length)) == -1)) {
-                    bos.write(tmp, 0, ret);
+            try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
+                try (InputStream is = (InputStream)obj) {
+                    boolean eof = false;
+                    int avail = is.available();
+                    byte[] tmp = new byte[avail > 8192 ? avail : 8192];
+                    do {
+                        int aValue;
+                        if (!(eof = (aValue = is.read(tmp, 0, tmp.length)) == -1)) {
+                            bos.write(tmp, 0, aValue);
+                        }
+                    } while (!eof);
                 }
-            } while (!eof);
-            is.close();
-
-            if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
-                byte[] bytes = bos.toByteArray();
-                bos.close();
-                String sourceEncoding = DataTransferer.getTextCharset(flavor);
-                return translateTransferableString(
-                    new String(bytes, sourceEncoding),
-                    format);
+
+                if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
+                    byte[] bytes = bos.toByteArray();
+                    String sourceEncoding = DataTransferer.getTextCharset(flavor);
+                    return translateTransferableString(
+                               new String(bytes, sourceEncoding),
+                               format);
+                }
+                theByteArray = bos.toByteArray();
             }
 
+
+
         // Source data is an RMI object
         } else if (flavor.isRepresentationClassRemote()) {
+
             Object mo = RMI.newMarshalledObject(obj);
-            ObjectOutputStream oos = new ObjectOutputStream(bos);
-            oos.writeObject(mo);
-            oos.close();
-
-        // Source data is Serializable
+            theByteArray = convertObjectToBytes(mo);
+
+            // Source data is Serializable
         } else if (flavor.isRepresentationClassSerializable()) {
-            ObjectOutputStream oos = new ObjectOutputStream(bos);
-            oos.writeObject(obj);
-            oos.close();
+
+            theByteArray = convertObjectToBytes(obj);
 
         } else {
             throw new IOException("data translation failed");
         }
 
-        byte[] ret = bos.toByteArray();
-        bos.close();
-        return ret;
+
+
+        return theByteArray;
+    }
+
+    private static byte[] convertObjectToBytes(Object object) throws IOException {
+        try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
+             ObjectOutputStream oos = new ObjectOutputStream(bos))
+        {
+            oos.writeObject(object);
+            return bos.toByteArray();
+        }
     }
 
     protected abstract ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList) throws IOException;
@@ -1565,38 +1574,8 @@
                                  long format, Transferable localeTransferable)
         throws IOException
     {
-        return translateBytesOrStream(null, bytes, flavor, format,
-                                      localeTransferable);
-    }
-
-    public Object translateStream(InputStream str, DataFlavor flavor,
-                                  long format, Transferable localeTransferable)
-        throws IOException
-    {
-        return translateBytesOrStream(str, null, flavor, format,
-                                      localeTransferable);
-    }
-
-
-    /**
-     * Primary translation function for translating either a byte array or
-     * an InputStream into an Object, given a source format and a target
-     * DataFlavor.
-     *
-     * One of str/bytes is non-null; the other is null.
-     * The conversion from byte[] to InputStream is cheap, so do that
-     * immediately if necessary. The opposite conversion is expensive,
-     * so avoid it if possible.
-     */
-    protected Object translateBytesOrStream(InputStream str, byte[] bytes,
-                                            DataFlavor flavor, long format,
-                                            Transferable localeTransferable)
-        throws IOException
-    {
-
-        if (str == null) {
-            str = new ByteArrayInputStream(bytes);
-        }
+
+        Object theObject = null;
 
         // Source data is a file list. Use the dragQueryFile native function to
         // do most of the decoding. Then wrap File objects around the String
@@ -1605,12 +1584,8 @@
             if (!DataFlavor.javaFileListFlavor.equals(flavor)) {
                 throw new IOException("data translation failed");
             }
-            if (bytes == null) {
-                bytes = inputStreamToByteArray(str);
-            }
             String[] filenames = dragQueryFile(bytes);
             if (filenames == null) {
-                str.close();
                 return null;
             }
 
@@ -1619,178 +1594,203 @@
             for (int i = 0; i < filenames.length; i++) {
                 files[i] = new File(filenames[i]);
             }
-            str.close();
 
             // Turn the list of Files into a List and return
-            return Arrays.asList(files);
-
-        // Source data is a URI list. Convert to DataFlavor.javaFileListFlavor
-        // where possible.
-        } else if (isURIListFormat(format) && DataFlavor.javaFileListFlavor.equals(flavor)) {
-            try {
-                URI uris[] = dragQueryURIs(str, bytes, format, localeTransferable);
-                if (uris == null) {
-                    return null;
-                }
-                ArrayList files = new ArrayList();
-                for (URI uri : uris) {
-                    try {
-                        files.add(new File(uri));
-                    } catch (IllegalArgumentException illegalArg) {
-                        // When converting from URIs to less generic files,
-                        // common practice (Wine, SWT) seems to be to
-                        // silently drop the URIs that aren't local files.
-                    }
-                }
-                return files;
-            } finally {
-                str.close();
-            }
-
-        // Target data is a String. Strip terminating NUL bytes. Decode bytes
-        // into characters. Search-and-replace EOLN.
+            theObject = Arrays.asList(files);
+
+            // Target data is a String. Strip terminating NUL bytes. Decode bytes
+            // into characters. Search-and-replace EOLN.
         } else if (String.class.equals(flavor.getRepresentationClass()) &&
-                   isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
-
-            return translateBytesOrStreamToString(
-                str, bytes,
-                format, localeTransferable);
-
-        // Special hack to maintain backwards-compatibility with the brokenness
-        // of StringSelection. Return a StringReader instead of an InputStream.
-        // Recur to obtain String and encapsulate.
-        } else if (DataFlavor.plainTextFlavor.equals(flavor)) {
-            return new StringReader(translateBytesOrStreamToString(
-                        str, bytes,
-                        format, localeTransferable));
-
-        // Target data is an InputStream. For arbitrary flavors, just return
-        // the raw bytes. For text flavors, decode to strip terminators and
-        // search-and-replace EOLN, then reencode according to the requested
-        // flavor.
-        } else if (flavor.isRepresentationClassInputStream()) {
-            return translateBytesOrStreamToInputStream(str, flavor, format,
-                                                       localeTransferable);
-
-        // Target data is a Reader. Obtain data in InputStream format, encoded
-        // as "Unicode" (utf-16be). Then use an InputStreamReader to decode
-        // back to chars on demand.
+                       isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
+
+            theObject = translateBytesToString(bytes, format, localeTransferable);
+
+            // Target data is a Reader. Obtain data in InputStream format, encoded
+            // as "Unicode" (utf-16be). Then use an InputStreamReader to decode
+            // back to chars on demand.
         } else if (flavor.isRepresentationClassReader()) {
-            if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) {
-                throw new IOException
-                    ("cannot transfer non-text data as Reader");
+            try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes)) {
+                theObject = translateStream(bais,
+                        flavor, format, localeTransferable);
             }
-
-            InputStream is = (InputStream)
-                translateBytesOrStreamToInputStream
-                    (str, DataFlavor.plainTextFlavor, format,
-                     localeTransferable);
-            String unicode =
-                DataTransferer.getTextCharset(DataFlavor.plainTextFlavor);
-            Reader reader = new InputStreamReader(is, unicode);
-
-            return constructFlavoredObject(reader, flavor, Reader.class);
-
-        // Target data is a CharBuffer. Recur to obtain String and wrap.
+            // Target data is a CharBuffer. Recur to obtain String and wrap.
         } else if (flavor.isRepresentationClassCharBuffer()) {
             if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) {
                 throw new IOException
-                    ("cannot transfer non-text data as CharBuffer");
+                          ("cannot transfer non-text data as CharBuffer");
             }
 
-            CharBuffer buffer = CharBuffer.wrap(translateBytesOrStreamToString(
-                str, bytes,
-                format, localeTransferable));
-
-            return constructFlavoredObject(buffer, flavor, CharBuffer.class);
-
-        // Target data is a char array. Recur to obtain String and convert to
-        // char array.
+            CharBuffer buffer = CharBuffer.wrap(
+                translateBytesToString(bytes,format, localeTransferable));
+
+            theObject = constructFlavoredObject(buffer, flavor, CharBuffer.class);
+
+            // Target data is a char array. Recur to obtain String and convert to
+            // char array.
         } else if (charArrayClass.equals(flavor.getRepresentationClass())) {
             if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) {
                 throw new IOException
-                    ("cannot transfer non-text data as char array");
+                          ("cannot transfer non-text data as char array");
             }
 
-            return translateBytesOrStreamToString(
-                    str, bytes,
-                    format, localeTransferable).toCharArray();
-
-        // Target data is a ByteBuffer. For arbitrary flavors, just return
-        // the raw bytes. For text flavors, convert to a String to strip
-        // terminators and search-and-replace EOLN, then reencode according to
-        // the requested flavor.
+            theObject = translateBytesToString(
+                bytes, format, localeTransferable).toCharArray();
+
+            // Target data is a ByteBuffer. For arbitrary flavors, just return
+            // the raw bytes. For text flavors, convert to a String to strip
+            // terminators and search-and-replace EOLN, then reencode according to
+            // the requested flavor.
         } else if (flavor.isRepresentationClassByteBuffer()) {
             if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
-                bytes = translateBytesOrStreamToString(
-                    str, bytes,
-                    format, localeTransferable
-                ).getBytes(
-                    DataTransferer.getTextCharset(flavor)
-                );
-            } else {
-                if (bytes == null) {
-                    bytes = inputStreamToByteArray(str);
-                }
+                bytes = translateBytesToString(
+                    bytes, format, localeTransferable).getBytes(
+                        DataTransferer.getTextCharset(flavor)
+                    );
             }
 
             ByteBuffer buffer = ByteBuffer.wrap(bytes);
-            return constructFlavoredObject(buffer, flavor, ByteBuffer.class);
-
-        // Target data is a byte array. For arbitrary flavors, just return
-        // the raw bytes. For text flavors, convert to a String to strip
-        // terminators and search-and-replace EOLN, then reencode according to
-        // the requested flavor.
+            theObject = constructFlavoredObject(buffer, flavor, ByteBuffer.class);
+
+            // Target data is a byte array. For arbitrary flavors, just return
+            // the raw bytes. For text flavors, convert to a String to strip
+            // terminators and search-and-replace EOLN, then reencode according to
+            // the requested flavor.
         } else if (byteArrayClass.equals(flavor.getRepresentationClass())) {
             if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
-                return translateBytesOrStreamToString(
-                    str, bytes,
-                    format, localeTransferable
-                ).getBytes(
-                    DataTransferer.getTextCharset(flavor)
-                );
+                theObject = translateBytesToString(
+                    bytes, format, localeTransferable
+                ).getBytes(DataTransferer.getTextCharset(flavor));
             } else {
-                return (bytes != null) ? bytes : inputStreamToByteArray(str);
+                theObject = bytes;
             }
 
-        // Target data is an RMI object
-        } else if (flavor.isRepresentationClassRemote()) {
-            try {
-                byte[] ba = inputStreamToByteArray(str);
-                ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(ba));
-                Object ret = RMI.getMarshalledObject(ois.readObject());
-                ois.close();
-                str.close();
-                return ret;
-            } catch (Exception e) {
-                throw new IOException(e.getMessage());
+            // Target data is an InputStream. For arbitrary flavors, just return
+            // the raw bytes. For text flavors, decode to strip terminators and
+            // search-and-replace EOLN, then reencode according to the requested
+            // flavor.
+        } else if (flavor.isRepresentationClassInputStream()) {
+
+            try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes)) {
+                theObject = translateStream(bais, flavor, format, localeTransferable);
             }
 
-        // Target data is Serializable
+            // Target data is Serializable
         } else if (flavor.isRepresentationClassSerializable()) {
-            try {
-                byte[] ba = inputStreamToByteArray(str);
-                ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(ba));
-                Object ret = ois.readObject();
-                ois.close();
-                str.close();
-                return ret;
-            } catch (Exception e) {
-                throw new IOException(e.getMessage());
+
+            try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes)) {
+                theObject = translateStream(bais, flavor, format, localeTransferable);
             }
 
-        // Target data is Image
+            // Target data is Image
         } else if (DataFlavor.imageFlavor.equals(flavor)) {
             if (!isImageFormat(format)) {
                 throw new IOException("data translation failed");
             }
 
-            Image image = platformImageBytesOrStreamToImage(str, bytes, format);
-            str.close();
-            return image;
+            theObject = platformImageBytesToImage(bytes, format);
+        }
+
+        if (theObject == null) {
+            throw new IOException("data translation failed");
         }
 
-        throw new IOException("data translation failed");
+        return theObject;
+
+    }
+
+    /**
+     * Primary translation function for translating
+     * an InputStream into an Object, given a source format and a target
+     * DataFlavor.
+     */
+    public Object translateStream(InputStream str, DataFlavor flavor,
+                                  long format, Transferable localeTransferable)
+        throws IOException
+    {
+
+        Object theObject = null;
+        // Source data is a URI list. Convert to DataFlavor.javaFileListFlavor
+        // where possible.
+        if (isURIListFormat(format)
+                && DataFlavor.javaFileListFlavor.equals(flavor))
+        {
+
+            URI uris[] = dragQueryURIs(str, format, localeTransferable);
+            if (uris == null) {
+                return null;
+            }
+            ArrayList files = new ArrayList();
+            for (URI uri : uris) {
+                try {
+                    files.add(new File(uri));
+                } catch (IllegalArgumentException illegalArg) {
+                    // When converting from URIs to less generic files,
+                    // common practice (Wine, SWT) seems to be to
+                    // silently drop the URIs that aren't local files.
+                }
+            }
+            theObject = files;
+
+            // Special hack to maintain backwards-compatibility with the brokenness
+            // of StringSelection. Return a StringReader instead of an InputStream.
+            // Recur to obtain String and encapsulate.
+        } else if (DataFlavor.plainTextFlavor.equals(flavor)) {
+            theObject = new StringReader(translateBytesToString(
+                inputStreamToByteArray(str),
+                format, localeTransferable));
+
+            // Target data is an InputStream. For arbitrary flavors, just return
+            // the raw bytes. For text flavors, decode to strip terminators and
+            // search-and-replace EOLN, then reencode according to the requested
+            // flavor.
+        } else if (flavor.isRepresentationClassInputStream()) {
+            theObject = translateStreamToInputStream(str, flavor, format,
+                                                               localeTransferable);
+
+            // Target data is a Reader. Obtain data in InputStream format, encoded
+            // as "Unicode" (utf-16be). Then use an InputStreamReader to decode
+            // back to chars on demand.
+        } else if (flavor.isRepresentationClassReader()) {
+            if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) {
+                throw new IOException
+                          ("cannot transfer non-text data as Reader");
+            }
+
+            InputStream is = (InputStream)translateStreamToInputStream(
+                    str, DataFlavor.plainTextFlavor,
+                    format, localeTransferable);
+
+            String unicode = DataTransferer.getTextCharset(DataFlavor.plainTextFlavor);
+
+            Reader reader = new InputStreamReader(is, unicode);
+
+            theObject = constructFlavoredObject(reader, flavor, Reader.class);
+
+            // Target data is an RMI object
+        } else if (flavor.isRepresentationClassRemote()) {
+
+            try (ObjectInputStream ois =
+                     new ObjectInputStream(str))
+            {
+                theObject = RMI.getMarshalledObject(ois.readObject());
+            }catch (Exception e) {
+                throw new IOException(e.getMessage());
+            }
+
+            // Target data is Serializable
+        } else if (flavor.isRepresentationClassSerializable()) {
+            try (ObjectInputStream ois =
+                     new ObjectInputStream(str))
+            {
+                theObject = ois.readObject();
+            } catch (Exception e) {
+                throw new IOException(e.getMessage());
+            }
+        }
+
+
+        return theObject;
+
     }
 
     /**
@@ -1798,7 +1798,7 @@
      * ReencodingInputStream will decode and reencode the InputStream on demand
      * so that we can strip terminators and search-and-replace EOLN.
      */
-    private Object translateBytesOrStreamToInputStream
+    private Object translateStreamToInputStream
         (InputStream str, DataFlavor flavor, long format,
          Transferable localeTransferable) throws IOException
     {
@@ -2054,7 +2054,6 @@
      * Decodes URIs from either a byte array or a stream.
      */
     protected URI[] dragQueryURIs(InputStream stream,
-                                  byte[] bytes,
                                   long format,
                                   Transferable localeTransferable)
       throws IOException
@@ -2067,10 +2066,10 @@
      * Translates either a byte array or an input stream which contain
      * platform-specific image data in the given format into an Image.
      */
-    protected abstract Image platformImageBytesOrStreamToImage(InputStream str,
-                                                               byte[] bytes,
-                                                               long format)
-      throws IOException;
+
+
+    protected abstract Image platformImageBytesToImage(
+        byte[] bytes,long format) throws IOException;
 
     /**
      * Translates either a byte array or an input stream which contain
@@ -2078,13 +2077,9 @@
      *
      * @param mimeType image MIME type, such as: image/png, image/jpeg, image/gif
      */
-    protected Image standardImageBytesOrStreamToImage(InputStream inputStream,
-                                                      byte[] bytes,
-                                                      String mimeType)
-      throws IOException {
-        if (inputStream == null) {
-            inputStream = new ByteArrayInputStream(bytes);
-        }
+    protected Image standardImageBytesToImage(
+        byte[] bytes, String mimeType) throws IOException
+    {
 
         Iterator readerIterator = ImageIO.getImageReadersByMIMEType(mimeType);
 
@@ -2097,9 +2092,9 @@
 
         while (readerIterator.hasNext()) {
             ImageReader imageReader = (ImageReader)readerIterator.next();
-            try {
+            try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes)) {
                 ImageInputStream imageInputStream =
-                    ImageIO.createImageInputStream(inputStream);
+                    ImageIO.createImageInputStream(bais);
 
                 try {
                     ImageReadParam param = imageReader.getDefaultReadParam();
@@ -2456,15 +2451,16 @@
     protected static byte[] inputStreamToByteArray(InputStream str)
         throws IOException
     {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        int len = 0;
-        byte[] buf = new byte[8192];
-
-        while ((len = str.read(buf)) != -1) {
-            baos.write(buf, 0, len);
+        try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+            int len = 0;
+            byte[] buf = new byte[8192];
+
+            while ((len = str.read(buf)) != -1) {
+                baos.write(buf, 0, len);
+            }
+
+            return baos.toByteArray();
         }
-
-        return baos.toByteArray();
     }
 
     /**
--- a/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,6 @@
 import sun.awt.datatransfer.DataTransferer;
 import java.awt.datatransfer.DataFlavor;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * <p>
@@ -64,8 +63,6 @@
  * @since JDK1.3.1
  *
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class SunDragSourceContextPeer implements DragSourceContextPeer {
 
     private DragGestureEvent  trigger;
@@ -278,7 +275,7 @@
      * upcall from native code
      */
 
-    private void dragEnter(final int targetActions,
+    protected void dragEnter(final int targetActions,
                            final int modifiers,
                            final int x, final int y) {
         postDragSourceDragEvent(targetActions, modifiers, x, y, DISPATCH_ENTER);
@@ -356,10 +353,6 @@
 
     public static void setDragDropInProgress(boolean b)
       throws InvalidDnDOperationException {
-        if (dragDropInProgress == b) {
-            throw new InvalidDnDOperationException(getExceptionMessage(b));
-        }
-
         synchronized (SunDragSourceContextPeer.class) {
             if (dragDropInProgress == b) {
                 throw new InvalidDnDOperationException(getExceptionMessage(b));
--- a/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -57,7 +57,6 @@
 import sun.awt.SunToolkit;
 import sun.awt.datatransfer.DataTransferer;
 import sun.awt.datatransfer.ToolkitThreadBlockedHandler;
-import sun.security.util.SecurityConstants;
 
 /**
  * <p>
@@ -260,6 +259,7 @@
         }
 
         final long format = lFormat.longValue();
+
         Object ret = getNativeData(format);
 
         if (ret instanceof byte[]) {
@@ -270,11 +270,14 @@
                 throw new InvalidDnDOperationException(e.getMessage());
             }
         } else if (ret instanceof InputStream) {
+            InputStream inputStream = (InputStream)ret;
             try {
                 return DataTransferer.getInstance().
-                    translateStream((InputStream)ret, df, format, this);
+                    translateStream(inputStream, df, format, this);
             } catch (IOException e) {
                 throw new InvalidDnDOperationException(e.getMessage());
+            } finally {
+                inputStream.close();
             }
         } else {
             throw new IOException("no native data was transfered");
--- a/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,10 +45,7 @@
 import sun.java2d.loops.CompositeType;
 import sun.java2d.loops.RenderLoops;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class BufImgSurfaceData extends SurfaceData {
     BufferedImage bufImg;
     private BufferedImageGraphicsConfig graphicsConfig;
--- a/jdk/src/share/classes/sun/font/FontManager.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/font/FontManager.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,11 @@
 
 import javax.swing.plaf.FontUIResource;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * Interface between Java Fonts (java.awt.Font) and the underlying
  * font files/native font resources and the Java and native font scalers.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public interface FontManager {
 
     // These constants are used in findFont().
--- a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,7 +92,7 @@
 import sun.java2d.DestSurfaceProvider;
 import sun.misc.PerformanceLogger;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * This is a the master Graphics2D superclass for all of the Sun
@@ -103,8 +103,6 @@
  *
  * @author Jim Graham
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public final class SunGraphics2D
     extends Graphics2D
     implements ConstrainableGraphics, Cloneable, DestSurfaceProvider
@@ -113,18 +111,29 @@
      * Attribute States
      */
     /* Paint */
+    @Native
     public static final int PAINT_CUSTOM       = 6; /* Any other Paint object */
+    @Native
     public static final int PAINT_TEXTURE      = 5; /* Tiled Image */
+    @Native
     public static final int PAINT_RAD_GRADIENT = 4; /* Color RadialGradient */
+    @Native
     public static final int PAINT_LIN_GRADIENT = 3; /* Color LinearGradient */
+    @Native
     public static final int PAINT_GRADIENT     = 2; /* Color Gradient */
+    @Native
     public static final int PAINT_ALPHACOLOR   = 1; /* Non-opaque Color */
+    @Native
     public static final int PAINT_OPAQUECOLOR  = 0; /* Opaque Color */
 
     /* Composite*/
+    @Native
     public static final int COMP_CUSTOM = 3;/* Custom Composite */
+    @Native
     public static final int COMP_XOR    = 2;/* XOR Mode Composite */
+    @Native
     public static final int COMP_ALPHA  = 1;/* AlphaComposite */
+    @Native
     public static final int COMP_ISCOPY = 0;/* simple stores into destination,
                                              * i.e. Src, SrcOverNoEa, and other
                                              * alpha modes which replace
@@ -132,21 +141,33 @@
                                              */
 
     /* Stroke */
+    @Native
     public static final int STROKE_CUSTOM = 3; /* custom Stroke */
+    @Native
     public static final int STROKE_WIDE   = 2; /* BasicStroke */
+    @Native
     public static final int STROKE_THINDASHED   = 1; /* BasicStroke */
+    @Native
     public static final int STROKE_THIN   = 0; /* BasicStroke */
 
     /* Transform */
+    @Native
     public static final int TRANSFORM_GENERIC = 4; /* any 3x2 */
+    @Native
     public static final int TRANSFORM_TRANSLATESCALE = 3; /* scale XY */
+    @Native
     public static final int TRANSFORM_ANY_TRANSLATE = 2; /* non-int translate */
+    @Native
     public static final int TRANSFORM_INT_TRANSLATE = 1; /* int translate */
+    @Native
     public static final int TRANSFORM_ISIDENT = 0; /* Identity */
 
     /* Clipping */
+    @Native
     public static final int CLIP_SHAPE       = 2; /* arbitrary clip */
+    @Native
     public static final int CLIP_RECTANGULAR = 1; /* rectangular clip */
+    @Native
     public static final int CLIP_DEVICE      = 0; /* no clipping set */
 
     /* The following fields are used when the current Paint is a Color. */
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,10 +45,8 @@
 import sun.java2d.pipe.RenderBuffer;
 import sun.java2d.pipe.RenderQueue;
 import static sun.java2d.pipe.BufferedOpCodes.*;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 class OGLBlitLoops {
 
     static void register() {
@@ -190,12 +188,12 @@
      * createPackedParams().  (They are also used at the native level when
      * unpacking the params.)
      */
-    private static final int OFFSET_SRCTYPE = 16;
-    private static final int OFFSET_HINT    =  8;
-    private static final int OFFSET_TEXTURE =  3;
-    private static final int OFFSET_RTT     =  2;
-    private static final int OFFSET_XFORM   =  1;
-    private static final int OFFSET_ISOBLIT =  0;
+    @Native private static final int OFFSET_SRCTYPE = 16;
+    @Native private static final int OFFSET_HINT    =  8;
+    @Native private static final int OFFSET_TEXTURE =  3;
+    @Native private static final int OFFSET_RTT     =  2;
+    @Native private static final int OFFSET_XFORM   =  1;
+    @Native private static final int OFFSET_ISOBLIT =  0;
 
     /**
      * Packs the given parameters into a single int value in order to save
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLContext.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLContext.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 import static sun.java2d.pipe.BufferedOpCodes.*;
 import static sun.java2d.pipe.hw.ContextCapabilities.*;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * Note that the RenderQueue lock must be acquired before calling any of
@@ -155,39 +155,44 @@
         rq.flushNow();
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     static class OGLContextCaps extends ContextCapabilities {
         /**
          * Indicates the presence of the GL_EXT_framebuffer_object extension.
          * This cap will only be set if the fbobject system property has been
          * enabled and we are able to create an FBO with depth buffer.
          */
+        @Native
         static final int CAPS_EXT_FBOBJECT     =
                 (CAPS_RT_TEXTURE_ALPHA | CAPS_RT_TEXTURE_OPAQUE);
         /** Indicates that the context supports a stored alpha channel. */
+        @Native
         static final int CAPS_STORED_ALPHA     = CAPS_RT_PLAIN_ALPHA;
         /** Indicates that the context is doublebuffered. */
+        @Native
         static final int CAPS_DOUBLEBUFFERED   = (FIRST_PRIVATE_CAP << 0);
         /**
          * Indicates the presence of the GL_ARB_fragment_shader extension.
          * This cap will only be set if the lcdshader system property has been
          * enabled and the hardware supports the minimum number of texture units
          */
+        @Native
         static final int CAPS_EXT_LCD_SHADER   = (FIRST_PRIVATE_CAP << 1);
         /**
          * Indicates the presence of the GL_ARB_fragment_shader extension.
          * This cap will only be set if the biopshader system property has been
          * enabled and the hardware meets our minimum requirements.
          */
+        @Native
         static final int CAPS_EXT_BIOP_SHADER  = (FIRST_PRIVATE_CAP << 2);
         /**
          * Indicates the presence of the GL_ARB_fragment_shader extension.
          * This cap will only be set if the gradshader system property has been
          * enabled and the hardware meets our minimum requirements.
          */
+        @Native
         static final int CAPS_EXT_GRAD_SHADER  = (FIRST_PRIVATE_CAP << 3);
         /** Indicates the presence of the GL_ARB_texture_rectangle extension. */
+        @Native
         static final int CAPS_EXT_TEXRECT      = (FIRST_PRIVATE_CAP << 4);
 
         OGLContextCaps(int caps, String adapterId) {
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
 import static sun.java2d.pipe.BufferedOpCodes.*;
 import static sun.java2d.pipe.BufferedRenderPipe.BYTES_PER_SPAN;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * Base context class for managing state in a single-threaded rendering
@@ -49,8 +49,6 @@
  *
  * @see RenderQueue
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class BufferedContext {
 
     /*
@@ -63,19 +61,19 @@
     /**
      * Indicates that no flags are needed; take all default code paths.
      */
-    public static final int NO_CONTEXT_FLAGS = (0 << 0);
+    @Native public static final int NO_CONTEXT_FLAGS = (0 << 0);
     /**
      * Indicates that the source surface (or color value, if it is a simple
      * rendering operation) is opaque (has an alpha value of 1.0).  If this
      * flag is present, it allows us to disable blending in certain
      * situations in order to improve performance.
      */
-    public static final int SRC_IS_OPAQUE    = (1 << 0);
+    @Native public static final int SRC_IS_OPAQUE    = (1 << 0);
     /**
      * Indicates that the operation uses an alpha mask, which may determine
      * the code path that is used when setting up the current paint state.
      */
-    public static final int USE_MASK         = (1 << 1);
+    @Native public static final int USE_MASK         = (1 << 1);
 
     protected RenderQueue rq;
     protected RenderBuffer buf;
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedOpCodes.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedOpCodes.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,79 +25,77 @@
 
 package sun.java2d.pipe;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class BufferedOpCodes {
     // draw ops
-    public static final int DRAW_LINE            = 10;
-    public static final int DRAW_RECT            = 11;
-    public static final int DRAW_POLY            = 12;
-    public static final int DRAW_PIXEL           = 13;
-    public static final int DRAW_SCANLINES       = 14;
-    public static final int DRAW_PARALLELOGRAM   = 15;
-    public static final int DRAW_AAPARALLELOGRAM = 16;
+    @Native public static final int DRAW_LINE            = 10;
+    @Native public static final int DRAW_RECT            = 11;
+    @Native public static final int DRAW_POLY            = 12;
+    @Native public static final int DRAW_PIXEL           = 13;
+    @Native public static final int DRAW_SCANLINES       = 14;
+    @Native public static final int DRAW_PARALLELOGRAM   = 15;
+    @Native public static final int DRAW_AAPARALLELOGRAM = 16;
 
     // fill ops
-    public static final int FILL_RECT            = 20;
-    public static final int FILL_SPANS           = 21;
-    public static final int FILL_PARALLELOGRAM   = 22;
-    public static final int FILL_AAPARALLELOGRAM = 23;
+    @Native public static final int FILL_RECT            = 20;
+    @Native public static final int FILL_SPANS           = 21;
+    @Native public static final int FILL_PARALLELOGRAM   = 22;
+    @Native public static final int FILL_AAPARALLELOGRAM = 23;
 
     // copy-related ops
-    public static final int COPY_AREA            = 30;
-    public static final int BLIT                 = 31;
-    public static final int MASK_FILL            = 32;
-    public static final int MASK_BLIT            = 33;
-    public static final int SURFACE_TO_SW_BLIT   = 34;
+    @Native public static final int COPY_AREA            = 30;
+    @Native public static final int BLIT                 = 31;
+    @Native public static final int MASK_FILL            = 32;
+    @Native public static final int MASK_BLIT            = 33;
+    @Native public static final int SURFACE_TO_SW_BLIT   = 34;
 
     // text-related ops
-    public static final int DRAW_GLYPH_LIST      = 40;
+    @Native public static final int DRAW_GLYPH_LIST      = 40;
 
     // state-related ops
-    public static final int SET_RECT_CLIP        = 51;
-    public static final int BEGIN_SHAPE_CLIP     = 52;
-    public static final int SET_SHAPE_CLIP_SPANS = 53;
-    public static final int END_SHAPE_CLIP       = 54;
-    public static final int RESET_CLIP           = 55;
-    public static final int SET_ALPHA_COMPOSITE  = 56;
-    public static final int SET_XOR_COMPOSITE    = 57;
-    public static final int RESET_COMPOSITE      = 58;
-    public static final int SET_TRANSFORM        = 59;
-    public static final int RESET_TRANSFORM      = 60;
+    @Native public static final int SET_RECT_CLIP        = 51;
+    @Native public static final int BEGIN_SHAPE_CLIP     = 52;
+    @Native public static final int SET_SHAPE_CLIP_SPANS = 53;
+    @Native public static final int END_SHAPE_CLIP       = 54;
+    @Native public static final int RESET_CLIP           = 55;
+    @Native public static final int SET_ALPHA_COMPOSITE  = 56;
+    @Native public static final int SET_XOR_COMPOSITE    = 57;
+    @Native public static final int RESET_COMPOSITE      = 58;
+    @Native public static final int SET_TRANSFORM        = 59;
+    @Native public static final int RESET_TRANSFORM      = 60;
 
     // context-related ops
-    public static final int SET_SURFACES         = 70;
-    public static final int SET_SCRATCH_SURFACE  = 71;
-    public static final int FLUSH_SURFACE        = 72;
-    public static final int DISPOSE_SURFACE      = 73;
-    public static final int DISPOSE_CONFIG       = 74;
-    public static final int INVALIDATE_CONTEXT   = 75;
-    public static final int SYNC                 = 76;
-    public static final int RESTORE_DEVICES      = 77;
-    public static final int SAVE_STATE           = 78;
-    public static final int RESTORE_STATE        = 79;
+    @Native public static final int SET_SURFACES         = 70;
+    @Native public static final int SET_SCRATCH_SURFACE  = 71;
+    @Native public static final int FLUSH_SURFACE        = 72;
+    @Native public static final int DISPOSE_SURFACE      = 73;
+    @Native public static final int DISPOSE_CONFIG       = 74;
+    @Native public static final int INVALIDATE_CONTEXT   = 75;
+    @Native public static final int SYNC                 = 76;
+    @Native public static final int RESTORE_DEVICES      = 77;
+    @Native public static final int SAVE_STATE           = 78;
+    @Native public static final int RESTORE_STATE        = 79;
 
     // multibuffering ops
-    public static final int SWAP_BUFFERS         = 80;
+    @Native public static final int SWAP_BUFFERS         = 80;
 
     // special no-op op code (mainly used for achieving 8-byte alignment)
-    public static final int NOOP                 = 90;
+    @Native public static final int NOOP                 = 90;
 
     // paint-related ops
-    public static final int RESET_PAINT               = 100;
-    public static final int SET_COLOR                 = 101;
-    public static final int SET_GRADIENT_PAINT        = 102;
-    public static final int SET_LINEAR_GRADIENT_PAINT = 103;
-    public static final int SET_RADIAL_GRADIENT_PAINT = 104;
-    public static final int SET_TEXTURE_PAINT         = 105;
+    @Native public static final int RESET_PAINT               = 100;
+    @Native public static final int SET_COLOR                 = 101;
+    @Native public static final int SET_GRADIENT_PAINT        = 102;
+    @Native public static final int SET_LINEAR_GRADIENT_PAINT = 103;
+    @Native public static final int SET_RADIAL_GRADIENT_PAINT = 104;
+    @Native public static final int SET_TEXTURE_PAINT         = 105;
 
     // BufferedImageOp-related ops
-    public static final int ENABLE_CONVOLVE_OP     = 120;
-    public static final int DISABLE_CONVOLVE_OP    = 121;
-    public static final int ENABLE_RESCALE_OP      = 122;
-    public static final int DISABLE_RESCALE_OP     = 123;
-    public static final int ENABLE_LOOKUP_OP       = 124;
-    public static final int DISABLE_LOOKUP_OP      = 125;
+    @Native public static final int ENABLE_CONVOLVE_OP     = 120;
+    @Native public static final int DISABLE_CONVOLVE_OP    = 121;
+    @Native public static final int ENABLE_RESCALE_OP      = 122;
+    @Native public static final int DISABLE_RESCALE_OP     = 123;
+    @Native public static final int ENABLE_LOOKUP_OP       = 124;
+    @Native public static final int DISABLE_LOOKUP_OP      = 125;
 }
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,10 +46,8 @@
 import sun.java2d.loops.SurfaceType;
 import static sun.java2d.pipe.BufferedOpCodes.*;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class BufferedPaints {
 
     static void setPaint(RenderQueue rq, SunGraphics2D sg2d,
@@ -304,7 +302,7 @@
      * shaders.  So for now we will cap this value at 12, but we can
      * re-evaluate this in the future as hardware becomes more capable.
      */
-    public static final int MULTI_MAX_FRACTIONS = 12;
+    @Native public static final int MULTI_MAX_FRACTIONS = 12;
 
     /**
      * Helper function to convert a color component in sRGB space to
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedTextPipe.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedTextPipe.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,24 +32,22 @@
 import sun.java2d.SurfaceData;
 import static sun.java2d.pipe.BufferedOpCodes.*;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public abstract class BufferedTextPipe extends GlyphListPipe {
 
-    private static final int BYTES_PER_GLYPH_IMAGE = 8;
-    private static final int BYTES_PER_GLYPH_POSITION = 8;
+    @Native private static final int BYTES_PER_GLYPH_IMAGE = 8;
+    @Native private static final int BYTES_PER_GLYPH_POSITION = 8;
 
     /**
      * The following offsets are used to pack the parameters in
      * createPackedParams().  (They are also used at the native level when
      * unpacking the params.)
      */
-    private static final int OFFSET_CONTRAST  = 8;
-    private static final int OFFSET_RGBORDER  = 2;
-    private static final int OFFSET_SUBPIXPOS = 1;
-    private static final int OFFSET_POSITIONS = 0;
+    @Native private static final int OFFSET_CONTRAST  = 8;
+    @Native private static final int OFFSET_RGBORDER  = 2;
+    @Native private static final int OFFSET_SUBPIXPOS = 1;
+    @Native private static final int OFFSET_POSITIONS = 0;
 
     /**
      * Packs the given parameters into a single int value in order to save
--- a/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 import sun.misc.Unsafe;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * The RenderBuffer class is a simplified, high-performance, Unsafe wrapper
@@ -44,8 +43,6 @@
  * single-threaded rendering.  For example, there is no put(double[]) method
  * because we currently have no need for such a method in the STR classes.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class RenderBuffer {
 
     /**
--- a/jdk/src/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,16 +30,13 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * This class is used to notify listeners about accelerated device's
  * events such as device reset or dispose that are about to occur.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class AccelDeviceEventNotifier {
 
     private static AccelDeviceEventNotifier theInstance;
@@ -49,13 +46,13 @@
      * resources associated with the device which are required for the device
      * to be reset.
      */
-    public static final int DEVICE_RESET = 0;
+    @Native public static final int DEVICE_RESET = 0;
 
     /**
      * A device is about to be disposed. The listeners have to release all
      * resources associated with the device.
      */
-    public static final int DEVICE_DISPOSED = 1;
+    @Native public static final int DEVICE_DISPOSED = 1;
 
     private final Map<AccelDeviceEventListener, Integer> listeners;
 
--- a/jdk/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,41 +28,39 @@
 import java.awt.Rectangle;
 import sun.java2d.Surface;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * Abstraction for a hardware accelerated surface.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public interface AccelSurface extends BufferedContextProvider, Surface {
     /**
      * Undefined
      */
-    public static final int UNDEFINED       = 0;
+    @Native public static final int UNDEFINED       = 0;
     /**
      * Window (or window substitute) surface
      */
-    public static final int WINDOW          = 1;
+    @Native public static final int WINDOW          = 1;
     /**
      * Render-To Plain surface (pbuffer for OpenGL, Render Target surface
      * for Direct3D)
      */
-    public static final int RT_PLAIN        = 2;
+    @Native public static final int RT_PLAIN        = 2;
     /**
      * Texture surface
      */
-    public static final int TEXTURE         = 3;
+    @Native public static final int TEXTURE         = 3;
     /**
      * A back-buffer surface (SwapChain surface for Direct3D, backbuffer for
      * OpenGL)
      */
-    public static final int FLIP_BACKBUFFER = 4;
+    @Native public static final int FLIP_BACKBUFFER = 4;
     /**
      * Render-To Texture surface (fbobject for OpenGL, texture with render-to
      * attribute for Direct3D)
      */
-    public static final int RT_TEXTURE      = 5;
+    @Native public static final int RT_TEXTURE      = 5;
 
     /**
      * Returns {@code int} representing surface's type as defined by constants
--- a/jdk/src/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 
 package sun.java2d.pipe.hw;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * Represents a set of capabilities of a BufferedContext and associated
@@ -33,8 +32,6 @@
  *
  * @see AccelGraphicsConfig
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class ContextCapabilities {
     /** Indicates that the context has no capabilities. */
     public static final int CAPS_EMPTY             = (0 << 0);
--- a/jdk/src/share/classes/sun/misc/Version.java.template	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/misc/Version.java.template	Wed Jul 05 18:50:02 2017 +0200
@@ -52,8 +52,6 @@
         System.setProperty("java.version", java_version);
         System.setProperty("java.runtime.version", java_runtime_version);
         System.setProperty("java.runtime.name", java_runtime_name);
-        if (java_profile_name.length() > 0)
-            System.setProperty("java.runtime.profile", java_profile_name);
     }
 
     private static boolean versionsInitialized = false;
--- a/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1299,16 +1299,16 @@
      *         <code>null</code> if the command was unsuccessful.
      * @throws IOException if an error occured during the transmission.
      */
-    public OutputStream putFileStream(String name, boolean unique) throws sun.net.ftp.FtpProtocolException, IOException {
+    public OutputStream putFileStream(String name, boolean unique)
+        throws sun.net.ftp.FtpProtocolException, IOException
+    {
         String cmd = unique ? "STOU " : "STOR ";
         Socket s = openDataConnection(cmd + name);
         if (s == null) {
             return null;
         }
-        if (type == TransferType.BINARY) {
-            return s.getOutputStream();
-        }
-        return new sun.net.TelnetOutputStream(s.getOutputStream(), false);
+        boolean bm = (type == TransferType.BINARY);
+        return new sun.net.TelnetOutputStream(s.getOutputStream(), bm);
     }
 
     /**
--- a/jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java	Wed Jul 05 18:50:02 2017 +0200
@@ -124,6 +124,7 @@
         final String defaultVal;
         static NonProxyInfo ftpNonProxyInfo = new NonProxyInfo("ftp.nonProxyHosts", null, null, defStringVal);
         static NonProxyInfo httpNonProxyInfo = new NonProxyInfo("http.nonProxyHosts", null, null, defStringVal);
+        static NonProxyInfo socksNonProxyInfo = new NonProxyInfo("socksNonProxyHosts", null, null, defStringVal);
 
         NonProxyInfo(String p, String s, RegexpPool pool, String d) {
             property = p;
@@ -186,6 +187,8 @@
             pinfo = NonProxyInfo.httpNonProxyInfo;
         } else if ("ftp".equalsIgnoreCase(protocol)) {
             pinfo = NonProxyInfo.ftpNonProxyInfo;
+        } else if ("socket".equalsIgnoreCase(protocol)) {
+            pinfo = NonProxyInfo.socksNonProxyInfo;
         }
 
         /**
--- a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,15 +32,12 @@
 import java.nio.channels.*;
 import java.nio.channels.spi.*;
 import java.util.*;
-import javax.tools.annotation.GenerateNativeHeader;
 import sun.net.ResourceManager;
 
 /**
  * An implementation of DatagramChannels.
  */
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 class DatagramChannelImpl
     extends DatagramChannel
     implements SelChImpl
--- a/jdk/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,21 +25,19 @@
 package sun.nio.ch.sctp;
 
 import com.sun.nio.sctp.SctpSocketOption;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class SctpStdSocketOption<T>
     implements SctpSocketOption<T>
 {
     /* for native mapping of int options */
-    public static final int SCTP_DISABLE_FRAGMENTS = 1;
-    public static final int SCTP_EXPLICIT_COMPLETE = 2;
-    public static final int SCTP_FRAGMENT_INTERLEAVE = 3;
-    public static final int SCTP_NODELAY = 4;
-    public static final int SO_SNDBUF = 5;
-    public static final int SO_RCVBUF = 6;
-    public static final int SO_LINGER = 7;
+    @Native public static final int SCTP_DISABLE_FRAGMENTS = 1;
+    @Native public static final int SCTP_EXPLICIT_COMPLETE = 2;
+    @Native public static final int SCTP_FRAGMENT_INTERLEAVE = 3;
+    @Native public static final int SCTP_NODELAY = 4;
+    @Native public static final int SO_SNDBUF = 5;
+    @Native public static final int SO_RCVBUF = 6;
+    @Native public static final int SO_LINGER = 7;
 
     private final String name;
     private final Class<T> type;
--- a/jdk/src/share/classes/sun/reflect/annotation/AnnotationType.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/reflect/annotation/AnnotationType.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,19 +45,18 @@
      * types.  This matches the return value that must be used for a
      * dynamic proxy, allowing for a simple isInstance test.
      */
-    private final Map<String, Class<?>> memberTypes = new HashMap<String,Class<?>>();
+    private final Map<String, Class<?>> memberTypes;
 
     /**
      * Member name -> default value mapping.
      */
-    private final Map<String, Object> memberDefaults =
-        new HashMap<String, Object>();
+    private final Map<String, Object> memberDefaults;
 
     /**
      * Member name -> Method object mapping. This (and its assoicated
      * accessor) are used only to generate AnnotationTypeMismatchExceptions.
      */
-    private final Map<String, Method> members = new HashMap<String, Method>();
+    private final Map<String, Method> members;
 
     /**
      * The retention policy for this annotation type.
@@ -105,6 +104,9 @@
                 }
             });
 
+        memberTypes = new HashMap<String,Class<?>>(methods.length+1, 1.0f);
+        memberDefaults = new HashMap<String, Object>(0);
+        members = new HashMap<String, Method>(methods.length+1, 1.0f);
 
         for (Method method :  methods) {
             if (method.getParameterTypes().length != 0)
@@ -117,8 +119,6 @@
             Object defaultValue = method.getDefaultValue();
             if (defaultValue != null)
                 memberDefaults.put(name, defaultValue);
-
-            members.put(name, method);
         }
 
         sun.misc.SharedSecrets.getJavaLangAccess().
--- a/jdk/src/share/classes/sun/security/pkcs11/Secmod.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/security/pkcs11/Secmod.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
 import sun.security.pkcs11.wrapper.*;
 import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * The Secmod class defines the interface to the native NSS
@@ -57,8 +56,6 @@
  * @since   1.6
  * @author  Andreas Sterbenz
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public final class Secmod {
 
     private final static boolean DEBUG = false;
--- a/jdk/src/share/classes/sun/security/pkcs11/wrapper/PKCS11.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/security/pkcs11/wrapper/PKCS11.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  */
 
 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
@@ -55,7 +55,6 @@
 import java.security.PrivilegedAction;
 
 import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
-import javax.tools.annotation.GenerateNativeHeader;
 
 /**
  * This is the default implementation of the PKCS11 interface. IT connects to
@@ -68,8 +67,6 @@
  * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
  * @invariants (pkcs11ModulePath_ <> null)
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class PKCS11 {
 
     /**
--- a/jdk/src/share/classes/sun/security/tools/keytool/Main.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/security/tools/keytool/Main.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1832,9 +1832,9 @@
         if (alias != null) {
             doImportKeyStoreSingle(loadSourceKeyStore(), alias);
         } else {
-            if (dest != null || srckeyPass != null || destKeyPass != null) {
+            if (dest != null || srckeyPass != null) {
                 throw new Exception(rb.getString(
-                        "if.alias.not.specified.destalias.srckeypass.and.destkeypass.must.not.be.specified"));
+                        "if.alias.not.specified.destalias.and.srckeypass.must.not.be.specified"));
             }
             doImportKeyStoreAll(loadSourceKeyStore());
         }
@@ -1888,14 +1888,25 @@
         // using destkeypass. If destkeypass is not provided, the destination
         // entry will be protected with the source entry password."
         // so always try to protect with destKeyPass.
+        char[] newPass = null;
         if (destKeyPass != null) {
+            newPass = destKeyPass;
             pp = new PasswordProtection(destKeyPass);
         } else if (objs.snd != null) {
+            newPass = objs.snd;
             pp = new PasswordProtection(objs.snd);
         }
 
         try {
             keyStore.setEntry(newAlias, entry, pp);
+            // Place the check so that only successful imports are blocked.
+            // For example, we don't block a failed SecretEntry import.
+            if (P12KEYSTORE.equalsIgnoreCase(storetype)) {
+                if (newPass != null && !Arrays.equals(newPass, storePass)) {
+                    throw new Exception(rb.getString(
+                            "The.destination.pkcs12.keystore.has.different.storepass.and.keypass.Please.retry.with.destkeypass.specified."));
+                }
+            }
             return 1;
         } catch (KeyStoreException kse) {
             Object[] source2 = {alias, kse.toString()};
--- a/jdk/src/share/classes/sun/security/tools/keytool/Resources.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/security/tools/keytool/Resources.java	Wed Jul 05 18:50:02 2017 +0200
@@ -242,8 +242,10 @@
         {"Certification.request.stored.in.file.filename.",
                 "Certification request stored in file <{0}>"},
         {"Submit.this.to.your.CA", "Submit this to your CA"},
-        {"if.alias.not.specified.destalias.srckeypass.and.destkeypass.must.not.be.specified",
-            "if alias not specified, destalias, srckeypass, and destkeypass must not be specified"},
+        {"if.alias.not.specified.destalias.and.srckeypass.must.not.be.specified",
+            "if alias not specified, destalias and srckeypass must not be specified"},
+        {"The.destination.pkcs12.keystore.has.different.storepass.and.keypass.Please.retry.with.destkeypass.specified.",
+            "The destination pkcs12 keystore has different storepass and keypass. Please retry with -destkeypass specified."},
         {"Certificate.stored.in.file.filename.",
                 "Certificate stored in file <{0}>"},
         {"Certificate.reply.was.installed.in.keystore",
--- a/jdk/src/share/classes/sun/swing/JLightweightFrame.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/swing/JLightweightFrame.java	Wed Jul 05 18:50:02 2017 +0200
@@ -72,8 +72,10 @@
     public JLightweightFrame() {
         super();
         add(rootPane, BorderLayout.CENTER);
-        setBackground(new Color(0, 0, 0, 0));
         setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
+        if (getGraphicsConfiguration().isTranslucencyCapable()) {
+            setBackground(new Color(0, 0, 0, 0));
+        }
     }
 
     /**
--- a/jdk/src/share/classes/sun/util/logging/LoggingProxy.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/util/logging/LoggingProxy.java	Wed Jul 05 18:50:02 2017 +0200
@@ -61,6 +61,8 @@
 
     public String getLevelName(Object level);
 
+    public int getLevelValue(Object level);
+
     // return the logging property
     public String getProperty(String key);
 }
--- a/jdk/src/share/classes/sun/util/logging/LoggingSupport.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/util/logging/LoggingSupport.java	Wed Jul 05 18:50:02 2017 +0200
@@ -140,6 +140,11 @@
         return proxy.getLevelName(level);
     }
 
+    public static int getLevelValue(Object level) {
+        ensureAvailable();
+        return proxy.getLevelValue(level);
+    }
+
     private static final String DEFAULT_FORMAT =
         "%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%6$s%n";
 
--- a/jdk/src/share/classes/sun/util/logging/PlatformLogger.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/classes/sun/util/logging/PlatformLogger.java	Wed Jul 05 18:50:02 2017 +0200
@@ -27,14 +27,12 @@
 package sun.util.logging;
 
 import java.lang.ref.WeakReference;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import java.text.MessageFormat;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -87,7 +85,13 @@
  * @since 1.7
  */
 public class PlatformLogger {
-    // Same values as java.util.logging.Level for easy mapping
+    /*
+     * These constants should be shortcuts to Level enum constants that
+     * the clients of sun.util.logging.PlatformLogger require no source
+     * modification and avoid the conversion from int to Level enum.
+     *
+     * This can be done when JavaFX is converted to use the new PlatformLogger.Level API.
+     */
     public static final int OFF     = Integer.MAX_VALUE;
     public static final int SEVERE  = 1000;
     public static final int WARNING = 900;
@@ -98,7 +102,63 @@
     public static final int FINEST  = 300;
     public static final int ALL     = Integer.MIN_VALUE;
 
-    private static final int defaultLevel = INFO;
+    /**
+     * PlatformLogger logging levels.
+     */
+    public static enum Level {
+        // The name and value must match that of {@code java.util.logging.Level}s.
+        // Declare in ascending order of the given value for binary search.
+        ALL,
+        FINEST,
+        FINER,
+        FINE,
+        CONFIG,
+        INFO,
+        WARNING,
+        SEVERE,
+        OFF;
+
+        /**
+         * Associated java.util.logging.Level lazily initialized in
+         * JavaLoggerProxy's static initializer only once
+         * when java.util.logging is available and enabled.
+         * Only accessed by JavaLoggerProxy.
+         */
+        /* java.util.logging.Level */ Object javaLevel;
+
+        // ascending order for binary search matching the list of enum constants
+        private static final int[] levelValues = new int[] {
+            PlatformLogger.ALL, PlatformLogger.FINEST, PlatformLogger.FINER,
+            PlatformLogger.FINE, PlatformLogger.CONFIG, PlatformLogger.INFO,
+            PlatformLogger.WARNING, PlatformLogger.SEVERE, PlatformLogger.OFF
+        };
+
+        public int intValue() {
+            return levelValues[this.ordinal()];
+        }
+
+        static Level valueOf(int level) {
+            switch (level) {
+                // ordering per the highest occurences in the jdk source
+                // finest, fine, finer, info first
+                case PlatformLogger.FINEST  : return Level.FINEST;
+                case PlatformLogger.FINE    : return Level.FINE;
+                case PlatformLogger.FINER   : return Level.FINER;
+                case PlatformLogger.INFO    : return Level.INFO;
+                case PlatformLogger.WARNING : return Level.WARNING;
+                case PlatformLogger.CONFIG  : return Level.CONFIG;
+                case PlatformLogger.SEVERE  : return Level.SEVERE;
+                case PlatformLogger.OFF     : return Level.OFF;
+                case PlatformLogger.ALL     : return Level.ALL;
+            }
+            // return the nearest Level value >= the given level,
+            // for level > SEVERE, return SEVERE and exclude OFF
+            int i = Arrays.binarySearch(levelValues, 0, levelValues.length-2, level);
+            return values()[i >= 0 ? i : (-i-1)];
+        }
+    }
+
+    private static final Level DEFAULT_LEVEL = Level.INFO;
     private static boolean loggingEnabled;
     static {
         loggingEnabled = AccessController.doPrivileged(
@@ -109,6 +169,20 @@
                     return (cname != null || fname != null);
                 }
             });
+
+        // force loading of all JavaLoggerProxy (sub)classes to make JIT de-optimizations
+        // less probable.  Don't initialize JavaLoggerProxy class since
+        // java.util.logging may not be enabled.
+        try {
+            Class.forName("sun.util.logging.PlatformLogger$DefaultLoggerProxy",
+                          false,
+                          PlatformLogger.class.getClassLoader());
+            Class.forName("sun.util.logging.PlatformLogger$JavaLoggerProxy",
+                          false,   // do not invoke class initializer
+                          PlatformLogger.class.getClassLoader());
+        } catch (ClassNotFoundException ex) {
+            throw new InternalError(ex);
+        }
     }
 
     // Table of known loggers.  Maps names to PlatformLoggers.
@@ -143,27 +217,32 @@
             WeakReference<PlatformLogger> ref = entry.getValue();
             PlatformLogger plog = ref.get();
             if (plog != null) {
-                plog.newJavaLogger();
+                plog.redirectToJavaLoggerProxy();
             }
         }
     }
 
     /**
-     * Creates a new JavaLogger that the platform logger uses
+     * Creates a new JavaLoggerProxy and redirects the platform logger to it
      */
-    private void newJavaLogger() {
-        logger = new JavaLogger(logger.name, logger.effectiveLevel);
+    private void redirectToJavaLoggerProxy() {
+        DefaultLoggerProxy lp = DefaultLoggerProxy.class.cast(this.loggerProxy);
+        JavaLoggerProxy jlp = new JavaLoggerProxy(lp.name, lp.level);
+        // the order of assignments is important
+        this.javaLoggerProxy = jlp;   // isLoggable checks javaLoggerProxy if set
+        this.loggerProxy = jlp;
     }
 
-    // logger may be replaced with a JavaLogger object
-    // when the logging facility is enabled
-    private volatile LoggerProxy logger;
-
+    // DefaultLoggerProxy may be replaced with a JavaLoggerProxy object
+    // when the java.util.logging facility is enabled
+    private volatile LoggerProxy loggerProxy;
+    // javaLoggerProxy is only set when the java.util.logging facility is enabled
+    private volatile JavaLoggerProxy javaLoggerProxy;
     private PlatformLogger(String name) {
         if (loggingEnabled) {
-            this.logger = new JavaLogger(name);
+            this.loggerProxy = this.javaLoggerProxy = new JavaLoggerProxy(name);
         } else {
-            this.logger = new LoggerProxy(name);
+            this.loggerProxy = new DefaultLoggerProxy(name);
         }
     }
 
@@ -172,204 +251,278 @@
      * (i.e. its level is OFF).
      */
     public boolean isEnabled() {
-        return logger.isEnabled();
+        return loggerProxy.isEnabled();
     }
 
     /**
      * Gets the name for this platform logger.
      */
     public String getName() {
-        return logger.name;
+        return loggerProxy.name;
+    }
+
+    /**
+     * Returns true if a message of the given level would actually
+     * be logged by this logger.
+     *
+     * @deprecated Use isLoggable(Level) instead.
+     */
+    @Deprecated
+    public boolean isLoggable(int levelValue) {
+        return isLoggable(Level.valueOf(levelValue));
+    }
+
+    /**
+     * Gets the current log level. Returns 0 if the current effective level is
+     * not set (equivalent to Logger.getLevel() returns null).
+     *
+     * @deprecated Use level() instead
+     */
+    @Deprecated
+    public int getLevel() {
+        Level level = loggerProxy.getLevel();
+        return level != null ? level.intValue() : 0;
+    }
+
+    /**
+     * Sets the log level.
+     *
+     * @deprecated Use setLevel(Level) instead
+     */
+    @Deprecated
+    public void setLevel(int newLevel) {
+        loggerProxy.setLevel(newLevel == 0 ? null : Level.valueOf(newLevel));
     }
 
     /**
      * Returns true if a message of the given level would actually
      * be logged by this logger.
      */
-    public boolean isLoggable(int level) {
-        return logger.isLoggable(level);
+    public boolean isLoggable(Level level) {
+        if (level == null) {
+            throw new NullPointerException();
+        }
+        // performance-sensitive method: use two monomorphic call-sites
+        JavaLoggerProxy jlp = javaLoggerProxy;
+        return jlp != null ? jlp.isLoggable(level) : loggerProxy.isLoggable(level);
     }
 
     /**
-     * Gets the current log level.  Returns 0 if the current effective level
-     * is not set (equivalent to Logger.getLevel() returns null).
+     * Get the log level that has been specified for this PlatformLogger.
+     * The result may be null, which means that this logger's
+     * effective level will be inherited from its parent.
+     *
+     * @return  this PlatformLogger's level
      */
-    public int getLevel() {
-        return logger.getLevel();
+    public Level level() {
+        return loggerProxy.getLevel();
     }
 
     /**
-     * Sets the log level.
+     * Set the log level specifying which message levels will be
+     * logged by this logger.  Message levels lower than this
+     * value will be discarded.  The level value {@link #OFF}
+     * can be used to turn off logging.
+     * <p>
+     * If the new level is null, it means that this node should
+     * inherit its level from its nearest ancestor with a specific
+     * (non-null) level value.
+     *
+     * @param newLevel the new value for the log level (may be null)
      */
-    public void setLevel(int newLevel) {
-        logger.setLevel(newLevel);
+    public void setLevel(Level newLevel) {
+        loggerProxy.setLevel(newLevel);
     }
 
     /**
      * Logs a SEVERE message.
      */
     public void severe(String msg) {
-        logger.doLog(SEVERE, msg);
+        loggerProxy.doLog(Level.SEVERE, msg);
     }
 
     public void severe(String msg, Throwable t) {
-        logger.doLog(SEVERE, msg, t);
+        loggerProxy.doLog(Level.SEVERE, msg, t);
     }
 
     public void severe(String msg, Object... params) {
-        logger.doLog(SEVERE, msg, params);
+        loggerProxy.doLog(Level.SEVERE, msg, params);
     }
 
     /**
      * Logs a WARNING message.
      */
     public void warning(String msg) {
-        logger.doLog(WARNING, msg);
+        loggerProxy.doLog(Level.WARNING, msg);
     }
 
     public void warning(String msg, Throwable t) {
-        logger.doLog(WARNING, msg, t);
+        loggerProxy.doLog(Level.WARNING, msg, t);
     }
 
     public void warning(String msg, Object... params) {
-        logger.doLog(WARNING, msg, params);
+        loggerProxy.doLog(Level.WARNING, msg, params);
     }
 
     /**
      * Logs an INFO message.
      */
     public void info(String msg) {
-        logger.doLog(INFO, msg);
+        loggerProxy.doLog(Level.INFO, msg);
     }
 
     public void info(String msg, Throwable t) {
-        logger.doLog(INFO, msg, t);
+        loggerProxy.doLog(Level.INFO, msg, t);
     }
 
     public void info(String msg, Object... params) {
-        logger.doLog(INFO, msg, params);
+        loggerProxy.doLog(Level.INFO, msg, params);
     }
 
     /**
      * Logs a CONFIG message.
      */
     public void config(String msg) {
-        logger.doLog(CONFIG, msg);
+        loggerProxy.doLog(Level.CONFIG, msg);
     }
 
     public void config(String msg, Throwable t) {
-        logger.doLog(CONFIG, msg, t);
+        loggerProxy.doLog(Level.CONFIG, msg, t);
     }
 
     public void config(String msg, Object... params) {
-        logger.doLog(CONFIG, msg, params);
+        loggerProxy.doLog(Level.CONFIG, msg, params);
     }
 
     /**
      * Logs a FINE message.
      */
     public void fine(String msg) {
-        logger.doLog(FINE, msg);
+        loggerProxy.doLog(Level.FINE, msg);
     }
 
     public void fine(String msg, Throwable t) {
-        logger.doLog(FINE, msg, t);
+        loggerProxy.doLog(Level.FINE, msg, t);
     }
 
     public void fine(String msg, Object... params) {
-        logger.doLog(FINE, msg, params);
+        loggerProxy.doLog(Level.FINE, msg, params);
     }
 
     /**
      * Logs a FINER message.
      */
     public void finer(String msg) {
-        logger.doLog(FINER, msg);
+        loggerProxy.doLog(Level.FINER, msg);
     }
 
     public void finer(String msg, Throwable t) {
-        logger.doLog(FINER, msg, t);
+        loggerProxy.doLog(Level.FINER, msg, t);
     }
 
     public void finer(String msg, Object... params) {
-        logger.doLog(FINER, msg, params);
+        loggerProxy.doLog(Level.FINER, msg, params);
     }
 
     /**
      * Logs a FINEST message.
      */
     public void finest(String msg) {
-        logger.doLog(FINEST, msg);
+        loggerProxy.doLog(Level.FINEST, msg);
     }
 
     public void finest(String msg, Throwable t) {
-        logger.doLog(FINEST, msg, t);
+        loggerProxy.doLog(Level.FINEST, msg, t);
     }
 
     public void finest(String msg, Object... params) {
-        logger.doLog(FINEST, msg, params);
+        loggerProxy.doLog(Level.FINEST, msg, params);
     }
 
     /**
-     * Default platform logging support - output messages to
-     * System.err - equivalent to ConsoleHandler with SimpleFormatter.
+     * Abstract base class for logging support, defining the API and common field.
      */
-    static class LoggerProxy {
-        private static final PrintStream defaultStream = System.err;
+    private static abstract class LoggerProxy {
+        final String name;
 
-        final String name;
-        volatile int levelValue;
-        volatile int effectiveLevel = 0; // current effective level value
-
-        LoggerProxy(String name) {
-            this(name, defaultLevel);
+        protected LoggerProxy(String name) {
+            this.name = name;
         }
 
-        LoggerProxy(String name, int level) {
-            this.name = name;
-            this.levelValue = level == 0 ? defaultLevel : level;
+        abstract boolean isEnabled();
+
+        abstract Level getLevel();
+        abstract void setLevel(Level newLevel);
+
+        abstract void doLog(Level level, String msg);
+        abstract void doLog(Level level, String msg, Throwable thrown);
+        abstract void doLog(Level level, String msg, Object... params);
+
+        abstract boolean isLoggable(Level level);
+    }
+
+
+    private static final class DefaultLoggerProxy extends LoggerProxy {
+        /**
+         * Default platform logging support - output messages to System.err -
+         * equivalent to ConsoleHandler with SimpleFormatter.
+         */
+        private static PrintStream outputStream() {
+            return System.err;
+        }
+
+        volatile Level effectiveLevel; // effective level (never null)
+        volatile Level level;          // current level set for this node (may be null)
+
+        DefaultLoggerProxy(String name) {
+            super(name);
+            this.effectiveLevel = deriveEffectiveLevel(null);
+            this.level = null;
         }
 
         boolean isEnabled() {
-            return levelValue != OFF;
+            return effectiveLevel != Level.OFF;
         }
 
-        int getLevel() {
-            return effectiveLevel;
+        Level getLevel() {
+            return level;
         }
 
-        void setLevel(int newLevel) {
-            levelValue = newLevel;
-            effectiveLevel = newLevel;
+        void setLevel(Level newLevel) {
+            Level oldLevel = level;
+            if (oldLevel != newLevel) {
+                level = newLevel;
+                effectiveLevel = deriveEffectiveLevel(newLevel);
+            }
         }
 
-        void doLog(int level, String msg) {
-            if (level < levelValue || levelValue == OFF) {
-                return;
+        void doLog(Level level, String msg) {
+            if (isLoggable(level)) {
+                outputStream().print(format(level, msg, null));
             }
-            defaultStream.print(format(level, msg, null));
         }
 
-        void doLog(int level, String msg, Throwable thrown) {
-            if (level < levelValue || levelValue == OFF) {
-                return;
+        void doLog(Level level, String msg, Throwable thrown) {
+            if (isLoggable(level)) {
+                outputStream().print(format(level, msg, thrown));
             }
-            defaultStream.print(format(level, msg, thrown));
         }
 
-        void doLog(int level, String msg, Object... params) {
-            if (level < levelValue || levelValue == OFF) {
-                return;
+        void doLog(Level level, String msg, Object... params) {
+            if (isLoggable(level)) {
+                String newMsg = formatMessage(msg, params);
+                outputStream().print(format(level, newMsg, null));
             }
-            String newMsg = formatMessage(msg, params);
-            defaultStream.print(format(level, newMsg, null));
         }
 
-        public boolean isLoggable(int level) {
-            if (level < levelValue || levelValue == OFF) {
-                return false;
-            }
-            return true;
+        boolean isLoggable(Level level) {
+            Level effectiveLevel = this.effectiveLevel;
+            return level.intValue() >= effectiveLevel.intValue() && effectiveLevel != Level.OFF;
+        }
+
+        // derive effective level (could do inheritance search like j.u.l.Logger)
+        private Level deriveEffectiveLevel(Level level) {
+            return level == null ? DEFAULT_LEVEL : level;
         }
 
         // Copied from java.util.logging.Formatter.formatMessage
@@ -401,7 +554,7 @@
 
         // minimize memory allocation
         private Date date = new Date();
-        private synchronized String format(int level, String msg, Throwable thrown) {
+        private synchronized String format(Level level, String msg, Throwable thrown) {
             date.setTime(System.currentTimeMillis());
             String throwable = "";
             if (thrown != null) {
@@ -417,7 +570,7 @@
                                  date,
                                  getCallerInfo(),
                                  name,
-                                 PlatformLogger.getLevelName(level),
+                                 level.name(),
                                  msg,
                                  throwable);
         }
@@ -464,58 +617,41 @@
     }
 
     /**
-     * JavaLogger forwards all the calls to its corresponding
+     * JavaLoggerProxy forwards all the calls to its corresponding
      * java.util.logging.Logger object.
      */
-    static class JavaLogger extends LoggerProxy {
-        private static final Map<Integer, Object> levelObjects =
-            new HashMap<>();
-
+    private static final class JavaLoggerProxy extends LoggerProxy {
+        // initialize javaLevel fields for mapping from Level enum -> j.u.l.Level object
         static {
-            if (LoggingSupport.isAvailable()) {
-                // initialize the map to Level objects
-                getLevelObjects();
-            }
-        }
-
-        private static void getLevelObjects() {
-            // get all java.util.logging.Level objects
-            int[] levelArray = new int[] {OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL};
-            for (int l : levelArray) {
-                Object level = LoggingSupport.parseLevel(getLevelName(l));
-                levelObjects.put(l, level);
+            for (Level level : Level.values()) {
+                level.javaLevel = LoggingSupport.parseLevel(level.name());
             }
         }
 
-        private final Object javaLogger;
-        JavaLogger(String name) {
-            this(name, 0);
+        private final /* java.util.logging.Logger */ Object javaLogger;
+
+        JavaLoggerProxy(String name) {
+            this(name, null);
         }
 
-        JavaLogger(String name, int level) {
-            super(name, level);
+        JavaLoggerProxy(String name, Level level) {
+            super(name);
             this.javaLogger = LoggingSupport.getLogger(name);
-            if (level != 0) {
+            if (level != null) {
                 // level has been updated and so set the Logger's level
-                LoggingSupport.setLevel(javaLogger, levelObjects.get(level));
+                LoggingSupport.setLevel(javaLogger, level.javaLevel);
             }
         }
 
-       /**
-        * Let Logger.log() do the filtering since if the level of a
-        * platform logger is altered directly from
-        * java.util.logging.Logger.setLevel(), the levelValue will
-        * not be updated.
-        */
-        void doLog(int level, String msg) {
-            LoggingSupport.log(javaLogger, levelObjects.get(level), msg);
+        void doLog(Level level, String msg) {
+            LoggingSupport.log(javaLogger, level.javaLevel, msg);
         }
 
-        void doLog(int level, String msg, Throwable t) {
-            LoggingSupport.log(javaLogger, levelObjects.get(level), msg, t);
+        void doLog(Level level, String msg, Throwable t) {
+            LoggingSupport.log(javaLogger, level.javaLevel, msg, t);
         }
 
-        void doLog(int level, String msg, Object... params) {
+        void doLog(Level level, String msg, Object... params) {
             if (!isLoggable(level)) {
                 return;
             }
@@ -526,49 +662,35 @@
             for (int i = 0; i < len; i++) {
                 sparams [i] = String.valueOf(params[i]);
             }
-            LoggingSupport.log(javaLogger, levelObjects.get(level), msg, sparams);
+            LoggingSupport.log(javaLogger, level.javaLevel, msg, sparams);
         }
 
         boolean isEnabled() {
-            Object level = LoggingSupport.getLevel(javaLogger);
-            return level == null || level.equals(levelObjects.get(OFF)) == false;
-        }
-
-        int getLevel() {
-            Object level = LoggingSupport.getLevel(javaLogger);
-            if (level != null) {
-                for (Map.Entry<Integer, Object> l : levelObjects.entrySet()) {
-                    if (level == l.getValue()) {
-                        return l.getKey();
-                    }
-                }
-            }
-            return 0;
-        }
-
-        void setLevel(int newLevel) {
-            levelValue = newLevel;
-            LoggingSupport.setLevel(javaLogger, levelObjects.get(newLevel));
+            return LoggingSupport.isLoggable(javaLogger, Level.OFF.javaLevel);
         }
 
-        public boolean isLoggable(int level) {
-            return LoggingSupport.isLoggable(javaLogger, levelObjects.get(level));
+        /**
+         * Returns the PlatformLogger.Level mapped from j.u.l.Level
+         * set in the logger.  If the j.u.l.Logger is set to a custom Level,
+         * this method will return the nearest Level.
+         */
+        Level getLevel() {
+            Object javaLevel = LoggingSupport.getLevel(javaLogger);
+            if (javaLevel == null) return null;
+
+            try {
+                return Level.valueOf(LoggingSupport.getLevelName(javaLevel));
+            } catch (IllegalArgumentException e) {
+                return Level.valueOf(LoggingSupport.getLevelValue(javaLevel));
+            }
+        }
+
+        void setLevel(Level level) {
+            LoggingSupport.setLevel(javaLogger, level == null ? null : level.javaLevel);
+        }
+
+        boolean isLoggable(Level level) {
+            return LoggingSupport.isLoggable(javaLogger, level.javaLevel);
         }
     }
-
-    private static String getLevelName(int level) {
-        switch (level) {
-            case OFF     : return "OFF";
-            case SEVERE  : return "SEVERE";
-            case WARNING : return "WARNING";
-            case INFO    : return "INFO";
-            case CONFIG  : return "CONFIG";
-            case FINE    : return "FINE";
-            case FINER   : return "FINER";
-            case FINEST  : return "FINEST";
-            case ALL     : return "ALL";
-            default      : return "UNKNOWN";
-        }
-    }
-
 }
--- a/jdk/src/share/demo/jvmti/hprof/hprof_md.h	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/demo/jvmti/hprof/hprof_md.h	Wed Jul 05 18:50:02 2017 +0200
@@ -69,7 +69,7 @@
 unsigned md_ntohs(unsigned short s);
 unsigned md_ntohl(unsigned l);
 
-void   md_build_library_name(char *holder, int holderlen, char *pname, char *fname);
+void   md_build_library_name(char *holder, int holderlen, const char *pname, const char *fname);
 void * md_load_library(const char *name, char *err_buf, int err_buflen);
 void   md_unload_library(void *handle);
 void * md_find_library_entry(void *handle, const char *name);
--- a/jdk/src/share/lib/security/java.security-linux	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/lib/security/java.security-linux	Wed Jul 05 18:50:02 2017 +0200
@@ -157,6 +157,8 @@
                com.sun.org.apache.xalan.internal.utils.,\
                com.sun.org.glassfish.external.,\
                com.sun.org.glassfish.gmbal.,\
+               com.oracle.xmlns.internal.,\
+               com.oracle.webservices.internal.,\
 	       jdk.internal.,\
 	       jdk.nashorn.internal.,\
 	       jdk.nashorn.tools.
@@ -183,6 +185,8 @@
                    com.sun.org.apache.xalan.internal.utils.,\
                    com.sun.org.glassfish.external.,\
                    com.sun.org.glassfish.gmbal.,\
+                   com.oracle.xmlns.internal.,\
+                   com.oracle.webservices.internal.,\
 		   jdk.internal.,\
 		   jdk.nashorn.internal.,\
 		   jdk.nashorn.tools.
--- a/jdk/src/share/lib/security/java.security-macosx	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/lib/security/java.security-macosx	Wed Jul 05 18:50:02 2017 +0200
@@ -158,6 +158,8 @@
                com.sun.org.apache.xalan.internal.utils.,\
                com.sun.org.glassfish.external.,\
                com.sun.org.glassfish.gmbal.,\
+               com.oracle.xmlns.internal.,\
+               com.oracle.webservices.internal.,\
 	       jdk.internal.,\
 	       jdk.nashorn.internal.,\
 	       jdk.nashorn.tools.,\
@@ -185,6 +187,8 @@
                    com.sun.org.apache.xalan.internal.utils.,\
                    com.sun.org.glassfish.external.,\
                    com.sun.org.glassfish.gmbal.,\
+                   com.oracle.xmlns.internal.,\
+                   com.oracle.webservices.internal.,\
 		   jdk.internal.,\
 		   jdk.nashorn.internal.,\
 		   jdk.nashorn.tools.,\
--- a/jdk/src/share/lib/security/java.security-solaris	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/lib/security/java.security-solaris	Wed Jul 05 18:50:02 2017 +0200
@@ -159,6 +159,8 @@
                com.sun.org.apache.xalan.internal.utils.,\
                com.sun.org.glassfish.external.,\
                com.sun.org.glassfish.gmbal.,\
+               com.oracle.xmlns.internal.,\
+               com.oracle.webservices.internal.,\
 	       jdk.internal.,\
 	       jdk.nashorn.internal.,\
 	       jdk.nashorn.tools.
@@ -185,6 +187,8 @@
                    com.sun.org.apache.xalan.internal.utils.,\
                    com.sun.org.glassfish.external.,\
                    com.sun.org.glassfish.gmbal.,\
+                   com.oracle.xmlns.internal.,\
+                   com.oracle.webservices.internal.,\
 		   jdk.internal.,\
 		   jdk.nashorn.internal.,\
 		   jdk.nashorn.tools.
--- a/jdk/src/share/lib/security/java.security-windows	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/share/lib/security/java.security-windows	Wed Jul 05 18:50:02 2017 +0200
@@ -158,6 +158,8 @@
                com.sun.org.apache.xalan.internal.utils.,\
                com.sun.org.glassfish.external.,\
                com.sun.org.glassfish.gmbal.,\
+               com.oracle.xmlns.internal.,\
+               com.oracle.webservices.internal.,\
 	       jdk.internal.,\
 	       jdk.nashorn.internal.,\
 	       jdk.nashorn.tools.
@@ -184,6 +186,8 @@
                    com.sun.org.apache.xalan.internal.utils.,\
                    com.sun.org.glassfish.external.,\
                    com.sun.org.glassfish.gmbal.,\
+                   com.oracle.xmlns.internal.,\
+                   com.oracle.webservices.internal.,\
 		   jdk.internal.,\
 		   jdk.nashorn.internal.,\
 		   jdk.nashorn.tools.
--- a/jdk/src/solaris/back/linker_md.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/back/linker_md.c	Wed Jul 05 18:50:02 2017 +0200
@@ -55,34 +55,27 @@
 #endif
 
 static void dll_build_name(char* buffer, size_t buflen,
-                           const char* pname, const char* fname) {
-    // Based on os_solaris.cpp
+                           const char* paths, const char* fname) {
+    char *path, *paths_copy, *next_token;
 
-    char *path_sep = PATH_SEPARATOR;
-    char *pathname = (char *)pname;
-    *buffer = '\0';
-    while (strlen(pathname) > 0) {
-        char *p = strchr(pathname, *path_sep);
-        if (p == NULL) {
-            p = pathname + strlen(pathname);
-        }
-        /* check for NULL path */
-        if (p == pathname) {
-            continue;
-        }
-        (void)snprintf(buffer, buflen, "%.*s/lib%s." LIB_SUFFIX, (int)(p - pathname),
-                       pathname, fname);
+    paths_copy = strdup(paths);
+    if (paths_copy == NULL) {
+        return;
+    }
 
+    next_token = NULL;
+    path = strtok_r(paths_copy, PATH_SEPARATOR, &next_token);
+
+    while (path != NULL) {
+        snprintf(buffer, buflen, "%s/lib%s." LIB_SUFFIX, path, fname);
         if (access(buffer, F_OK) == 0) {
             break;
         }
-        if (*p == '\0') {
-            pathname = p;
-        } else {
-            pathname = p + 1;
-        }
         *buffer = '\0';
+        path = strtok_r(NULL, PATH_SEPARATOR, &next_token);
     }
+
+    free(paths_copy);
 }
 
 /*
@@ -103,7 +96,7 @@
  * appropriate pre and extensions to a filename and the path
  */
 void
-dbgsysBuildLibName(char *holder, int holderlen, char *pname, char *fname)
+dbgsysBuildLibName(char *holder, int holderlen, const char *pname, const char *fname)
 {
     const int pnamelen = pname ? strlen(pname) : 0;
 
--- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,10 +70,7 @@
 import sun.java2d.BackBufferCapsProvider;
 import sun.java2d.pipe.Region;
 
-import javax.tools.annotation.GenerateNativeHeader;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class XComponentPeer extends XWindow implements ComponentPeer, DropTargetPeer,
     BackBufferCapsProvider
 {
--- a/jdk/src/solaris/classes/sun/awt/X11/XDataTransferer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDataTransferer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -212,10 +212,9 @@
      * Translates either a byte array or an input stream which contain
      * platform-specific image data in the given format into an Image.
      */
-    protected Image platformImageBytesOrStreamToImage(InputStream inputStream,
-                                                      byte[] bytes,
-                                                      long format)
-      throws IOException {
+    protected Image platformImageBytesToImage(
+        byte[] bytes, long format) throws IOException
+    {
         String mimeType = null;
         if (format == PNG_ATOM.getAtom()) {
             mimeType = "image/png";
@@ -235,7 +234,7 @@
             }
         }
         if (mimeType != null) {
-            return standardImageBytesOrStreamToImage(inputStream, bytes, mimeType);
+            return standardImageBytesToImage(bytes, mimeType);
         } else {
             String nativeFormat = getNativeForFormat(format);
             throw new IOException("Translation from " + nativeFormat +
@@ -330,8 +329,8 @@
      * a valid MIME and return a list of flavors to which the data in this MIME
      * type can be translated by the Data Transfer subsystem.
      */
-    public List getPlatformMappingsForNative(String nat) {
-        List flavors = new ArrayList();
+    public List <DataFlavor> getPlatformMappingsForNative(String nat) {
+        List <DataFlavor> flavors = new ArrayList();
 
         if (nat == null) {
             return flavors;
@@ -346,16 +345,14 @@
             return flavors;
         }
 
-        Object value = df;
+        DataFlavor value = df;
         final String primaryType = df.getPrimaryType();
         final String baseType = primaryType + "/" + df.getSubType();
 
         // For text formats we map natives to MIME strings instead of data
         // flavors to enable dynamic text native-to-flavor mapping generation.
         // See SystemFlavorMap.getFlavorsForNative() for details.
-        if ("text".equals(primaryType)) {
-            value = primaryType + "/" + df.getSubType();
-        } else if ("image".equals(primaryType)) {
+        if ("image".equals(primaryType)) {
             Iterator readers = ImageIO.getImageReadersByMIMEType(baseType);
             if (readers.hasNext()) {
                 flavors.add(DataFlavor.imageFlavor);
@@ -438,16 +435,13 @@
                 }
             }
         } else if (DataTransferer.isFlavorCharsetTextType(df)) {
-            final Iterator iter = DataTransferer.standardEncodings();
-
             // stringFlavor is semantically equivalent to the standard
             // "text/plain" MIME type.
             if (DataFlavor.stringFlavor.equals(df)) {
                 baseType = "text/plain";
             }
 
-            while (iter.hasNext()) {
-                String encoding = (String)iter.next();
+            for (String encoding : DataTransferer.standardEncodings()) {
                 if (!encoding.equals(charset)) {
                     natives.add(baseType + ";charset=" + encoding);
                 }
--- a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -642,5 +642,11 @@
         return getBounds();
     }
 
-    public void emulateActivation(boolean doActivate) {}
+    public void emulateActivation(boolean doActivate) {
+        if (doActivate) {
+            handleWindowFocusIn(0);
+        } else {
+            handleWindowFocusOut(null, 0);
+        }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.awt.X11;
+
+import java.awt.Graphics;
+
+import sun.awt.LightweightFrame;
+
+public class XLightweightFramePeer extends XFramePeer {
+
+    XLightweightFramePeer(LightweightFrame target) {
+        super(target);
+    }
+
+    private LightweightFrame getLwTarget() {
+        return (LightweightFrame)target;
+    }
+
+    @Override
+    public Graphics getGraphics() {
+        return getLwTarget().getGraphics();
+    }
+
+    @Override
+    public void xSetVisible(boolean visible) {
+        this.visible = visible;
+    }
+
+    @Override
+    protected void requestXFocus(long time, boolean timeProvided) {
+        // not sending native focus events to the proxy
+    }
+
+    @Override
+    public void setGrab(boolean grab) {
+        if (grab) {
+            getLwTarget().grabFocus();
+        } else {
+            getLwTarget().ungrabFocus();
+        }
+    }
+}
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Wed Jul 05 18:50:02 2017 +0200
@@ -420,7 +420,9 @@
     }
 
     public FramePeer createLightweightFrame(LightweightFrame target) {
-        return null;
+        FramePeer peer = new XLightweightFramePeer(target);
+        targetCreatedPeer(target, peer);
+        return peer;
     }
 
     public FramePeer createFrame(Frame target) {
--- a/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,22 +26,20 @@
 
 import com.sun.nio.sctp.Association;
 import com.sun.nio.sctp.AssociationChangeNotification;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * An implementation of AssociationChangeNotification
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class AssociationChange extends AssociationChangeNotification
     implements SctpNotification
 {
     /* static final ints so that they can be referenced from native */
-    private final static int SCTP_COMM_UP = 1;
-    private final static int SCTP_COMM_LOST = 2;
-    private final static int SCTP_RESTART = 3;
-    private final static int SCTP_SHUTDOWN = 4;
-    private final static int SCTP_CANT_START = 5;
+    @Native private final static int SCTP_COMM_UP = 1;
+    @Native private final static int SCTP_COMM_LOST = 2;
+    @Native private final static int SCTP_RESTART = 3;
+    @Native private final static int SCTP_SHUTDOWN = 4;
+    @Native private final static int SCTP_CANT_START = 5;
 
     private Association association;
 
--- a/jdk/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,23 +27,21 @@
 import java.net.SocketAddress;
 import com.sun.nio.sctp.Association;
 import com.sun.nio.sctp.PeerAddressChangeNotification;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * An implementation of PeerAddressChangeNotification
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class PeerAddrChange extends PeerAddressChangeNotification
     implements SctpNotification
 {
     /* static final ints so that they can be referenced from native */
-    private final static int SCTP_ADDR_AVAILABLE = 1;
-    private final static int SCTP_ADDR_UNREACHABLE = 2;
-    private final static int SCTP_ADDR_REMOVED = 3;
-    private final static int SCTP_ADDR_ADDED = 4;
-    private final static int SCTP_ADDR_MADE_PRIM = 5;
-    private final static int SCTP_ADDR_CONFIRMED =6;
+    @Native private final static int SCTP_ADDR_AVAILABLE = 1;
+    @Native private final static int SCTP_ADDR_UNREACHABLE = 2;
+    @Native private final static int SCTP_ADDR_REMOVED = 3;
+    @Native private final static int SCTP_ADDR_ADDED = 4;
+    @Native private final static int SCTP_ADDR_MADE_PRIM = 5;
+    @Native private final static int SCTP_ADDR_CONFIRMED =6;
 
     private Association association;
 
--- a/jdk/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,22 +24,20 @@
  */
 package sun.nio.ch.sctp;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 
 /**
  * Wraps the actual message or notification so that it can be
  * set and returned from the native receive implementation.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 public class ResultContainer {
     /* static final ints so that they can be referenced from native */
-    static final int NOTHING = 0;
-    static final int MESSAGE = 1;
-    static final int SEND_FAILED = 2;
-    static final int ASSOCIATION_CHANGED = 3;
-    static final int PEER_ADDRESS_CHANGED = 4;
-    static final int SHUTDOWN = 5;
+    @Native static final int NOTHING = 0;
+    @Native static final int MESSAGE = 1;
+    @Native static final int SEND_FAILED = 2;
+    @Native static final int ASSOCIATION_CHANGED = 3;
+    @Native static final int PEER_ADDRESS_CHANGED = 4;
+    @Native static final int SHUTDOWN = 5;
 
     private Object value;
     private int type;
--- a/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c	Wed Jul 05 18:50:02 2017 +0200
@@ -381,38 +381,32 @@
 }
 
 static void dll_build_name(char* buffer, size_t buflen,
-                           const char* pname, const char* fname) {
-    // Loosely based on os_solaris.cpp
+                           const char* paths, const char* fname) {
+    char *path, *paths_copy, *next_token;
+
+    paths_copy = strdup(paths);
+    if (paths_copy == NULL) {
+        return;
+    }
+
+    next_token = NULL;
+    path = strtok_r(paths_copy, ":", &next_token);
 
-      char *pathname = (char *)pname;
-      *buffer = '\0';
-      while (strlen(pathname) > 0) {
-          char *p = strchr(pathname, ':');
-          if (p == NULL) {
-              p = pathname + strlen(pathname);
-          }
-          /* check for NULL path */
-          if (p == pathname) {
-              continue;
-          }
-          (void)snprintf(buffer, buflen, "%.*s/lib%s" JNI_LIB_SUFFIX,
-                         (int)(p - pathname), pathname, fname);
+    while (path != NULL) {
+        snprintf(buffer, buflen, "%s/lib%s" JNI_LIB_SUFFIX, path, fname);
+        if (access(buffer, F_OK) == 0) {
+            break;
+        }
+        *buffer = '\0';
+        path = strtok_r(NULL, ":", &next_token);
+    }
 
-          if (access(buffer, F_OK) == 0) {
-              break;
-          }
-          if (*p == '\0') {
-              pathname = p;
-          } else {
-              pathname = p + 1;
-          }
-          *buffer = '\0';
-      }
+    free(paths_copy);
 }
 
 /* Create the actual fill filename for a dynamic library.  */
 void
-md_build_library_name(char *holder, int holderlen, char *pname, char *fname)
+md_build_library_name(char *holder, int holderlen, const char *pname, const char *fname)
 {
     int   pnamelen;
 
--- a/jdk/src/solaris/native/java/io/io_util_md.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/native/java/io/io_util_md.c	Wed Jul 05 18:50:02 2017 +0200
@@ -200,12 +200,8 @@
             return 0;
     }
 
-    if (size >= current) {
-        *pbytes = size - current;
-        return 1;
-    } else {
-        return 0;
-    }
+    *pbytes = size - current;
+    return 1;
 }
 
 jint
--- a/jdk/src/solaris/native/sun/awt/awt_InputMethod.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/native/sun/awt/awt_InputMethod.c	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
 #include "awt_p.h"
 
 #include <sun_awt_X11InputMethod.h>
-#include <sun_awt_X11_XComponentPeer.h>
 #include <sun_awt_X11_XInputMethod.h>
 
 #define THROW_OUT_OF_MEMORY_ERROR() \
--- a/jdk/src/solaris/native/sun/awt/fontpath.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/native/sun/awt/fontpath.c	Wed Jul 05 18:50:02 2017 +0200
@@ -41,7 +41,6 @@
 #include <jni.h>
 #include <jni_util.h>
 #include <jvm_md.h>
-#include <sun_font_FontManager.h>
 #ifndef HEADLESS
 #include <X11/Xlib.h>
 #include <awt.h>
--- a/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  */
 
 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
@@ -104,6 +104,10 @@
     if (hModule == NULL) {
         systemErrorMessage = dlerror();
         exceptionMessage = (char *) malloc(sizeof(char) * (strlen(systemErrorMessage) + strlen(libraryNameStr) + 1));
+        if (exceptionMessage == NULL) {
+            throwOutOfMemoryError(env, 0);
+            return;
+        }
         strcpy(exceptionMessage, systemErrorMessage);
         strcat(exceptionMessage, libraryNameStr);
         throwIOException(env, exceptionMessage);
@@ -134,6 +138,11 @@
      * Get function pointers to all PKCS #11 functions
      */
     moduleData = (ModuleData *) malloc(sizeof(ModuleData));
+    if (moduleData == NULL) {
+        dlclose(hModule);
+        throwOutOfMemoryError(env, 0);
+        return;
+    }
     moduleData->hModule = hModule;
     moduleData->applicationMutexHandler = NULL;
     rv = (C_GetFunctionList)(&(moduleData->ckFunctionListPtr));
--- a/jdk/src/windows/back/linker_md.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/back/linker_md.c	Wed Jul 05 18:50:02 2017 +0200
@@ -39,38 +39,27 @@
 #include "path_md.h"
 
 static void dll_build_name(char* buffer, size_t buflen,
-                           const char* pname, const char* fname) {
-    // Based on os_windows.cpp
+                           const char* paths, const char* fname) {
+    char *path, *paths_copy, *next_token;
 
-    char *path_sep = PATH_SEPARATOR;
-    char *pathname = (char *)pname;
-    *buffer = '\0';
-    while (strlen(pathname) > 0) {
-        char *p = strchr(pathname, *path_sep);
-        if (p == NULL) {
-            p = pathname + strlen(pathname);
-        }
-        /* check for NULL path */
-        if (p == pathname) {
-            continue;
-        }
-        if (*(p-1) == ':' || *(p-1) == '\\') {
-            (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname),
-                            pathname, fname);
-        } else {
-            (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname),
-                            pathname, fname);
-        }
+    paths_copy = strdup(paths);
+    if (paths_copy == NULL) {
+        return;
+    }
+
+    next_token = NULL;
+    path = strtok_s(paths_copy, PATH_SEPARATOR, &next_token);
+
+    while (path != NULL) {
+        _snprintf(buffer, buflen, "%s\\%s.dll", path, fname);
         if (_access(buffer, 0) == 0) {
             break;
         }
-        if (*p == '\0') {
-            pathname = p;
-        } else {
-            pathname = p + 1;
-        }
         *buffer = '\0';
+        path = strtok_s(NULL, PATH_SEPARATOR, &next_token);
     }
+
+    free(paths_copy);
 }
 
 /*
@@ -113,7 +102,7 @@
  * Build a machine dependent library name out of a path and file name.
  */
 void
-dbgsysBuildLibName(char *holder, int holderlen, char *pname, char *fname)
+dbgsysBuildLibName(char *holder, int holderlen, const char *pname, const char *fname)
 {
     const int pnamelen = pname ? (int)strlen(pname) : 0;
 
--- a/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java	Wed Jul 05 18:50:02 2017 +0200
@@ -87,35 +87,35 @@
  */
 public class WDataTransferer extends DataTransferer {
     private static final String[] predefinedClipboardNames = {
-        "",
-        "TEXT",
-        "BITMAP",
-        "METAFILEPICT",
-        "SYLK",
-        "DIF",
-        "TIFF",
-        "OEM TEXT",
-        "DIB",
-        "PALETTE",
-        "PENDATA",
-        "RIFF",
-        "WAVE",
-        "UNICODE TEXT",
-        "ENHMETAFILE",
-        "HDROP",
-        "LOCALE",
-        "DIBV5"
+            "",
+            "TEXT",
+            "BITMAP",
+            "METAFILEPICT",
+            "SYLK",
+            "DIF",
+            "TIFF",
+            "OEM TEXT",
+            "DIB",
+            "PALETTE",
+            "PENDATA",
+            "RIFF",
+            "WAVE",
+            "UNICODE TEXT",
+            "ENHMETAFILE",
+            "HDROP",
+            "LOCALE",
+            "DIBV5"
     };
 
     private static final Map <String, Long> predefinedClipboardNameMap;
     static {
         Map <String,Long> tempMap =
-            new HashMap <> (predefinedClipboardNames.length, 1.0f);
+                new HashMap <> (predefinedClipboardNames.length, 1.0f);
         for (int i = 1; i < predefinedClipboardNames.length; i++) {
             tempMap.put(predefinedClipboardNames[i], Long.valueOf(i));
         }
         predefinedClipboardNameMap =
-            Collections.synchronizedMap(tempMap);
+                Collections.synchronizedMap(tempMap);
     }
 
     /**
@@ -138,18 +138,18 @@
     //CF_FILECONTENTS supported as mandatory associated clipboard
 
     private static final Long L_CF_LOCALE =
-      predefinedClipboardNameMap.get(predefinedClipboardNames[CF_LOCALE]);
+            predefinedClipboardNameMap.get(predefinedClipboardNames[CF_LOCALE]);
 
     private static final DirectColorModel directColorModel =
-        new DirectColorModel(24,
-                             0x00FF0000,  /* red mask   */
-                             0x0000FF00,  /* green mask */
-                             0x000000FF); /* blue mask  */
+            new DirectColorModel(24,
+                    0x00FF0000,  /* red mask   */
+                    0x0000FF00,  /* green mask */
+                    0x000000FF); /* blue mask  */
 
     private static final int[] bandmasks = new int[] {
-        directColorModel.getRedMask(),
-        directColorModel.getGreenMask(),
-        directColorModel.getBlueMask() };
+            directColorModel.getRedMask(),
+            directColorModel.getGreenMask(),
+            directColorModel.getBlueMask() };
 
     /**
      * Singleton constructor
@@ -171,10 +171,10 @@
     }
 
     public SortedMap <Long, DataFlavor> getFormatsForFlavors(
-        DataFlavor[] flavors, FlavorTable map)
+            DataFlavor[] flavors, FlavorTable map)
     {
         SortedMap <Long, DataFlavor> retval =
-            super.getFormatsForFlavors(flavors, map);
+                super.getFormatsForFlavors(flavors, map);
 
         // The Win32 native code does not support exporting LOCALE data, nor
         // should it.
@@ -191,32 +191,60 @@
                                         DataFlavor flavor,
                                         long format) throws IOException
     {
-        byte[] bytes = super.translateTransferable(contents, flavor, format);
-
+        byte[] bytes = null;
         if (format == CF_HTML) {
-            bytes = HTMLCodec.convertToHTMLFormat(bytes);
+            if (contents.isDataFlavorSupported(DataFlavor.selectionHtmlFlavor)) {
+                // if a user provides data represented by
+                // DataFlavor.selectionHtmlFlavor format, we use this
+                // type to store the data in the native clipboard
+                bytes = super.translateTransferable(contents,
+                        DataFlavor.selectionHtmlFlavor,
+                        format);
+            } else if (contents.isDataFlavorSupported(DataFlavor.allHtmlFlavor)) {
+                // if we cannot get data represented by the
+                // DataFlavor.selectionHtmlFlavor format
+                // but the DataFlavor.allHtmlFlavor format is avialable
+                // we belive that the user knows how to represent
+                // the data and how to mark up selection in a
+                // system specific manner. Therefor, we use this data
+                bytes = super.translateTransferable(contents,
+                        DataFlavor.allHtmlFlavor,
+                        format);
+            } else {
+                // handel other html flavor types, including custom and
+                // fragment ones
+                bytes = HTMLCodec.convertToHTMLFormat(bytes);
+            }
+        } else {
+            // we handle non-html types basing on  their
+            // flavors
+            bytes = super.translateTransferable(contents, flavor, format);
         }
         return bytes;
     }
 
-    protected Object translateBytesOrStream(InputStream str, byte[] bytes,
-                                            DataFlavor flavor, long format,
-                                            Transferable localeTransferable)
+    // The stream is closed as a closable object
+    public Object translateStream(InputStream str,
+                                 DataFlavor flavor, long format,
+                                 Transferable localeTransferable)
         throws IOException
     {
         if (format == CF_HTML && flavor.isFlavorTextType()) {
-            if (str == null) {
-                str = new ByteArrayInputStream(bytes);
-                bytes = null;
-            }
+            str = new HTMLCodec(str,
+                                 EHTMLReadMode.getEHTMLReadMode(flavor));
+
+        }
+        return super.translateStream(str, flavor, format,
+                                        localeTransferable);
 
-            str = new HTMLCodec(str,  EHTMLReadMode.HTML_READ_SELECTION);
-        }
+    }
+
+    public Object translateBytes(byte[] bytes, DataFlavor flavor, long format,
+        Transferable localeTransferable) throws IOException
+    {
+
 
         if (format == CF_FILEGROUPDESCRIPTORA || format == CF_FILEGROUPDESCRIPTORW) {
-            if (null != str ) {
-                str.close();
-            }
             if (bytes == null || !DataFlavor.javaFileListFlavor.equals(flavor)) {
                 throw new IOException("data translation failed");
             }
@@ -238,28 +266,24 @@
         }
 
         if (format == CFSTR_INETURL &&
-            URL.class.equals(flavor.getRepresentationClass()))
+                URL.class.equals(flavor.getRepresentationClass()))
         {
-            if (bytes == null) {
-                bytes = inputStreamToByteArray(str);
-                str = null;
-            }
             String charset = getDefaultTextCharset();
             if (localeTransferable != null && localeTransferable.
-                isDataFlavorSupported(javaTextEncodingFlavor))
+                                                                    isDataFlavorSupported(javaTextEncodingFlavor))
             {
                 try {
                     charset = new String((byte[])localeTransferable.
-                                   getTransferData(javaTextEncodingFlavor),
-                                   "UTF-8");
+                        getTransferData(javaTextEncodingFlavor), "UTF-8");
                 } catch (UnsupportedFlavorException cannotHappen) {
                 }
             }
             return new URL(new String(bytes, charset));
         }
 
-        return super.translateBytesOrStream(str, bytes, flavor, format,
-                                            localeTransferable);
+        return super.translateBytes(bytes , flavor, format,
+                                        localeTransferable);
+
     }
 
     public boolean isLocaleDependentTextFormat(long format) {
@@ -280,18 +304,18 @@
 
     protected String getNativeForFormat(long format) {
         return (format < predefinedClipboardNames.length)
-            ? predefinedClipboardNames[(int)format]
-            : getClipboardFormatName(format);
+                ? predefinedClipboardNames[(int)format]
+                : getClipboardFormatName(format);
     }
 
     private final ToolkitThreadBlockedHandler handler =
-        new WToolkitThreadBlockedHandler();
+            new WToolkitThreadBlockedHandler();
 
     public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() {
         return handler;
     }
 
-   /**
+    /**
      * Calls the Win32 RegisterClipboardFormat function to register
      * a non-standard format.
      */
@@ -305,12 +329,12 @@
 
     public boolean isImageFormat(long format) {
         return format == CF_DIB || format == CF_ENHMETAFILE ||
-               format == CF_METAFILEPICT || format == CF_PNG ||
-               format == CF_JFIF;
+                format == CF_METAFILEPICT || format == CF_PNG ||
+                format == CF_JFIF;
     }
 
     protected byte[] imageToPlatformBytes(Image image, long format)
-      throws IOException {
+            throws IOException {
         String mimeType = null;
         if (format == CF_PNG) {
             mimeType = "image/png";
@@ -352,11 +376,11 @@
         int[] nBits = {8, 8, 8};
         int[] bOffs = {2, 1, 0};
         ColorModel colorModel =
-            new ComponentColorModel(cs, nBits, false, false,
-                                    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
+                new ComponentColorModel(cs, nBits, false, false,
+                        Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
         WritableRaster raster =
-            Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height,
-                                           width * 3 + pad, 3, bOffs, null);
+                Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height,
+                        width * 3 + pad, 3, bOffs, null);
 
         BufferedImage bimage = new BufferedImage(colorModel, raster, false, null);
 
@@ -364,7 +388,7 @@
         // top-down DIBs.
         // So we flip the image vertically and create a bottom-up DIB.
         AffineTransform imageFlipTransform =
-            new AffineTransform(1, 0, 0, -1, 0, height);
+                new AffineTransform(1, 0, 0, -1, 0, height);
 
         Graphics2D g2d = bimage.createGraphics();
 
@@ -383,7 +407,7 @@
     private static final byte [] UNICODE_NULL_TERMINATOR =  new byte [] {0,0};
 
     protected ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList)
-        throws IOException
+            throws IOException
     {
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
@@ -407,10 +431,10 @@
         return bos;
     }
 
-   /**
-    * Returns a byte array which contains data special for the given format
-    * and for the given image data.
-    */
+    /**
+     * Returns a byte array which contains data special for the given format
+     * and for the given image data.
+     */
     private native byte[] imageDataToPlatformImageBytes(byte[] imageData,
                                                         int width, int height,
                                                         long format);
@@ -419,10 +443,8 @@
      * Translates either a byte array or an input stream which contain
      * platform-specific image data in the given format into an Image.
      */
-    protected Image platformImageBytesOrStreamToImage(InputStream str,
-                                                      byte[] bytes,
-                                                      long format)
-      throws IOException {
+    protected Image platformImageBytesToImage(byte[] bytes, long format)
+            throws IOException {
         String mimeType = null;
         if (format == CF_PNG) {
             mimeType = "image/png";
@@ -430,11 +452,7 @@
             mimeType = "image/jpeg";
         }
         if (mimeType != null) {
-            return standardImageBytesOrStreamToImage(str, bytes, mimeType);
-        }
-
-        if (bytes == null) {
-            bytes = inputStreamToByteArray(str);
+            return standardImageBytesToImage(bytes, mimeType);
         }
 
         int[] imageData = platformImageBytesToImageData(bytes, format);
@@ -448,8 +466,8 @@
 
         DataBufferInt buffer = new DataBufferInt(imageData, len);
         WritableRaster raster = Raster.createPackedRaster(buffer, width,
-                                                          height, width,
-                                                          bandmasks, null);
+                height, width,
+                bandmasks, null);
 
         return new BufferedImage(directColorModel, raster, false, null);
     }
@@ -462,13 +480,13 @@
      */
     private native int[] platformImageBytesToImageData(byte[] bytes,
                                                        long format)
-      throws IOException;
+            throws IOException;
 
     protected native String[] dragQueryFile(byte[] bytes);
 }
 
 final class WToolkitThreadBlockedHandler extends Mutex
-                       implements ToolkitThreadBlockedHandler {
+        implements ToolkitThreadBlockedHandler {
 
     public void enter() {
         if (!isOwned()) {
@@ -492,7 +510,22 @@
 enum EHTMLReadMode {
     HTML_READ_ALL,
     HTML_READ_FRAGMENT,
-    HTML_READ_SELECTION
+    HTML_READ_SELECTION;
+
+    public static EHTMLReadMode getEHTMLReadMode (DataFlavor df) {
+
+        EHTMLReadMode mode = HTML_READ_SELECTION;
+
+        String parameter = df.getParameter("document");
+
+        if ("all".equals(parameter)) {
+            mode = HTML_READ_ALL;
+        } else if ("fragment".equals(parameter)) {
+            mode = HTML_READ_FRAGMENT;
+        }
+
+        return mode;
+    }
 }
 
 /**
@@ -581,26 +614,24 @@
                     htmlSuffix = "</BODY>" + htmlSuffix;
                 };
             };
-            htmlPrefix = htmlPrefix + START_FRAGMENT_CMT;
-            htmlSuffix = END_FRAGMENT_CMT + htmlSuffix;
         }
 
         String stBaseUrl = DEF_SOURCE_URL;
         int nStartHTML =
-            VERSION.length() + VERSION_NUM.length() + EOLN.length()
-            + START_HTML.length() + PADDED_WIDTH + EOLN.length()
-            + END_HTML.length() + PADDED_WIDTH + EOLN.length()
-            + START_FRAGMENT.length() + PADDED_WIDTH + EOLN.length()
-            + END_FRAGMENT.length() + PADDED_WIDTH + EOLN.length()
-            + SOURCE_URL.length() + stBaseUrl.length() + EOLN.length()
-            ;
+                VERSION.length() + VERSION_NUM.length() + EOLN.length()
+                        + START_HTML.length() + PADDED_WIDTH + EOLN.length()
+                        + END_HTML.length() + PADDED_WIDTH + EOLN.length()
+                        + START_FRAGMENT.length() + PADDED_WIDTH + EOLN.length()
+                        + END_FRAGMENT.length() + PADDED_WIDTH + EOLN.length()
+                        + SOURCE_URL.length() + stBaseUrl.length() + EOLN.length()
+                ;
         int nStartFragment = nStartHTML + htmlPrefix.length();
         int nEndFragment = nStartFragment + bytes.length - 1;
         int nEndHTML = nEndFragment + htmlSuffix.length();
 
         StringBuilder header = new StringBuilder(
-            nStartFragment
-            + START_FRAGMENT_CMT.length()
+                nStartFragment
+                        + START_FRAGMENT_CMT.length()
         );
         //header
         header.append(VERSION);
@@ -639,14 +670,14 @@
         }
 
         byte[] retval = new byte[headerBytes.length + bytes.length +
-                                 trailerBytes.length];
+                trailerBytes.length];
 
         System.arraycopy(headerBytes, 0, retval, 0, headerBytes.length);
         System.arraycopy(bytes, 0, retval, headerBytes.length,
-                       bytes.length - 1);
+                bytes.length - 1);
         System.arraycopy(trailerBytes, 0, retval,
-                         headerBytes.length + bytes.length - 1,
-                         trailerBytes.length);
+                headerBytes.length + bytes.length - 1,
+                trailerBytes.length);
         retval[retval.length-1] = 0;
 
         return retval;
@@ -659,7 +690,7 @@
     private boolean descriptionParsed = false;
     private boolean closed = false;
 
-     // InputStreamReader uses an 8K buffer. The size is not customizable.
+    // InputStreamReader uses an 8K buffer. The size is not customizable.
     public static final int BYTE_BUFFER_LEN = 8192;
 
     // CharToByteUTF8.getMaxBytesPerChar returns 3, so we should not buffer
@@ -667,30 +698,30 @@
     public static final int CHAR_BUFFER_LEN = BYTE_BUFFER_LEN / 3;
 
     private static final String FAILURE_MSG =
-        "Unable to parse HTML description: ";
+            "Unable to parse HTML description: ";
     private static final String INVALID_MSG =
-        " invalid";
+            " invalid";
 
     //HTML header mapping:
     private long   iHTMLStart,// StartHTML -- shift in array to the first byte after the header
-                   iHTMLEnd,  // EndHTML -- shift in array of last byte for HTML syntax analysis
-                   iFragStart,// StartFragment -- shift in array jast after <!--StartFragment-->
-                   iFragEnd,  // EndFragment -- shift in array before start <!--EndFragment-->
-                   iSelStart, // StartSelection -- shift in array of the first char in copied selection
-                   iSelEnd;   // EndSelection -- shift in array of the last char in copied selection
+            iHTMLEnd,  // EndHTML -- shift in array of last byte for HTML syntax analysis
+            iFragStart,// StartFragment -- shift in array jast after <!--StartFragment-->
+            iFragEnd,  // EndFragment -- shift in array before start <!--EndFragment-->
+            iSelStart, // StartSelection -- shift in array of the first char in copied selection
+            iSelEnd;   // EndSelection -- shift in array of the last char in copied selection
     private String stBaseURL; // SourceURL -- base URL for related referenses
     private String stVersion; // Version -- current supported version
 
     //Stream reader markers:
     private long iStartOffset,
-                 iEndOffset,
-                 iReadCount;
+            iEndOffset,
+            iReadCount;
 
     private EHTMLReadMode readMode;
 
     public HTMLCodec(
-        InputStream _bytestream,
-        EHTMLReadMode _readMode) throws IOException
+            InputStream _bytestream,
+            EHTMLReadMode _readMode) throws IOException
     {
         bufferedStream = new BufferedInputStream(_bytestream, BYTE_BUFFER_LEN);
         readMode = _readMode;
@@ -723,31 +754,31 @@
         // initialization of array offset pointers
         // to the same "uninitialized" state.
         iHTMLEnd =
-            iHTMLStart =
-                iFragEnd =
-                    iFragStart =
-                        iSelEnd =
-                            iSelStart = -1;
+                iHTMLStart =
+                        iFragEnd =
+                                iFragStart =
+                                        iSelEnd =
+                                                iSelStart = -1;
 
         bufferedStream.mark(BYTE_BUFFER_LEN);
         String astEntries[] = new String[] {
-            //common
-            VERSION,
-            START_HTML,
-            END_HTML,
-            START_FRAGMENT,
-            END_FRAGMENT,
-            //ver 1.0
-            START_SELECTION,
-            END_SELECTION,
-            SOURCE_URL
+                //common
+                VERSION,
+                START_HTML,
+                END_HTML,
+                START_FRAGMENT,
+                END_FRAGMENT,
+                //ver 1.0
+                START_SELECTION,
+                END_SELECTION,
+                SOURCE_URL
         };
         BufferedReader bufferedReader = new BufferedReader(
-            new InputStreamReader(
-                bufferedStream,
-                ENCODING
-            ),
-            CHAR_BUFFER_LEN
+                new InputStreamReader(
+                        bufferedStream,
+                        ENCODING
+                ),
+                CHAR_BUFFER_LEN
         );
         long iHeadSize = 0;
         long iCRSize = EOLN.length();
@@ -769,30 +800,30 @@
                 if( null!=stValue ) {
                     try{
                         switch( iEntry ){
-                        case 0:
-                            stVersion = stValue;
-                            break;
-                        case 1:
-                            iHTMLStart = Integer.parseInt(stValue);
-                            break;
-                        case 2:
-                            iHTMLEnd = Integer.parseInt(stValue);
-                            break;
-                        case 3:
-                            iFragStart = Integer.parseInt(stValue);
-                            break;
-                        case 4:
-                            iFragEnd = Integer.parseInt(stValue);
-                            break;
-                        case 5:
-                            iSelStart = Integer.parseInt(stValue);
-                            break;
-                        case 6:
-                            iSelEnd = Integer.parseInt(stValue);
-                            break;
-                        case 7:
-                            stBaseURL = stValue;
-                            break;
+                            case 0:
+                                stVersion = stValue;
+                                break;
+                            case 1:
+                                iHTMLStart = Integer.parseInt(stValue);
+                                break;
+                            case 2:
+                                iHTMLEnd = Integer.parseInt(stValue);
+                                break;
+                            case 3:
+                                iFragStart = Integer.parseInt(stValue);
+                                break;
+                            case 4:
+                                iFragEnd = Integer.parseInt(stValue);
+                                break;
+                            case 5:
+                                iSelStart = Integer.parseInt(stValue);
+                                break;
+                            case 6:
+                                iSelEnd = Integer.parseInt(stValue);
+                                break;
+                            case 7:
+                                stBaseURL = stValue;
+                                break;
                         };
                     } catch ( NumberFormatException e ) {
                         throw new IOException(FAILURE_MSG + astEntries[iEntry]+ " value " + e + INVALID_MSG);
@@ -816,19 +847,19 @@
 
         //one of possible modes
         switch( readMode ){
-        case HTML_READ_ALL:
-            iStartOffset = iHTMLStart;
-            iEndOffset = iHTMLEnd;
-            break;
-        case HTML_READ_FRAGMENT:
-            iStartOffset = iFragStart;
-            iEndOffset = iFragEnd;
-            break;
-        case HTML_READ_SELECTION:
-        default:
-            iStartOffset = iSelStart;
-            iEndOffset = iSelEnd;
-            break;
+            case HTML_READ_ALL:
+                iStartOffset = iHTMLStart;
+                iEndOffset = iHTMLEnd;
+                break;
+            case HTML_READ_FRAGMENT:
+                iStartOffset = iFragStart;
+                iEndOffset = iFragEnd;
+                break;
+            case HTML_READ_SELECTION:
+            default:
+                iStartOffset = iSelStart;
+                iEndOffset = iSelEnd;
+                break;
         }
 
         bufferedStream.reset();
--- a/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 import java.awt.image.BufferedImage;
 import java.awt.image.BufferedImageOp;
 import java.lang.ref.WeakReference;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 import sun.java2d.ScreenUpdateManager;
 import sun.java2d.SurfaceData;
 import sun.java2d.loops.Blit;
@@ -48,8 +48,6 @@
 import static sun.java2d.pipe.BufferedOpCodes.*;
 import sun.java2d.windows.GDIWindowSurfaceData;
 
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 class D3DBlitLoops {
 
     static void register() {
@@ -179,12 +177,12 @@
      * createPackedParams().  (They are also used at the native level when
      * unpacking the params.)
      */
-    private static final int OFFSET_SRCTYPE = 16;
-    private static final int OFFSET_HINT    =  8;
-    private static final int OFFSET_TEXTURE =  3;
-    private static final int OFFSET_RTT     =  2;
-    private static final int OFFSET_XFORM   =  1;
-    private static final int OFFSET_ISOBLIT =  0;
+    @Native private static final int OFFSET_SRCTYPE = 16;
+    @Native private static final int OFFSET_HINT    =  8;
+    @Native private static final int OFFSET_TEXTURE =  3;
+    @Native private static final int OFFSET_RTT     =  2;
+    @Native private static final int OFFSET_XFORM   =  1;
+    @Native private static final int OFFSET_ISOBLIT =  0;
 
     /**
      * Packs the given parameters into a single int value in order to save
--- a/jdk/src/windows/classes/sun/java2d/d3d/D3DContext.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DContext.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 package sun.java2d.d3d;
 
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 import sun.java2d.pipe.BufferedContext;
 import sun.java2d.pipe.RenderBuffer;
 import sun.java2d.pipe.RenderQueue;
@@ -38,8 +38,6 @@
  * Note that the RenderQueue lock must be acquired before calling any of
  * the methods in this class.
  */
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
 class D3DContext extends BufferedContext {
 
     private final D3DGraphicsDevice device;
@@ -143,31 +141,29 @@
         return device;
     }
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     static class D3DContextCaps extends ContextCapabilities {
         /**
          * Indicates the presence of pixel shaders (v2.0 or greater).
          * This cap will only be set if the hardware supports the minimum number
          * of texture units.
          */
-        static final int CAPS_LCD_SHADER       = (FIRST_PRIVATE_CAP << 0);
+    @Native static final int CAPS_LCD_SHADER       = (FIRST_PRIVATE_CAP << 0);
         /**
          * Indicates the presence of pixel shaders (v2.0 or greater).
          * This cap will only be set if the hardware meets our
          * minimum requirements.
          */
-        static final int CAPS_BIOP_SHADER      = (FIRST_PRIVATE_CAP << 1);
+    @Native static final int CAPS_BIOP_SHADER      = (FIRST_PRIVATE_CAP << 1);
         /**
          * Indicates that the device was successfully initialized and can
          * be safely used.
          */
-        static final int CAPS_DEVICE_OK        = (FIRST_PRIVATE_CAP << 2);
+    @Native static final int CAPS_DEVICE_OK        = (FIRST_PRIVATE_CAP << 2);
         /**
          * Indicates that the device has all of the necessary capabilities
          * to support the Antialiasing Pixel Shader program.
          */
-        static final int CAPS_AA_SHADER        = (FIRST_PRIVATE_CAP << 3);
+    @Native static final int CAPS_AA_SHADER        = (FIRST_PRIVATE_CAP << 3);
 
         D3DContextCaps(int caps, String adapterId) {
             super(caps, adapterId);
--- a/jdk/src/windows/classes/sun/java2d/d3d/D3DPaints.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DPaints.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +33,7 @@
 import java.awt.image.BufferedImage;
 import java.util.HashMap;
 import java.util.Map;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
 import sun.java2d.SunGraphics2D;
 import sun.java2d.SurfaceData;
 import sun.java2d.loops.CompositeType;
@@ -158,8 +158,6 @@
 
 /****************** Shared MultipleGradientPaint support ********************/
 
-    /* No native methods here, but the constants are needed in the supporting JNI code */
-    @GenerateNativeHeader
     private static abstract class MultiGradient extends D3DPaints {
 
         /**
@@ -170,7 +168,7 @@
          * all versions of the shader can be compiled for PS 2.0 hardware,
          * we need to cap this maximum value at 8.
          */
-        public static final int MULTI_MAX_FRACTIONS_D3D = 8;
+    @Native public static final int MULTI_MAX_FRACTIONS_D3D = 8;
 
         protected MultiGradient() {}
 
--- a/jdk/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java	Wed Jul 05 18:50:02 2017 +0200
@@ -303,9 +303,7 @@
                     dfs.setNaN(getNaN(langTag, dfs.getNaN()));
                     dfs.setPercent(getPercent(langTag, dfs.getPercent()));
                     dfs.setPerMill(getPerMill(langTag, dfs.getPerMill()));
-                    if (isNativeDigit(langTag)) {
-                        dfs.setZeroDigit(getZeroDigit(langTag, dfs.getZeroDigit()));
-                    }
+                    dfs.setZeroDigit(getZeroDigit(langTag, dfs.getZeroDigit()));
                     ref = new SoftReference<>(dfs);
                     decimalFormatSymbolsCache.put(locale, ref);
                 }
@@ -420,9 +418,13 @@
             return false;
         }
 
+        int calid = getCalendarID(locale.toLanguageTag());
+        if (calid <= 0 || calid >= calIDToLDML.length) {
+            return false;
+        }
+
         String requestedCalType = locale.getUnicodeLocaleType("ca");
-        String nativeCalType =
-                calIDToLDML[getCalendarID(locale.toLanguageTag())]
+        String nativeCalType = calIDToLDML[calid]
                 .replaceFirst("_.*", ""); // remove locale part.
 
         if (requestedCalType == null) {
--- a/jdk/src/windows/demo/jvmti/hprof/hprof_md.c	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/demo/jvmti/hprof/hprof_md.c	Wed Jul 05 18:50:02 2017 +0200
@@ -368,42 +368,32 @@
 }
 
 static void dll_build_name(char* buffer, size_t buflen,
-                           const char* pname, const char* fname) {
-    // Loosley based on os_windows.cpp
+                           const char* paths, const char* fname) {
+    char *path, *paths_copy, *next_token;
 
-    char *pathname = (char *)pname;
-    *buffer = '\0';
-    while (strlen(pathname) > 0) {
-        char *p = strchr(pathname, ';');
-        if (p == NULL) {
-            p = pathname + strlen(pathname);
-        }
-        /* check for NULL path */
-        if (p == pathname) {
-            continue;
-        }
-        if (*(p-1) == ':' || *(p-1) == '\\') {
-          (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname),
-                            pathname, fname);
-        } else {
-          (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname),
-                            pathname, fname);
-        }
+    paths_copy = strdup(paths);
+    if (paths_copy == NULL) {
+        return;
+    }
+
+    next_token = NULL;
+    path = strtok_s(paths_copy, ";", &next_token);
+
+    while (path != NULL) {
+        _snprintf(buffer, buflen, "%s\\%s.dll", path, fname);
         if (_access(buffer, 0) == 0) {
             break;
         }
-        if (*p == '\0') {
-            pathname = p;
-        } else {
-            pathname = p + 1;
-        }
         *buffer = '\0';
+        path = strtok_s(NULL, ";", &next_token);
     }
+
+    free(paths_copy);
 }
 
 /* Build a machine dependent library name out of a path and file name.  */
 void
-md_build_library_name(char *holder, int holderlen, char *pname, char *fname)
+md_build_library_name(char *holder, int holderlen, const char *pname, const char *fname)
 {
     int   pnamelen;
 
--- a/jdk/src/windows/native/sun/java2d/d3d/D3DContext.h	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/native/sun/java2d/d3d/D3DContext.h	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +28,6 @@
 
 #include "java_awt_Transparency.h"
 #include "sun_java2d_pipe_BufferedContext.h"
-#include "sun_java2d_d3d_D3DContext.h"
 #include "sun_java2d_d3d_D3DContext_D3DContextCaps.h"
 #include "sun_java2d_d3d_D3DSurfaceData.h"
 #include "sun_java2d_pipe_hw_AccelDeviceEventNotifier.h"
--- a/jdk/src/windows/native/sun/windows/awt_Component.h	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Component.h	Wed Jul 05 18:50:02 2017 +0200
@@ -37,7 +37,6 @@
 #include "java_awt_Component.h"
 #include "sun_awt_windows_WComponentPeer.h"
 #include "java_awt_event_KeyEvent.h"
-#include "java_awt_event_FocusEvent.h"
 #include "java_awt_event_MouseEvent.h"
 #include "java_awt_event_WindowEvent.h"
 #include "java_awt_Dimension.h"
--- a/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,6 @@
 
 #include "java_awt_event_InputEvent.h"
 #include "java_awt_dnd_DnDConstants.h"
-#include "sun_awt_dnd_SunDragSourceContextPeer.h"
 #include "sun_awt_windows_WDragSourceContextPeer.h"
 
 #include "awt_ole.h"
--- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * 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,7 +34,6 @@
 #include <windowsx.h>
 
 #include <java_lang_Integer.h>
-#include <sun_awt_EmbeddedFrame.h>
 #include <sun_awt_windows_WEmbeddedFrame.h>
 #include <sun_awt_windows_WEmbeddedFramePeer.h>
 
--- a/jdk/src/windows/native/sun/windows/awt_List.h	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_List.h	Wed Jul 05 18:50:02 2017 +0200
@@ -28,7 +28,6 @@
 
 #include "awt_Component.h"
 
-#include "java_awt_List.h"
 #include "sun_awt_windows_WListPeer.h"
 
 
--- a/jdk/src/windows/native/sun/windows/awt_PopupMenu.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_PopupMenu.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -28,7 +28,6 @@
 #include "awt_Event.h"
 #include "awt_Window.h"
 
-#include <java_awt_PopupMenu.h>
 #include <sun_awt_windows_WPopupMenuPeer.h>
 #include <java_awt_Event.h>
 
--- a/jdk/src/windows/native/sun/windows/awt_PopupMenu.h	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_PopupMenu.h	Wed Jul 05 18:50:02 2017 +0200
@@ -30,7 +30,6 @@
 
 #include <java_awt_MenuItem.h>
 #include <sun_awt_windows_WMenuItemPeer.h>
-#include <java_awt_PopupMenu.h>
 #include <sun_awt_windows_WPopupMenuPeer.h>
 
 
--- a/jdk/src/windows/native/sun/windows/awt_TextComponent.h	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_TextComponent.h	Wed Jul 05 18:50:02 2017 +0200
@@ -28,7 +28,6 @@
 
 #include "awt_Component.h"
 
-#include "java_awt_TextComponent.h"
 #include "sun_awt_windows_WTextComponentPeer.h"
 
 #include <ole2.h>
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,7 +62,6 @@
 
 #include <java_awt_Toolkit.h>
 #include <java_awt_event_InputMethodEvent.h>
-#include <java_awt_peer_ComponentPeer.h>
 
 extern void initScreens(JNIEnv *env);
 extern "C" void awt_dnd_initialize();
--- a/jdk/test/Makefile	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/Makefile	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -336,7 +336,7 @@
 	@$(ECHO) "Testing completed successfully"
 
 # Prep for output
-prep: clean
+prep:
 	@$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR)
 	@$(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`
 
@@ -704,200 +704,6 @@
 
 ################################################################
 
-# packtest
-
-# Expect JPRT to set JPRT_PACKTEST_HOME.
-PACKTEST_HOME = /net/jprt-web.sfbay.sun.com/jprt/allproducts/packtest
-ifdef JPRT_PACKTEST_HOME
-  PACKTEST_HOME = $(JPRT_PACKTEST_HOME)
-endif
-
-packtest: prep $(PACKTEST_HOME)/ptest $(PRODUCT_HOME)
-	( $(CD) $(PACKTEST_HOME) &&            \
-	    $(PACKTEST_HOME)/ptest             \
-		 -t "$(PRODUCT_HOME)"          \
-	         $(PACKTEST_STRESS_OPTION)     \
-		 $(EXTRA_PACKTEST_OPTIONS)     \
-		 -W $(ABS_TEST_OUTPUT_DIR)     \
-                 $(JAVA_ARGS:%=-J %)           \
-                 $(JAVA_VM_ARGS:%=-J %)        \
-	 ) ; $(BUNDLE_UP_AND_EXIT)
-
-packtest_stress: PACKTEST_STRESS_OPTION=-s
-packtest_stress: packtest
-
-PHONY_LIST += packtest packtest_stress
-
-################################################################
-
-# perftest to collect statistics
-
-# Expect JPRT to set JPRT_PACKTEST_HOME.
-PERFTEST_HOME = $(TEST_ROOT)/perf
-ifdef JPRT_PERFTEST_HOME
-  PERFTEST_HOME = $(JPRT_PERFTEST_HOME)
-endif
-
-perftest: ( $(PERFTEST_HOME)/perftest          \
-                 -t $(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")               \
-                 -w $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)") \
-                 -h $(PERFTEST_HOME) \
-	 ) ; $(BUNDLE_UP_AND_EXIT)
-
-
-PHONY_LIST += perftest
-
-################################################################
-
-# vmsqe tests
-
-# Expect JPRT to set JPRT_VMSQE_HOME.
-VMSQE_HOME = $(SLASH_JAVA)/sqe/comp/vm/testbase/sqe/vm/current/build/latest/vm
-ifdef JPRT_VMSQE_HOME
-  VMSQE_HOME = $(JPRT_VMSQE_HOME)
-endif
-
-# Expect JPRT to set JPRT_RUNVMSQE_HOME.
-RUNVMSQE_HOME = /net/jprt-web.sfbay.sun.com/jprt/allproducts/runvmsqe
-ifdef JPRT_RUNVMSQE_HOME
-  RUNVMSQE_HOME = $(JPRT_RUNVMSQE_HOME)
-endif
-
-# Expect JPRT to set JPRT_TONGA3_HOME.
-TONGA3_HOME = $(SLASH_JAVA)/sqe/tools/gtee/harness/tonga
-ifdef JPRT_TONGA3_HOME
-  TONGA3_HOME = $(JPRT_TONGA3_HOME)
-endif
-
-RUNVMSQE_BIN = $(RUNVMSQE_HOME)/bin/runvmsqe
-
-vmsqe_tests: prep $(VMSQE_HOME)/vm $(TONGA3_HOME) $(RUNVMSQE_BIN) $(PRODUCT_HOME)
-	$(RM) -r $(ABS_TEST_OUTPUT_DIR)/vmsqe
-	( $(CD) $(ABS_TEST_OUTPUT_DIR) &&          \
-	    $(RUNVMSQE_BIN)                        \
-		 -jdk "$(PRODUCT_HOME)"            \
-		 -o "$(ABS_TEST_OUTPUT_DIR)/vmsqe" \
-		 -testbase "$(VMSQE_HOME)/vm"      \
-		 -tonga "$(TONGA3_HOME)"           \
-		 -tongajdk "$(ALT_BOOTDIR)"        \
-                 $(JAVA_ARGS)                      \
-                 $(JAVA_VM_ARGS)                   \
-	         $(RUNVMSQE_TEST_OPTION)           \
-		 $(EXTRA_RUNVMSQE_OPTIONS)         \
-	 ) ; $(BUNDLE_UP_AND_EXIT)
-
-vmsqe_jdwp: RUNVMSQE_TEST_OPTION=-jdwp
-vmsqe_jdwp: vmsqe_tests
-
-vmsqe_jdi: RUNVMSQE_TEST_OPTION=-jdi
-vmsqe_jdi: vmsqe_tests
-
-vmsqe_jdb: RUNVMSQE_TEST_OPTION=-jdb
-vmsqe_jdb: vmsqe_tests
-
-vmsqe_quick-jdi: RUNVMSQE_TEST_OPTION=-quick-jdi
-vmsqe_quick-jdi: vmsqe_tests
-
-vmsqe_sajdi: RUNVMSQE_TEST_OPTION=-sajdi
-vmsqe_sajdi: vmsqe_tests
-
-vmsqe_jvmti: RUNVMSQE_TEST_OPTION=-jvmti
-vmsqe_jvmti: vmsqe_tests
-
-vmsqe_hprof: RUNVMSQE_TEST_OPTION=-hprof
-vmsqe_hprof: vmsqe_tests
-
-vmsqe_monitoring: RUNVMSQE_TEST_OPTION=-monitoring
-vmsqe_monitoring: vmsqe_tests
-
-PHONY_LIST += vmsqe_jdwp vmsqe_jdi vmsqe_jdb vmsqe_quick-jdi vmsqe_sajdi \
-              vmsqe_jvmti vmsqe_hprof vmsqe_monitoring vmsqe_tests
-
-################################################################
-
-# jck tests
-
-# Default is to use jck 7 from /java/re
-JCK7_DEFAULT_HOME = $(SLASH_JAVA)/re/jck/7/promoted/latest/binaries
-
-# Expect JPRT to set JPRT_JCK7COMPILER_HOME.
-JCK7COMPILER_HOME = $(JCK7_DEFAULT_HOME)/JCK-compiler-7
-ifdef JPRT_JCK7COMPILER_HOME
-  JCK7COMPILER_HOME = $(JPRT_JCK7COMPILER_HOME)/JCK-compiler-7
-endif
-
-# Expect JPRT to set JPRT_JCK7RUNTIME_HOME.
-JCK7RUNTIME_HOME = $(JCK7_DEFAULT_HOME)/JCK-runtime-7
-ifdef JPRT_JCK7RUNTIME_HOME
-  JCK7RUNTIME_HOME = $(JPRT_JCK7RUNTIME_HOME)/JCK-runtime-7
-endif
-
-# Expect JPRT to set JPRT_JCK7DEVTOOLS_HOME.
-JCK7DEVTOOLS_HOME = $(JCK7_DEFAULT_HOME)/JCK-devtools-7
-ifdef JPRT_JCK7DEVTOOLS_HOME
-  JCK7DEVTOOLS_HOME = $(JPRT_JCK7DEVTOOLS_HOME)/JCK-devtools-7
-endif
-
-# The jtjck.jar utility to use to run the tests
-JTJCK_JAR = $(JCK_HOME)/lib/jtjck.jar
-JTJCK_JAVA_ARGS =  -XX:MaxPermSize=256m -Xmx512m
-JTJCK_OPTIONS = -headless -v
-
-# Default tests to run
-ifndef JCK_COMPILER_TESTS
-  JCK_COMPILER_TESTS =
-endif
-ifndef JCK_RUNTIME_TESTS
-  JCK_RUNTIME_TESTS  =
-endif
-ifndef JCK_DEVTOOLS_TESTS
-  JCK_DEVTOOLS_TESTS =
-endif
-
-# Generic rule used to run jck tests
-_generic_jck_tests: prep $(PRODUCT_HOME) $(EXCLUDELIST)
-	@$(EXPAND) $(EXCLUDELIST) \
-            | $(CUT) -d' ' -f1 \
-            | $(SED) -e 's@^@Excluding: @'
-	( $(CD) $(ABS_TEST_OUTPUT_DIR) &&          			   \
-	  $(PRODUCT_HOME)/bin/java $(JTJCK_JAVA_ARGS) 			   \
-	    -jar "$(JTJCK_JAR)" 					   \
-	    $(JTJCK_OPTIONS) 						   \
-            -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport  \
-            -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork    \
-            -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                \
-	    $(TESTDIRS) 						   \
-        ) ; $(BUNDLE_UP_AND_EXIT)
-
-# JCK7 compiler tests
-jck7compiler:
-	$(MAKE) UNIQUE_DIR=$@ \
-	        JCK_HOME=$(JCK7COMPILER_HOME) \
-	        TESTDIRS="$(JCK_COMPILER_TESTS)" \
-                _generic_jck_tests
-
-# JCK7 runtime tests
-jck7runtime:
-	$(MAKE) UNIQUE_DIR=$@ \
-	        JCK_HOME=$(JCK7RUNTIME_HOME) \
-	        TESTDIRS="$(JCK_RUNTIME_TESTS)" \
-                _generic_jck_tests
-
-# JCK7 devtools tests
-jck7devtools:
-	$(MAKE) UNIQUE_DIR=$@ \
-	        JCK_HOME=$(JCK7DEVTOOLS_HOME) \
-                TESTDIRS="$(JCK_DEVTOOLS_TESTS)" \
-                _generic_jck_tests
-
-# Run all 3 sets of JCK7 tests
-jck_all: jck7runtime jck7devtools jck7compiler
-
-PHONY_LIST += jck_all _generic_jck_tests \
-	      jck7compiler jck7runtime jck7devtools
-
-################################################################
-
 # Phony targets (e.g. these are not filenames)
 .PHONY: all clean prep $(PHONY_LIST)
 
--- a/jdk/test/ProblemList.txt	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/ProblemList.txt	Wed Jul 05 18:50:02 2017 +0200
@@ -339,23 +339,6 @@
 # 8007410
 tools/launcher/FXLauncherTest.java                              linux-all
 
-# 8004172
-sun/tools/jstat/jstatGcCapacityOutput1.sh                       generic-all
-sun/tools/jstat/jstatGcCauseOutput1.sh                          generic-all
-sun/tools/jstat/jstatGcOldOutput1.sh                            generic-all
-sun/tools/jstat/jstatGcOutput1.sh                               generic-all
-sun/tools/jstat/jstatGcPermCapacityOutput1.sh                   generic-all
-sun/tools/jstat/jstatLineCounts1.sh                             generic-all
-sun/tools/jstat/jstatLineCounts2.sh                             generic-all
-sun/tools/jstat/jstatLineCounts3.sh                             generic-all
-sun/tools/jstat/jstatLineCounts4.sh                             generic-all
-sun/tools/jstat/jstatOptions1.sh                                generic-all
-sun/tools/jstat/jstatTimeStamp1.sh                              generic-all
-sun/tools/jstatd/jstatdExternalRegistry.sh                      generic-all
-sun/tools/jstatd/jstatdDefaults.sh                              generic-all
-sun/tools/jstatd/jstatdPort.sh                                  generic-all
-sun/tools/jstatd/jstatdServerName.sh                            generic-all
-
 ############################################################################
 
 # jdk_jdi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact 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 7075105
+  @summary WIN: Provide a way to format HTML on drop
+  @author Denis Fokin: area=datatransfer
+  @build HtmlTransferable PutAllHtmlFlavorsOnClipboard
+  @build PutOnlyAllHtmlFlavorOnClipboard PutSelectionAndFragmentHtmlFlavorsOnClipboard
+  @run main HTMLDataFlavorTest
+*/
+
+import java.awt.*;
+import java.awt.datatransfer.*;
+import java.io.*;
+import java.util.HashMap;
+
+public class HTMLDataFlavorTest {
+
+    private static HashMap<DataFlavor, String> dataFlavors = new HashMap<DataFlavor, String>();
+
+
+    public static void main(String[] args) throws IOException, UnsupportedFlavorException {
+
+        dataFlavors.put(DataFlavor.allHtmlFlavor, HtmlTransferable.ALL_HTML_AS_STRING);
+        dataFlavors.put(DataFlavor.fragmentHtmlFlavor, HtmlTransferable.FRAGMENT_HTML_AS_STRING);
+        dataFlavors.put(DataFlavor.selectionHtmlFlavor, HtmlTransferable.SELECTION_HTML_AS_STRING);
+
+        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+        resetClipboardContent(clipboard);
+
+        // 1. Put all three html flavors on clipboard.
+        //    Get the data within the same JVM
+        //    Expect that the resulted html is the selection
+        //    wrapped in all three types
+
+        clipboard.setContents(new HtmlTransferable(HtmlTransferable.htmlDataFlavors),null);
+
+        // Test local transfer
+        testClipboardContent(clipboard, HtmlTransferable.htmlDataFlavors);
+
+        resetClipboardContent(clipboard);
+
+        // 2. Put only DataFlavor.allHtmlFlavor on clipboard.
+        //    Expect that the resulted html is the all
+        //    wrapped in all three types
+
+        putHtmlInAnotherProcess("PutOnlyAllHtmlFlavorOnClipboard");
+
+        for (DataFlavor df : HtmlTransferable.htmlDataFlavors) {
+            if (!clipboard.isDataFlavorAvailable(df)) {
+                throw new RuntimeException("The data should be available.");
+            }
+        }
+
+        if (!clipboard.getData(DataFlavor.allHtmlFlavor).toString().
+                equals(dataFlavors.get(DataFlavor.allHtmlFlavor).toString()))
+        {
+            throw new RuntimeException("DataFlavor.allHtmlFlavor data " +
+                    "should be identical to the data put on the source side.");
+        }
+
+        resetClipboardContent(clipboard);
+
+        // 3. Put all three html flavors on clipboard.
+        //    Expect that the resulted html is the selection
+        //    wrapped in all three types
+
+        putHtmlInAnotherProcess("PutAllHtmlFlavorsOnClipboard");
+
+        for (DataFlavor df : HtmlTransferable.htmlDataFlavors) {
+            if (!clipboard.isDataFlavorAvailable(df)) {
+                throw new RuntimeException("The data should be available.");
+            }
+        }
+
+        if (!clipboard.getData(DataFlavor.selectionHtmlFlavor).toString().
+                equals(dataFlavors.get(DataFlavor.selectionHtmlFlavor)))
+        {
+            throw new RuntimeException("DataFlavor.allHtmlFlavor data " +
+                    "should be identical to the data put on the source side.");
+        }
+
+    }
+
+    private static void resetClipboardContent(Clipboard clipboard) {
+        clipboard.setContents(
+                new StringSelection("The data is used to empty the clipboard content"
+                ),null);
+    }
+
+
+    private static void putHtmlInAnotherProcess(String putterCommand) {
+        try {
+
+            String command = System.getProperty("java.home") + "/bin/java -cp " +
+                    System.getProperty("test.classes", ".") + " "  +
+                    putterCommand;
+
+            System.out.println("Execute process : " + command);
+
+            Process p = Runtime.getRuntime().exec(command);
+
+            try {
+                p.waitFor();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+
+            System.out.println("The data has been set remotely");
+
+            try (BufferedReader stdstr = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
+                String s;
+                while ((s = stdstr.readLine()) != null) {
+                    s = stdstr.readLine();
+                    System.out.println(s);
+                }
+            }
+
+            try (BufferedReader br = new BufferedReader(new InputStreamReader(p.getErrorStream()))) {
+                String s;
+                while ((s = br.readLine()) != null) {
+                    s = br.readLine();
+                    System.err.println(s);
+                }
+            }
+
+
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private static void testClipboardContent(Clipboard clipboard,
+                                             DataFlavor [] expectedDataFlavors)
+            throws UnsupportedFlavorException, IOException {
+
+        for (DataFlavor df : clipboard.getAvailableDataFlavors()) {
+            System.out.println("available df: " + df.getMimeType());
+        }
+
+        for (DataFlavor df : expectedDataFlavors) {
+
+            if (!clipboard.isDataFlavorAvailable(df)) {
+                throw new RuntimeException("The data should be available.");
+            }
+
+
+            System.out.println("Checking \"" + df.getParameter("document") + "\" for correspondence");
+
+            if (!dataFlavors.get(df).toString().equals(clipboard.getData(df).toString())) {
+
+                System.err.println("Expected data: " + dataFlavors.get(df).toString());
+                System.err.println("Actual data: " + clipboard.getData(df).toString());
+
+
+                throw new RuntimeException("An html flavor with parameter \"" +
+                        df.getParameter("document") + "\" does not correspond to the transferred data.");
+
+
+            }
+        }
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/HTMLDataFlavors/HtmlTransferable.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+
+/**
+ * A transferable that mimic ie html data
+ */
+class HtmlTransferable implements Transferable {
+
+    final static String SOURCE_HTML = "<html><head><title>Simple html content</title></head>" +
+            "<body><ol><li>Dasha</li><li>Masha</li><li>Lida</li></ol></body></html>";
+
+    // Data identical to ie output for the next html without end of lines,
+    // that is gotten by java system clipboard
+    // <html>
+    // <head>
+    // <title>Simple html content</title>
+    // </head>
+    // <body>
+    // <ol>
+    // <li>Dasha</li>
+    // <li>Masha</li>
+    // <li>Lida</li>
+    // </ol>
+    // </body>
+    // </html>
+
+    final static String ALL_HTML_AS_STRING = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n" +
+            "\n" +
+            "<HTML><HEAD><TITLE>Simple html content</TITLE></HEAD>\n" +
+            "\n" +
+            "<BODY>\n" +
+            "\n" +
+            "<OL><!--StartFragment--><LI>Masha\n" +
+            "<LI>Lida</LI><!--EndFragment--></OL>\n" +
+            "</BODY>\n" +
+            "</HTML>";
+
+    final static String FRAGMENT_HTML_AS_STRING = "<LI>Masha\n" +
+            "<LI>Lida</LI>";
+
+    final static String SELECTION_HTML_AS_STRING =  "<LI>Masha" +
+            "<LI>Lida</LI>";
+
+    private DataFlavor[] supportedDataFlavors;
+
+    final static DataFlavor[] htmlDataFlavors = new DataFlavor [] {
+            DataFlavor.allHtmlFlavor,
+            DataFlavor.fragmentHtmlFlavor,
+            DataFlavor.selectionHtmlFlavor
+    };
+
+    @Override
+    public DataFlavor[] getTransferDataFlavors() {
+        return supportedDataFlavors;
+    }
+
+    @Override
+    public boolean isDataFlavorSupported(DataFlavor flavor) {
+        for (DataFlavor supportedDataFlavor : supportedDataFlavors) {
+            if (supportedDataFlavor.equals(flavor)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    HtmlTransferable(DataFlavor[] supportedDataFlavors) {
+        this.supportedDataFlavors = supportedDataFlavors;
+    }
+
+    @Override
+    public Object getTransferData(DataFlavor flavor)
+            throws UnsupportedFlavorException, IOException {
+
+        if (isDataFlavorSupported(flavor)) {
+            if (flavor.equals(DataFlavor.allHtmlFlavor)) {
+                return ALL_HTML_AS_STRING;
+            } else if (flavor.equals(DataFlavor.fragmentHtmlFlavor)) {
+                return FRAGMENT_HTML_AS_STRING;
+            } else if (flavor.equals(DataFlavor.selectionHtmlFlavor)) {
+                return SELECTION_HTML_AS_STRING;
+            }
+        }
+
+        throw new UnsupportedFlavorException(flavor);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/HTMLDataFlavors/ManualHTMLDataFlavorTest.html	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,20 @@
+<html>
+<!--  
+  @test
+  @bug 7075105
+  @summary WIN: Provide a way to format HTML on drop
+  @author Denis Fokin area=datatransfer
+  @run applet/manual=yesno ManualHTMLDataFlavorTest.html
+  -->
+<head>
+<title>ManualHTMLDataFlavorTest</title>
+</head>
+<body>
+
+<h1>ManualHTMLDataFlavorTest<br>Bug ID: 7075105</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="ManualHTMLDataFlavorTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/HTMLDataFlavors/ManualHTMLDataFlavorTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact 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 7075105
+  @summary WIN: Provide a way to format HTML on drop
+  @author Denis Fokin: area=datatransfer
+  @run applet/manual=yesno ManualHTMLDataFlavorTest
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.*;
+import java.io.IOException;
+
+public class ManualHTMLDataFlavorTest extends Applet {
+
+    class DropPane extends Panel implements DropTargetListener {
+
+        DropPane() {
+            requestFocus();
+            setBackground(Color.red);
+            setDropTarget(new DropTarget(this, DnDConstants.ACTION_COPY, this));
+        }
+
+        @Override
+        public Dimension getPreferredSize() {
+            return new Dimension(200,200);
+        }
+
+        @Override
+        public void dragEnter(DropTargetDragEvent dtde) {
+            dtde.acceptDrag(DnDConstants.ACTION_COPY);
+        }
+
+        @Override
+        public void dragOver(DropTargetDragEvent dtde) {
+            dtde.acceptDrag(DnDConstants.ACTION_COPY);
+        }
+
+        @Override
+        public void dropActionChanged(DropTargetDragEvent dtde) {
+            dtde.acceptDrag(DnDConstants.ACTION_COPY);
+        }
+
+        @Override
+        public void dragExit(DropTargetEvent dte) {}
+
+        @Override
+        public void drop(DropTargetDropEvent dtde) {
+            if (!dtde.isDataFlavorSupported(DataFlavor.allHtmlFlavor)) {
+                Sysout.println("DataFlavor.allHtmlFlavor is not present in the system clipboard");
+                dtde.rejectDrop();
+                return;
+            } else if (!dtde.isDataFlavorSupported(DataFlavor.fragmentHtmlFlavor)) {
+                Sysout.println("DataFlavor.fragmentHtmlFlavor is not present in the system clipboard");
+                dtde.rejectDrop();
+                return;
+            } else if (!dtde.isDataFlavorSupported(DataFlavor.selectionHtmlFlavor)) {
+                Sysout.println("DataFlavor.selectionHtmlFlavor is not present in the system clipboard");
+                dtde.rejectDrop();
+                return;
+            }
+
+            dtde.acceptDrop(DnDConstants.ACTION_COPY);
+
+            Transferable t = dtde.getTransferable();
+            try {
+                Sysout.println("ALL:");
+                Sysout.println(t.getTransferData(DataFlavor.allHtmlFlavor).toString());
+                Sysout.println("FRAGMENT:");
+                Sysout.println(t.getTransferData(DataFlavor.fragmentHtmlFlavor).toString());
+                Sysout.println("SELECTION:");
+                Sysout.println(t.getTransferData(DataFlavor.selectionHtmlFlavor).toString());
+            } catch (UnsupportedFlavorException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+
+        }
+    }
+
+    public void init() {
+
+        String[] instructions =
+            {
+                "1) The test contains a drop-aware panel with a red background",
+                "2) Open some page in a browser, select some text",
+                "   Drag and drop it on the red panel",
+                "   IMPORTANT NOTE: the page should be stored locally.",
+                "   otherwise for instance iexplore can prohibit drag and drop from",
+                "   the browser to other applications because of",
+                "   the protected mode restrictions.",
+                "3) Check the data in the output area of this dialog",
+                "5) The output should not contain information that any of",
+                "   flavors is not present in the system clipboard",
+                "6) The output should contain data in three different formats",
+                "   provided by the system clipboard",
+                "    - Data after the \"ALL:\" marker should include the data",
+                "      from the the \"SELECTION:\" marker",
+                "    - Data after the \"FRAGMENT\" marker should include the data",
+                "      from the \"SELECTION:\" marker and may be some closing",
+                "      tags could be added to the mark-up",
+                "    - Data after the \"SELECTION:\" marker should correspond",
+                "      to the data selected in the browser",
+                "7) If the above requirements are met, the test is passed"
+            };
+
+        add(new DropPane());
+        Sysout.createDialogWithInstructions( instructions );
+
+        new ManualHTMLDataFlavorTest();
+    }
+
+    public void start ()
+    {
+        setSize (200,200);
+        setVisible(true);
+        validate();
+
+    }// start()
+
+}
+
+
+/* Place other classes related to the test after this line */
+
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+ This is part of the standard test machinery.  It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                                                     lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/HTMLDataFlavors/PutAllHtmlFlavorsOnClipboard.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+
+public class PutAllHtmlFlavorsOnClipboard {
+    public static void main(String[] args) {
+        System.out.println("PutAllHtmlFlavorsOnClipboard has been started.");
+        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
+                new HtmlTransferable(HtmlTransferable.htmlDataFlavors), null);
+        System.out.println("Data has been put on clipboard in a separate process");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/HTMLDataFlavors/PutOnlyAllHtmlFlavorOnClipboard.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+
+public class PutOnlyAllHtmlFlavorOnClipboard {
+    public static void main(String[] args) {
+        System.out.println("PutOnlyAllHtmlFlavorOnClipboard has been started.");
+        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
+                new HtmlTransferable(new DataFlavor[]{DataFlavor.allHtmlFlavor}), null);
+        System.out.println("Data has been put on clipboard in a separate process");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/HTMLDataFlavors/PutSelectionAndFragmentHtmlFlavorsOnClipboard.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+
+public class PutSelectionAndFragmentHtmlFlavorsOnClipboard {
+    public static void main(String[] args) {
+        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
+                new HtmlTransferable(new DataFlavor[]{DataFlavor.selectionHtmlFlavor,
+                        DataFlavor.fragmentHtmlFlavor}), null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test @summary JVM crash if the frame is disposed in DropTargetListener
+ * @author Petr Pchelko
+ * @library ../../regtesthelpers
+ * @build Util
+ * @compile DisposeFrameOnDragTest.java
+ * @run main/othervm DisposeFrameOnDragTest
+ */
+import java.awt.AWTException;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.dnd.DropTargetAdapter;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.event.InputEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.util.TooManyListenersException;
+import javax.swing.JFrame;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import test.java.awt.regtesthelpers.Util;
+
+public class DisposeFrameOnDragTest {
+
+    private static JTextArea textArea;
+
+    public static void main(String[] args) throws Throwable {
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                constructTestUI();
+            }
+        });
+
+        Util.waitForIdle(null);
+        try {
+            Point loc = textArea.getLocationOnScreen();
+            Util.drag(new Robot(),
+                    new Point((int) loc.x + 3, (int) loc.y + 3),
+                    new Point((int) loc.x + 40, (int) loc.y + 40),
+                    InputEvent.BUTTON1_MASK);
+        } catch (AWTException ex) {
+            throw new RuntimeException("Could not initiate a drag operation");
+        }
+        Util.waitForIdle(null);
+    }
+
+    private static void constructTestUI() {
+        final JFrame frame = new JFrame("Test frame");
+        textArea = new JTextArea("Drag Me!");
+        try {
+            textArea.getDropTarget().addDropTargetListener(new DropTargetAdapter() {
+                @Override
+                public void drop(DropTargetDropEvent dtde) {
+                    //IGNORE
+                }
+
+                @Override
+                public void dragOver(DropTargetDragEvent dtde) {
+                    frame.dispose();
+                }
+            });
+        } catch (TooManyListenersException ex) {
+            throw new RuntimeException(ex);
+        }
+        textArea.setSize(100, 100);
+        textArea.setDragEnabled(true);
+        textArea.select(0, textArea.getText().length());
+        frame.add(textArea);
+        frame.setBounds(100, 100, 100, 100);
+        frame.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/FileInputStream/NegativeAvailable.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact 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 8010837
+ * @summary Test if available returns correct value when skipping beyond
+ *          the end of a file.
+ * @author Dan Xu
+ */
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class NegativeAvailable {
+
+    public static void main(String[] args) throws IOException {
+        final int SIZE = 10;
+        final int SKIP = 5;
+
+        // Create a temporary file with size of 10 bytes.
+        Path tmp = Files.createTempFile(null, null);
+        try (BufferedWriter writer =
+            Files.newBufferedWriter(tmp, Charset.defaultCharset())) {
+            for (int i = 0; i < SIZE; i++) {
+                writer.write('1');
+            }
+        }
+
+        File tempFile = tmp.toFile();
+        try (FileInputStream fis = new FileInputStream(tempFile)) {
+            if (tempFile.length() != SIZE) {
+                throw new RuntimeException("unexpected file size = "
+                    + tempFile.length());
+            }
+            long space = skipBytes(fis, SKIP, SIZE);
+            space = skipBytes(fis, SKIP, space);
+            space = skipBytes(fis, SKIP, space);
+            space = skipBytes(fis, SKIP, space);
+        }
+        Files.deleteIfExists(tmp);
+    }
+
+    /**
+     *  Skip toSkip number of bytes and return the remaining bytes of the file.
+     */
+    private static long skipBytes(FileInputStream fis, int toSkip, long space)
+            throws IOException {
+        long skip = fis.skip(toSkip);
+        if (skip != toSkip) {
+            throw new RuntimeException("skip() returns " + skip
+                + " but expected " + toSkip);
+        }
+        long remaining = space - toSkip;
+        int avail = fis.available();
+        if (avail != remaining) {
+            throw new RuntimeException("available() returns " + avail
+                + " but expected " + remaining);
+        }
+
+        System.out.println("Skipped " + skip + " bytes "
+            + " available() returns " + avail);
+        return remaining;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/Class/GenericStringTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact 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 6298888 6992705
+ * @summary Check Class.toGenericString()
+ * @author Joseph D. Darcy
+ */
+
+import java.lang.reflect.*;
+import java.lang.annotation.*;
+import java.util.*;
+
+@ExpectedGenericString("public class GenericStringTest")
+public class GenericStringTest {
+    public static void main(String... args){
+        int failures = 0;
+
+        failures += checkToGenericString(int.class, "int");
+
+        Class<?>[] types = {
+            GenericStringTest.class,
+            AnInterface.class,
+            LocalMap.class,
+            AnEnum.class,
+            AnotherEnum.class,
+        };
+
+        for(Class<?> clazz : types) {
+            failures += checkToGenericString(clazz, clazz.getAnnotation(ExpectedGenericString.class).value());
+        }
+
+        if (failures > 0) {
+            throw new RuntimeException();
+        }
+    }
+
+    private static int checkToGenericString(Class<?> clazz, String expected) {
+        String genericString = clazz.toGenericString();
+        if (!genericString.equals(expected)) {
+            System.err.printf("Unexpected Class.toGenericString output; expected '%s', got '%s'.%n",
+                              expected,
+                              genericString);
+            return 1;
+        } else
+            return 0;
+    }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface ExpectedGenericString {
+    String value();
+}
+
+@ExpectedGenericString("abstract interface AnInterface")
+strictfp interface AnInterface {}
+
+@ExpectedGenericString("abstract interface LocalMap<K,V>")
+interface LocalMap<K,V> {}
+
+@ExpectedGenericString("final enum AnEnum")
+enum AnEnum {
+    FOO;
+}
+
+@ExpectedGenericString("enum AnotherEnum")
+enum AnotherEnum {
+    BAR{};
+}
--- a/jdk/test/java/lang/Runtime/exec/WinCommand.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/java/lang/Runtime/exec/WinCommand.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -135,19 +135,24 @@
 
         // Win9x systems don't have a cmd.exe
         if (new File(systemDirW, "cmd.exe").exists()) {
-            out.println("Running cmd.exe tests...");
-            writeFile("cdcmd.cmd", "@echo off\r\nCD\r\n");
-            writeFile("cdbat.bat", "@echo off\r\nCD\r\n");
-            checkCD("cmd",
-                    "cmd.exe",
-                    systemDirW + "\\cmd.exe",
-                    // Only the ".exe" extension can be omitted
-                    systemDirW + "\\cmd",
-                    systemDirM + "/cmd.exe",
-                    systemDirM + "/cmd",
-                    "/" + systemDirM + "/cmd",
-                    "cdcmd.cmd", "./cdcmd.cmd", ".\\cdcmd.cmd",
-                    "cdbat.bat", "./cdbat.bat", ".\\cdbat.bat");
+            try {
+                out.println("Running cmd.exe tests...");
+                writeFile("cdcmd.cmd", "@echo off\r\nCD\r\n");
+                writeFile("cdbat.bat", "@echo off\r\nCD\r\n");
+                checkCD("cmd",
+                        "cmd.exe",
+                        systemDirW + "\\cmd.exe",
+                        // Only the ".exe" extension can be omitted
+                        systemDirW + "\\cmd",
+                        systemDirM + "/cmd.exe",
+                        systemDirM + "/cmd",
+                        "/" + systemDirM + "/cmd",
+                        "cdcmd.cmd", "./cdcmd.cmd", ".\\cdcmd.cmd",
+                        "cdbat.bat", "./cdbat.bat", ".\\cdbat.bat");
+            } finally {
+                new File("cdcmd.cmd").delete();
+                new File("cdbat.bat").delete();
+            }
         }
 
         // 16-bit apps like command.com must have a console;
--- a/jdk/test/java/lang/StringBuilder/Supplementary.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/java/lang/StringBuilder/Supplementary.java	Wed Jul 05 18:50:02 2017 +0200
@@ -37,6 +37,7 @@
         test4();        // Test for appendCodePoint(int codePoint)
         test5();        // Test for codePointCount(int beginIndex, int endIndex)
         test6();        // Test for offsetByCodePoints(int index, int offset)
+        testDontReadOutOfBoundsTrailingSurrogate();
     }
 
     /* Text strings which are used as input data.
@@ -305,6 +306,19 @@
         }
     }
 
+    static void testDontReadOutOfBoundsTrailingSurrogate() {
+        StringBuilder sb = new StringBuilder();
+        int suppl = Character.MIN_SUPPLEMENTARY_CODE_POINT;
+        sb.appendCodePoint(suppl);
+        check(sb.codePointAt(0) != (int) suppl,
+              "codePointAt(0)", sb.codePointAt(0), suppl);
+        check(sb.length() != 2, "sb.length()");
+        sb.setLength(1);
+        check(sb.length() != 1, "sb.length()");
+        check(sb.codePointAt(0) != Character.highSurrogate(suppl),
+              "codePointAt(0)",
+              sb.codePointAt(0), Character.highSurrogate(suppl));
+    }
 
     static final boolean At = true, Before = false;
 
--- a/jdk/test/java/lang/System/MacJNUEncoding/MacJNUEncoding.sh	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/java/lang/System/MacJNUEncoding/MacJNUEncoding.sh	Wed Jul 05 18:50:02 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+# 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/reflect/Method/DefaultMethodModeling.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact 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 8011590
+ * @summary Check modeling of default methods
+ * @author Joseph D. Darcy
+ */
+
+import java.util.Objects;
+import java.lang.reflect.*;
+import java.lang.annotation.*;
+
+import static java.lang.reflect.Modifier.*;
+
+public class DefaultMethodModeling {
+    public static void main(String... args) {
+        int failures = 0;
+
+        Class<?>[] classes = {SuperC.class, SuperCchild.class,
+                              SuperI.class, SuperIchild.class,
+                              SuperIwithDefault.class, SuperIwithDefaultChild.class,
+                              Base.class, Combo1.class, Combo2.class,
+                              SonSuperIwithDefault.class, DaughterSuperIwithDefault.class, GrandchildSuperIwithDefault.class, D.class,
+                              B.class, C.class
+        };
+
+        for(Class<?> clazz : classes) {
+            System.err.println(clazz.toString());
+            for(Method m : clazz.getMethods()) {
+                if (m.getDeclaringClass() != java.lang.Object.class)
+                    failures += testMethod(m);
+            }
+        }
+
+        if (failures > 0)
+            throw new RuntimeException();
+    }
+
+    private static int testMethod(Method m) {
+        ExpectedModel em = Objects.requireNonNull(m.getAnnotation(ExpectedModel.class));
+        boolean failed = false;
+
+        if (m.getModifiers() != em.modifiers()) {
+            failed = true;
+            System.err.printf("Unexpected modifiers %d; expected %d%n", m.getModifiers(), em.modifiers());
+        }
+
+        if (m.isDefault() != em.isDefault()) {
+            failed = true;
+            System.err.printf("Unexpected isDefualt %b; expected b%n", m.isDefault(), em.isDefault());
+        }
+
+        if (!m.getDeclaringClass().equals(em.declaringClass())) {
+            failed = true;
+            System.err.printf("Unexpected isDefualt %s; expected %s%n",
+                              m.getDeclaringClass().toString(), em.declaringClass().toString());
+        }
+
+        return (!failed) ? 0 :1;
+    }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface ExpectedModel {
+    boolean isDefault() default false;
+    int modifiers() default PUBLIC;
+    Class<?> declaringClass();
+}
+
+abstract class SuperC {
+    @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperC.class)
+    public abstract void foo();
+
+    @ExpectedModel(declaringClass=SuperC.class)
+    public void bar() {
+        ;
+    }
+}
+
+class SuperCchild extends SuperC {
+    @ExpectedModel(declaringClass=SuperCchild.class)
+    @Override
+    public void foo() {;}
+}
+
+// -=-=-=-
+
+interface SuperI {
+    @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperI.class)
+    void foo();
+
+    @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperI.class)
+    void bar();
+}
+
+class SuperIchild implements SuperI {
+    @ExpectedModel(declaringClass=SuperIchild.class)
+    public void foo() {;}
+
+    @ExpectedModel(declaringClass=SuperIchild.class)
+    public void bar() {;}
+}
+
+// -=-=-=-
+
+interface SuperIwithDefault {
+    @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperIwithDefault.class)
+    void foo();
+
+    @ExpectedModel(isDefault=true, declaringClass=SuperIwithDefault.class)
+    default void bar() {
+        ;
+    }
+}
+
+class SuperIwithDefaultChild implements SuperIwithDefault {
+    @ExpectedModel(declaringClass=SuperIwithDefaultChild.class)
+    @Override
+    public void foo() {;}
+}
+
+// -=-=-=-
+
+abstract class Base {
+    @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=Base.class)
+    abstract public void baz();
+
+    @ExpectedModel(declaringClass=Base.class)
+    public void quux() {;}
+}
+
+abstract class Combo1 extends Base implements SuperI {
+    @ExpectedModel(declaringClass=Combo1.class)
+    public void wombat() {}
+}
+
+abstract class Combo2 extends Base implements SuperIwithDefault {
+    @ExpectedModel(declaringClass=Combo2.class)
+    public void wombat() {}
+}
+
+// -=-=-=-
+
+interface SonSuperIwithDefault extends SuperIwithDefault {
+    @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SonSuperIwithDefault.class)
+    void baz();
+
+    @ExpectedModel(isDefault=true, declaringClass=SonSuperIwithDefault.class)
+    default void bazD() {;}
+}
+
+interface DaughterSuperIwithDefault extends SuperIwithDefault {
+    @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=DaughterSuperIwithDefault.class)
+    void quux();
+
+    @ExpectedModel(isDefault=true, declaringClass=DaughterSuperIwithDefault.class)
+    default void quuxD() {;}
+}
+
+interface GrandchildSuperIwithDefault extends SonSuperIwithDefault, DaughterSuperIwithDefault {
+    @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=GrandchildSuperIwithDefault.class)
+    void wombat();
+
+    @ExpectedModel(isDefault=true, declaringClass=GrandchildSuperIwithDefault.class)
+    default void wombatD() {;}
+
+}
+
+class D implements GrandchildSuperIwithDefault {
+    @ExpectedModel(declaringClass=D.class)
+    public void wombat(){}
+
+    @ExpectedModel(declaringClass=D.class)
+    public void  baz(){}
+
+    @ExpectedModel(declaringClass=D.class)
+    public void foo(){}
+
+    @ExpectedModel(declaringClass=D.class)
+    public void quux(){}
+}
+
+// -=-=-=-
+
+// What does re-abstraction look like?
+
+class A implements SuperIwithDefault {
+    @ExpectedModel(declaringClass=A.class)
+    @Override
+    public void foo(){;}
+}
+
+abstract class B extends A {
+    @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=B.class)
+    @Override
+    public abstract void bar();
+}
+
+class C extends B implements SuperIwithDefault {
+    @ExpectedModel(declaringClass=C.class)
+    public void bar(){}
+}
--- a/jdk/test/java/lang/reflect/Method/GenericStringTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/java/lang/reflect/Method/GenericStringTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 5033583 6316717 6470106
+ * @bug 5033583 6316717 6470106 8004979
  * @summary Check toGenericString() and toString() methods
  * @author Joseph D. Darcy
  */
@@ -39,6 +39,7 @@
         classList.add(TestClass1.class);
         classList.add(TestClass2.class);
         classList.add(Roebling.class);
+        classList.add(TestInterface1.class);
 
 
         for(Class<?> clazz: classList)
@@ -129,6 +130,27 @@
     void varArg(Object ... arg) {}
 }
 
+interface TestInterface1 {
+    @ExpectedGenericString(
+   "public default void TestInterface1.foo()")
+    @ExpectedString(
+   "public default void TestInterface1.foo()")
+    public default void foo(){;}
+
+    @ExpectedString(
+   "public default java.lang.Object TestInterface1.bar()")
+    @ExpectedGenericString(
+   "public default <A> A TestInterface1.bar()")
+    default <A> A bar(){return null;}
+
+    @ExpectedString(
+   "public default strictfp double TestInterface1.quux()")
+    @ExpectedGenericString(
+    "public default strictfp double TestInterface1.quux()")
+    strictfp default double quux(){return 1.0;}
+
+}
+
 @Retention(RetentionPolicy.RUNTIME)
 @interface ExpectedGenericString {
     String value();
--- a/jdk/test/java/lang/reflect/Method/IsDefaultTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/java/lang/reflect/Method/IsDefaultTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * 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
--- a/jdk/test/java/net/Socks/SocksProxyVersion.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/java/net/Socks/SocksProxyVersion.java	Wed Jul 05 18:50:02 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6964547
+ * @bug 6964547 5001942
  * @run main/othervm SocksProxyVersion
  * @summary test socksProxyVersion system property
  */
@@ -34,6 +34,7 @@
 import java.net.SocketException;
 import java.io.DataInputStream;
 import java.io.IOException;
+import java.net.InetAddress;
 
 public class SocksProxyVersion implements Runnable {
     final ServerSocket ss;
@@ -56,13 +57,19 @@
         Thread serverThread = new Thread(this);
         serverThread.start();
 
-        System.setProperty("socksProxyHost", "localhost");
+        /*
+         * Retreving the IP Address of the machine
+         * since "localhost" is bypassed as a non-proxy host
+         */
+        String addr = InetAddress.getLocalHost().getHostAddress();
+
+        System.setProperty("socksProxyHost", addr);
         System.setProperty("socksProxyPort", Integer.toString(port));
 
         // SOCKS V4
         System.setProperty("socksProxyVersion", Integer.toString(4));
         try (Socket s = new Socket()) {
-            s.connect(new InetSocketAddress("localhost", port));
+            s.connect(new InetSocketAddress(addr, port));
         } catch (SocketException e) {
             // java.net.SocketException: Malformed reply from SOCKS server
             // This exception is OK, since the "server" does not implement
@@ -72,7 +79,7 @@
         // SOCKS V5
         System.setProperty("socksProxyVersion", Integer.toString(5));
         try (Socket s = new Socket()) {
-            s.connect(new InetSocketAddress("localhost", port));
+            s.connect(new InetSocketAddress(addr, port));
         } catch (SocketException e) { /* OK */ }
 
         serverThread.join();
--- a/jdk/test/java/net/URLConnection/RequestProperties.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/java/net/URLConnection/RequestProperties.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/util/Base64/TestBase64.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/java/util/Base64/TestBase64.java	Wed Jul 05 18:50:02 2017 +0200
@@ -22,7 +22,7 @@
  */
 
 /**
- * @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530
+ * @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530 8007379 8008925
  * @summary tests java.util.Base64
  */
 
@@ -107,6 +107,9 @@
         checkIAE(new Runnable() { public void run() {
             Base64.getDecoder().decode(ByteBuffer.wrap(decoded), ByteBuffer.allocateDirect(1024)); }});
 
+        // illegal ending unit
+        checkIAE(new Runnable() { public void run() { Base64.getMimeDecoder().decode("$=#"); }});
+
         // test return value from decode(ByteBuffer, ByteBuffer)
         testDecBufRet();
 
@@ -115,7 +118,6 @@
 
         // test decoding of unpadded data
         testDecodeUnpadded();
-
         // test mime decoding with ignored character after padding
         testDecodeIgnoredAfterPadding();
     }
@@ -384,6 +386,10 @@
                 encoded = Arrays.copyOf(encoded, encoded.length + 1);
                 encoded[encoded.length - 1] = nonBase64;
                 checkEqual(decM.decode(encoded), src[i], "Non-base64 char is not ignored");
+                byte[] decoded = new byte[src[i].length];
+                decM.decode(encoded, decoded);
+                checkEqual(decoded, src[i], "Non-base64 char is not ignored");
+
                 try {
                     dec.decode(encoded);
                     throw new RuntimeException("No IAE for non-base64 char");
--- a/jdk/test/java/util/Optional/BasicDouble.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/java/util/Optional/BasicDouble.java	Wed Jul 05 18:50:02 2017 +0200
@@ -3,17 +3,17 @@
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2.0 only, as
+ * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2.0 for more details (a copy is included in the LICENSE file that
+ * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
  * You should have received a copy of the GNU General Public License version
- * 2.0 along with this work; if not, write to the Free Software Foundation,
+ * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/concurrent/CompletableFuture/Basic.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,761 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/*
+ * @test
+ * @bug 8005696
+ * @summary Basic tests for CompletableFuture
+ * @author Chris Hegarty
+ */
+
+import java.lang.reflect.Array;
+import java.util.concurrent.Phaser;
+import static java.util.concurrent.TimeUnit.*;
+import java.util.concurrent.CompletableFuture;
+import static java.util.concurrent.CompletableFuture.*;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import static java.util.concurrent.ForkJoinPool.*;
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+public class Basic {
+
+    static void checkCompletedNormally(CompletableFuture<?> cf, Object value) {
+        checkCompletedNormally(cf, value == null ? null : new Object[] { value });
+    }
+
+    static void checkCompletedNormally(CompletableFuture<?> cf, Object[] values) {
+        try { equalAnyOf(cf.join(), values); } catch (Throwable x) { unexpected(x); }
+        try { equalAnyOf(cf.getNow(null), values); } catch (Throwable x) { unexpected(x); }
+        try { equalAnyOf(cf.get(), values); } catch (Throwable x) { unexpected(x); }
+        try { equalAnyOf(cf.get(0L, SECONDS), values); } catch (Throwable x) { unexpected(x); }
+        check(cf.isDone(), "Expected isDone to be true, got:" + cf);
+        check(!cf.isCancelled(), "Expected isCancelled to be false");
+        check(!cf.cancel(true), "Expected cancel to return false");
+        check(cf.toString().contains("[Completed normally]"));
+        check(cf.complete(null) == false, "Expected complete() to fail");
+        check(cf.completeExceptionally(new Throwable()) == false,
+              "Expected completeExceptionally() to fail");
+    }
+
+    static <T> void checkCompletedExceptionally(CompletableFuture<T> cf)
+        throws Exception
+    {
+        checkCompletedExceptionally(cf, false);
+    }
+
+    @SuppressWarnings("unchecked")
+    static <T> void checkCompletedExceptionally(CompletableFuture<T> cf, boolean cancelled)
+        throws Exception
+    {
+        try { cf.join(); fail("Excepted exception to be thrown"); }
+        catch (CompletionException x) { if (cancelled) fail(); else pass(); }
+        catch (CancellationException x) { if (cancelled) pass(); else fail(); }
+        try { cf.getNow(null); fail("Excepted exception to be thrown"); }
+        catch (CompletionException x) { if (cancelled) fail(); else pass(); }
+        catch (CancellationException x) { if (cancelled) pass(); else fail(); }
+        try { cf.get(); fail("Excepted exception to be thrown");}
+        catch (CancellationException x) { if (cancelled) pass(); else fail(); }
+        catch (ExecutionException x) { if (cancelled) check(x.getCause() instanceof CancellationException); else pass(); }
+        try { cf.get(0L, SECONDS); fail("Excepted exception to be thrown");}
+        catch (CancellationException x) { if (cancelled) pass(); else fail(); }
+        catch (ExecutionException x) { if (cancelled) check(x.getCause() instanceof CancellationException); else pass(); }
+        check(cf.isDone(), "Expected isDone to be true, got:" + cf);
+        check(cf.isCancelled() == cancelled, "Expected isCancelled: " + cancelled + ", got:"  + cf.isCancelled());
+        check(cf.cancel(true) == cancelled, "Expected cancel: " + cancelled + ", got:"  + cf.cancel(true));
+        check(cf.toString().contains("[Completed exceptionally]"));  // ## TODO: 'E'xceptionally
+        check(cf.complete((T)new Object()) == false, "Expected complete() to fail");
+        check(cf.completeExceptionally(new Throwable()) == false,
+              "Expected completeExceptionally() to fail, already completed");
+    }
+
+    private static void realMain(String[] args) throws Throwable {
+        ExecutorService executor = Executors.newFixedThreadPool(2);
+        try {
+            test(executor);
+        } finally {
+            executor.shutdown();
+            executor.awaitTermination(30, SECONDS);
+        }
+    }
+
+    static AtomicInteger atomicInt = new AtomicInteger(0);
+
+    private static void test(ExecutorService executor) throws Throwable {
+
+        Thread.currentThread().setName("mainThread");
+
+        //----------------------------------------------------------------
+        // supplyAsync tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<String> cf = supplyAsync(() -> "a test string");
+            checkCompletedNormally(cf, cf.join());
+            cf = supplyAsync(() -> "a test string", commonPool());
+            checkCompletedNormally(cf, cf.join());
+            cf = supplyAsync(() -> "a test string", executor);
+            checkCompletedNormally(cf, cf.join());
+            cf = supplyAsync(() -> { throw new RuntimeException(); });
+            checkCompletedExceptionally(cf);
+            cf = supplyAsync(() -> { throw new RuntimeException(); }, commonPool());
+            checkCompletedExceptionally(cf);
+            cf = supplyAsync(() -> { throw new RuntimeException(); }, executor);
+            checkCompletedExceptionally(cf);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // runAsync tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Void> cf = runAsync(() -> { });
+            checkCompletedNormally(cf, cf.join());
+            cf = runAsync(() -> { }, commonPool());
+            checkCompletedNormally(cf, cf.join());
+            cf = runAsync(() -> { }, executor);
+            checkCompletedNormally(cf, cf.join());
+            cf = runAsync(() -> { throw new RuntimeException(); });
+            checkCompletedExceptionally(cf);
+            cf = runAsync(() -> { throw new RuntimeException(); }, commonPool());
+            checkCompletedExceptionally(cf);
+            cf = runAsync(() -> { throw new RuntimeException(); }, executor);
+            checkCompletedExceptionally(cf);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // explicit completion
+        //----------------------------------------------------------------
+        try {
+            final Phaser phaser = new Phaser(1);
+            final int phase = phaser.getPhase();
+            CompletableFuture<Integer> cf;
+            cf = supplyAsync(() -> { phaser.awaitAdvance(phase); return 1; });
+            cf.complete(2);
+            phaser.arrive();
+            checkCompletedNormally(cf, 2);
+
+            cf = supplyAsync(() -> { phaser.awaitAdvance(phase+1); return 1; });
+            cf.completeExceptionally(new Throwable());
+            phaser.arrive();
+            checkCompletedExceptionally(cf);
+
+            cf = supplyAsync(() -> { phaser.awaitAdvance(phase+2); return 1; });
+            cf.cancel(true);
+            phaser.arrive();
+            checkCompletedExceptionally(cf, true);
+
+            cf = supplyAsync(() -> { phaser.awaitAdvance(phase+3); return 1; });
+            check(cf.getNow(2) == 2);
+            phaser.arrive();
+            checkCompletedNormally(cf, 1);
+            check(cf.getNow(2) == 1);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // thenApplyXXX tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Integer> cf2;
+            CompletableFuture<String> cf1 = supplyAsync(() -> "a test string");
+            cf2 = cf1.thenApply((x) -> { if (x.equals("a test string")) return 1; else return 0; });
+            checkCompletedNormally(cf1, "a test string");
+            checkCompletedNormally(cf2, 1);
+
+            cf1 = supplyAsync(() -> "a test string");
+            cf2 = cf1.thenApplyAsync((x) -> { if (x.equals("a test string")) return 1; else return 0; });
+            checkCompletedNormally(cf1, "a test string");
+            checkCompletedNormally(cf2, 1);
+
+            cf1 = supplyAsync(() -> "a test string");
+            cf2 = cf1.thenApplyAsync((x) -> { if (x.equals("a test string")) return 1; else return 0; }, executor);
+            checkCompletedNormally(cf1, "a test string");
+            checkCompletedNormally(cf2, 1);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenApply((x) -> { return 0; } );
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenApplyAsync((x) -> { return 0; } );
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenApplyAsync((x) -> { return 0; }, executor);
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // thenAcceptXXX tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Void> cf2;
+            int before = atomicInt.get();
+            CompletableFuture<String> cf1 = supplyAsync(() -> "a test string");
+            cf2 = cf1.thenAccept((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); });
+            checkCompletedNormally(cf1, "a test string");
+            checkCompletedNormally(cf2, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> "a test string");
+            cf2 = cf1.thenAcceptAsync((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); });
+            checkCompletedNormally(cf1, "a test string");
+            checkCompletedNormally(cf2, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> "a test string");
+            cf2 = cf1.thenAcceptAsync((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); }, executor);
+            checkCompletedNormally(cf1, "a test string");
+            checkCompletedNormally(cf2, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenAccept((x) -> { atomicInt.incrementAndGet(); } );
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+            check(atomicInt.get() == before);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenAcceptAsync((x) -> { atomicInt.incrementAndGet(); } );
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+            check(atomicInt.get() == before);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenAcceptAsync((x) -> { atomicInt.incrementAndGet(); }, executor );
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+            check(atomicInt.get() == before);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // thenRunXXX tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Void> cf2;
+            int before = atomicInt.get();
+            CompletableFuture<String> cf1 = supplyAsync(() -> "a test string");
+            cf2 = cf1.thenRun(() -> { atomicInt.incrementAndGet(); });
+            checkCompletedNormally(cf1, "a test string");
+            checkCompletedNormally(cf2, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> "a test string");
+            cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); });
+            checkCompletedNormally(cf1, "a test string");
+            checkCompletedNormally(cf2, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> "a test string");
+            cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); }, executor);
+            checkCompletedNormally(cf1, "a test string");
+            checkCompletedNormally(cf2, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenRun(() -> { atomicInt.incrementAndGet(); });
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+            check(atomicInt.get() == before);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); });
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+            check(atomicInt.get() == before);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); }, executor);
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+            check(atomicInt.get() == before);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // thenCombineXXX tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Integer> cf3;
+            CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+            CompletableFuture<Integer> cf2 = supplyAsync(() -> 1);
+            cf3 = cf1.thenCombine(cf2, (x, y) -> { return x + y; });
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 1);
+            checkCompletedNormally(cf3, 2);
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> 1);
+            cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return x + y; });
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 1);
+            checkCompletedNormally(cf3, 2);
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> 1);
+            cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return x + y; }, executor);
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 1);
+            checkCompletedNormally(cf3, 2);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = supplyAsync(() -> 1);
+            cf3 = cf1.thenCombine(cf2, (x, y) -> { return 0; });
+            checkCompletedExceptionally(cf1);
+            checkCompletedNormally(cf2, 1);
+            checkCompletedExceptionally(cf3);
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return 0; });
+            checkCompletedNormally(cf1, 1);
+            checkCompletedExceptionally(cf2);
+            checkCompletedExceptionally(cf3);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return 0; }, executor);
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+            checkCompletedExceptionally(cf3);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // thenAcceptBothXXX tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Void> cf3;
+            int before = atomicInt.get();
+            CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+            CompletableFuture<Integer> cf2 = supplyAsync(() -> 1);
+            cf3 = cf1.thenAcceptBoth(cf2, (x, y) -> { check(x + y == 2); atomicInt.incrementAndGet(); });
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 1);
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> 1);
+            cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { check(x + y == 2); atomicInt.incrementAndGet(); });
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 1);
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> 1);
+            cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { check(x + y == 2); atomicInt.incrementAndGet(); }, executor);
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 1);
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = supplyAsync(() -> 1);
+            cf3 = cf1.thenAcceptBoth(cf2, (x, y) -> { atomicInt.incrementAndGet(); });
+            checkCompletedExceptionally(cf1);
+            checkCompletedNormally(cf2, 1);
+            checkCompletedExceptionally(cf3);
+            check(atomicInt.get() == before);
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { atomicInt.incrementAndGet(); });
+            checkCompletedNormally(cf1, 1);
+            checkCompletedExceptionally(cf2);
+            checkCompletedExceptionally(cf3);
+            check(atomicInt.get() == before);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { atomicInt.incrementAndGet(); }, executor);
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+            checkCompletedExceptionally(cf3);
+            check(atomicInt.get() == before);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // runAfterBothXXX tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Void> cf3;
+            int before = atomicInt.get();
+            CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+            CompletableFuture<Integer> cf2 = supplyAsync(() -> 1);
+            cf3 = cf1.runAfterBoth(cf2, () -> { check(cf1.isDone()); check(cf2.isDone()); atomicInt.incrementAndGet(); });
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 1);
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            CompletableFuture<Integer> cfa = supplyAsync(() -> 1);
+            CompletableFuture<Integer> cfb = supplyAsync(() -> 1);
+            cf3 = cfa.runAfterBothAsync(cfb, () -> { check(cfa.isDone()); check(cfb.isDone()); atomicInt.incrementAndGet(); });
+            checkCompletedNormally(cfa, 1);
+            checkCompletedNormally(cfb, 1);
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            CompletableFuture<Integer> cfx = supplyAsync(() -> 1);
+            CompletableFuture<Integer> cfy = supplyAsync(() -> 1);
+            cf3 = cfy.runAfterBothAsync(cfx, () -> { check(cfx.isDone()); check(cfy.isDone()); atomicInt.incrementAndGet(); }, executor);
+            checkCompletedNormally(cfx, 1);
+            checkCompletedNormally(cfy, 1);
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            CompletableFuture<Integer> cf4 = supplyAsync(() -> { throw new RuntimeException(); });
+            CompletableFuture<Integer> cf5 = supplyAsync(() -> 1);
+            cf3 = cf5.runAfterBothAsync(cf4, () -> { atomicInt.incrementAndGet(); }, executor);
+            checkCompletedExceptionally(cf4);
+            checkCompletedNormally(cf5, 1);
+            checkCompletedExceptionally(cf3);
+            check(atomicInt.get() == before);
+
+            before = atomicInt.get();
+            cf4 = supplyAsync(() -> 1);
+            cf5 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf5.runAfterBothAsync(cf4, () -> { atomicInt.incrementAndGet(); });
+            checkCompletedNormally(cf4, 1);
+            checkCompletedExceptionally(cf5);
+            checkCompletedExceptionally(cf3);
+            check(atomicInt.get() == before);
+
+            before = atomicInt.get();
+            cf4 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf5 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf5.runAfterBoth(cf4, () -> { atomicInt.incrementAndGet(); });
+            checkCompletedExceptionally(cf4);
+            checkCompletedExceptionally(cf5);
+            checkCompletedExceptionally(cf3);
+            check(atomicInt.get() == before);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // applyToEitherXXX tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Integer> cf3;
+            CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+            CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
+            cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 1 || x == 2); return x; });
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedNormally(cf3, new Object[] {1, 2});
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> 2);
+            cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); return x; });
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedNormally(cf3, new Object[] {1, 2});
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> 2);
+            cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); return x; }, executor);
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedNormally(cf3, new Object[] {1, 2});
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = supplyAsync(() -> 2);
+            cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 2); return x; });
+            check(cf1.isDone() || cf2.isDone());
+            try { check(cf3.join() == 1); } catch (CompletionException x) { pass(); }
+            check(cf3.isDone());
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1); return x; });
+            check(cf1.isDone() || cf2.isDone());
+            try { check(cf3.join() == 1); } catch (CompletionException x) { pass(); }
+            check(cf3.isDone());
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf1.applyToEitherAsync(cf2, (x) -> { fail(); return x; });
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedExceptionally(cf3);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // acceptEitherXXX tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Void> cf3;
+            int before = atomicInt.get();
+            CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+            CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
+            cf3 = cf1.acceptEither(cf2, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); });
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> 2);
+            cf3 = cf1.acceptEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); });
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> 2);
+            cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); }, executor);
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = supplyAsync(() -> 2);
+            cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 2); }, executor);
+            check(cf1.isDone() || cf2.isDone());
+            try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
+            check(cf3.isDone());
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 1); });
+            check(cf1.isDone() || cf2.isDone());
+            try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
+            check(cf3.isDone());
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf2.acceptEitherAsync(cf1, (x) -> { fail(); });
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedExceptionally(cf3);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // runAfterEitherXXX tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Void> cf3;
+            int before = atomicInt.get();
+            CompletableFuture<Void> cf1 = runAsync(() -> { });
+            CompletableFuture<Void> cf2 = runAsync(() -> { });
+            cf3 = cf1.runAfterEither(cf2, () -> { atomicInt.incrementAndGet(); });
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = runAsync(() -> { });
+            cf2 = runAsync(() -> { });
+            cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = runAsync(() -> { });
+            cf2 = runAsync(() -> { });
+            cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor);
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedNormally(cf3, null);
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = runAsync(() -> { throw new RuntimeException(); });
+            cf2 = runAsync(() -> { });
+            cf3 = cf2.runAfterEither(cf1, () -> { atomicInt.incrementAndGet(); });
+            check(cf1.isDone() || cf2.isDone());
+            try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
+            check(cf3.isDone());
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = runAsync(() -> { });
+            cf2 = runAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
+            check(cf1.isDone() || cf2.isDone());
+            try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
+            check(cf3.isDone());
+            check(atomicInt.get() == (before + 1));
+
+            before = atomicInt.get();
+            cf1 = runAsync(() -> { throw new RuntimeException(); });
+            cf2 = runAsync(() -> { throw new RuntimeException(); });
+            cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor);
+            check(cf1.isDone() || cf2.isDone());
+            checkCompletedExceptionally(cf3);
+            check(atomicInt.get() == before);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // thenComposeXXX tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Integer> cf2;
+            CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+            cf2 = cf1.thenCompose((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); });
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 2);
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = cf1.thenComposeAsync((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); });
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 2);
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = cf1.thenComposeAsync((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); }, executor);
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 2);
+
+            int before = atomicInt.get();
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenCompose((x) -> { atomicInt.incrementAndGet(); return CompletableFuture.completedFuture(2); });
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+            check(atomicInt.get() == before);
+
+            cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+            cf2 = cf1.thenComposeAsync((x) -> { atomicInt.incrementAndGet(); return CompletableFuture.completedFuture(2); });
+            checkCompletedExceptionally(cf1);
+            checkCompletedExceptionally(cf2);
+            check(atomicInt.get() == before);
+
+            cf1 = supplyAsync(() -> 1);
+            cf2 = cf1.thenComposeAsync((x) -> { throw new RuntimeException(); }, executor);
+            checkCompletedNormally(cf1, 1);
+            checkCompletedExceptionally(cf2);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // anyOf tests
+        //----------------------------------------------------------------
+        //try {
+        //    CompletableFuture<Object> cf3;
+        //    for (int k=0; k < 10; k++){
+        //        CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+        //        CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
+        //        cf3 = CompletableFuture.anyOf(cf1, cf2);
+        //        check(cf1.isDone() || cf2.isDone());
+        //        checkCompletedNormally(cf3, new Object[] {1, 2});
+        //    }
+        //} catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // allOf tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<?> cf3;
+            for (int k=0; k < 10; k++){
+                CompletableFuture<Integer>[] cfs = (CompletableFuture<Integer>[])
+                        Array.newInstance(CompletableFuture.class, 10);
+                for (int j=0; j < 10; j++) {
+                    final int v = j;
+                    cfs[j] = supplyAsync(() -> v);
+                }
+                cf3 = CompletableFuture.allOf(cfs);
+                for (int j=0; j < 10; j++)
+                    checkCompletedNormally(cfs[j], j);
+                checkCompletedNormally(cf3, null);
+            }
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // exceptionally tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Integer> cf2;
+            CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+            cf2 = cf1.exceptionally((t) -> { fail("function should never be called"); return 2;});
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 1);
+
+            final RuntimeException t = new RuntimeException();
+            cf1 = supplyAsync(() -> { throw t; });
+            cf2 = cf1.exceptionally((x) -> { check(x.getCause() == t); return 2;});
+            checkCompletedExceptionally(cf1);
+            checkCompletedNormally(cf2, 2);
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // handle tests
+        //----------------------------------------------------------------
+        try {
+            CompletableFuture<Integer> cf2;
+            CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+            cf2 = cf1.handle((x,t) -> x+1);
+            checkCompletedNormally(cf1, 1);
+            checkCompletedNormally(cf2, 2);
+
+            final RuntimeException ex = new RuntimeException();
+            cf1 = supplyAsync(() -> { throw ex; });
+            cf2 = cf1.handle((x,t) -> { check(t.getCause() == ex); return 2;});
+            checkCompletedExceptionally(cf1);
+            checkCompletedNormally(cf2, 2);
+        } catch (Throwable t) { unexpected(t); }
+
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    static volatile int passed = 0, failed = 0;
+    static void pass() {passed++;}
+    static void fail() {failed++; Thread.dumpStack();}
+    static void fail(String msg) {System.out.println(msg); fail();}
+    static void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    static void check(boolean cond) {if (cond) pass(); else fail();}
+    static void check(boolean cond, String msg) {if (cond) pass(); else fail(msg);}
+    static void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(x + " not equal to " + y);}
+    static void equalAnyOf(Object x, Object[] y) {
+        if (x == null && y == null) { pass(); return; }
+        for (Object z : y) { if (x.equals(z)) { pass(); return; } }
+        StringBuilder sb = new StringBuilder();
+        for (Object o : y)
+            sb.append(o).append(" ");
+        fail(x + " not equal to one of [" + sb + "]");}
+    public static void main(String[] args) throws Throwable {
+        try {realMain(args);} catch (Throwable t) {unexpected(t);}
+        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+        if (failed > 0) throw new AssertionError("Some tests failed");}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/zip/EntryCount64k.java	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013 Google Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Test java.util.zip behavior with ~64k entries
+ * @run main/othervm EntryCount64k
+ * @run main/othervm -Djdk.util.zip.inhibitZip64=true EntryCount64k
+ * @run main/othervm -Djdk.util.zip.inhibitZip64=false EntryCount64k
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+
+public class EntryCount64k {
+
+    public static void main(String[] args) throws Exception {
+        for (int i = (1 << 16) - 2; i < (1 << 16) + 2; i++)
+            test(i);
+    }
+
+    static void test(int entryCount) throws Exception {
+        File zipFile = new File("EntryCount64k-tmp.zip");
+        zipFile.delete();
+
+        try (ZipOutputStream zos =
+             new ZipOutputStream(
+                new BufferedOutputStream(
+                    new FileOutputStream(zipFile)))) {
+            for (int i = 0; i < entryCount; i++) {
+                ZipEntry e = new ZipEntry(Integer.toString(i));
+                zos.putNextEntry(e);
+                zos.closeEntry();
+            }
+        }
+
+        String p = System.getProperty("jdk.util.zip.inhibitZip64");
+        boolean tooManyEntries = entryCount >= (1 << 16) - 1;
+        boolean shouldUseZip64 = tooManyEntries & !("true".equals(p));
+        boolean usesZip64 = usesZip64(zipFile);
+        String details = String.format
+            ("entryCount=%d shouldUseZip64=%s usesZip64=%s zipSize=%d%n",
+             entryCount, shouldUseZip64, usesZip64, zipFile.length());
+        System.err.println(details);
+        checkCanRead(zipFile, entryCount);
+        if (shouldUseZip64 != usesZip64)
+            throw new Error(details);
+        zipFile.delete();
+    }
+
+    static boolean usesZip64(File zipFile) throws Exception {
+        RandomAccessFile raf = new RandomAccessFile(zipFile, "r");
+        byte[] buf = new byte[4096];
+        raf.seek(raf.length() - buf.length);
+        raf.read(buf);
+        for (int i = 0; i < buf.length - 4; i++) {
+            // Look for ZIP64 End Header Signature
+            // Phil Katz: yes, we will always remember you
+            if (buf[i+0] == 'P' &&
+                buf[i+1] == 'K' &&
+                buf[i+2] == 6   &&
+                buf[i+3] == 6)
+                return true;
+        }
+        return false;
+    }
+
+    static void checkCanRead(File zipFile, int entryCount) throws Exception {
+        // Check ZipInputStream API
+        try (ZipInputStream zis =
+             new ZipInputStream(
+                 new BufferedInputStream(
+                     new FileInputStream(zipFile)))) {
+            for (int i = 0; i < entryCount; i++) {
+                ZipEntry e = zis.getNextEntry();
+                if (Integer.parseInt(e.getName()) != i)
+                    throw new AssertionError();
+            }
+            if (zis.getNextEntry() != null)
+                throw new AssertionError();
+        }
+
+        // Check ZipFile API
+        try (ZipFile zf = new ZipFile(zipFile)) {
+            Enumeration<? extends ZipEntry> en = zf.entries();
+            for (int i = 0; i < entryCount; i++) {
+                ZipEntry e = en.nextElement();
+                if (Integer.parseInt(e.getName()) != i)
+                    throw new AssertionError();
+            }
+            if (en.hasMoreElements()
+                || (zf.size() != entryCount)
+                || (zf.getEntry(Integer.toString(entryCount - 1)) == null)
+                || (zf.getEntry(Integer.toString(entryCount)) != null))
+                throw new AssertionError();
+        }
+    }
+}
--- a/jdk/test/javax/script/GetInterfaceTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/javax/script/GetInterfaceTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -22,7 +22,6 @@
  */
 
 /*
- * @run ignore
  * @test
  * @bug 6960211
  * @summary JavaScript engine allows creation of interface although methods not available.
@@ -49,30 +48,30 @@
         }
 
         // now define "run"
-        engine.eval("function run() { println('this is run function'); }");
+        engine.eval("function run() { print('this is run function'); }");
         runnable = ((Invocable)engine).getInterface(Runnable.class);
         // should not return null now!
         runnable.run();
 
         // define only one method of "Foo2"
-        engine.eval("function bar() { println('bar function'); }");
+        engine.eval("function bar() { print('bar function'); }");
         Foo2 foo2 = ((Invocable)engine).getInterface(Foo2.class);
         if (foo2 != null) {
             throw new RuntimeException("foo2 is not null!");
         }
 
         // now define other method of "Foo2"
-        engine.eval("function bar2() { println('bar2 function'); }");
+        engine.eval("function bar2() { print('bar2 function'); }");
         foo2 = ((Invocable)engine).getInterface(Foo2.class);
         foo2.bar();
         foo2.bar2();
     }
 
-    interface Foo {
+    public interface Foo {
         public void bar();
     }
 
-    interface Foo2 extends Foo {
+    public interface Foo2 extends Foo {
         public void bar2();
     }
 }
--- a/jdk/test/javax/swing/JPopupMenu/6827786/bug6827786.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/javax/swing/JPopupMenu/6827786/bug6827786.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,7 +65,11 @@
         checkfocus();
 
         // select menu
-        Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
+        if (sun.awt.OSInfo.getOSType() == sun.awt.OSInfo.OSType.MACOSX) {
+            Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_F);
+        } else {
+            Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
+        }
         // select submenu
         Util.hitKeys(robot, KeyEvent.VK_S);
         toolkit.realSync();
--- a/jdk/test/javax/swing/text/html/7189299/bug7189299.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/javax/swing/text/html/7189299/bug7189299.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/sun/management/jdp/JdpTest.sh	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/sun/management/jdp/JdpTest.sh	Wed Jul 05 18:50:02 2017 +0200
@@ -1,6 +1,6 @@
 #!/bin/sh -x
 
-# Copyright (c) 2011, 2012 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
--- a/jdk/test/sun/misc/URLClassPath/JarLoaderTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/sun/misc/URLClassPath/JarLoaderTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/tools/keytool/p12importks.sh	Wed Jul 05 18:50:02 2017 +0200
@@ -0,0 +1,118 @@
+#
+# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact 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 8010125
+# @summary keytool -importkeystore could create a pkcs12 keystore with
+#  different storepass and keypass
+#
+
+if [ "${TESTJAVA}" = "" ] ; then
+  JAVAC_CMD=`which javac`
+  TESTJAVA=`dirname $JAVAC_CMD`/..
+fi
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+  Windows_* )
+    FS="\\"
+    ;;
+  * )
+    FS="/"
+    ;;
+esac
+
+LANG=C
+KT=$TESTJAVA${FS}bin${FS}keytool
+
+# Part 1: JKS keystore with same storepass and keypass
+
+rm jks 2> /dev/null
+$KT -genkeypair -keystore jks -storetype jks -alias me -dname CN=Me \
+	-storepass pass1111 -keypass pass1111 || exit 11
+
+# Cannot only change storepass
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt \
+    -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+    -srcstorepass pass1111 \
+    -deststorepass pass2222 \
+        && exit 12
+
+# You can keep storepass unchanged
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt \
+    -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+    -srcstorepass pass1111 \
+    -deststorepass pass1111 \
+        || exit 13
+$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
+	-storepass pass1111 -keypass pass1111 || exit 14
+
+# Or change storepass and keypass both
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt \
+    -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+    -srcstorepass pass1111 \
+    -deststorepass pass2222 -destkeypass pass2222 \
+        || exit 15
+$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
+	-storepass pass2222 -keypass pass2222 || exit 16
+
+# Part 2: JKS keystore with different storepass and keypass
+# Must import by alias (-srckeypass is not available when importing all)
+
+rm jks 2> /dev/null
+$KT -genkeypair -keystore jks -storetype jks -alias me -dname CN=Me \
+	-storepass pass1111 -keypass pass2222 || exit 21
+
+# Can use old keypass as new storepass so new storepass and keypass are same
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt -srcalias me \
+    -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+    -srcstorepass pass1111 -srckeypass pass2222  \
+	-deststorepass pass2222 \
+	    || exit 22
+$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
+	-storepass pass2222 -keypass pass2222 || exit 23
+
+# Or specify both storepass and keypass to brand new ones
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt -srcalias me \
+    -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+    -srcstorepass pass1111 -srckeypass pass2222  \
+	-deststorepass pass3333 -destkeypass pass3333 \
+	    || exit 24
+$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
+	-storepass pass3333 -keypass pass3333 || exit 25
+
+# Anyway you cannot make new storepass and keypass different
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt -srcalias me \
+    -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+    -srcstorepass pass1111 -srckeypass pass2222  \
+	-deststorepass pass1111 \
+	    && exit 26
+
+exit 0
--- a/jdk/test/sun/util/calendar/zi/ZoneInfoFile.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/sun/util/calendar/zi/ZoneInfoFile.java	Wed Jul 05 18:50:02 2017 +0200
@@ -5,7 +5,7 @@
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Class-path" exception as provided
+ * particular file as subject to the "Classpath" exception as provided
  * by Oracle in the LICENSE file that accompanied this code.
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
--- a/jdk/test/sun/util/logging/PlatformLoggerTest.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/sun/util/logging/PlatformLoggerTest.java	Wed Jul 05 18:50:02 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug     6882376 6985460
+ * @bug     6882376 6985460 8010309
  * @summary Test if java.util.logging.Logger is created before and after
  *          logging is enabled.  Also validate some basic PlatformLogger
  *          operations.  othervm mode to make sure java.util.logging
@@ -33,11 +33,12 @@
  * @run main/othervm PlatformLoggerTest
  */
 
+import java.lang.reflect.Field;
 import java.util.logging.*;
 import sun.util.logging.PlatformLogger;
+import static sun.util.logging.PlatformLogger.Level.*;
 
 public class PlatformLoggerTest {
-    private static final int defaultEffectiveLevel = 0;
     public static void main(String[] args) throws Exception {
         final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo";
         final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar";
@@ -69,39 +70,63 @@
         checkLogger(GOO_PLATFORM_LOGGER, null);
         checkLogger(BAR_LOGGER, Level.WARNING);
 
-        foo.setLevel(PlatformLogger.SEVERE);
+        foo.setLevel(PlatformLogger.Level.SEVERE);
         checkLogger(FOO_PLATFORM_LOGGER, Level.SEVERE);
 
+        checkPlatformLoggerLevels(foo, bar);
     }
 
+    // don't use java.util.logging here to prevent it from initialized
     private static void checkPlatformLogger(PlatformLogger logger, String name) {
         if (!logger.getName().equals(name)) {
             throw new RuntimeException("Invalid logger's name " +
                 logger.getName() + " but expected " + name);
         }
 
-        if (logger.getLevel() != defaultEffectiveLevel) {
+        if (logger.level() != null) {
             throw new RuntimeException("Invalid default level for logger " +
-                logger.getName());
+                logger.getName() + ": " + logger.level());
         }
 
-        if (logger.isLoggable(PlatformLogger.FINE) != false) {
-            throw new RuntimeException("isLoggerable(FINE) returns true for logger " +
-                logger.getName() + " but expected false");
+        checkLoggable(logger, FINE, false);
+
+        logger.setLevel(FINER);
+        checkLevel(logger, FINER);
+        checkLoggable(logger, FINER, true);
+        checkLoggable(logger, FINE, true);
+        checkLoggable(logger, FINEST, false);
+
+        logger.info("OK: Testing log message");
+    }
+
+    private static void checkLoggable(PlatformLogger logger, PlatformLogger.Level level, boolean expected) {
+        if (logger.isLoggable(level) != expected) {
+            throw new RuntimeException("logger " + logger.getName() + ": " + level +
+                (expected ? " not loggable" : " loggable"));
         }
 
-        logger.setLevel(PlatformLogger.FINER);
-        if (logger.getLevel() != Level.FINER.intValue()) {
-            throw new RuntimeException("Invalid level for logger " +
-                logger.getName() + " " + logger.getLevel());
+        if (logger.isLoggable(level.intValue()) != expected) {
+            throw new RuntimeException("logger " + logger.getName() + ": " + level.intValue() +
+                (expected ? " not loggable" : " loggable"));
         }
 
-        if (logger.isLoggable(PlatformLogger.FINE) != true) {
-            throw new RuntimeException("isLoggerable(FINE) returns false for logger " +
-                logger.getName() + " but expected true");
+        int value = level.intValue() + 5; // custom level value
+        if (expected && !logger.isLoggable(value)) {
+            throw new RuntimeException("logger " + logger.getName() + ": " + value +
+                " not loggable");
+        }
+    }
+
+    private static void checkLevel(PlatformLogger logger, PlatformLogger.Level level) {
+        if (logger.level() != level) {
+            throw new RuntimeException("Invalid level for logger " +
+                logger.getName() + ": " + logger.level() + " != " + level);
         }
 
-        logger.info("OK: Testing log message");
+        if (logger.getLevel() != level.intValue()) {
+            throw new RuntimeException("Invalid level for logger " +
+                logger.getName() + ": " + logger.getLevel() + " != " + level.intValue());
+        }
     }
 
     private static void checkLogger(String name, Level level) {
@@ -125,6 +150,81 @@
         logger.info("Test info(String)");
     }
 
+    private static void checkPlatformLoggerLevels(PlatformLogger... loggers) {
+        final Level[] levels = new Level[] {
+            Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST,
+            Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING
+        };
+
+        int count = PlatformLogger.Level.values().length;
+        if (levels.length != count) {
+            throw new RuntimeException("There are " + count +
+                    " PlatformLogger.Level members, but " + levels.length +
+                    " standard java.util.logging levels - the numbers should be equal.");
+        }
+        // check mappings
+        for (Level level : levels) {
+            checkPlatformLoggerLevelMapping(level);
+        }
+
+        for (Level level : levels) {
+            PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName());
+            for (PlatformLogger logger : loggers) {
+                logger.setLevel(platformLevel);       // setLevel(PlatformLogger.Level)
+                checkLoggerLevel(logger, level);
+
+                logger.setLevel(ALL);  // setLevel(int)
+                checkLoggerLevel(logger, Level.ALL);
+            }
+        }
+    }
+
+    private static void checkLoggerLevel(PlatformLogger logger, Level level) {
+        PlatformLogger.Level plevel = PlatformLogger.Level.valueOf(level.getName());
+        if (plevel != logger.level()) {
+            throw new RuntimeException("Retrieved PlatformLogger level "
+                    + logger.level()
+                    + " is not the same as set level " + plevel);
+        }
+
+        // check the level set in java.util.logging.Logger
+        Logger javaLogger = LogManager.getLogManager().getLogger(logger.getName());
+        Level javaLevel = javaLogger.getLevel();
+        if (javaLogger.getLevel() != level) {
+            throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
+                    + javaLevel + " is not the expected " + level);
+        }
+    }
+
+    private static void checkPlatformLoggerLevelMapping(Level level) {
+        // map the given level to PlatformLogger.Level of the same name and value
+        PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName());
+        if (platformLevel.intValue() != level.intValue()) {
+            throw new RuntimeException("Mismatched level: " + level
+                    + " PlatformLogger.Level" + platformLevel);
+        }
+
+        try {
+            // validate if there is a public static final field in PlatformLogger
+            Field constantField = PlatformLogger.class.getField(level.getName());
+            int l = (int) constantField.get(null);
+            if (l != platformLevel.intValue()) {
+                throw new RuntimeException("static final " + level.getName() + " (" +
+                    l + ") != " + platformLevel.intValue());
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("No public static PlatformLogger." + level.getName() +
+                                       " field", e);
+        }
+        if (!platformLevel.name().equals(level.getName()))
+            throw new RuntimeException("The value of PlatformLogger." + level.getName() + ".name() is "
+                                       + platformLevel.name() + " but expected " + level.getName());
+
+        if (platformLevel.intValue() != level.intValue())
+            throw new RuntimeException("The value of PlatformLogger." + level.intValue() + ".intValue() is "
+                                       + platformLevel.intValue() + " but expected " + level.intValue());
+    }
+
     static Point[] getPoints() {
         Point[] res = new Point[3];
         res[0] = new Point(0,0);
--- a/jdk/test/vm/verifier/TestStaticIF.java	Thu Apr 11 09:39:48 2013 -0700
+++ b/jdk/test/vm/verifier/TestStaticIF.java	Wed Jul 05 18:50:02 2017 +0200
@@ -26,7 +26,7 @@
  * @test
  * @bug 8007736
  * @summary Test static interface method.
- * @run main/othervm -Xverify:all -XX:-UseSplitVerifier TestStaticIF
+ * @run main/othervm -Xverify:all TestStaticIF
  */
 
 public class TestStaticIF implements StaticMethodInInterface {
--- a/make/scripts/webrev.ksh	Thu Apr 11 09:39:48 2013 -0700
+++ b/make/scripts/webrev.ksh	Wed Jul 05 18:50:02 2017 +0200
@@ -1436,14 +1436,15 @@
 {
     rm -f $FLIST
     if [ -z "$Nflag" ]; then
-	print " File list from hg foutgoing $PWS ..."
+        print " File list from hg foutgoing $PWS ..."
         outgoing_from_mercurial_forest
         HG_LIST_FROM_COMMIT=1
     fi
     if [ ! -f $FLIST ]; then
         # hg commit hasn't been run see what is lying around
-	print "\n No outgoing, perhaps you haven't commited."
-	print " File list from hg fstatus -mard ...\c"
+        print "\n No outgoing, perhaps you haven't commited."
+        NO_OUTGOING=
+        print " File list from hg fstatus -mard ...\c"
         FSTAT_OPT=
         fstatus
         HG_LIST_FROM_COMMIT=0
@@ -1466,7 +1467,7 @@
     done >> $FLIST
 
     # Then all the added files
-    # But some of these could have been "moved" or renamed ones
+    # But some of these could have been "moved" or renamed ones or copied ones
     # so let's make sure we get the proper info
     # hg status -aC will produce something like:
     #	A subdir/File3
@@ -1474,8 +1475,11 @@
     #	  File4
     #	A subdir/File5
     # The first and last are simple addition while the middle one
-    # is a move/rename
-
+    # is a move/rename or a copy.  We can't distinguish from a rename vs a copy
+    # without also getting the status of removed files.  The middle case above
+    # is a rename if File4 is also shown a being removed.  If File4 is not a 
+    # removed file, then the middle case is a copy from File4 to subdir/File4
+    # FIXME - we're not distinguishing copy from rename
     $HGCMD -aC | $FILTER | while read LINE; do
 	ldone=""
 	while [ -z "$ldone" ]; do
@@ -1625,6 +1629,7 @@
         else
             # hg commit hasn't been run see what is lying around
             print "\n No outgoing, perhaps you haven't commited."
+            NO_OUTGOING=
         fi
 	# First let's list all the modified or deleted files
 
@@ -1638,8 +1643,12 @@
 	#	A subdir/File4
 	#	  File4
 	#	A subdir/File5
-	# The first and last are simple addition while the middle one
-	# is a move/rename
+        # The first and last are simple addition while the middle one
+        # is a move/rename or a copy.  We can't distinguish from a rename vs a copy
+        # without also getting the status of removed files.  The middle case above
+        # is a rename if File4 is also shown a being removed.  If File4 is not a 
+        # removed file, then the middle case is a copy from File4 to subdir/File4
+        # FIXME - we're not distinguishing copy from rename
 
 	hg status $STATUS_REV -aC | $FILTER >$FLIST.temp
 	while read LINE; do
@@ -1905,7 +1914,7 @@
 		fi
 	    fi
 	else
-	    # It's a rename (or a move), so let's make sure we move
+	    # It's a rename (or a move), or a copy, so let's make sure we move
 	    # to the right directory first, then restore it once done
 	    current_dir=`pwd`
 	    cd $CWS/$PDIR
@@ -2774,34 +2783,38 @@
 	    cleanse_rmfile="sed 's/^\(@@ [0-9+,-]*\) [0-9+,-]* @@$/\1 +0,0 @@/'"
 	    cleanse_newfile="sed 's/^@@ [0-9+,-]* \([0-9+,-]* @@\)$/@@ -0,0 \1/'"
 
-	    rm -f $WDIR/$DIR/$F.patch
-	    if [[ -z $rename ]]; then
-		if [ ! -f $ofile ]; then
-		    diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
-			> $WDIR/$DIR/$F.patch
-		elif [ ! -f $nfile ]; then
-		    diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
-			> $WDIR/$DIR/$F.patch
-		else
-		    diff -u $ofile $nfile > $WDIR/$DIR/$F.patch
-		fi
-	    else
-		diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
-		    > $WDIR/$DIR/$F.patch
-
-		diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
-		    >> $WDIR/$DIR/$F.patch
-
-	    fi
-
-
-	#
-	# Tack the patch we just made onto the accumulated patch for the
-	# whole wad.
-	#
-	    cat $WDIR/$DIR/$F.patch >> $WDIR/$WNAME.patch
-
-	    print " patch\c"
+            if [[ -v NO_OUTGOING ]];
+            then
+              # Only need to generate a patch file here if there are no commits in outgoing
+              rm -f $WDIR/$DIR/$F.patch
+              if [[ -z $rename ]]; then
+                  if [ ! -f $ofile ]; then
+                      diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
+                          > $WDIR/$DIR/$F.patch
+                  elif [ ! -f $nfile ]; then
+                      diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
+                          > $WDIR/$DIR/$F.patch
+                  else
+                      diff -u $ofile $nfile > $WDIR/$DIR/$F.patch
+                  fi
+              else
+                  diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
+                      > $WDIR/$DIR/$F.patch
+
+                  diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
+                      >> $WDIR/$DIR/$F.patch
+
+              fi
+
+
+            #
+            # Tack the patch we just made onto the accumulated patch for the
+            # whole wad.
+            #
+              cat $WDIR/$DIR/$F.patch >> $WDIR/$WNAME.patch
+            fi
+
+            print " patch\c"
 
 	    if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then
 
@@ -2894,6 +2907,32 @@
 	print
 done < $FLIST
 
+# Create the new style mercurial patch here using hg export -r [all-revs] -g -o $CHANGESETPATH
+if [[ $SCM_MODE == "mercurial" ]]; then
+  if [[ !(-v NO_OUTGOING) ]]; then
+    EXPORTCHANGESET="$WNAME.changeset"
+    CHANGESETPATH=${WDIR}/${EXPORTCHANGESET}
+    rm -f $CHANGESETPATH
+    touch $CHANGESETPATH
+    if [[ -n $ALL_CREV ]]; then
+      rev_opt=
+      for rev in $ALL_CREV; do
+        rev_opt="$rev_opt --rev $rev"
+      done
+    elif [[ -n $FIRST_CREV ]]; then
+      rev_opt="--rev $FIRST_CREV"
+    fi
+
+    if [[ -n $rev_opt ]]; then
+      (cd $CWS;hg export -g $rev_opt -o $CHANGESETPATH)
+      # echo "Created new-patch: $CHANGESETPATH" 1>&2
+      # Use it in place of the jdk.patch created above
+      rm -f $WDIR/$WNAME.patch
+    fi
+  set +x
+  fi
+fi
+
 frame_nav_js > $WDIR/ancnav.js
 frame_navigation > $WDIR/ancnav.html
 
@@ -2989,9 +3028,13 @@
 print "</td></tr>"
 
 if [[ -f $WDIR/$WNAME.patch ]]; then
-	print "<tr><th>Patch of changes:</th><td>"
-	print "<a href=\"$WNAME.patch\">$WNAME.patch</a></td></tr>"
+  print "<tr><th>Patch of changes:</th><td>"
+  print "<a href=\"$WNAME.patch\">$WNAME.patch</a></td></tr>"
+elif [[ -f $CHANGESETPATH ]]; then
+  print "<tr><th>Changeset:</th><td>"
+  print "<a href=\"$EXPORTCHANGESET\">$EXPORTCHANGESET</a></td></tr>"
 fi
+
 if [[ -f $WDIR/$WNAME.pdf ]]; then
 	print "<tr><th>Printable review:</th><td>"
 	print "<a href=\"$WNAME.pdf\">$WNAME.pdf</a></td></tr>"