Merge
authorduke
Wed, 05 Jul 2017 18:09:02 +0200
changeset 12461 4865115b34cf
parent 12460 69a997cbdf15 (current diff)
parent 12455 edb2fe739e54 (diff)
child 12463 a3b1ce50a059
Merge
--- a/.hgtags-top-repo	Mon Apr 23 16:55:12 2012 -0700
+++ b/.hgtags-top-repo	Wed Jul 05 18:09:02 2017 +0200
@@ -156,3 +156,4 @@
 88176171e940f02916a312c265a34c32552a8376 jdk8-b32
 42f275168fa5d9e7c70b246614dca8cf81f52c2e jdk8-b33
 894a478d2c4819a1a0f230bd7bdd09f3b2de9a8c jdk8-b34
+5285317ebb4e8e4f6d8d52b5616fa801e2ea844d jdk8-b35
--- a/corba/.hgtags	Mon Apr 23 16:55:12 2012 -0700
+++ b/corba/.hgtags	Wed Jul 05 18:09:02 2017 +0200
@@ -156,3 +156,4 @@
 5d820cb6b1afd75b619e7fd69e4f2b0eb1d5d6a1 jdk8-b32
 1e2ac1ea3f6c32a62bf88f3fa330120c30db59cb jdk8-b33
 e24c5cc8b0f7cc48374eef0f995838fb4823e0eb jdk8-b34
+e3d735914edd0a621b16bb85417423f8e6af5d51 jdk8-b35
--- a/hotspot/.hgtags	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/.hgtags	Wed Jul 05 18:09:02 2017 +0200
@@ -239,3 +239,5 @@
 785bcf415ead2eaa5f6677aaf528481008140bac jdk8-b33
 7c6aba65acd2c334f1c3512b574f9038cddac24b hs24-b07
 f284b08835584517c1ca3dd67341f569e763841f jdk8-b34
+f621660a297baa48fab9dca28e99d318826e8304 jdk8-b35
+dff6e3459210f8dd0430b9b03ccc99280560da30 hs24-b08
--- a/hotspot/agent/src/os/linux/ps_core.c	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/agent/src/os/linux/ps_core.c	Wed Jul 05 18:09:02 2017 +0200
@@ -440,7 +440,7 @@
       int j = 0;
       print_debug("---- sorted virtual address map ----\n");
       for (j = 0; j < ph->core->num_maps; j++) {
-        print_debug("base = 0x%lx\tsize = %d\n", ph->core->map_array[j]->vaddr,
+        print_debug("base = 0x%lx\tsize = %zd\n", ph->core->map_array[j]->vaddr,
                                          ph->core->map_array[j]->memsz);
       }
    }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
 public class HeapRegionSeq extends VMObject {
     // HeapRegion** _regions;
     static private AddressField regionsField;
-    // size_t _length;
+    // uint _length;
     static private CIntegerField lengthField;
 
     static {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSetBase.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSetBase.java	Wed Jul 05 18:09:02 2017 +0200
@@ -40,9 +40,9 @@
 // Mirror class for HeapRegionSetBase. Represents a group of regions.
 
 public class HeapRegionSetBase extends VMObject {
-    // size_t _length;
+    // uint _length;
     static private CIntegerField lengthField;
-    // size_t _region_num;
+    // uint _region_num;
     static private CIntegerField regionNumField;
     // size_t _total_used_bytes;
     static private CIntegerField totalUsedBytesField;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/VirtualMachineImpl.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/VirtualMachineImpl.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -889,15 +889,9 @@
         Klass kls = ((ReferenceTypeImpl)type).ref();
         if (kls instanceof InstanceKlass) {
             InstanceKlass ik = (InstanceKlass) kls;
-            if (ik.isInterface()) {
-                if (ik.nofImplementors() == 0L) {
-                    return new ArrayList(0);
-                }
-            } else {
-                // if the Klass is final or if there are no subklasses loaded yet
-                if (ik.getAccessFlagsObj().isFinal() || ik.getSubklassKlass() == null) {
-                    includeSubtypes = false;
-                }
+            // if the Klass is final or if there are no subklasses loaded yet
+            if (ik.getAccessFlagsObj().isFinal() || ik.getSubklassKlass() == null) {
+                includeSubtypes = false;
             }
         } else {
             // no subtypes for primitive array types
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,6 @@
   private static int HIGH_OFFSET;
   private static int GENERIC_SIGNATURE_INDEX_OFFSET;
   private static int FIELD_SLOTS;
-  public static int IMPLEMENTORS_LIMIT;
 
   // ClassState constants
   private static int CLASS_STATE_UNPARSABLE_BY_GC;
@@ -70,13 +69,6 @@
     methodOrdering       = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize());
     localInterfaces      = new OopField(type.getOopField("_local_interfaces"), Oop.getHeaderSize());
     transitiveInterfaces = new OopField(type.getOopField("_transitive_interfaces"), Oop.getHeaderSize());
-    nofImplementors      = new CIntField(type.getCIntegerField("_nof_implementors"), Oop.getHeaderSize());
-    IMPLEMENTORS_LIMIT   = db.lookupIntConstant("instanceKlass::implementors_limit").intValue();
-    implementors         = new OopField[IMPLEMENTORS_LIMIT];
-    for (int i = 0; i < IMPLEMENTORS_LIMIT; i++) {
-      long arrayOffset = Oop.getHeaderSize() + (i * db.getAddressSize());
-      implementors[i]    = new OopField(type.getOopField("_implementors[0]"), arrayOffset);
-    }
     fields               = new OopField(type.getOopField("_fields"), Oop.getHeaderSize());
     javaFieldsCount      = new CIntField(type.getCIntegerField("_java_fields_count"), Oop.getHeaderSize());
     constants            = new OopField(type.getOopField("_constants"), Oop.getHeaderSize());
@@ -136,8 +128,6 @@
   private static OopField  methodOrdering;
   private static OopField  localInterfaces;
   private static OopField  transitiveInterfaces;
-  private static CIntField nofImplementors;
-  private static OopField[] implementors;
   private static OopField  fields;
   private static CIntField javaFieldsCount;
   private static OopField  constants;
@@ -317,9 +307,6 @@
   public TypeArray getMethodOrdering()      { return (TypeArray)    methodOrdering.getValue(this); }
   public ObjArray  getLocalInterfaces()     { return (ObjArray)     localInterfaces.getValue(this); }
   public ObjArray  getTransitiveInterfaces() { return (ObjArray)     transitiveInterfaces.getValue(this); }
-  public long      nofImplementors()        { return                nofImplementors.getValue(this); }
-  public Klass     getImplementor()         { return (Klass)        implementors[0].getValue(this); }
-  public Klass     getImplementor(int i)    { return (Klass)        implementors[i].getValue(this); }
   public TypeArray getFields()              { return (TypeArray)    fields.getValue(this); }
   public int       getJavaFieldsCount()     { return                (int) javaFieldsCount.getValue(this); }
   public int       getAllFieldsCount()      { return                (int)getFields().getLength() / FIELD_SLOTS; }
@@ -527,9 +514,6 @@
       visitor.doOop(methodOrdering, true);
       visitor.doOop(localInterfaces, true);
       visitor.doOop(transitiveInterfaces, true);
-      visitor.doCInt(nofImplementors, true);
-      for (int i = 0; i < IMPLEMENTORS_LIMIT; i++)
-        visitor.doOop(implementors[i], true);
       visitor.doOop(fields, true);
       visitor.doOop(constants, true);
       visitor.doOop(classLoader, true);
--- a/hotspot/make/hotspot_version	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/make/hotspot_version	Wed Jul 05 18:09:02 2017 +0200
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=24
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=07
+HS_BUILD_NUMBER=08
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=8
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -2651,56 +2651,49 @@
     // Check to see if a field modification watch has been set before we take
     // the time to call into the VM.
     Label L2;
-    __ mov32(rcx, ExternalAddress((address)JvmtiExport::get_field_modification_count_addr()));
-    __ testl(rcx,rcx);
-    __ jcc(Assembler::zero, L2);
-    __ pop_ptr(rbx);               // copy the object pointer from tos
-    __ verify_oop(rbx);
-    __ push_ptr(rbx);              // put the object pointer back on tos
-    __ subptr(rsp, sizeof(jvalue));  // add space for a jvalue object
-    __ mov(rcx, rsp);
-    __ push_ptr(rbx);                 // save object pointer so we can steal rbx,
-    __ xorptr(rbx, rbx);
-    const Address lo_value(rcx, rbx, Address::times_1, 0*wordSize);
-    const Address hi_value(rcx, rbx, Address::times_1, 1*wordSize);
-    switch (bytecode()) {          // load values into the jvalue object
-    case Bytecodes::_fast_bputfield: __ movb(lo_value, rax); break;
-    case Bytecodes::_fast_sputfield: __ movw(lo_value, rax); break;
-    case Bytecodes::_fast_cputfield: __ movw(lo_value, rax); break;
-    case Bytecodes::_fast_iputfield: __ movl(lo_value, rax);                         break;
-    case Bytecodes::_fast_lputfield:
-      NOT_LP64(__ movptr(hi_value, rdx));
-      __ movptr(lo_value, rax);
-      break;
-
-    // need to call fld_s() after fstp_s() to restore the value for below
-    case Bytecodes::_fast_fputfield: __ fstp_s(lo_value); __ fld_s(lo_value);        break;
-
-    // need to call fld_d() after fstp_d() to restore the value for below
-    case Bytecodes::_fast_dputfield: __ fstp_d(lo_value); __ fld_d(lo_value);        break;
-
-    // since rcx is not an object we don't call store_check() here
-    case Bytecodes::_fast_aputfield: __ movptr(lo_value, rax);                       break;
-
-    default:  ShouldNotReachHere();
-    }
-    __ pop_ptr(rbx);  // restore copy of object pointer
-
-    // Save rax, and sometimes rdx because call_VM() will clobber them,
-    // then use them for JVM/DI purposes
-    __ push(rax);
-    if (bytecode() == Bytecodes::_fast_lputfield) __ push(rdx);
-    // access constant pool cache entry
-    __ get_cache_entry_pointer_at_bcp(rax, rdx, 1);
-    __ verify_oop(rbx);
-    // rbx,: object pointer copied above
-    // rax,: cache entry pointer
-    // rcx: jvalue object on the stack
-    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification), rbx, rax, rcx);
-    if (bytecode() == Bytecodes::_fast_lputfield) __ pop(rdx);  // restore high value
-    __ pop(rax);     // restore lower value
-    __ addptr(rsp, sizeof(jvalue));  // release jvalue object space
-    __ bind(L2);
+     __ mov32(rcx, ExternalAddress((address)JvmtiExport::get_field_modification_count_addr()));
+     __ testl(rcx,rcx);
+     __ jcc(Assembler::zero, L2);
+     __ pop_ptr(rbx);               // copy the object pointer from tos
+     __ verify_oop(rbx);
+     __ push_ptr(rbx);              // put the object pointer back on tos
+
+     // Save tos values before call_VM() clobbers them. Since we have
+     // to do it for every data type, we use the saved values as the
+     // jvalue object.
+     switch (bytecode()) {          // load values into the jvalue object
+     case Bytecodes::_fast_aputfield: __ push_ptr(rax); break;
+     case Bytecodes::_fast_bputfield: // fall through
+     case Bytecodes::_fast_sputfield: // fall through
+     case Bytecodes::_fast_cputfield: // fall through
+     case Bytecodes::_fast_iputfield: __ push_i(rax); break;
+     case Bytecodes::_fast_dputfield: __ push_d(); break;
+     case Bytecodes::_fast_fputfield: __ push_f(); break;
+     case Bytecodes::_fast_lputfield: __ push_l(rax); break;
+
+     default:
+       ShouldNotReachHere();
+     }
+     __ mov(rcx, rsp);              // points to jvalue on the stack
+     // access constant pool cache entry
+     __ get_cache_entry_pointer_at_bcp(rax, rdx, 1);
+     __ verify_oop(rbx);
+     // rbx,: object pointer copied above
+     // rax,: cache entry pointer
+     // rcx: jvalue object on the stack
+     __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification), rbx, rax, rcx);
+
+     switch (bytecode()) {             // restore tos values
+     case Bytecodes::_fast_aputfield: __ pop_ptr(rax); break;
+     case Bytecodes::_fast_bputfield: // fall through
+     case Bytecodes::_fast_sputfield: // fall through
+     case Bytecodes::_fast_cputfield: // fall through
+     case Bytecodes::_fast_iputfield: __ pop_i(rax); break;
+     case Bytecodes::_fast_dputfield: __ pop_d(); break;
+     case Bytecodes::_fast_fputfield: __ pop_f(); break;
+     case Bytecodes::_fast_lputfield: __ pop_l(rax); break;
+     }
+     __ bind(L2);
   }
 }
 
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -2685,26 +2685,23 @@
     __ pop_ptr(rbx);                  // copy the object pointer from tos
     __ verify_oop(rbx);
     __ push_ptr(rbx);                 // put the object pointer back on tos
-    __ subptr(rsp, sizeof(jvalue));  // add space for a jvalue object
-    __ mov(c_rarg3, rsp);
-    const Address field(c_rarg3, 0);
-
+    // Save tos values before call_VM() clobbers them. Since we have
+    // to do it for every data type, we use the saved values as the
+    // jvalue object.
     switch (bytecode()) {          // load values into the jvalue object
-    case Bytecodes::_fast_aputfield: __ movq(field, rax); break;
-    case Bytecodes::_fast_lputfield: __ movq(field, rax); break;
-    case Bytecodes::_fast_iputfield: __ movl(field, rax); break;
-    case Bytecodes::_fast_bputfield: __ movb(field, rax); break;
+    case Bytecodes::_fast_aputfield: __ push_ptr(rax); break;
+    case Bytecodes::_fast_bputfield: // fall through
     case Bytecodes::_fast_sputfield: // fall through
-    case Bytecodes::_fast_cputfield: __ movw(field, rax); break;
-    case Bytecodes::_fast_fputfield: __ movflt(field, xmm0); break;
-    case Bytecodes::_fast_dputfield: __ movdbl(field, xmm0); break;
+    case Bytecodes::_fast_cputfield: // fall through
+    case Bytecodes::_fast_iputfield: __ push_i(rax); break;
+    case Bytecodes::_fast_dputfield: __ push_d(); break;
+    case Bytecodes::_fast_fputfield: __ push_f(); break;
+    case Bytecodes::_fast_lputfield: __ push_l(rax); break;
+
     default:
       ShouldNotReachHere();
     }
-
-    // Save rax because call_VM() will clobber it, then use it for
-    // JVMTI purposes
-    __ push(rax);
+    __ mov(c_rarg3, rsp);             // points to jvalue on the stack
     // access constant pool cache entry
     __ get_cache_entry_pointer_at_bcp(c_rarg2, rax, 1);
     __ verify_oop(rbx);
@@ -2715,8 +2712,17 @@
                CAST_FROM_FN_PTR(address,
                                 InterpreterRuntime::post_field_modification),
                rbx, c_rarg2, c_rarg3);
-    __ pop(rax);     // restore lower value
-    __ addptr(rsp, sizeof(jvalue));  // release jvalue object space
+
+    switch (bytecode()) {             // restore tos values
+    case Bytecodes::_fast_aputfield: __ pop_ptr(rax); break;
+    case Bytecodes::_fast_bputfield: // fall through
+    case Bytecodes::_fast_sputfield: // fall through
+    case Bytecodes::_fast_cputfield: // fall through
+    case Bytecodes::_fast_iputfield: __ pop_i(rax); break;
+    case Bytecodes::_fast_dputfield: __ pop_d(); break;
+    case Bytecodes::_fast_fputfield: __ pop_f(); break;
+    case Bytecodes::_fast_lputfield: __ pop_l(rax); break;
+    }
     __ bind(L2);
   }
 }
--- a/hotspot/src/os/bsd/vm/osThread_bsd.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/os/bsd/vm/osThread_bsd.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -72,15 +72,18 @@
 
 #ifdef _ALLBSD_SOURCE
 #ifdef __APPLE__
+  static size_t thread_id_size()         { return sizeof(thread_t); }
   thread_t thread_id() const {
     return _thread_id;
   }
 #else
+  static size_t thread_id_size()         { return sizeof(pthread_t); }
   pthread_t thread_id() const {
     return _thread_id;
   }
 #endif
 #else
+  static size_t thread_id_size()         { return sizeof(pid_t); }
   pid_t thread_id() const {
     return _thread_id;
   }
--- a/hotspot/src/os/linux/vm/osThread_linux.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/os/linux/vm/osThread_linux.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, 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
@@ -56,6 +56,8 @@
   sigset_t  caller_sigmask() const       { return _caller_sigmask; }
   void    set_caller_sigmask(sigset_t sigmask)  { _caller_sigmask = sigmask; }
 
+  static size_t thread_id_size()         { return sizeof(pid_t); }
+
   pid_t thread_id() const {
     return _thread_id;
   }
--- a/hotspot/src/os/solaris/vm/osThread_solaris.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/os/solaris/vm/osThread_solaris.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -36,6 +36,7 @@
   bool     _vm_created_thread; // true if the VM created this thread,
                                // false if primary thread or attached thread
  public:
+  static size_t thread_id_size()   { return sizeof(thread_t); }
   thread_t thread_id() const       { return _thread_id; }
   uint     lwp_id() const          { return _lwp_id; }
   int      native_priority() const { return _native_priority; }
--- a/hotspot/src/os/windows/vm/osThread_windows.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/os/windows/vm/osThread_windows.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,8 @@
   HANDLE interrupt_event() const                   { return _interrupt_event; }
   void set_interrupt_event(HANDLE interrupt_event) { _interrupt_event = interrupt_event; }
 
+
+  static size_t thread_id_size()                   { return sizeof(unsigned long); }
   unsigned long thread_id() const                  { return _thread_id; }
 #ifndef PRODUCT
   // Used for debugging, return a unique integer for each thread.
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1694,7 +1694,9 @@
       // they are roughly equivalent to Object.
       ciInstanceKlass* singleton = NULL;
       if (target->holder()->nof_implementors() == 1) {
-        singleton = target->holder()->implementor(0);
+        singleton = target->holder()->implementor();
+        assert(singleton != NULL && singleton != target->holder(),
+               "just checking");
 
         assert(holder->is_interface(), "invokeinterface to non interface?");
         ciInstanceKlass* decl_interface = (ciInstanceKlass*)holder;
@@ -3130,10 +3132,23 @@
   bool cantrap = true;
   vmIntrinsics::ID id = callee->intrinsic_id();
   switch (id) {
-    case vmIntrinsics::_arraycopy     :
+    case vmIntrinsics::_arraycopy:
       if (!InlineArrayCopy) return false;
       break;
 
+#ifdef TRACE_HAVE_INTRINSICS
+    case vmIntrinsics::_classID:
+    case vmIntrinsics::_threadID:
+      preserves_state = true;
+      cantrap = true;
+      break;
+
+    case vmIntrinsics::_counterTime:
+      preserves_state = true;
+      cantrap = false;
+      break;
+#endif
+
     case vmIntrinsics::_currentTimeMillis:
     case vmIntrinsics::_nanoTime:
       preserves_state = true;
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -2879,6 +2879,50 @@
   __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
 }
 
+void LIRGenerator::do_RuntimeCall(address routine, int expected_arguments, Intrinsic* x) {
+    assert(x->number_of_arguments() == expected_arguments, "wrong type");
+    LIR_Opr reg = result_register_for(x->type());
+    __ call_runtime_leaf(routine, getThreadTemp(),
+                         reg, new LIR_OprList());
+    LIR_Opr result = rlock_result(x);
+    __ move(reg, result);
+}
+
+#ifdef TRACE_HAVE_INTRINSICS
+void LIRGenerator::do_ThreadIDIntrinsic(Intrinsic* x) {
+    LIR_Opr thread = getThreadPointer();
+    LIR_Opr osthread = new_pointer_register();
+    __ move(new LIR_Address(thread, in_bytes(JavaThread::osthread_offset()), osthread->type()), osthread);
+    size_t thread_id_size = OSThread::thread_id_size();
+    if (thread_id_size == (size_t) BytesPerLong) {
+      LIR_Opr id = new_register(T_LONG);
+      __ move(new LIR_Address(osthread, in_bytes(OSThread::thread_id_offset()), T_LONG), id);
+      __ convert(Bytecodes::_l2i, id, rlock_result(x));
+    } else if (thread_id_size == (size_t) BytesPerInt) {
+      __ move(new LIR_Address(osthread, in_bytes(OSThread::thread_id_offset()), T_INT), rlock_result(x));
+    } else {
+      ShouldNotReachHere();
+    }
+}
+
+void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) {
+    CodeEmitInfo* info = state_for(x);
+    CodeEmitInfo* info2 = new CodeEmitInfo(info); // Clone for the second null check
+    assert(info != NULL, "must have info");
+    LIRItem arg(x->argument_at(1), this);
+    arg.load_item();
+    LIR_Opr klass = new_register(T_OBJECT);
+    __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), T_OBJECT), klass, info);
+    LIR_Opr id = new_register(T_LONG);
+    ByteSize offset = TRACE_ID_OFFSET;
+    LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG);
+    __ move(trace_id_addr, id);
+    __ logical_or(id, LIR_OprFact::longConst(0x01l), id);
+    __ store(id, trace_id_addr);
+    __ logical_and(id, LIR_OprFact::longConst(~0x3l), id);
+    __ move(id, rlock_result(x));
+}
+#endif
 
 void LIRGenerator::do_Intrinsic(Intrinsic* x) {
   switch (x->id()) {
@@ -2890,25 +2934,21 @@
     break;
   }
 
-  case vmIntrinsics::_currentTimeMillis: {
-    assert(x->number_of_arguments() == 0, "wrong type");
-    LIR_Opr reg = result_register_for(x->type());
-    __ call_runtime_leaf(CAST_FROM_FN_PTR(address, os::javaTimeMillis), getThreadTemp(),
-                         reg, new LIR_OprList());
-    LIR_Opr result = rlock_result(x);
-    __ move(reg, result);
+#ifdef TRACE_HAVE_INTRINSICS
+  case vmIntrinsics::_threadID: do_ThreadIDIntrinsic(x); break;
+  case vmIntrinsics::_classID: do_ClassIDIntrinsic(x); break;
+  case vmIntrinsics::_counterTime:
+    do_RuntimeCall(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), 0, x);
     break;
-  }
-
-  case vmIntrinsics::_nanoTime: {
-    assert(x->number_of_arguments() == 0, "wrong type");
-    LIR_Opr reg = result_register_for(x->type());
-    __ call_runtime_leaf(CAST_FROM_FN_PTR(address, os::javaTimeNanos), getThreadTemp(),
-                         reg, new LIR_OprList());
-    LIR_Opr result = rlock_result(x);
-    __ move(reg, result);
+#endif
+
+  case vmIntrinsics::_currentTimeMillis:
+    do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), 0, x);
     break;
-  }
+
+  case vmIntrinsics::_nanoTime:
+    do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), 0, x);
+    break;
 
   case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
   case vmIntrinsics::_getClass:       do_getClass(x);      break;
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -426,6 +426,12 @@
   SwitchRangeArray* create_lookup_ranges(LookupSwitch* x);
   void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux);
 
+  void do_RuntimeCall(address routine, int expected_arguments, Intrinsic* x);
+#ifdef TRACE_HAVE_INTRINSICS
+  void do_ThreadIDIntrinsic(Intrinsic* x);
+  void do_ClassIDIntrinsic(Intrinsic* x);
+#endif
+
  public:
   Compilation*  compilation() const              { return _compilation; }
   FrameMap*     frame_map() const                { return _compilation->frame_map(); }
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -295,6 +295,9 @@
   FUNCTION_CASE(entry, SharedRuntime::dtrace_method_entry);
   FUNCTION_CASE(entry, SharedRuntime::dtrace_method_exit);
   FUNCTION_CASE(entry, trace_block_entry);
+#ifdef TRACE_HAVE_INTRINSICS
+  FUNCTION_CASE(entry, TRACE_TIME_METHOD);
+#endif
 
 #undef FUNCTION_CASE
 
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -59,10 +59,7 @@
   _has_nonstatic_fields = ik->has_nonstatic_fields();
   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
 
-  _nof_implementors = ik->nof_implementors();
-  for (int i = 0; i < implementors_limit; i++) {
-    _implementors[i] = NULL;  // we will fill these lazily
-  }
+  _implementor = NULL; // we will fill these lazily
 
   Thread *thread = Thread::current();
   if (ciObjectFactory::is_initialized()) {
@@ -102,7 +99,6 @@
   _nonstatic_field_size = -1;
   _has_nonstatic_fields = false;
   _nonstatic_fields = NULL;
-  _nof_implementors = -1;
   _loader = loader;
   _protection_domain = protection_domain;
   _is_shared = false;
@@ -133,17 +129,6 @@
 }
 
 // ------------------------------------------------------------------
-// ciInstanceKlass::compute_shared_nof_implementors
-int ciInstanceKlass::compute_shared_nof_implementors() {
-  // We requery this property, since it is a very old ciObject.
-  GUARDED_VM_ENTRY(
-    instanceKlass* ik = get_instanceKlass();
-    _nof_implementors = ik->nof_implementors();
-    return _nof_implementors;
-  )
-}
-
-// ------------------------------------------------------------------
 // ciInstanceKlass::loader
 oop ciInstanceKlass::loader() {
   ASSERT_IN_VM;
@@ -540,7 +525,7 @@
   if (is_shared()) {
     return is_final();  // approximately correct
   } else {
-    return !_has_subklass && (_nof_implementors == 0);
+    return !_has_subklass && (nof_implementors() == 0);
   }
 }
 
@@ -548,35 +533,31 @@
 // ciInstanceKlass::implementor
 //
 // Report an implementor of this interface.
-// Returns NULL if exact information is not available.
 // Note that there are various races here, since my copy
 // of _nof_implementors might be out of date with respect
 // to results returned by instanceKlass::implementor.
 // This is OK, since any dependencies we decide to assert
 // will be checked later under the Compile_lock.
-ciInstanceKlass* ciInstanceKlass::implementor(int n) {
-  if (n >= implementors_limit) {
-    return NULL;
-  }
-  ciInstanceKlass* impl = _implementors[n];
+ciInstanceKlass* ciInstanceKlass::implementor() {
+  ciInstanceKlass* impl = _implementor;
   if (impl == NULL) {
-    if (_nof_implementors > implementors_limit) {
-      return NULL;
-    }
     // Go into the VM to fetch the implementor.
     {
       VM_ENTRY_MARK;
-      klassOop k = get_instanceKlass()->implementor(n);
+      klassOop k = get_instanceKlass()->implementor();
       if (k != NULL) {
-        impl = CURRENT_THREAD_ENV->get_object(k)->as_instance_klass();
+        if (k == get_instanceKlass()->as_klassOop()) {
+          // More than one implementors. Use 'this' in this case.
+          impl = this;
+        } else {
+          impl = CURRENT_THREAD_ENV->get_object(k)->as_instance_klass();
+        }
       }
     }
     // Memoize this result.
     if (!is_shared()) {
-      _implementors[n] = (impl == NULL)? this: impl;
+      _implementor = impl;
     }
-  } else if (impl == this) {
-    impl = NULL;  // memoized null result from a VM query
   }
   return impl;
 }
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, 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
@@ -65,9 +65,11 @@
   ciConstantPoolCache*   _field_cache;  // cached map index->field
   GrowableArray<ciField*>* _nonstatic_fields;
 
-  enum { implementors_limit = instanceKlass::implementors_limit };
-  ciInstanceKlass*       _implementors[implementors_limit];
-  jint                   _nof_implementors;
+  // The possible values of the _implementor fall into following three cases:
+  //   NULL: no implementor.
+  //   A ciInstanceKlass that's not itself: one implementor.
+  //   Itsef: more than one implementors.
+  ciInstanceKlass*       _implementor;
 
   GrowableArray<ciField*>* _non_static_fields;
 
@@ -97,7 +99,6 @@
 
   void compute_shared_init_state();
   bool compute_shared_has_subklass();
-  int  compute_shared_nof_implementors();
   int  compute_nonstatic_fields();
   GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
 
@@ -158,10 +159,17 @@
     assert(is_loaded(), "must be loaded");
     return _nonstatic_oop_map_size; }
   ciInstanceKlass*       super();
-  jint                   nof_implementors()  {
+  jint                   nof_implementors() {
+    ciInstanceKlass* impl;
     assert(is_loaded(), "must be loaded");
-    if (_is_shared)  return compute_shared_nof_implementors();
-    return _nof_implementors;
+    impl = implementor();
+    if (impl == NULL) {
+      return 0;
+    } else if (impl != this) {
+      return 1;
+    } else {
+      return 2;
+    }
   }
 
   ciInstanceKlass* get_canonical_holder(int offset);
@@ -207,7 +215,7 @@
   // but consider adding to vmSymbols.hpp instead.
 
   bool is_leaf_type();
-  ciInstanceKlass* implementor(int n);
+  ciInstanceKlass* implementor();
 
   // Is the defining class loader of this class the default loader?
   bool uses_default_loader();
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -3354,6 +3354,7 @@
     klassOop ik = oopFactory::new_instanceKlass(name, vtable_size, itable_size,
                                                 static_field_size,
                                                 total_oop_map_count,
+                                                access_flags,
                                                 rt, CHECK_(nullHandle));
     instanceKlassHandle this_klass (THREAD, ik);
 
@@ -3362,7 +3363,6 @@
            "sanity");
 
     // Fill in information already parsed
-    this_klass->set_access_flags(access_flags);
     this_klass->set_should_verify_class(verify);
     jint lh = Klass::instance_layout_helper(instance_size, false);
     this_klass->set_layout_helper(lh);
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -27,6 +27,7 @@
 
 #include "oops/symbol.hpp"
 #include "memory/iterator.hpp"
+#include "trace/traceMacros.hpp"
 
 // The class vmSymbols is a name space for fast lookup of
 // symbols commonly used in the VM.
@@ -424,6 +425,7 @@
   template(throwable_throwable_signature,             "(Ljava/lang/Throwable;)Ljava/lang/Throwable;")             \
   template(class_void_signature,                      "(Ljava/lang/Class;)V")                     \
   template(class_int_signature,                       "(Ljava/lang/Class;)I")                     \
+  template(class_long_signature,                      "(Ljava/lang/Class;)J")                     \
   template(class_boolean_signature,                   "(Ljava/lang/Class;)Z")                     \
   template(throwable_string_void_signature,           "(Ljava/lang/Throwable;Ljava/lang/String;)V")               \
   template(string_array_void_signature,               "([Ljava/lang/String;)V")                                   \
@@ -539,10 +541,12 @@
   template(serializePropertiesToByteArray_signature,   "()[B")                                                    \
   template(serializeAgentPropertiesToByteArray_name,   "serializeAgentPropertiesToByteArray")                     \
   template(classRedefinedCount_name,                   "classRedefinedCount")                                     \
+                                                                                                                  \
+  /* trace signatures */                                                                                          \
+  TRACE_TEMPLATES(template)                                                                                       \
+                                                                                                                  \
   /*end*/
 
-
-
 // Here are all the intrinsics known to the runtime and the CI.
 // Each intrinsic consists of a public enum name (like _hashCode),
 // followed by a specification of its klass, name, and signature:
@@ -648,6 +652,8 @@
   do_intrinsic(_nanoTime,                 java_lang_System,       nanoTime_name,          void_long_signature,   F_S)   \
    do_name(     nanoTime_name,                                   "nanoTime")                                            \
                                                                                                                         \
+  TRACE_INTRINSICS(do_intrinsic, do_class, do_name, do_signature, do_alias)                                             \
+                                                                                                                        \
   do_intrinsic(_arraycopy,                java_lang_System,       arraycopy_name, arraycopy_signature,           F_S)   \
    do_name(     arraycopy_name,                                  "arraycopy")                                           \
    do_signature(arraycopy_signature,                             "(Ljava/lang/Object;ILjava/lang/Object;II)V")          \
--- a/hotspot/src/share/vm/code/dependencies.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/code/dependencies.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -1033,21 +1033,25 @@
     // (Old CHA had the same limitation.)
     return context_type;
   }
-  for (int i = 0; i < nof_impls; i++) {
-    klassOop impl = instanceKlass::cast(context_type)->implementor(i);
-    if (impl == NULL) {
-      // implementors array overflowed => no exact info.
+  if (nof_impls > 0) {
+    klassOop impl = instanceKlass::cast(context_type)->implementor();
+    assert(impl != NULL, "just checking");
+    // If impl is the same as the context_type, then more than one
+    // implementor has seen. No exact info in this case.
+    if (impl == context_type) {
       return context_type;  // report an inexact witness to this sad affair
     }
     if (do_counts)
       { NOT_PRODUCT(deps_find_witness_steps++); }
     if (is_participant(impl)) {
-      if (participants_hide_witnesses)  continue;
-      // else fall through to process this guy's subclasses
+      if (!participants_hide_witnesses) {
+        ADD_SUBCLASS_CHAIN(impl);
+      }
     } else if (is_witness(impl) && !ignore_witness(impl)) {
       return impl;
+    } else {
+      ADD_SUBCLASS_CHAIN(impl);
     }
-    ADD_SUBCLASS_CHAIN(impl);
   }
 
   // Recursively process each non-trivial sibling chain.
@@ -1174,8 +1178,9 @@
   } else if (ctx->nof_implementors() != 0) {
     // if it is an interface, it must be unimplemented
     // (if it is not an interface, nof_implementors is always zero)
-    klassOop impl = ctx->implementor(0);
-    return (impl != NULL)? impl: ctxk;
+    klassOop impl = ctx->implementor();
+    assert(impl != NULL, "must be set");
+    return impl;
   } else {
     return NULL;
   }
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -2444,7 +2444,7 @@
   virtual void do_oop(narrowOop* p) { VerifyAllOopsClosure::do_oop_work(p); }
 };
 
-void CompactibleFreeListSpace::verify(bool ignored) const {
+void CompactibleFreeListSpace::verify() const {
   assert_lock_strong(&_freelistLock);
   verify_objects_initialized();
   MemRegion span = _collector->_span;
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -492,7 +492,7 @@
   void print()                            const;
   void print_on(outputStream* st)         const;
   void prepare_for_verify();
-  void verify(bool allow_dirty)           const;
+  void verify()                           const;
   void verifyFreeLists()                  const PRODUCT_RETURN;
   void verifyIndexedFreeLists()           const;
   void verifyIndexedFreeList(size_t size) const;
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -3109,21 +3109,21 @@
 }
 
 void
-ConcurrentMarkSweepGeneration::verify(bool allow_dirty /* ignored */) {
+ConcurrentMarkSweepGeneration::verify() {
   // Locks are normally acquired/released in gc_prologue/gc_epilogue, but those
   // are not called when the heap is verified during universe initialization and
   // at vm shutdown.
   if (freelistLock()->owned_by_self()) {
-    cmsSpace()->verify(false /* ignored */);
+    cmsSpace()->verify();
   } else {
     MutexLockerEx fll(freelistLock(), Mutex::_no_safepoint_check_flag);
-    cmsSpace()->verify(false /* ignored */);
-  }
-}
-
-void CMSCollector::verify(bool allow_dirty /* ignored */) {
-  _cmsGen->verify(allow_dirty);
-  _permGen->verify(allow_dirty);
+    cmsSpace()->verify();
+  }
+}
+
+void CMSCollector::verify() {
+  _cmsGen->verify();
+  _permGen->verify();
 }
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -988,7 +988,7 @@
   CMSGCAdaptivePolicyCounters* gc_adaptive_policy_counters();
 
   // debugging
-  void verify(bool);
+  void verify();
   bool verify_after_remark();
   void verify_ok_to_terminate() const PRODUCT_RETURN;
   void verify_work_stacks_empty() const PRODUCT_RETURN;
@@ -1279,7 +1279,7 @@
 
   // Debugging
   void prepare_for_verify();
-  void verify(bool allow_dirty);
+  void verify();
   void print_statistics()               PRODUCT_RETURN;
 
   // Performance Counters support
--- a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -29,102 +29,6 @@
 #include "gc_implementation/g1/g1ErgoVerbose.hpp"
 #include "memory/space.inline.hpp"
 
-CSetChooserCache::CSetChooserCache() {
-  for (int i = 0; i < CacheLength; ++i)
-    _cache[i] = NULL;
-  clear();
-}
-
-void CSetChooserCache::clear() {
-  _occupancy = 0;
-  _first = 0;
-  for (int i = 0; i < CacheLength; ++i) {
-    HeapRegion *hr = _cache[i];
-    if (hr != NULL)
-      hr->set_sort_index(-1);
-    _cache[i] = NULL;
-  }
-}
-
-#ifndef PRODUCT
-bool CSetChooserCache::verify() {
-  guarantee(false, "CSetChooserCache::verify(): don't call this any more");
-
-  int index = _first;
-  HeapRegion *prev = NULL;
-  for (int i = 0; i < _occupancy; ++i) {
-    guarantee(_cache[index] != NULL, "cache entry should not be empty");
-    HeapRegion *hr = _cache[index];
-    guarantee(!hr->is_young(), "should not be young!");
-    if (prev != NULL) {
-      guarantee(prev->gc_efficiency() >= hr->gc_efficiency(),
-                "cache should be correctly ordered");
-    }
-    guarantee(hr->sort_index() == get_sort_index(index),
-              "sort index should be correct");
-    index = trim_index(index + 1);
-    prev = hr;
-  }
-
-  for (int i = 0; i < (CacheLength - _occupancy); ++i) {
-    guarantee(_cache[index] == NULL, "cache entry should be empty");
-    index = trim_index(index + 1);
-  }
-
-  guarantee(index == _first, "we should have reached where we started from");
-  return true;
-}
-#endif // PRODUCT
-
-void CSetChooserCache::insert(HeapRegion *hr) {
-  guarantee(false, "CSetChooserCache::insert(): don't call this any more");
-
-  assert(!is_full(), "cache should not be empty");
-  hr->calc_gc_efficiency();
-
-  int empty_index;
-  if (_occupancy == 0) {
-    empty_index = _first;
-  } else {
-    empty_index = trim_index(_first + _occupancy);
-    assert(_cache[empty_index] == NULL, "last slot should be empty");
-    int last_index = trim_index(empty_index - 1);
-    HeapRegion *last = _cache[last_index];
-    assert(last != NULL,"as the cache is not empty, last should not be empty");
-    while (empty_index != _first &&
-           last->gc_efficiency() < hr->gc_efficiency()) {
-      _cache[empty_index] = last;
-      last->set_sort_index(get_sort_index(empty_index));
-      empty_index = last_index;
-      last_index = trim_index(last_index - 1);
-      last = _cache[last_index];
-    }
-  }
-  _cache[empty_index] = hr;
-  hr->set_sort_index(get_sort_index(empty_index));
-
-  ++_occupancy;
-  assert(verify(), "cache should be consistent");
-}
-
-HeapRegion *CSetChooserCache::remove_first() {
-  guarantee(false, "CSetChooserCache::remove_first(): "
-                   "don't call this any more");
-
-  if (_occupancy > 0) {
-    assert(_cache[_first] != NULL, "cache should have at least one region");
-    HeapRegion *ret = _cache[_first];
-    _cache[_first] = NULL;
-    ret->set_sort_index(-1);
-    --_occupancy;
-    _first = trim_index(_first + 1);
-    assert(verify(), "cache should be consistent");
-    return ret;
-  } else {
-    return NULL;
-  }
-}
-
 // Even though we don't use the GC efficiency in our heuristics as
 // much as we used to, we still order according to GC efficiency. This
 // will cause regions with a lot of live objects and large RSets to
@@ -134,7 +38,7 @@
 // the ones we'll skip are ones with both large RSets and a lot of
 // live objects, not the ones with just a lot of live objects if we
 // ordered according to the amount of reclaimable bytes per region.
-static int orderRegions(HeapRegion* hr1, HeapRegion* hr2) {
+static int order_regions(HeapRegion* hr1, HeapRegion* hr2) {
   if (hr1 == NULL) {
     if (hr2 == NULL) {
       return 0;
@@ -156,8 +60,8 @@
   }
 }
 
-static int orderRegions(HeapRegion** hr1p, HeapRegion** hr2p) {
-  return orderRegions(*hr1p, *hr2p);
+static int order_regions(HeapRegion** hr1p, HeapRegion** hr2p) {
+  return order_regions(*hr1p, *hr2p);
 }
 
 CollectionSetChooser::CollectionSetChooser() :
@@ -175,105 +79,74 @@
   //
   // Note: containing object is allocated on C heap since it is CHeapObj.
   //
-  _markedRegions((ResourceObj::set_allocation_type((address)&_markedRegions,
+  _regions((ResourceObj::set_allocation_type((address) &_regions,
                                              ResourceObj::C_HEAP),
                   100), true /* C_Heap */),
-    _curr_index(0), _length(0),
-    _regionLiveThresholdBytes(0), _remainingReclaimableBytes(0),
-    _first_par_unreserved_idx(0) {
-  _regionLiveThresholdBytes =
+    _curr_index(0), _length(0), _first_par_unreserved_idx(0),
+    _region_live_threshold_bytes(0), _remaining_reclaimable_bytes(0) {
+  _region_live_threshold_bytes =
     HeapRegion::GrainBytes * (size_t) G1OldCSetRegionLiveThresholdPercent / 100;
 }
 
 #ifndef PRODUCT
-bool CollectionSetChooser::verify() {
-  guarantee(_length >= 0, err_msg("_length: %d", _length));
-  guarantee(0 <= _curr_index && _curr_index <= _length,
-            err_msg("_curr_index: %d _length: %d", _curr_index, _length));
-  int index = 0;
+void CollectionSetChooser::verify() {
+  guarantee(_length <= regions_length(),
+         err_msg("_length: %u regions length: %u", _length, regions_length()));
+  guarantee(_curr_index <= _length,
+            err_msg("_curr_index: %u _length: %u", _curr_index, _length));
+  uint index = 0;
   size_t sum_of_reclaimable_bytes = 0;
   while (index < _curr_index) {
-    guarantee(_markedRegions.at(index) == NULL,
+    guarantee(regions_at(index) == NULL,
               "all entries before _curr_index should be NULL");
     index += 1;
   }
   HeapRegion *prev = NULL;
   while (index < _length) {
-    HeapRegion *curr = _markedRegions.at(index++);
-    guarantee(curr != NULL, "Regions in _markedRegions array cannot be NULL");
-    int si = curr->sort_index();
+    HeapRegion *curr = regions_at(index++);
+    guarantee(curr != NULL, "Regions in _regions array cannot be NULL");
     guarantee(!curr->is_young(), "should not be young!");
     guarantee(!curr->isHumongous(), "should not be humongous!");
-    guarantee(si > -1 && si == (index-1), "sort index invariant");
     if (prev != NULL) {
-      guarantee(orderRegions(prev, curr) != 1,
+      guarantee(order_regions(prev, curr) != 1,
                 err_msg("GC eff prev: %1.4f GC eff curr: %1.4f",
                         prev->gc_efficiency(), curr->gc_efficiency()));
     }
     sum_of_reclaimable_bytes += curr->reclaimable_bytes();
     prev = curr;
   }
-  guarantee(sum_of_reclaimable_bytes == _remainingReclaimableBytes,
+  guarantee(sum_of_reclaimable_bytes == _remaining_reclaimable_bytes,
             err_msg("reclaimable bytes inconsistent, "
                     "remaining: "SIZE_FORMAT" sum: "SIZE_FORMAT,
-                    _remainingReclaimableBytes, sum_of_reclaimable_bytes));
-  return true;
+                    _remaining_reclaimable_bytes, sum_of_reclaimable_bytes));
 }
-#endif
-
-void CollectionSetChooser::fillCache() {
-  guarantee(false, "fillCache: don't call this any more");
+#endif // !PRODUCT
 
-  while (!_cache.is_full() && (_curr_index < _length)) {
-    HeapRegion* hr = _markedRegions.at(_curr_index);
-    assert(hr != NULL,
-           err_msg("Unexpected NULL hr in _markedRegions at index %d",
-                   _curr_index));
-    _curr_index += 1;
-    assert(!hr->is_young(), "should not be young!");
-    assert(hr->sort_index() == _curr_index-1, "sort_index invariant");
-    _markedRegions.at_put(hr->sort_index(), NULL);
-    _cache.insert(hr);
-    assert(!_cache.is_empty(), "cache should not be empty");
-  }
-  assert(verify(), "cache should be consistent");
-}
-
-void CollectionSetChooser::sortMarkedHeapRegions() {
+void CollectionSetChooser::sort_regions() {
   // First trim any unused portion of the top in the parallel case.
   if (_first_par_unreserved_idx > 0) {
-    if (G1PrintParCleanupStats) {
-      gclog_or_tty->print("     Truncating _markedRegions from %d to %d.\n",
-                          _markedRegions.length(), _first_par_unreserved_idx);
-    }
-    assert(_first_par_unreserved_idx <= _markedRegions.length(),
+    assert(_first_par_unreserved_idx <= regions_length(),
            "Or we didn't reserved enough length");
-    _markedRegions.trunc_to(_first_par_unreserved_idx);
+    regions_trunc_to(_first_par_unreserved_idx);
   }
-  _markedRegions.sort(orderRegions);
-  assert(_length <= _markedRegions.length(), "Requirement");
-  assert(_length == 0 || _markedRegions.at(_length - 1) != NULL,
-         "Testing _length");
-  assert(_length == _markedRegions.length() ||
-                        _markedRegions.at(_length) == NULL, "Testing _length");
-  if (G1PrintParCleanupStats) {
-    gclog_or_tty->print_cr("     Sorted %d marked regions.", _length);
+  _regions.sort(order_regions);
+  assert(_length <= regions_length(), "Requirement");
+#ifdef ASSERT
+  for (uint i = 0; i < _length; i++) {
+    assert(regions_at(i) != NULL, "Should be true by sorting!");
   }
-  for (int i = 0; i < _length; i++) {
-    assert(_markedRegions.at(i) != NULL, "Should be true by sorting!");
-    _markedRegions.at(i)->set_sort_index(i);
-  }
+#endif // ASSERT
   if (G1PrintRegionLivenessInfo) {
     G1PrintRegionLivenessInfoClosure cl(gclog_or_tty, "Post-Sorting");
-    for (int i = 0; i < _length; ++i) {
-      HeapRegion* r = _markedRegions.at(i);
+    for (uint i = 0; i < _length; ++i) {
+      HeapRegion* r = regions_at(i);
       cl.doHeapRegion(r);
     }
   }
-  assert(verify(), "CSet chooser verification");
+  verify();
 }
 
-size_t CollectionSetChooser::calcMinOldCSetLength() {
+uint CollectionSetChooser::calc_min_old_cset_length() {
   // The min old CSet region bound is based on the maximum desired
   // number of mixed GCs after a cycle. I.e., even if some old regions
   // look expensive, we should add them to the CSet anyway to make
@@ -291,10 +164,10 @@
   if (result * gc_num < region_num) {
     result += 1;
   }
-  return result;
+  return (uint) result;
 }
 
-size_t CollectionSetChooser::calcMaxOldCSetLength() {
+uint CollectionSetChooser::calc_max_old_cset_length() {
   // The max old CSet region bound is based on the threshold expressed
   // as a percentage of the heap size. I.e., it should bound the
   // number of old regions added to the CSet irrespective of how many
@@ -308,23 +181,23 @@
   if (100 * result < region_num * perc) {
     result += 1;
   }
-  return result;
+  return (uint) result;
 }
 
-void CollectionSetChooser::addMarkedHeapRegion(HeapRegion* hr) {
+void CollectionSetChooser::add_region(HeapRegion* hr) {
   assert(!hr->isHumongous(),
          "Humongous regions shouldn't be added to the collection set");
   assert(!hr->is_young(), "should not be young!");
-  _markedRegions.append(hr);
+  _regions.append(hr);
   _length++;
-  _remainingReclaimableBytes += hr->reclaimable_bytes();
+  _remaining_reclaimable_bytes += hr->reclaimable_bytes();
   hr->calc_gc_efficiency();
 }
 
-void CollectionSetChooser::prepareForAddMarkedHeapRegionsPar(size_t n_regions,
-                                                             size_t chunkSize) {
+void CollectionSetChooser::prepare_for_par_region_addition(uint n_regions,
+                                                           uint chunk_size) {
   _first_par_unreserved_idx = 0;
-  int n_threads = ParallelGCThreads;
+  uint n_threads = (uint) ParallelGCThreads;
   if (UseDynamicNumberOfGCThreads) {
     assert(G1CollectedHeap::heap()->workers()->active_workers() > 0,
       "Should have been set earlier");
@@ -335,57 +208,46 @@
     n_threads = MAX2(G1CollectedHeap::heap()->workers()->active_workers(),
                      1U);
   }
-  size_t max_waste = n_threads * chunkSize;
-  // it should be aligned with respect to chunkSize
-  size_t aligned_n_regions =
-                     (n_regions + (chunkSize - 1)) / chunkSize * chunkSize;
-  assert( aligned_n_regions % chunkSize == 0, "should be aligned" );
-  _markedRegions.at_put_grow((int)(aligned_n_regions + max_waste - 1), NULL);
+  uint max_waste = n_threads * chunk_size;
+  // it should be aligned with respect to chunk_size
+  uint aligned_n_regions = (n_regions + chunk_size - 1) / chunk_size * chunk_size;
+  assert(aligned_n_regions % chunk_size == 0, "should be aligned");
+  regions_at_put_grow(aligned_n_regions + max_waste - 1, NULL);
 }
 
-jint CollectionSetChooser::getParMarkedHeapRegionChunk(jint n_regions) {
-  // Don't do this assert because this can be called at a point
-  // where the loop up stream will not execute again but might
-  // try to claim more chunks (loop test has not been done yet).
-  // assert(_markedRegions.length() > _first_par_unreserved_idx,
-  //  "Striding beyond the marked regions");
-  jint res = Atomic::add(n_regions, &_first_par_unreserved_idx);
-  assert(_markedRegions.length() > res + n_regions - 1,
+uint CollectionSetChooser::claim_array_chunk(uint chunk_size) {
+  uint res = (uint) Atomic::add((jint) chunk_size,
+                                (volatile jint*) &_first_par_unreserved_idx);
+  assert(regions_length() > res + chunk_size - 1,
          "Should already have been expanded");
-  return res - n_regions;
+  return res - chunk_size;
 }
 
-void CollectionSetChooser::setMarkedHeapRegion(jint index, HeapRegion* hr) {
-  assert(_markedRegions.at(index) == NULL, "precondition");
+void CollectionSetChooser::set_region(uint index, HeapRegion* hr) {
+  assert(regions_at(index) == NULL, "precondition");
   assert(!hr->is_young(), "should not be young!");
-  _markedRegions.at_put(index, hr);
+  regions_at_put(index, hr);
   hr->calc_gc_efficiency();
 }
 
-void CollectionSetChooser::updateTotals(jint region_num,
-                                        size_t reclaimable_bytes) {
+void CollectionSetChooser::update_totals(uint region_num,
+                                         size_t reclaimable_bytes) {
   // Only take the lock if we actually need to update the totals.
   if (region_num > 0) {
     assert(reclaimable_bytes > 0, "invariant");
     // We could have just used atomics instead of taking the
     // lock. However, we currently don't have an atomic add for size_t.
     MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
-    _length += (int) region_num;
-    _remainingReclaimableBytes += reclaimable_bytes;
+    _length += region_num;
+    _remaining_reclaimable_bytes += reclaimable_bytes;
   } else {
     assert(reclaimable_bytes == 0, "invariant");
   }
 }
 
-void CollectionSetChooser::clearMarkedHeapRegions() {
-  for (int i = 0; i < _markedRegions.length(); i++) {
-    HeapRegion* r = _markedRegions.at(i);
-    if (r != NULL) {
-      r->set_sort_index(-1);
-    }
-  }
-  _markedRegions.clear();
+void CollectionSetChooser::clear() {
+  _regions.clear();
   _curr_index = 0;
   _length = 0;
-  _remainingReclaimableBytes = 0;
+  _remaining_reclaimable_bytes = 0;
 };
--- a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -28,77 +28,42 @@
 #include "gc_implementation/g1/heapRegion.hpp"
 #include "utilities/growableArray.hpp"
 
-class CSetChooserCache VALUE_OBJ_CLASS_SPEC {
-private:
-  enum {
-    CacheLength = 16
-  } PrivateConstants;
-
-  HeapRegion*  _cache[CacheLength];
-  int          _occupancy; // number of regions in cache
-  int          _first;     // (index of) "first" region in the cache
-
-  // adding CacheLength to deal with negative values
-  inline int trim_index(int index) {
-    return (index + CacheLength) % CacheLength;
-  }
-
-  inline int get_sort_index(int index) {
-    return -index-2;
-  }
-  inline int get_index(int sort_index) {
-    return -sort_index-2;
-  }
-
-public:
-  CSetChooserCache(void);
-
-  inline int occupancy(void) { return _occupancy; }
-  inline bool is_full()      { return _occupancy == CacheLength; }
-  inline bool is_empty()     { return _occupancy == 0; }
-
-  void clear(void);
-  void insert(HeapRegion *hr);
-  HeapRegion *remove_first(void);
-  inline HeapRegion *get_first(void) {
-    return _cache[_first];
-  }
-
-#ifndef PRODUCT
-  bool verify (void);
-  bool region_in_cache(HeapRegion *hr) {
-    int sort_index = hr->sort_index();
-    if (sort_index < -1) {
-      int index = get_index(sort_index);
-      guarantee(index < CacheLength, "should be within bounds");
-      return _cache[index] == hr;
-    } else
-      return 0;
-  }
-#endif // PRODUCT
-};
-
 class CollectionSetChooser: public CHeapObj {
 
-  GrowableArray<HeapRegion*> _markedRegions;
+  GrowableArray<HeapRegion*> _regions;
+
+  // Unfortunately, GrowableArray uses ints for length and indexes. To
+  // avoid excessive casting in the rest of the class the following
+  // wrapper methods are provided that use uints.
+
+  uint regions_length()          { return (uint) _regions.length(); }
+  HeapRegion* regions_at(uint i) { return _regions.at((int) i);     }
+  void regions_at_put(uint i, HeapRegion* hr) {
+    _regions.at_put((int) i, hr);
+  }
+  void regions_at_put_grow(uint i, HeapRegion* hr) {
+    _regions.at_put_grow((int) i, hr);
+  }
+  void regions_trunc_to(uint i)  { _regions.trunc_to((uint) i); }
 
   // The index of the next candidate old region to be considered for
   // addition to the CSet.
-  int _curr_index;
+  uint _curr_index;
 
   // The number of candidate old regions added to the CSet chooser.
-  int _length;
+  uint _length;
 
-  CSetChooserCache _cache;
-  jint _first_par_unreserved_idx;
+  // Keeps track of the start of the next array chunk to be claimed by
+  // parallel GC workers.
+  uint _first_par_unreserved_idx;
 
   // If a region has more live bytes than this threshold, it will not
   // be added to the CSet chooser and will not be a candidate for
   // collection.
-  size_t _regionLiveThresholdBytes;
+  size_t _region_live_threshold_bytes;
 
   // The sum of reclaimable bytes over all the regions in the CSet chooser.
-  size_t _remainingReclaimableBytes;
+  size_t _remaining_reclaimable_bytes;
 
 public:
 
@@ -107,9 +72,9 @@
   HeapRegion* peek() {
     HeapRegion* res = NULL;
     if (_curr_index < _length) {
-      res = _markedRegions.at(_curr_index);
+      res = regions_at(_curr_index);
       assert(res != NULL,
-             err_msg("Unexpected NULL hr in _markedRegions at index %d",
+             err_msg("Unexpected NULL hr in _regions at index %u",
                      _curr_index));
     }
     return res;
@@ -121,90 +86,71 @@
   void remove_and_move_to_next(HeapRegion* hr) {
     assert(hr != NULL, "pre-condition");
     assert(_curr_index < _length, "pre-condition");
-    assert(_markedRegions.at(_curr_index) == hr, "pre-condition");
-    hr->set_sort_index(-1);
-    _markedRegions.at_put(_curr_index, NULL);
-    assert(hr->reclaimable_bytes() <= _remainingReclaimableBytes,
+    assert(regions_at(_curr_index) == hr, "pre-condition");
+    regions_at_put(_curr_index, NULL);
+    assert(hr->reclaimable_bytes() <= _remaining_reclaimable_bytes,
            err_msg("remaining reclaimable bytes inconsistent "
                    "from region: "SIZE_FORMAT" remaining: "SIZE_FORMAT,
-                   hr->reclaimable_bytes(), _remainingReclaimableBytes));
-    _remainingReclaimableBytes -= hr->reclaimable_bytes();
+                   hr->reclaimable_bytes(), _remaining_reclaimable_bytes));
+    _remaining_reclaimable_bytes -= hr->reclaimable_bytes();
     _curr_index += 1;
   }
 
   CollectionSetChooser();
 
-  void sortMarkedHeapRegions();
-  void fillCache();
+  void sort_regions();
 
   // Determine whether to add the given region to the CSet chooser or
   // not. Currently, we skip humongous regions (we never add them to
   // the CSet, we only reclaim them during cleanup) and regions whose
   // live bytes are over the threshold.
-  bool shouldAdd(HeapRegion* hr) {
+  bool should_add(HeapRegion* hr) {
     assert(hr->is_marked(), "pre-condition");
     assert(!hr->is_young(), "should never consider young regions");
     return !hr->isHumongous() &&
-            hr->live_bytes() < _regionLiveThresholdBytes;
+            hr->live_bytes() < _region_live_threshold_bytes;
   }
 
   // Calculate the minimum number of old regions we'll add to the CSet
   // during a mixed GC.
-  size_t calcMinOldCSetLength();
+  uint calc_min_old_cset_length();
 
   // Calculate the maximum number of old regions we'll add to the CSet
   // during a mixed GC.
-  size_t calcMaxOldCSetLength();
+  uint calc_max_old_cset_length();
 
   // Serial version.
-  void addMarkedHeapRegion(HeapRegion *hr);
+  void add_region(HeapRegion *hr);
 
-  // Must be called before calls to getParMarkedHeapRegionChunk.
-  // "n_regions" is the number of regions, "chunkSize" the chunk size.
-  void prepareForAddMarkedHeapRegionsPar(size_t n_regions, size_t chunkSize);
-  // Returns the first index in a contiguous chunk of "n_regions" indexes
+  // Must be called before calls to claim_array_chunk().
+  // n_regions is the number of regions, chunk_size the chunk size.
+  void prepare_for_par_region_addition(uint n_regions, uint chunk_size);
+  // Returns the first index in a contiguous chunk of chunk_size indexes
   // that the calling thread has reserved.  These must be set by the
-  // calling thread using "setMarkedHeapRegion" (to NULL if necessary).
-  jint getParMarkedHeapRegionChunk(jint n_regions);
+  // calling thread using set_region() (to NULL if necessary).
+  uint claim_array_chunk(uint chunk_size);
   // Set the marked array entry at index to hr.  Careful to claim the index
   // first if in parallel.
-  void setMarkedHeapRegion(jint index, HeapRegion* hr);
+  void set_region(uint index, HeapRegion* hr);
   // Atomically increment the number of added regions by region_num
   // and the amount of reclaimable bytes by reclaimable_bytes.
-  void updateTotals(jint region_num, size_t reclaimable_bytes);
+  void update_totals(uint region_num, size_t reclaimable_bytes);
 
-  void clearMarkedHeapRegions();
+  void clear();
 
   // Return the number of candidate regions that remain to be collected.
-  size_t remainingRegions() { return _length - _curr_index; }
+  uint remaining_regions() { return _length - _curr_index; }
 
   // Determine whether the CSet chooser has more candidate regions or not.
-  bool isEmpty() { return remainingRegions() == 0; }
+  bool is_empty() { return remaining_regions() == 0; }
 
   // Return the reclaimable bytes that remain to be collected on
   // all the candidate regions in the CSet chooser.
-  size_t remainingReclaimableBytes () { return _remainingReclaimableBytes; }
+  size_t remaining_reclaimable_bytes() { return _remaining_reclaimable_bytes; }
 
-  // Returns true if the used portion of "_markedRegions" is properly
+  // Returns true if the used portion of "_regions" is properly
   // sorted, otherwise asserts false.
-#ifndef PRODUCT
-  bool verify(void);
-  bool regionProperlyOrdered(HeapRegion* r) {
-    int si = r->sort_index();
-    if (si > -1) {
-      guarantee(_curr_index <= si && si < _length,
-                err_msg("curr: %d sort index: %d: length: %d",
-                        _curr_index, si, _length));
-      guarantee(_markedRegions.at(si) == r,
-                err_msg("sort index: %d at: "PTR_FORMAT" r: "PTR_FORMAT,
-                        si, _markedRegions.at(si), r));
-    } else {
-      guarantee(si == -1, err_msg("sort index: %d", si));
-    }
-    return true;
-  }
-#endif
-
+  void verify() PRODUCT_RETURN;
 };
 
 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -29,6 +29,7 @@
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
 #include "gc_implementation/g1/g1ErgoVerbose.hpp"
+#include "gc_implementation/g1/g1Log.hpp"
 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
 #include "gc_implementation/g1/g1RemSet.hpp"
 #include "gc_implementation/g1/heapRegion.inline.hpp"
@@ -402,8 +403,7 @@
   return MAX2((n_par_threads + 2) / 4, 1U);
 }
 
-ConcurrentMark::ConcurrentMark(ReservedSpace rs,
-                               int max_regions) :
+ConcurrentMark::ConcurrentMark(ReservedSpace rs, uint max_regions) :
   _markBitMap1(rs, MinObjAlignment - 1),
   _markBitMap2(rs, MinObjAlignment - 1),
 
@@ -414,7 +414,7 @@
   _cleanup_sleep_factor(0.0),
   _cleanup_task_overhead(1.0),
   _cleanup_list("Cleanup List"),
-  _region_bm(max_regions, false /* in_resource_area*/),
+  _region_bm((BitMap::idx_t) max_regions, false /* in_resource_area*/),
   _card_bm((rs.size() + CardTableModRefBS::card_size - 1) >>
            CardTableModRefBS::card_shift,
            false /* in_resource_area*/),
@@ -496,7 +496,7 @@
     _task_queues->register_queue(i, task_queue);
 
     _count_card_bitmaps[i] = BitMap(card_bm_size, false);
-    _count_marked_bytes[i] = NEW_C_HEAP_ARRAY(size_t, max_regions);
+    _count_marked_bytes[i] = NEW_C_HEAP_ARRAY(size_t, (size_t) max_regions);
 
     _tasks[i] = new CMTask(i, this,
                            _count_marked_bytes[i],
@@ -846,7 +846,7 @@
     clear_marking_state(concurrent() /* clear_overflow */);
     force_overflow()->update();
 
-    if (PrintGC) {
+    if (G1Log::fine()) {
       gclog_or_tty->date_stamp(PrintGCDateStamps);
       gclog_or_tty->stamp(PrintGCTimeStamps);
       gclog_or_tty->print_cr("[GC concurrent-mark-reset-for-overflow]");
@@ -1119,8 +1119,7 @@
     HandleMark hm;  // handle scope
     gclog_or_tty->print(" VerifyDuringGC:(before)");
     Universe::heap()->prepare_for_verify();
-    Universe::verify(/* allow dirty */ true,
-                     /* silent      */ false,
+    Universe::verify(/* silent      */ false,
                      /* option      */ VerifyOption_G1UsePrevMarking);
   }
 
@@ -1159,8 +1158,7 @@
       HandleMark hm;  // handle scope
       gclog_or_tty->print(" VerifyDuringGC:(after)");
       Universe::heap()->prepare_for_verify();
-      Universe::verify(/* allow dirty */ true,
-                       /* silent      */ false,
+      Universe::verify(/* silent      */ false,
                        /* option      */ VerifyOption_G1UseNextMarking);
     }
     assert(!restart_for_overflow(), "sanity");
@@ -1194,11 +1192,6 @@
   BitMap* _region_bm;
   BitMap* _card_bm;
 
-  // Debugging
-  size_t _tot_words_done;
-  size_t _tot_live;
-  size_t _tot_used;
-
   size_t _region_marked_bytes;
 
   intptr_t _bottom_card_num;
@@ -1217,9 +1210,7 @@
   CalcLiveObjectsClosure(CMBitMapRO *bm, ConcurrentMark *cm,
                          BitMap* region_bm, BitMap* card_bm) :
     _bm(bm), _cm(cm), _region_bm(region_bm), _card_bm(card_bm),
-    _region_marked_bytes(0), _tot_words_done(0),
-    _tot_live(0), _tot_used(0),
-    _bottom_card_num(cm->heap_bottom_card_num()) { }
+    _region_marked_bytes(0), _bottom_card_num(cm->heap_bottom_card_num()) { }
 
   // It takes a region that's not empty (i.e., it has at least one
   // live object in it and sets its corresponding bit on the region
@@ -1229,18 +1220,17 @@
   void set_bit_for_region(HeapRegion* hr) {
     assert(!hr->continuesHumongous(), "should have filtered those out");
 
-    size_t index = hr->hrs_index();
+    BitMap::idx_t index = (BitMap::idx_t) hr->hrs_index();
     if (!hr->startsHumongous()) {
       // Normal (non-humongous) case: just set the bit.
-      _region_bm->par_at_put((BitMap::idx_t) index, true);
+      _region_bm->par_at_put(index, true);
     } else {
       // Starts humongous case: calculate how many regions are part of
       // this humongous region and then set the bit range.
       G1CollectedHeap* g1h = G1CollectedHeap::heap();
       HeapRegion *last_hr = g1h->heap_region_containing_raw(hr->end() - 1);
-      size_t end_index = last_hr->hrs_index() + 1;
-      _region_bm->par_at_put_range((BitMap::idx_t) index,
-                                   (BitMap::idx_t) end_index, true);
+      BitMap::idx_t end_index = (BitMap::idx_t) last_hr->hrs_index() + 1;
+      _region_bm->par_at_put_range(index, end_index, true);
     }
   }
 
@@ -1265,9 +1255,6 @@
                    "start: "PTR_FORMAT", nextTop: "PTR_FORMAT", end: "PTR_FORMAT,
                    start, nextTop, hr->end()));
 
-    // Record the number of word's we'll examine.
-    size_t words_done = (nextTop - start);
-
     // Find the first marked object at or after "start".
     start = _bm->getNextMarkedWordAddress(start, nextTop);
 
@@ -1346,19 +1333,10 @@
     // it can be queried by a calling verificiation routine
     _region_marked_bytes = marked_bytes;
 
-    _tot_live += hr->next_live_bytes();
-    _tot_used += hr->used();
-    _tot_words_done = words_done;
-
     return false;
   }
 
   size_t region_marked_bytes() const { return _region_marked_bytes; }
-
-  // Debugging
-  size_t tot_words_done() const      { return _tot_words_done; }
-  size_t tot_live() const            { return _tot_live; }
-  size_t tot_used() const            { return _tot_used; }
 };
 
 // Heap region closure used for verifying the counting data
@@ -1419,7 +1397,7 @@
     // Verify that _top_at_conc_count == ntams
     if (hr->top_at_conc_mark_count() != hr->next_top_at_mark_start()) {
       if (_verbose) {
-        gclog_or_tty->print_cr("Region " SIZE_FORMAT ": top at conc count incorrect: "
+        gclog_or_tty->print_cr("Region %u: top at conc count incorrect: "
                                "expected " PTR_FORMAT ", actual: " PTR_FORMAT,
                                hr->hrs_index(), hr->next_top_at_mark_start(),
                                hr->top_at_conc_mark_count());
@@ -1435,7 +1413,7 @@
     // we have missed accounting some objects during the actual marking.
     if (exp_marked_bytes > act_marked_bytes) {
       if (_verbose) {
-        gclog_or_tty->print_cr("Region " SIZE_FORMAT ": marked bytes mismatch: "
+        gclog_or_tty->print_cr("Region %u: marked bytes mismatch: "
                                "expected: " SIZE_FORMAT ", actual: " SIZE_FORMAT,
                                hr->hrs_index(), exp_marked_bytes, act_marked_bytes);
       }
@@ -1446,15 +1424,16 @@
     // (which was just calculated) region bit maps.
     // We're not OK if the bit in the calculated expected region
     // bitmap is set and the bit in the actual region bitmap is not.
-    BitMap::idx_t index = (BitMap::idx_t)hr->hrs_index();
+    BitMap::idx_t index = (BitMap::idx_t) hr->hrs_index();
 
     bool expected = _exp_region_bm->at(index);
     bool actual = _region_bm->at(index);
     if (expected && !actual) {
       if (_verbose) {
-        gclog_or_tty->print_cr("Region " SIZE_FORMAT ": region bitmap mismatch: "
-                               "expected: %d, actual: %d",
-                               hr->hrs_index(), expected, actual);
+        gclog_or_tty->print_cr("Region %u: region bitmap mismatch: "
+                               "expected: %s, actual: %s",
+                               hr->hrs_index(),
+                               BOOL_TO_STR(expected), BOOL_TO_STR(actual));
       }
       failures += 1;
     }
@@ -1472,9 +1451,10 @@
 
       if (expected && !actual) {
         if (_verbose) {
-          gclog_or_tty->print_cr("Region " SIZE_FORMAT ": card bitmap mismatch at " SIZE_FORMAT ": "
-                                 "expected: %d, actual: %d",
-                                 hr->hrs_index(), i, expected, actual);
+          gclog_or_tty->print_cr("Region %u: card bitmap mismatch at " SIZE_FORMAT ": "
+                                 "expected: %s, actual: %s",
+                                 hr->hrs_index(), i,
+                                 BOOL_TO_STR(expected), BOOL_TO_STR(actual));
         }
         failures += 1;
       }
@@ -1575,10 +1555,6 @@
   BitMap* _region_bm;
   BitMap* _card_bm;
 
-  size_t _total_live_bytes;
-  size_t _total_used_bytes;
-  size_t _total_words_done;
-
   void set_card_bitmap_range(BitMap::idx_t start_idx, BitMap::idx_t last_idx) {
     assert(start_idx <= last_idx, "sanity");
 
@@ -1604,18 +1580,17 @@
   void set_bit_for_region(HeapRegion* hr) {
     assert(!hr->continuesHumongous(), "should have filtered those out");
 
-    size_t index = hr->hrs_index();
+    BitMap::idx_t index = (BitMap::idx_t) hr->hrs_index();
     if (!hr->startsHumongous()) {
       // Normal (non-humongous) case: just set the bit.
-      _region_bm->par_set_bit((BitMap::idx_t) index);
+      _region_bm->par_set_bit(index);
     } else {
       // Starts humongous case: calculate how many regions are part of
       // this humongous region and then set the bit range.
       G1CollectedHeap* g1h = G1CollectedHeap::heap();
       HeapRegion *last_hr = g1h->heap_region_containing_raw(hr->end() - 1);
-      size_t end_index = last_hr->hrs_index() + 1;
-      _region_bm->par_at_put_range((BitMap::idx_t) index,
-                                   (BitMap::idx_t) end_index, true);
+      BitMap::idx_t end_index = (BitMap::idx_t) last_hr->hrs_index() + 1;
+      _region_bm->par_at_put_range(index, end_index, true);
     }
   }
 
@@ -1623,8 +1598,7 @@
   FinalCountDataUpdateClosure(ConcurrentMark* cm,
                               BitMap* region_bm,
                               BitMap* card_bm) :
-    _cm(cm), _region_bm(region_bm), _card_bm(card_bm),
-    _total_words_done(0), _total_live_bytes(0), _total_used_bytes(0) { }
+    _cm(cm), _region_bm(region_bm), _card_bm(card_bm) { }
 
   bool doHeapRegion(HeapRegion* hr) {
 
@@ -1646,8 +1620,6 @@
     assert(hr->bottom() <= start && start <= hr->end() &&
            hr->bottom() <= ntams && ntams <= hr->end(), "Preconditions.");
 
-    size_t words_done = ntams - hr->bottom();
-
     if (start < ntams) {
       // Region was changed between remark and cleanup pauses
       // We need to add (ntams - start) to the marked bytes
@@ -1678,16 +1650,8 @@
       set_bit_for_region(hr);
     }
 
-    _total_words_done += words_done;
-    _total_used_bytes += hr->used();
-    _total_live_bytes += hr->next_marked_bytes();
-
     return false;
   }
-
-  size_t total_words_done() const { return _total_words_done; }
-  size_t total_live_bytes() const { return _total_live_bytes; }
-  size_t total_used_bytes() const { return _total_used_bytes; }
 };
 
 class G1ParFinalCountTask: public AbstractGangTask {
@@ -1699,9 +1663,6 @@
 
   uint    _n_workers;
 
-  size_t *_live_bytes;
-  size_t *_used_bytes;
-
 public:
   G1ParFinalCountTask(G1CollectedHeap* g1h, BitMap* region_bm, BitMap* card_bm)
     : AbstractGangTask("G1 final counting"),
@@ -1709,8 +1670,7 @@
       _actual_region_bm(region_bm), _actual_card_bm(card_bm),
       _n_workers(0) {
     // Use the value already set as the number of active threads
-    // in the call to run_task().  Needed for the allocation of
-    // _live_bytes and _used_bytes.
+    // in the call to run_task().
     if (G1CollectedHeap::use_parallel_gc_threads()) {
       assert( _g1h->workers()->active_workers() > 0,
         "Should have been previously set");
@@ -1718,14 +1678,6 @@
     } else {
       _n_workers = 1;
     }
-
-    _live_bytes = NEW_C_HEAP_ARRAY(size_t, _n_workers);
-    _used_bytes = NEW_C_HEAP_ARRAY(size_t, _n_workers);
-  }
-
-  ~G1ParFinalCountTask() {
-    FREE_C_HEAP_ARRAY(size_t, _live_bytes);
-    FREE_C_HEAP_ARRAY(size_t, _used_bytes);
   }
 
   void work(uint worker_id) {
@@ -1743,23 +1695,6 @@
     } else {
       _g1h->heap_region_iterate(&final_update_cl);
     }
-
-    _live_bytes[worker_id] = final_update_cl.total_live_bytes();
-    _used_bytes[worker_id] = final_update_cl.total_used_bytes();
-  }
-
-  size_t live_bytes()  {
-    size_t live_bytes = 0;
-    for (uint i = 0; i < _n_workers; ++i)
-      live_bytes += _live_bytes[i];
-    return live_bytes;
-  }
-
-  size_t used_bytes()  {
-    size_t used_bytes = 0;
-    for (uint i = 0; i < _n_workers; ++i)
-      used_bytes += _used_bytes[i];
-    return used_bytes;
   }
 };
 
@@ -1769,7 +1704,7 @@
   G1CollectedHeap* _g1;
   int _worker_num;
   size_t _max_live_bytes;
-  size_t _regions_claimed;
+  uint _regions_claimed;
   size_t _freed_bytes;
   FreeRegionList* _local_cleanup_list;
   OldRegionSet* _old_proxy_set;
@@ -1822,7 +1757,7 @@
   }
 
   size_t max_live_bytes() { return _max_live_bytes; }
-  size_t regions_claimed() { return _regions_claimed; }
+  uint regions_claimed() { return _regions_claimed; }
   double claimed_region_time_sec() { return _claimed_region_time; }
   double max_region_time_sec() { return _max_region_time; }
 };
@@ -1894,15 +1829,6 @@
 
       HeapRegionRemSet::finish_cleanup_task(&hrrs_cleanup_task);
     }
-    double end = os::elapsedTime();
-    if (G1PrintParCleanupStats) {
-      gclog_or_tty->print("     Worker thread %d [%8.3f..%8.3f = %8.3f ms] "
-                          "claimed %u regions (tot = %8.3f ms, max = %8.3f ms).\n",
-                          worker_id, start, end, (end-start)*1000.0,
-                          g1_note_end.regions_claimed(),
-                          g1_note_end.claimed_region_time_sec()*1000.0,
-                          g1_note_end.max_region_time_sec()*1000.0);
-    }
   }
   size_t max_live_bytes() { return _max_live_bytes; }
   size_t freed_bytes() { return _freed_bytes; }
@@ -1949,8 +1875,7 @@
     HandleMark hm;  // handle scope
     gclog_or_tty->print(" VerifyDuringGC:(before)");
     Universe::heap()->prepare_for_verify();
-    Universe::verify(/* allow dirty */ true,
-                     /* silent      */ false,
+    Universe::verify(/* silent      */ false,
                      /* option      */ VerifyOption_G1UsePrevMarking);
   }
 
@@ -2014,29 +1939,11 @@
     guarantee(g1_par_verify_task.failures() == 0, "Unexpected accounting failures");
   }
 
-  size_t known_garbage_bytes =
-    g1_par_count_task.used_bytes() - g1_par_count_task.live_bytes();
-  g1p->set_known_garbage_bytes(known_garbage_bytes);
-
   size_t start_used_bytes = g1h->used();
   g1h->set_marking_complete();
 
-  ergo_verbose4(ErgoConcCycles,
-           "finish cleanup",
-           ergo_format_byte("occupancy")
-           ergo_format_byte("capacity")
-           ergo_format_byte_perc("known garbage"),
-           start_used_bytes, g1h->capacity(),
-           known_garbage_bytes,
-           ((double) known_garbage_bytes / (double) g1h->capacity()) * 100.0);
-
   double count_end = os::elapsedTime();
   double this_final_counting_time = (count_end - start);
-  if (G1PrintParCleanupStats) {
-    gclog_or_tty->print_cr("Cleanup:");
-    gclog_or_tty->print_cr("  Finalize counting: %8.3f ms",
-                           this_final_counting_time*1000.0);
-  }
   _total_counting_time += this_final_counting_time;
 
   if (G1PrintRegionLivenessInfo) {
@@ -2050,7 +1957,6 @@
   g1h->reset_gc_time_stamp();
 
   // Note end of marking in all heap regions.
-  double note_end_start = os::elapsedTime();
   G1ParNoteEndTask g1_par_note_end_task(g1h, &_cleanup_list);
   if (G1CollectedHeap::use_parallel_gc_threads()) {
     g1h->set_par_threads((int)n_workers);
@@ -2069,11 +1975,6 @@
     // regions that there will be more free regions coming soon.
     g1h->set_free_regions_coming();
   }
-  double note_end_end = os::elapsedTime();
-  if (G1PrintParCleanupStats) {
-    gclog_or_tty->print_cr("  note end of marking: %8.3f ms.",
-                           (note_end_end - note_end_start)*1000.0);
-  }
 
   // call below, since it affects the metric by which we sort the heap
   // regions.
@@ -2105,16 +2006,13 @@
   double end = os::elapsedTime();
   _cleanup_times.add((end - start) * 1000.0);
 
-  if (PrintGC || PrintGCDetails) {
+  if (G1Log::fine()) {
     g1h->print_size_transition(gclog_or_tty,
                                start_used_bytes,
                                g1h->used(),
                                g1h->capacity());
   }
 
-  size_t cleaned_up_bytes = start_used_bytes - g1h->used();
-  g1p->decrease_known_garbage_bytes(cleaned_up_bytes);
-
   // Clean up will have freed any regions completely full of garbage.
   // Update the soft reference policy with the new heap occupancy.
   Universe::update_heap_info_at_gc();
@@ -2131,8 +2029,7 @@
     HandleMark hm;  // handle scope
     gclog_or_tty->print(" VerifyDuringGC:(after)");
     Universe::heap()->prepare_for_verify();
-    Universe::verify(/* allow dirty */ true,
-                     /* silent      */ false,
+    Universe::verify(/* silent      */ false,
                      /* option      */ VerifyOption_G1UsePrevMarking);
   }
 
@@ -2149,7 +2046,7 @@
 
   if (G1ConcRegionFreeingVerbose) {
     gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
-                           "cleanup list has "SIZE_FORMAT" entries",
+                           "cleanup list has %u entries",
                            _cleanup_list.length());
   }
 
@@ -2171,9 +2068,8 @@
         _cleanup_list.is_empty()) {
       if (G1ConcRegionFreeingVerbose) {
         gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
-                               "appending "SIZE_FORMAT" entries to the "
-                               "secondary_free_list, clean list still has "
-                               SIZE_FORMAT" entries",
+                               "appending %u entries to the secondary_free_list, "
+                               "cleanup list still has %u entries",
                                tmp_free_list.length(),
                                _cleanup_list.length());
       }
@@ -2446,11 +2342,10 @@
   // Inner scope to exclude the cleaning of the string and symbol
   // tables from the displayed time.
   {
-    bool verbose = PrintGC && PrintGCDetails;
-    if (verbose) {
+    if (G1Log::finer()) {
       gclog_or_tty->put(' ');
     }
-    TraceTime t("GC ref-proc", verbose, false, gclog_or_tty);
+    TraceTime t("GC ref-proc", G1Log::finer(), false, gclog_or_tty);
 
     ReferenceProcessor* rp = g1h->ref_processor_cm();
 
@@ -3144,7 +3039,7 @@
     assert(limit_idx <= end_idx, "or else use atomics");
 
     // Aggregate the "stripe" in the count data associated with hr.
-    size_t hrs_index = hr->hrs_index();
+    uint hrs_index = hr->hrs_index();
     size_t marked_bytes = 0;
 
     for (int i = 0; (size_t)i < _max_task_num; i += 1) {
@@ -3252,7 +3147,7 @@
   // of the final counting task.
   _region_bm.clear();
 
-  size_t max_regions = _g1h->max_regions();
+  uint max_regions = _g1h->max_regions();
   assert(_max_task_num != 0, "unitialized");
 
   for (int i = 0; (size_t) i < _max_task_num; i += 1) {
@@ -3262,7 +3157,7 @@
     assert(task_card_bm->size() == _card_bm.size(), "size mismatch");
     assert(marked_bytes_array != NULL, "uninitialized");
 
-    memset(marked_bytes_array, 0, (max_regions * sizeof(size_t)));
+    memset(marked_bytes_array, 0, (size_t) max_regions * sizeof(size_t));
     task_card_bm->clear();
   }
 }
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -636,7 +636,7 @@
     return _task_queues->steal(task_num, hash_seed, obj);
   }
 
-  ConcurrentMark(ReservedSpace rs, int max_regions);
+  ConcurrentMark(ReservedSpace rs, uint max_regions);
   ~ConcurrentMark();
 
   ConcurrentMarkThread* cmThread() { return _cmThread; }
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -49,7 +49,7 @@
   HeapWord* start = mr.start();
   HeapWord* last = mr.last();
   size_t region_size_bytes = mr.byte_size();
-  size_t index = hr->hrs_index();
+  uint index = hr->hrs_index();
 
   assert(!hr->continuesHumongous(), "should not be HC region");
   assert(hr == g1h->heap_region_containing(start), "sanity");
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -26,6 +26,7 @@
 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
+#include "gc_implementation/g1/g1Log.hpp"
 #include "gc_implementation/g1/g1MMUTracker.hpp"
 #include "gc_implementation/g1/vm_operations_g1.hpp"
 #include "memory/resourceArea.hpp"
@@ -104,7 +105,7 @@
 
       double scan_start = os::elapsedTime();
       if (!cm()->has_aborted()) {
-        if (PrintGC) {
+        if (G1Log::fine()) {
           gclog_or_tty->date_stamp(PrintGCDateStamps);
           gclog_or_tty->stamp(PrintGCTimeStamps);
           gclog_or_tty->print_cr("[GC concurrent-root-region-scan-start]");
@@ -113,7 +114,7 @@
         _cm->scanRootRegions();
 
         double scan_end = os::elapsedTime();
-        if (PrintGC) {
+        if (G1Log::fine()) {
           gclog_or_tty->date_stamp(PrintGCDateStamps);
           gclog_or_tty->stamp(PrintGCTimeStamps);
           gclog_or_tty->print_cr("[GC concurrent-root-region-scan-end, %1.7lf]",
@@ -122,7 +123,7 @@
       }
 
       double mark_start_sec = os::elapsedTime();
-      if (PrintGC) {
+      if (G1Log::fine()) {
         gclog_or_tty->date_stamp(PrintGCDateStamps);
         gclog_or_tty->stamp(PrintGCTimeStamps);
         gclog_or_tty->print_cr("[GC concurrent-mark-start]");
@@ -146,7 +147,7 @@
             os::sleep(current_thread, sleep_time_ms, false);
           }
 
-          if (PrintGC) {
+          if (G1Log::fine()) {
             gclog_or_tty->date_stamp(PrintGCDateStamps);
             gclog_or_tty->stamp(PrintGCTimeStamps);
             gclog_or_tty->print_cr("[GC concurrent-mark-end, %1.7lf sec]",
@@ -165,7 +166,7 @@
         }
 
         if (cm()->restart_for_overflow()) {
-          if (PrintGC) {
+          if (G1Log::fine()) {
             gclog_or_tty->date_stamp(PrintGCDateStamps);
             gclog_or_tty->stamp(PrintGCTimeStamps);
             gclog_or_tty->print_cr("[GC concurrent-mark-restart-for-overflow]");
@@ -211,7 +212,7 @@
         // reclaimed by cleanup.
 
         double cleanup_start_sec = os::elapsedTime();
-        if (PrintGC) {
+        if (G1Log::fine()) {
           gclog_or_tty->date_stamp(PrintGCDateStamps);
           gclog_or_tty->stamp(PrintGCTimeStamps);
           gclog_or_tty->print_cr("[GC concurrent-cleanup-start]");
@@ -232,7 +233,7 @@
         g1h->reset_free_regions_coming();
 
         double cleanup_end_sec = os::elapsedTime();
-        if (PrintGC) {
+        if (G1Log::fine()) {
           gclog_or_tty->date_stamp(PrintGCDateStamps);
           gclog_or_tty->stamp(PrintGCTimeStamps);
           gclog_or_tty->print_cr("[GC concurrent-cleanup-end, %1.7lf]",
@@ -273,7 +274,7 @@
       _sts.leave();
 
       if (cm()->has_aborted()) {
-        if (PrintGC) {
+        if (G1Log::fine()) {
           gclog_or_tty->date_stamp(PrintGCDateStamps);
           gclog_or_tty->stamp(PrintGCTimeStamps);
           gclog_or_tty->print_cr("[GC concurrent-mark-abort]");
--- a/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -140,7 +140,7 @@
 }
 
 void G1AllocRegion::fill_in_ext_msg(ar_ext_msg* msg, const char* message) {
-  msg->append("[%s] %s c: "SIZE_FORMAT" b: %s r: "PTR_FORMAT" u: "SIZE_FORMAT,
+  msg->append("[%s] %s c: %u b: %s r: "PTR_FORMAT" u: "SIZE_FORMAT,
               _name, message, _count, BOOL_TO_STR(_bot_updates),
               _alloc_region, _used_bytes_before);
 }
@@ -215,7 +215,7 @@
       jio_snprintf(rest_buffer, buffer_length, "");
     }
 
-    tty->print_cr("[%s] "SIZE_FORMAT" %s : %s %s",
+    tty->print_cr("[%s] %u %s : %s %s",
                   _name, _count, hr_buffer, str, rest_buffer);
   }
 }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,7 @@
   // the region that is re-used using the set() method. This count can
   // be used in any heuristics that might want to bound how many
   // distinct regions this object can used during an active interval.
-  size_t _count;
+  uint _count;
 
   // When we set up a new active region we save its used bytes in this
   // field so that, when we retire it, we can calculate how much space
@@ -136,7 +136,7 @@
     return (_alloc_region == _dummy_region) ? NULL : _alloc_region;
   }
 
-  size_t count() { return _count; }
+  uint count() { return _count; }
 
   // The following two are the building blocks for the allocation method.
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -33,6 +33,7 @@
 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
 #include "gc_implementation/g1/g1ErgoVerbose.hpp"
 #include "gc_implementation/g1/g1EvacFailure.hpp"
+#include "gc_implementation/g1/g1Log.hpp"
 #include "gc_implementation/g1/g1MarkSweep.hpp"
 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
 #include "gc_implementation/g1/g1RemSet.inline.hpp"
@@ -233,7 +234,7 @@
 bool YoungList::check_list_well_formed() {
   bool ret = true;
 
-  size_t length = 0;
+  uint length = 0;
   HeapRegion* curr = _head;
   HeapRegion* last = NULL;
   while (curr != NULL) {
@@ -252,7 +253,7 @@
 
   if (!ret) {
     gclog_or_tty->print_cr("### YOUNG LIST seems not well formed!");
-    gclog_or_tty->print_cr("###   list has %d entries, _length is %d",
+    gclog_or_tty->print_cr("###   list has %u entries, _length is %u",
                            length, _length);
   }
 
@@ -263,7 +264,7 @@
   bool ret = true;
 
   if (_length != 0) {
-    gclog_or_tty->print_cr("### YOUNG LIST should have 0 length, not %d",
+    gclog_or_tty->print_cr("### YOUNG LIST should have 0 length, not %u",
                   _length);
     ret = false;
   }
@@ -336,8 +337,7 @@
     _g1h->g1_policy()->add_region_to_incremental_cset_rhs(curr);
     young_index_in_cset += 1;
   }
-  assert((size_t) young_index_in_cset == _survivor_length,
-         "post-condition");
+  assert((uint) young_index_in_cset == _survivor_length, "post-condition");
   _g1h->g1_policy()->note_stop_adding_survivor_regions();
 
   _head   = _survivor_head;
@@ -532,7 +532,7 @@
     if (!_secondary_free_list.is_empty()) {
       if (G1ConcRegionFreeingVerbose) {
         gclog_or_tty->print_cr("G1ConcRegionFreeing [region alloc] : "
-                               "secondary_free_list has "SIZE_FORMAT" entries",
+                               "secondary_free_list has %u entries",
                                _secondary_free_list.length());
       }
       // It looks as if there are free regions available on the
@@ -618,12 +618,12 @@
   return res;
 }
 
-size_t G1CollectedHeap::humongous_obj_allocate_find_first(size_t num_regions,
-                                                          size_t word_size) {
+uint G1CollectedHeap::humongous_obj_allocate_find_first(uint num_regions,
+                                                        size_t word_size) {
   assert(isHumongous(word_size), "word_size should be humongous");
   assert(num_regions * HeapRegion::GrainWords >= word_size, "pre-condition");
 
-  size_t first = G1_NULL_HRS_INDEX;
+  uint first = G1_NULL_HRS_INDEX;
   if (num_regions == 1) {
     // Only one region to allocate, no need to go through the slower
     // path. The caller will attempt the expasion if this fails, so
@@ -649,7 +649,7 @@
     if (free_regions() >= num_regions) {
       first = _hrs.find_contiguous(num_regions);
       if (first != G1_NULL_HRS_INDEX) {
-        for (size_t i = first; i < first + num_regions; ++i) {
+        for (uint i = first; i < first + num_regions; ++i) {
           HeapRegion* hr = region_at(i);
           assert(hr->is_empty(), "sanity");
           assert(is_on_master_free_list(hr), "sanity");
@@ -663,15 +663,15 @@
 }
 
 HeapWord*
-G1CollectedHeap::humongous_obj_allocate_initialize_regions(size_t first,
-                                                           size_t num_regions,
+G1CollectedHeap::humongous_obj_allocate_initialize_regions(uint first,
+                                                           uint num_regions,
                                                            size_t word_size) {
   assert(first != G1_NULL_HRS_INDEX, "pre-condition");
   assert(isHumongous(word_size), "word_size should be humongous");
   assert(num_regions * HeapRegion::GrainWords >= word_size, "pre-condition");
 
   // Index of last region in the series + 1.
-  size_t last = first + num_regions;
+  uint last = first + num_regions;
 
   // We need to initialize the region(s) we just discovered. This is
   // a bit tricky given that it can happen concurrently with
@@ -682,7 +682,7 @@
   // a specific order.
 
   // The word size sum of all the regions we will allocate.
-  size_t word_size_sum = num_regions * HeapRegion::GrainWords;
+  size_t word_size_sum = (size_t) num_regions * HeapRegion::GrainWords;
   assert(word_size <= word_size_sum, "sanity");
 
   // This will be the "starts humongous" region.
@@ -721,7 +721,7 @@
   // Then, if there are any, we will set up the "continues
   // humongous" regions.
   HeapRegion* hr = NULL;
-  for (size_t i = first + 1; i < last; ++i) {
+  for (uint i = first + 1; i < last; ++i) {
     hr = region_at(i);
     hr->set_continuesHumongous(first_hr);
   }
@@ -767,7 +767,7 @@
   // last one) is actually used when we will free up the humongous
   // region in free_humongous_region().
   hr = NULL;
-  for (size_t i = first + 1; i < last; ++i) {
+  for (uint i = first + 1; i < last; ++i) {
     hr = region_at(i);
     if ((i + 1) == last) {
       // last continues humongous region
@@ -803,14 +803,14 @@
 
   verify_region_sets_optional();
 
-  size_t num_regions =
-         round_to(word_size, HeapRegion::GrainWords) / HeapRegion::GrainWords;
-  size_t x_size = expansion_regions();
-  size_t fs = _hrs.free_suffix();
-  size_t first = humongous_obj_allocate_find_first(num_regions, word_size);
+  size_t word_size_rounded = round_to(word_size, HeapRegion::GrainWords);
+  uint num_regions = (uint) (word_size_rounded / HeapRegion::GrainWords);
+  uint x_num = expansion_regions();
+  uint fs = _hrs.free_suffix();
+  uint first = humongous_obj_allocate_find_first(num_regions, word_size);
   if (first == G1_NULL_HRS_INDEX) {
     // The only thing we can do now is attempt expansion.
-    if (fs + x_size >= num_regions) {
+    if (fs + x_num >= num_regions) {
       // If the number of regions we're trying to allocate for this
       // object is at most the number of regions in the free suffix,
       // then the call to humongous_obj_allocate_find_first() above
@@ -1255,10 +1255,10 @@
     // Timing
     bool system_gc = (gc_cause() == GCCause::_java_lang_system_gc);
     assert(!system_gc || explicit_gc, "invariant");
-    gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
-    TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
+    gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps);
+    TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
     TraceTime t(system_gc ? "Full GC (System.gc())" : "Full GC",
-                PrintGC, true, gclog_or_tty);
+                G1Log::fine(), true, gclog_or_tty);
 
     TraceCollectorStats tcs(g1mm()->full_collection_counters());
     TraceMemoryManagerStats tms(true /* fullGC */, gc_cause());
@@ -1290,8 +1290,7 @@
       HandleMark hm;  // Discard invalid handles created during verification
       gclog_or_tty->print(" VerifyBeforeGC:");
       prepare_for_verify();
-      Universe::verify(/* allow dirty */ true,
-                       /* silent      */ false,
+      Universe::verify(/* silent      */ false,
                        /* option      */ VerifyOption_G1UsePrevMarking);
 
     }
@@ -1365,8 +1364,7 @@
       HandleMark hm;  // Discard invalid handles created during verification
       gclog_or_tty->print(" VerifyAfterGC:");
       prepare_for_verify();
-      Universe::verify(/* allow dirty */ false,
-                       /* silent      */ false,
+      Universe::verify(/* silent      */ false,
                        /* option      */ VerifyOption_G1UsePrevMarking);
 
     }
@@ -1444,7 +1442,7 @@
       heap_region_iterate(&rebuild_rs);
     }
 
-    if (PrintGC) {
+    if (G1Log::fine()) {
       print_size_transition(gclog_or_tty, g1h_prev_used, used(), capacity());
     }
 
@@ -1782,7 +1780,7 @@
     ReservedSpace::page_align_size_down(shrink_bytes);
   aligned_shrink_bytes = align_size_down(aligned_shrink_bytes,
                                          HeapRegion::GrainBytes);
-  size_t num_regions_deleted = 0;
+  uint num_regions_deleted = 0;
   MemRegion mr = _hrs.shrink_by(aligned_shrink_bytes, &num_regions_deleted);
   HeapWord* old_end = (HeapWord*) _g1_storage.high();
   assert(mr.end() == old_end, "post-condition");
@@ -1917,6 +1915,8 @@
   CollectedHeap::pre_initialize();
   os::enable_vtime();
 
+  G1Log::init();
+
   // Necessary to satisfy locking discipline assertions.
 
   MutexLocker x(Heap_lock);
@@ -2003,7 +2003,7 @@
   _reserved.set_start((HeapWord*)heap_rs.base());
   _reserved.set_end((HeapWord*)(heap_rs.base() + heap_rs.size()));
 
-  _expansion_regions = max_byte_size/HeapRegion::GrainBytes;
+  _expansion_regions = (uint) (max_byte_size / HeapRegion::GrainBytes);
 
   // Create the gen rem set (and barrier set) for the entire reserved region.
   _rem_set = collector_policy()->create_rem_set(_reserved, 2);
@@ -2040,7 +2040,7 @@
 
   // 6843694 - ensure that the maximum region index can fit
   // in the remembered set structures.
-  const size_t max_region_idx = ((size_t)1 << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
+  const uint max_region_idx = (1U << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
   guarantee((max_regions() - 1) <= max_region_idx, "too many regions");
 
   size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
@@ -2056,13 +2056,14 @@
   _g1h = this;
 
    _in_cset_fast_test_length = max_regions();
-   _in_cset_fast_test_base = NEW_C_HEAP_ARRAY(bool, _in_cset_fast_test_length);
+   _in_cset_fast_test_base =
+                   NEW_C_HEAP_ARRAY(bool, (size_t) _in_cset_fast_test_length);
 
    // We're biasing _in_cset_fast_test to avoid subtracting the
    // beginning of the heap every time we want to index; basically
    // it's the same with what we do with the card table.
    _in_cset_fast_test = _in_cset_fast_test_base -
-                ((size_t) _g1_reserved.start() >> HeapRegion::LogOfHRGrainBytes);
+               ((uintx) _g1_reserved.start() >> HeapRegion::LogOfHRGrainBytes);
 
    // Clear the _cset_fast_test bitmap in anticipation of adding
    // regions to the incremental collection set for the first
@@ -2071,7 +2072,7 @@
 
   // Create the ConcurrentMark data structure and thread.
   // (Must do this late, so that "max_regions" is defined.)
-  _cm       = new ConcurrentMark(heap_rs, (int) max_regions());
+  _cm       = new ConcurrentMark(heap_rs, max_regions());
   _cmThread = _cm->cmThread();
 
   // Initialize the from_card cache structure of HeapRegionRemSet.
@@ -2580,7 +2581,7 @@
                                                  uint worker,
                                                  uint no_of_par_workers,
                                                  jint claim_value) {
-  const size_t regions = n_regions();
+  const uint regions = n_regions();
   const uint max_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
                              no_of_par_workers :
                              1);
@@ -2588,11 +2589,11 @@
          no_of_par_workers == workers()->total_workers(),
          "Non dynamic should use fixed number of workers");
   // try to spread out the starting points of the workers
-  const size_t start_index = regions / max_workers * (size_t) worker;
+  const uint start_index = regions / max_workers * worker;
 
   // each worker will actually look at all regions
-  for (size_t count = 0; count < regions; ++count) {
-    const size_t index = (start_index + count) % regions;
+  for (uint count = 0; count < regions; ++count) {
+    const uint index = (start_index + count) % regions;
     assert(0 <= index && index < regions, "sanity");
     HeapRegion* r = region_at(index);
     // we'll ignore "continues humongous" regions (we'll process them
@@ -2614,7 +2615,7 @@
         // result, we might end up processing them twice. So, we'll do
         // them first (notice: most closures will ignore them anyway) and
         // then we'll do the "starts humongous" region.
-        for (size_t ch_index = index + 1; ch_index < regions; ++ch_index) {
+        for (uint ch_index = index + 1; ch_index < regions; ++ch_index) {
           HeapRegion* chr = region_at(ch_index);
 
           // if the region has already been claimed or it's not
@@ -2682,8 +2683,9 @@
 class CheckClaimValuesClosure : public HeapRegionClosure {
 private:
   jint _claim_value;
-  size_t _failures;
+  uint _failures;
   HeapRegion* _sh_region;
+
 public:
   CheckClaimValuesClosure(jint claim_value) :
     _claim_value(claim_value), _failures(0), _sh_region(NULL) { }
@@ -2711,9 +2713,7 @@
     }
     return false;
   }
-  size_t failures() {
-    return _failures;
-  }
+  uint failures() { return _failures; }
 };
 
 bool G1CollectedHeap::check_heap_region_claim_values(jint claim_value) {
@@ -2723,17 +2723,15 @@
 }
 
 class CheckClaimValuesInCSetHRClosure: public HeapRegionClosure {
-  jint   _claim_value;
-  size_t _failures;
+private:
+  jint _claim_value;
+  uint _failures;
 
 public:
   CheckClaimValuesInCSetHRClosure(jint claim_value) :
-    _claim_value(claim_value),
-    _failures(0) { }
-
-  size_t failures() {
-    return _failures;
-  }
+    _claim_value(claim_value), _failures(0) { }
+
+  uint failures() { return _failures; }
 
   bool doHeapRegion(HeapRegion* hr) {
     assert(hr->in_collection_set(), "how?");
@@ -2800,14 +2798,14 @@
 
   result = g1_policy()->collection_set();
   if (G1CollectedHeap::use_parallel_gc_threads()) {
-    size_t cs_size = g1_policy()->cset_region_length();
+    uint cs_size = g1_policy()->cset_region_length();
     uint active_workers = workers()->active_workers();
     assert(UseDynamicNumberOfGCThreads ||
              active_workers == workers()->total_workers(),
              "Unless dynamic should use total workers");
 
-    size_t end_ind   = (cs_size * worker_i) / active_workers;
-    size_t start_ind = 0;
+    uint end_ind   = (cs_size * worker_i) / active_workers;
+    uint start_ind = 0;
 
     if (worker_i > 0 &&
         _worker_cset_start_region_time_stamp[worker_i - 1] == gc_time_stamp) {
@@ -2817,7 +2815,7 @@
       result = _worker_cset_start_region[worker_i - 1];
     }
 
-    for (size_t i = start_ind; i < end_ind; i++) {
+    for (uint i = start_ind; i < end_ind; i++) {
       result = result->next_in_collection_set();
     }
   }
@@ -3033,7 +3031,6 @@
 
 class VerifyRegionClosure: public HeapRegionClosure {
 private:
-  bool         _allow_dirty;
   bool         _par;
   VerifyOption _vo;
   bool         _failures;
@@ -3041,9 +3038,8 @@
   // _vo == UsePrevMarking -> use "prev" marking information,
   // _vo == UseNextMarking -> use "next" marking information,
   // _vo == UseMarkWord    -> use mark word from object header.
-  VerifyRegionClosure(bool allow_dirty, bool par, VerifyOption vo)
-    : _allow_dirty(allow_dirty),
-      _par(par),
+  VerifyRegionClosure(bool par, VerifyOption vo)
+    : _par(par),
       _vo(vo),
       _failures(false) {}
 
@@ -3056,7 +3052,7 @@
               "Should be unclaimed at verify points.");
     if (!r->continuesHumongous()) {
       bool failures = false;
-      r->verify(_allow_dirty, _vo, &failures);
+      r->verify(_vo, &failures);
       if (failures) {
         _failures = true;
       } else {
@@ -3124,7 +3120,6 @@
 class G1ParVerifyTask: public AbstractGangTask {
 private:
   G1CollectedHeap* _g1h;
-  bool             _allow_dirty;
   VerifyOption     _vo;
   bool             _failures;
 
@@ -3132,10 +3127,9 @@
   // _vo == UsePrevMarking -> use "prev" marking information,
   // _vo == UseNextMarking -> use "next" marking information,
   // _vo == UseMarkWord    -> use mark word from object header.
-  G1ParVerifyTask(G1CollectedHeap* g1h, bool allow_dirty, VerifyOption vo) :
+  G1ParVerifyTask(G1CollectedHeap* g1h, VerifyOption vo) :
     AbstractGangTask("Parallel verify task"),
     _g1h(g1h),
-    _allow_dirty(allow_dirty),
     _vo(vo),
     _failures(false) { }
 
@@ -3145,7 +3139,7 @@
 
   void work(uint worker_id) {
     HandleMark hm;
-    VerifyRegionClosure blk(_allow_dirty, true, _vo);
+    VerifyRegionClosure blk(true, _vo);
     _g1h->heap_region_par_iterate_chunked(&blk, worker_id,
                                           _g1h->workers()->active_workers(),
                                           HeapRegion::ParVerifyClaimValue);
@@ -3155,12 +3149,11 @@
   }
 };
 
-void G1CollectedHeap::verify(bool allow_dirty, bool silent) {
-  verify(allow_dirty, silent, VerifyOption_G1UsePrevMarking);
-}
-
-void G1CollectedHeap::verify(bool allow_dirty,
-                             bool silent,
+void G1CollectedHeap::verify(bool silent) {
+  verify(silent, VerifyOption_G1UsePrevMarking);
+}
+
+void G1CollectedHeap::verify(bool silent,
                              VerifyOption vo) {
   if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) {
     if (!silent) { gclog_or_tty->print("Roots (excluding permgen) "); }
@@ -3212,7 +3205,7 @@
       assert(check_heap_region_claim_values(HeapRegion::InitialClaimValue),
              "sanity check");
 
-      G1ParVerifyTask task(this, allow_dirty, vo);
+      G1ParVerifyTask task(this, vo);
       assert(UseDynamicNumberOfGCThreads ||
         workers()->active_workers() == workers()->total_workers(),
         "If not dynamic should be using all the workers");
@@ -3234,7 +3227,7 @@
       assert(check_heap_region_claim_values(HeapRegion::InitialClaimValue),
              "sanity check");
     } else {
-      VerifyRegionClosure blk(allow_dirty, false, vo);
+      VerifyRegionClosure blk(false, vo);
       heap_region_iterate(&blk);
       if (blk.failures()) {
         failures = true;
@@ -3284,12 +3277,12 @@
             _g1_storage.high_boundary());
   st->cr();
   st->print("  region size " SIZE_FORMAT "K, ", HeapRegion::GrainBytes / K);
-  size_t young_regions = _young_list->length();
-  st->print(SIZE_FORMAT " young (" SIZE_FORMAT "K), ",
-            young_regions, young_regions * HeapRegion::GrainBytes / K);
-  size_t survivor_regions = g1_policy()->recorded_survivor_regions();
-  st->print(SIZE_FORMAT " survivors (" SIZE_FORMAT "K)",
-            survivor_regions, survivor_regions * HeapRegion::GrainBytes / K);
+  uint young_regions = _young_list->length();
+  st->print("%u young (" SIZE_FORMAT "K), ", young_regions,
+            (size_t) young_regions * HeapRegion::GrainBytes / K);
+  uint survivor_regions = g1_policy()->recorded_survivor_regions();
+  st->print("%u survivors (" SIZE_FORMAT "K)", survivor_regions,
+            (size_t) survivor_regions * HeapRegion::GrainBytes / K);
   st->cr();
   perm()->as_gen()->print_on(st);
 }
@@ -3299,7 +3292,11 @@
 
   // Print the per-region information.
   st->cr();
-  st->print_cr("Heap Regions: (Y=young(eden), SU=young(survivor), HS=humongous(starts), HC=humongous(continues), CS=collection set, F=free, TS=gc time stamp, PTAMS=previous top-at-mark-start, NTAMS=next top-at-mark-start)");
+  st->print_cr("Heap Regions: (Y=young(eden), SU=young(survivor), "
+               "HS=humongous(starts), HC=humongous(continues), "
+               "CS=collection set, F=free, TS=gc time stamp, "
+               "PTAMS=previous top-at-mark-start, "
+               "NTAMS=next top-at-mark-start)");
   PrintRegionClosure blk(st);
   heap_region_iterate(&blk);
 }
@@ -3477,16 +3474,16 @@
 
 void
 G1CollectedHeap::setup_surviving_young_words() {
-  guarantee( _surviving_young_words == NULL, "pre-condition" );
-  size_t array_length = g1_policy()->young_cset_region_length();
-  _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, array_length);
+  assert(_surviving_young_words == NULL, "pre-condition");
+  uint array_length = g1_policy()->young_cset_region_length();
+  _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length);
   if (_surviving_young_words == NULL) {
     vm_exit_out_of_memory(sizeof(size_t) * array_length,
                           "Not enough space for young surv words summary.");
   }
-  memset(_surviving_young_words, 0, array_length * sizeof(size_t));
+  memset(_surviving_young_words, 0, (size_t) array_length * sizeof(size_t));
 #ifdef ASSERT
-  for (size_t i = 0;  i < array_length; ++i) {
+  for (uint i = 0;  i < array_length; ++i) {
     assert( _surviving_young_words[i] == 0, "memset above" );
   }
 #endif // !ASSERT
@@ -3495,9 +3492,10 @@
 void
 G1CollectedHeap::update_surviving_young_words(size_t* surv_young_words) {
   MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
-  size_t array_length = g1_policy()->young_cset_region_length();
-  for (size_t i = 0; i < array_length; ++i)
+  uint array_length = g1_policy()->young_cset_region_length();
+  for (uint i = 0; i < array_length; ++i) {
     _surviving_young_words[i] += surv_young_words[i];
+  }
 }
 
 void
@@ -3609,12 +3607,12 @@
       increment_total_full_collections();
     }
 
-    // if PrintGCDetails is on, we'll print long statistics information
+    // if the log level is "finer" is on, we'll print long statistics information
     // in the collector policy code, so let's not print this as the output
     // is messy if we do.
-    gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
-    TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
-    TraceTime t(verbose_str, PrintGC && !PrintGCDetails, true, gclog_or_tty);
+    gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps);
+    TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
+    TraceTime t(verbose_str, G1Log::fine() && !G1Log::finer(), true, gclog_or_tty);
 
     TraceCollectorStats tcs(g1mm()->incremental_collection_counters());
     TraceMemoryManagerStats tms(false /* fullGC */, gc_cause());
@@ -3647,8 +3645,7 @@
         HandleMark hm;  // Discard invalid handles created during verification
         gclog_or_tty->print(" VerifyBeforeGC:");
         prepare_for_verify();
-        Universe::verify(/* allow dirty */ false,
-                         /* silent      */ false,
+        Universe::verify(/* silent      */ false,
                          /* option      */ VerifyOption_G1UsePrevMarking);
       }
 
@@ -3892,8 +3889,7 @@
           HandleMark hm;  // Discard invalid handles created during verification
           gclog_or_tty->print(" VerifyAfterGC:");
           prepare_for_verify();
-          Universe::verify(/* allow dirty */ true,
-                           /* silent      */ false,
+          Universe::verify(/* silent      */ false,
                            /* option      */ VerifyOption_G1UsePrevMarking);
         }
 
@@ -3931,8 +3927,8 @@
   }
 
   // The closing of the inner scope, immediately above, will complete
-  // the PrintGC logging output. The record_collection_pause_end() call
-  // above will complete the logging output of PrintGCDetails.
+  // logging at the "fine" level. The record_collection_pause_end() call
+  // above will complete logging at the "finer" level.
   //
   // It is not yet to safe, however, to tell the concurrent mark to
   // start as we have some optional output below. We don't want the
@@ -4068,7 +4064,6 @@
 
 void G1CollectedHeap::remove_self_forwarding_pointers() {
   assert(check_cset_heap_region_claim_values(HeapRegion::InitialClaimValue), "sanity");
-  assert(g1_policy()->assertMarkedBytesDataOK(), "Should be!");
 
   G1ParRemoveSelfForwardPtrsTask rsfp_task(this);
 
@@ -4086,7 +4081,6 @@
   reset_cset_heap_region_claim_values();
 
   assert(check_cset_heap_region_claim_values(HeapRegion::InitialClaimValue), "sanity");
-  assert(g1_policy()->assertMarkedBytesDataOK(), "Should be!");
 
   // Now restore saved marks, if any.
   if (_objs_with_preserved_marks != NULL) {
@@ -4248,16 +4242,16 @@
   // non-young regions (where the age is -1)
   // We also add a few elements at the beginning and at the end in
   // an attempt to eliminate cache contention
-  size_t real_length = 1 + _g1h->g1_policy()->young_cset_region_length();
-  size_t array_length = PADDING_ELEM_NUM +
-                        real_length +
-                        PADDING_ELEM_NUM;
+  uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length();
+  uint array_length = PADDING_ELEM_NUM +
+                      real_length +
+                      PADDING_ELEM_NUM;
   _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length);
   if (_surviving_young_words_base == NULL)
     vm_exit_out_of_memory(array_length * sizeof(size_t),
                           "Not enough space for young surv histo.");
   _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
-  memset(_surviving_young_words, 0, real_length * sizeof(size_t));
+  memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t));
 
   _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer;
   _alloc_buffers[GCAllocForTenured]  = &_tenured_alloc_buffer;
@@ -4394,7 +4388,7 @@
 template <bool do_gen_barrier, G1Barrier barrier, bool do_mark_object>
 oop G1ParCopyClosure<do_gen_barrier, barrier, do_mark_object>
   ::copy_to_survivor_space(oop old) {
-  size_t    word_sz = old->size();
+  size_t word_sz = old->size();
   HeapRegion* from_region = _g1->heap_region_containing_raw(old);
   // +1 to make the -1 indexes valid...
   int       young_index = from_region->young_index_in_cset()+1;
@@ -5514,9 +5508,9 @@
 
   if (evacuation_failed()) {
     remove_self_forwarding_pointers();
-    if (PrintGCDetails) {
+    if (G1Log::finer()) {
       gclog_or_tty->print(" (to-space overflow)");
-    } else if (PrintGC) {
+    } else if (G1Log::fine()) {
       gclog_or_tty->print("--");
     }
   }
@@ -5591,8 +5585,8 @@
   hr->set_notHumongous();
   free_region(hr, &hr_pre_used, free_list, par);
 
-  size_t i = hr->hrs_index() + 1;
-  size_t num = 1;
+  uint i = hr->hrs_index() + 1;
+  uint num = 1;
   while (i < n_regions()) {
     HeapRegion* curr_hr = region_at(i);
     if (!curr_hr->continuesHumongous()) {
@@ -5801,7 +5795,7 @@
     if (cur->is_young()) {
       int index = cur->young_index_in_cset();
       assert(index != -1, "invariant");
-      assert((size_t) index < policy->young_cset_region_length(), "invariant");
+      assert((uint) index < policy->young_cset_region_length(), "invariant");
       size_t words_survived = _surviving_young_words[index];
       cur->record_surv_words_in_group(words_survived);
 
@@ -6141,7 +6135,7 @@
 // Methods for the GC alloc regions
 
 HeapRegion* G1CollectedHeap::new_gc_alloc_region(size_t word_size,
-                                                 size_t count,
+                                                 uint count,
                                                  GCAllocPurpose ap) {
   assert(FreeList_lock->owned_by_self(), "pre-condition");
 
@@ -6213,7 +6207,7 @@
   FreeRegionList*     _free_list;
   OldRegionSet*       _old_set;
   HumongousRegionSet* _humongous_set;
-  size_t              _region_count;
+  uint                _region_count;
 
 public:
   VerifyRegionListsClosure(OldRegionSet* old_set,
@@ -6222,7 +6216,7 @@
     _old_set(old_set), _humongous_set(humongous_set),
     _free_list(free_list), _region_count(0) { }
 
-  size_t region_count()      { return _region_count;      }
+  uint region_count() { return _region_count; }
 
   bool doHeapRegion(HeapRegion* hr) {
     _region_count += 1;
@@ -6244,7 +6238,7 @@
   }
 };
 
-HeapRegion* G1CollectedHeap::new_heap_region(size_t hrs_index,
+HeapRegion* G1CollectedHeap::new_heap_region(uint hrs_index,
                                              HeapWord* bottom) {
   HeapWord* end = bottom + HeapRegion::GrainWords;
   MemRegion mr(bottom, end);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -85,8 +85,8 @@
 
   HeapRegion* _curr;
 
-  size_t      _length;
-  size_t      _survivor_length;
+  uint        _length;
+  uint        _survivor_length;
 
   size_t      _last_sampled_rs_lengths;
   size_t      _sampled_rs_lengths;
@@ -101,8 +101,8 @@
 
   void         empty_list();
   bool         is_empty() { return _length == 0; }
-  size_t       length() { return _length; }
-  size_t       survivor_length() { return _survivor_length; }
+  uint         length() { return _length; }
+  uint         survivor_length() { return _survivor_length; }
 
   // Currently we do not keep track of the used byte sum for the
   // young list and the survivors and it'd be quite a lot of work to
@@ -111,10 +111,10 @@
   // we'll report the more accurate information then.
   size_t       eden_used_bytes() {
     assert(length() >= survivor_length(), "invariant");
-    return (length() - survivor_length()) * HeapRegion::GrainBytes;
+    return (size_t) (length() - survivor_length()) * HeapRegion::GrainBytes;
   }
   size_t       survivor_used_bytes() {
-    return survivor_length() * HeapRegion::GrainBytes;
+    return (size_t) survivor_length() * HeapRegion::GrainBytes;
   }
 
   void rs_length_sampling_init();
@@ -247,7 +247,7 @@
   MasterHumongousRegionSet  _humongous_set;
 
   // The number of regions we could create by expansion.
-  size_t _expansion_regions;
+  uint _expansion_regions;
 
   // The block offset table for the G1 heap.
   G1BlockOffsetSharedArray* _bot_shared;
@@ -339,7 +339,7 @@
   bool* _in_cset_fast_test_base;
 
   // The length of the _in_cset_fast_test_base array.
-  size_t _in_cset_fast_test_length;
+  uint _in_cset_fast_test_length;
 
   volatile unsigned _gc_time_stamp;
 
@@ -458,14 +458,14 @@
   // length and remove them from the master free list. Return the
   // index of the first region or G1_NULL_HRS_INDEX if the search
   // was unsuccessful.
-  size_t humongous_obj_allocate_find_first(size_t num_regions,
-                                           size_t word_size);
+  uint humongous_obj_allocate_find_first(uint num_regions,
+                                         size_t word_size);
 
   // Initialize a contiguous set of free regions of length num_regions
   // and starting at index first so that they appear as a single
   // humongous region.
-  HeapWord* humongous_obj_allocate_initialize_regions(size_t first,
-                                                      size_t num_regions,
+  HeapWord* humongous_obj_allocate_initialize_regions(uint first,
+                                                      uint num_regions,
                                                       size_t word_size);
 
   // Attempt to allocate a humongous object of the given size. Return
@@ -574,7 +574,7 @@
                                    size_t allocated_bytes);
 
   // For GC alloc regions.
-  HeapRegion* new_gc_alloc_region(size_t word_size, size_t count,
+  HeapRegion* new_gc_alloc_region(size_t word_size, uint count,
                                   GCAllocPurpose ap);
   void retire_gc_alloc_region(HeapRegion* alloc_region,
                               size_t allocated_bytes, GCAllocPurpose ap);
@@ -641,7 +641,7 @@
   void register_region_with_in_cset_fast_test(HeapRegion* r) {
     assert(_in_cset_fast_test_base != NULL, "sanity");
     assert(r->in_collection_set(), "invariant");
-    size_t index = r->hrs_index();
+    uint index = r->hrs_index();
     assert(index < _in_cset_fast_test_length, "invariant");
     assert(!_in_cset_fast_test_base[index], "invariant");
     _in_cset_fast_test_base[index] = true;
@@ -655,7 +655,7 @@
     if (_g1_committed.contains((HeapWord*) obj)) {
       // no need to subtract the bottom of the heap from obj,
       // _in_cset_fast_test is biased
-      size_t index = ((size_t) obj) >> HeapRegion::LogOfHRGrainBytes;
+      uintx index = (uintx) obj >> HeapRegion::LogOfHRGrainBytes;
       bool ret = _in_cset_fast_test[index];
       // let's make sure the result is consistent with what the slower
       // test returns
@@ -670,7 +670,7 @@
   void clear_cset_fast_test() {
     assert(_in_cset_fast_test_base != NULL, "sanity");
     memset(_in_cset_fast_test_base, false,
-        _in_cset_fast_test_length * sizeof(bool));
+           (size_t) _in_cset_fast_test_length * sizeof(bool));
   }
 
   // This is called at the end of either a concurrent cycle or a Full
@@ -1101,23 +1101,23 @@
   }
 
   // The total number of regions in the heap.
-  size_t n_regions() { return _hrs.length(); }
+  uint n_regions() { return _hrs.length(); }
 
   // The max number of regions in the heap.
-  size_t max_regions() { return _hrs.max_length(); }
+  uint max_regions() { return _hrs.max_length(); }
 
   // The number of regions that are completely free.
-  size_t free_regions() { return _free_list.length(); }
+  uint free_regions() { return _free_list.length(); }
 
   // The number of regions that are not completely free.
-  size_t used_regions() { return n_regions() - free_regions(); }
+  uint used_regions() { return n_regions() - free_regions(); }
 
   // The number of regions available for "regular" expansion.
-  size_t expansion_regions() { return _expansion_regions; }
+  uint expansion_regions() { return _expansion_regions; }
 
   // Factory method for HeapRegion instances. It will return NULL if
   // the allocation fails.
-  HeapRegion* new_heap_region(size_t hrs_index, HeapWord* bottom);
+  HeapRegion* new_heap_region(uint hrs_index, HeapWord* bottom);
 
   void verify_not_dirty_region(HeapRegion* hr) PRODUCT_RETURN;
   void verify_dirty_region(HeapRegion* hr) PRODUCT_RETURN;
@@ -1301,7 +1301,7 @@
   void heap_region_iterate_from(HeapRegion* r, HeapRegionClosure* blk) const;
 
   // Return the region with the given index. It assumes the index is valid.
-  HeapRegion* region_at(size_t index) const { return _hrs.at(index); }
+  HeapRegion* region_at(uint index) const { return _hrs.at(index); }
 
   // Divide the heap region sequence into "chunks" of some size (the number
   // of regions divided by the number of parallel threads times some
@@ -1504,10 +1504,10 @@
   // Currently there is only one place where this is called with
   // vo == UseMarkWord, which is to verify the marking during a
   // full GC.
-  void verify(bool allow_dirty, bool silent, VerifyOption vo);
+  void verify(bool silent, VerifyOption vo);
 
   // Override; it uses the "prev" marking information
-  virtual void verify(bool allow_dirty, bool silent);
+  virtual void verify(bool silent);
   virtual void print_on(outputStream* st) const;
   virtual void print_extended_on(outputStream* st) const;
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -29,6 +29,7 @@
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
 #include "gc_implementation/g1/g1ErgoVerbose.hpp"
+#include "gc_implementation/g1/g1Log.hpp"
 #include "gc_implementation/g1/heapRegionRemSet.hpp"
 #include "gc_implementation/shared/gcPolicyCounters.hpp"
 #include "runtime/arguments.hpp"
@@ -191,11 +192,6 @@
   _in_marking_window(false),
   _in_marking_window_im(false),
 
-  _known_garbage_ratio(0.0),
-  _known_garbage_bytes(0),
-
-  _young_gc_eff_seq(new TruncatedSeq(TruncatedSeqLength)),
-
   _recent_prev_end_times_for_all_gcs_sec(
                                 new TruncatedSeq(NumPrevPausesForHeuristics)),
 
@@ -430,31 +426,36 @@
   }
 
   if (FLAG_IS_CMDLINE(NewSize)) {
-     _min_desired_young_length = MAX2((size_t) 1, NewSize / HeapRegion::GrainBytes);
+    _min_desired_young_length = MAX2((uint) (NewSize / HeapRegion::GrainBytes),
+                                     1U);
     if (FLAG_IS_CMDLINE(MaxNewSize)) {
-      _max_desired_young_length = MAX2((size_t) 1, MaxNewSize / HeapRegion::GrainBytes);
+      _max_desired_young_length =
+                             MAX2((uint) (MaxNewSize / HeapRegion::GrainBytes),
+                                  1U);
       _sizer_kind = SizerMaxAndNewSize;
       _adaptive_size = _min_desired_young_length == _max_desired_young_length;
     } else {
       _sizer_kind = SizerNewSizeOnly;
     }
   } else if (FLAG_IS_CMDLINE(MaxNewSize)) {
-    _max_desired_young_length = MAX2((size_t) 1, MaxNewSize / HeapRegion::GrainBytes);
+    _max_desired_young_length =
+                             MAX2((uint) (MaxNewSize / HeapRegion::GrainBytes),
+                                  1U);
     _sizer_kind = SizerMaxNewSizeOnly;
   }
 }
 
-size_t G1YoungGenSizer::calculate_default_min_length(size_t new_number_of_heap_regions) {
-  size_t default_value = (new_number_of_heap_regions * G1DefaultMinNewGenPercent) / 100;
-  return MAX2((size_t)1, default_value);
+uint G1YoungGenSizer::calculate_default_min_length(uint new_number_of_heap_regions) {
+  uint default_value = (new_number_of_heap_regions * G1DefaultMinNewGenPercent) / 100;
+  return MAX2(1U, default_value);
 }
 
-size_t G1YoungGenSizer::calculate_default_max_length(size_t new_number_of_heap_regions) {
-  size_t default_value = (new_number_of_heap_regions * G1DefaultMaxNewGenPercent) / 100;
-  return MAX2((size_t)1, default_value);
+uint G1YoungGenSizer::calculate_default_max_length(uint new_number_of_heap_regions) {
+  uint default_value = (new_number_of_heap_regions * G1DefaultMaxNewGenPercent) / 100;
+  return MAX2(1U, default_value);
 }
 
-void G1YoungGenSizer::heap_size_changed(size_t new_number_of_heap_regions) {
+void G1YoungGenSizer::heap_size_changed(uint new_number_of_heap_regions) {
   assert(new_number_of_heap_regions > 0, "Heap must be initialized");
 
   switch (_sizer_kind) {
@@ -511,16 +512,16 @@
   _gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 3);
 }
 
-bool G1CollectorPolicy::predict_will_fit(size_t young_length,
+bool G1CollectorPolicy::predict_will_fit(uint young_length,
                                          double base_time_ms,
-                                         size_t base_free_regions,
+                                         uint base_free_regions,
                                          double target_pause_time_ms) {
   if (young_length >= base_free_regions) {
     // end condition 1: not enough space for the young regions
     return false;
   }
 
-  double accum_surv_rate = accum_yg_surv_rate_pred((int)(young_length - 1));
+  double accum_surv_rate = accum_yg_surv_rate_pred((int) young_length - 1);
   size_t bytes_to_copy =
                (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes);
   double copy_time_ms = predict_object_copy_time_ms(bytes_to_copy);
@@ -532,7 +533,7 @@
   }
 
   size_t free_bytes =
-                  (base_free_regions - young_length) * HeapRegion::GrainBytes;
+                   (base_free_regions - young_length) * HeapRegion::GrainBytes;
   if ((2.0 * sigma()) * (double) bytes_to_copy > (double) free_bytes) {
     // end condition 3: out-of-space (conservatively!)
     return false;
@@ -542,25 +543,25 @@
   return true;
 }
 
-void G1CollectorPolicy::record_new_heap_size(size_t new_number_of_regions) {
+void G1CollectorPolicy::record_new_heap_size(uint new_number_of_regions) {
   // re-calculate the necessary reserve
   double reserve_regions_d = (double) new_number_of_regions * _reserve_factor;
   // We use ceiling so that if reserve_regions_d is > 0.0 (but
   // smaller than 1.0) we'll get 1.
-  _reserve_regions = (size_t) ceil(reserve_regions_d);
+  _reserve_regions = (uint) ceil(reserve_regions_d);
 
   _young_gen_sizer->heap_size_changed(new_number_of_regions);
 }
 
-size_t G1CollectorPolicy::calculate_young_list_desired_min_length(
-                                                     size_t base_min_length) {
-  size_t desired_min_length = 0;
+uint G1CollectorPolicy::calculate_young_list_desired_min_length(
+                                                       uint base_min_length) {
+  uint desired_min_length = 0;
   if (adaptive_young_list_length()) {
     if (_alloc_rate_ms_seq->num() > 3) {
       double now_sec = os::elapsedTime();
       double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0;
       double alloc_rate_ms = predict_alloc_rate_ms();
-      desired_min_length = (size_t) ceil(alloc_rate_ms * when_ms);
+      desired_min_length = (uint) ceil(alloc_rate_ms * when_ms);
     } else {
       // otherwise we don't have enough info to make the prediction
     }
@@ -570,7 +571,7 @@
   return MAX2(_young_gen_sizer->min_desired_young_length(), desired_min_length);
 }
 
-size_t G1CollectorPolicy::calculate_young_list_desired_max_length() {
+uint G1CollectorPolicy::calculate_young_list_desired_max_length() {
   // Here, we might want to also take into account any additional
   // constraints (i.e., user-defined minimum bound). Currently, we
   // effectively don't set this bound.
@@ -587,11 +588,11 @@
   // Calculate the absolute and desired min bounds.
 
   // This is how many young regions we already have (currently: the survivors).
-  size_t base_min_length = recorded_survivor_regions();
+  uint base_min_length = recorded_survivor_regions();
   // This is the absolute minimum young length, which ensures that we
   // can allocate one eden region in the worst-case.
-  size_t absolute_min_length = base_min_length + 1;
-  size_t desired_min_length =
+  uint absolute_min_length = base_min_length + 1;
+  uint desired_min_length =
                      calculate_young_list_desired_min_length(base_min_length);
   if (desired_min_length < absolute_min_length) {
     desired_min_length = absolute_min_length;
@@ -600,16 +601,16 @@
   // Calculate the absolute and desired max bounds.
 
   // We will try our best not to "eat" into the reserve.
-  size_t absolute_max_length = 0;
+  uint absolute_max_length = 0;
   if (_free_regions_at_end_of_collection > _reserve_regions) {
     absolute_max_length = _free_regions_at_end_of_collection - _reserve_regions;
   }
-  size_t desired_max_length = calculate_young_list_desired_max_length();
+  uint desired_max_length = calculate_young_list_desired_max_length();
   if (desired_max_length > absolute_max_length) {
     desired_max_length = absolute_max_length;
   }
 
-  size_t young_list_target_length = 0;
+  uint young_list_target_length = 0;
   if (adaptive_young_list_length()) {
     if (gcs_are_young()) {
       young_list_target_length =
@@ -647,11 +648,11 @@
   update_max_gc_locker_expansion();
 }
 
-size_t
+uint
 G1CollectorPolicy::calculate_young_list_target_length(size_t rs_lengths,
-                                                   size_t base_min_length,
-                                                   size_t desired_min_length,
-                                                   size_t desired_max_length) {
+                                                     uint base_min_length,
+                                                     uint desired_min_length,
+                                                     uint desired_max_length) {
   assert(adaptive_young_list_length(), "pre-condition");
   assert(gcs_are_young(), "only call this for young GCs");
 
@@ -666,9 +667,9 @@
   // will be reflected in the predictions by the
   // survivor_regions_evac_time prediction.
   assert(desired_min_length > base_min_length, "invariant");
-  size_t min_young_length = desired_min_length - base_min_length;
+  uint min_young_length = desired_min_length - base_min_length;
   assert(desired_max_length > base_min_length, "invariant");
-  size_t max_young_length = desired_max_length - base_min_length;
+  uint max_young_length = desired_max_length - base_min_length;
 
   double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0;
   double survivor_regions_evac_time = predict_survivor_regions_evac_time();
@@ -678,8 +679,8 @@
   double base_time_ms =
     predict_base_elapsed_time_ms(pending_cards, scanned_cards) +
     survivor_regions_evac_time;
-  size_t available_free_regions = _free_regions_at_end_of_collection;
-  size_t base_free_regions = 0;
+  uint available_free_regions = _free_regions_at_end_of_collection;
+  uint base_free_regions = 0;
   if (available_free_regions > _reserve_regions) {
     base_free_regions = available_free_regions - _reserve_regions;
   }
@@ -716,9 +717,9 @@
       // the new max. This way we maintain the loop invariants.
 
       assert(min_young_length < max_young_length, "invariant");
-      size_t diff = (max_young_length - min_young_length) / 2;
+      uint diff = (max_young_length - min_young_length) / 2;
       while (diff > 0) {
-        size_t young_length = min_young_length + diff;
+        uint young_length = min_young_length + diff;
         if (predict_will_fit(young_length, base_time_ms,
                              base_free_regions, target_pause_time_ms)) {
           min_young_length = young_length;
@@ -862,8 +863,6 @@
   _last_young_gc = false;
   clear_initiate_conc_mark_if_possible();
   clear_during_initial_mark_pause();
-  _known_garbage_bytes = 0;
-  _known_garbage_ratio = 0.0;
   _in_marking_window = false;
   _in_marking_window_im = false;
 
@@ -876,7 +875,7 @@
   // Reset survivors SurvRateGroup.
   _survivor_surv_rate_group->reset();
   update_young_list_target_length();
-  _collectionSetChooser->clearMarkedHeapRegions();
+  _collectionSetChooser->clear();
 }
 
 void G1CollectorPolicy::record_stop_world_start() {
@@ -885,7 +884,7 @@
 
 void G1CollectorPolicy::record_collection_pause_start(double start_time_sec,
                                                       size_t start_used) {
-  if (PrintGCDetails) {
+  if (G1Log::finer()) {
     gclog_or_tty->stamp(PrintGCTimeStamps);
     gclog_or_tty->print("[GC pause");
     gclog_or_tty->print(" (%s)", gcs_are_young() ? "young" : "mixed");
@@ -1022,11 +1021,16 @@
     if (val > max)
       max = val;
     total += val;
-    buf.append("  %3.1lf", val);
+    if (G1Log::finest()) {
+      buf.append("  %.1lf", val);
+    }
   }
-  buf.append_and_print_cr("");
+
+  if (G1Log::finest()) {
+    buf.append_and_print_cr("");
+  }
   double avg = total / (double) no_of_gc_threads();
-  buf.append_and_print_cr(" Avg: %5.1lf, Min: %5.1lf, Max: %5.1lf, Diff: %5.1lf]",
+  buf.append_and_print_cr(" Avg: %.1lf Min: %.1lf Max: %.1lf Diff: %.1lf]",
     avg, min, max, max - min);
 }
 
@@ -1223,7 +1227,7 @@
 
   // These values are used to update the summary information that is
   // displayed when TraceGen0Time is enabled, and are output as part
-  // of the PrintGCDetails output, in the non-parallel case.
+  // of the "finer" output, in the non-parallel case.
 
   double ext_root_scan_time = avg_value(_par_last_ext_root_scan_times_ms);
   double satb_filtering_time = avg_value(_par_last_satb_filtering_times_ms);
@@ -1316,7 +1320,7 @@
     // given that humongous object allocations do not really affect
     // either the pause's duration nor when the next pause will take
     // place we can safely ignore them here.
-    size_t regions_allocated = eden_cset_region_length();
+    uint regions_allocated = eden_cset_region_length();
     double alloc_rate_ms = (double) regions_allocated / app_time_ms;
     _alloc_rate_ms_seq->add(alloc_rate_ms);
 
@@ -1356,8 +1360,7 @@
     }
   }
 
-  // PrintGCDetails output
-  if (PrintGCDetails) {
+  if (G1Log::finer()) {
     bool print_marking_info =
       _g1->mark_in_progress() && !last_pause_included_initial_mark;
 
@@ -1376,11 +1379,15 @@
         print_par_stats(2, "SATB Filtering", _par_last_satb_filtering_times_ms);
       }
       print_par_stats(2, "Update RS", _par_last_update_rs_times_ms);
-      print_par_sizes(3, "Processed Buffers", _par_last_update_rs_processed_buffers);
+      if (G1Log::finest()) {
+        print_par_sizes(3, "Processed Buffers", _par_last_update_rs_processed_buffers);
+      }
       print_par_stats(2, "Scan RS", _par_last_scan_rs_times_ms);
       print_par_stats(2, "Object Copy", _par_last_obj_copy_times_ms);
       print_par_stats(2, "Termination", _par_last_termination_times_ms);
-      print_par_sizes(3, "Termination Attempts", _par_last_termination_attempts);
+      if (G1Log::finest()) {
+        print_par_sizes(3, "Termination Attempts", _par_last_termination_attempts);
+      }
 
       for (int i = 0; i < _parallel_gc_threads; i++) {
         _par_last_gc_worker_times_ms[i] = _par_last_gc_worker_end_times_ms[i] -
@@ -1406,7 +1413,9 @@
         print_stats(1, "SATB Filtering", satb_filtering_time);
       }
       print_stats(1, "Update RS", update_rs_time);
-      print_stats(2, "Processed Buffers", (int)update_rs_processed_buffers);
+      if (G1Log::finest()) {
+        print_stats(2, "Processed Buffers", (int)update_rs_processed_buffers);
+      }
       print_stats(1, "Scan RS", scan_rs_time);
       print_stats(1, "Object Copying", obj_copy_time);
     }
@@ -1440,16 +1449,6 @@
     }
   }
 
-  // Update the efficiency-since-mark vars.
-  double proc_ms = elapsed_ms * (double) _parallel_gc_threads;
-  if (elapsed_ms < MIN_TIMER_GRANULARITY) {
-    // This usually happens due to the timer not having the required
-    // granularity. Some Linuxes are the usual culprits.
-    // We'll just set it to something (arbitrarily) small.
-    proc_ms = 1.0;
-  }
-  double cur_efficiency = (double) freed_bytes / proc_ms;
-
   bool new_in_marking_window = _in_marking_window;
   bool new_in_marking_window_im = false;
   if (during_initial_mark_pause()) {
@@ -1484,10 +1483,6 @@
     }
   }
 
-  if (_last_gc_was_young && !_during_marking) {
-    _young_gc_eff_seq->add(cur_efficiency);
-  }
-
   _short_lived_surv_rate_group->start_adding_regions();
   // do that for any other surv rate groupsx
 
@@ -1495,8 +1490,9 @@
     double pause_time_ms = elapsed_ms;
 
     size_t diff = 0;
-    if (_max_pending_cards >= _pending_cards)
+    if (_max_pending_cards >= _pending_cards) {
       diff = _max_pending_cards - _pending_cards;
+    }
     _pending_card_diff_seq->add((double) diff);
 
     double cost_per_card_ms = 0.0;
@@ -1601,7 +1597,7 @@
   double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
   adjust_concurrent_refinement(update_rs_time, update_rs_processed_buffers, update_rs_time_goal_ms);
 
-  assert(assertMarkedBytesDataOK(), "Marked regions not OK at pause end.");
+  _collectionSetChooser->verify();
 }
 
 #define EXT_SIZE_FORMAT "%d%s"
@@ -1610,7 +1606,7 @@
   proper_unit_for_byte_size((bytes))
 
 void G1CollectorPolicy::print_heap_transition() {
-  if (PrintGCDetails) {
+  if (G1Log::finer()) {
     YoungList* young_list = _g1->young_list();
     size_t eden_bytes = young_list->eden_used_bytes();
     size_t survivor_bytes = young_list->survivor_used_bytes();
@@ -1637,7 +1633,7 @@
       EXT_SIZE_PARAMS(capacity));
 
     _prev_eden_capacity = eden_capacity;
-  } else if (PrintGC) {
+  } else if (G1Log::fine()) {
     _g1->print_size_transition(gclog_or_tty,
                                _cur_collection_pause_used_at_start_bytes,
                                _g1->used(), _g1->capacity());
@@ -1730,8 +1726,7 @@
   return region_elapsed_time_ms;
 }
 
-size_t
-G1CollectorPolicy::predict_bytes_to_copy(HeapRegion* hr) {
+size_t G1CollectorPolicy::predict_bytes_to_copy(HeapRegion* hr) {
   size_t bytes_to_copy;
   if (hr->is_marked())
     bytes_to_copy = hr->max_live_bytes();
@@ -1745,8 +1740,8 @@
 }
 
 void
-G1CollectorPolicy::init_cset_region_lengths(size_t eden_cset_region_length,
-                                          size_t survivor_cset_region_length) {
+G1CollectorPolicy::init_cset_region_lengths(uint eden_cset_region_length,
+                                            uint survivor_cset_region_length) {
   _eden_cset_region_length     = eden_cset_region_length;
   _survivor_cset_region_length = survivor_cset_region_length;
   _old_cset_region_length      = 0;
@@ -2010,7 +2005,7 @@
 }
 #endif // PRODUCT
 
-size_t G1CollectorPolicy::max_regions(int purpose) {
+uint G1CollectorPolicy::max_regions(int purpose) {
   switch (purpose) {
     case GCAllocForSurvived:
       return _max_survivor_regions;
@@ -2023,13 +2018,13 @@
 }
 
 void G1CollectorPolicy::update_max_gc_locker_expansion() {
-  size_t expansion_region_num = 0;
+  uint expansion_region_num = 0;
   if (GCLockerEdenExpansionPercent > 0) {
     double perc = (double) GCLockerEdenExpansionPercent / 100.0;
     double expansion_region_num_d = perc * (double) _young_list_target_length;
     // We use ceiling so that if expansion_region_num_d is > 0.0 (but
     // less than 1.0) we'll get 1.
-    expansion_region_num = (size_t) ceil(expansion_region_num_d);
+    expansion_region_num = (uint) ceil(expansion_region_num_d);
   } else {
     assert(expansion_region_num == 0, "sanity");
   }
@@ -2043,34 +2038,12 @@
                  (double) _young_list_target_length / (double) SurvivorRatio;
   // We use ceiling so that if max_survivor_regions_d is > 0.0 (but
   // smaller than 1.0) we'll get 1.
-  _max_survivor_regions = (size_t) ceil(max_survivor_regions_d);
+  _max_survivor_regions = (uint) ceil(max_survivor_regions_d);
 
   _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold(
         HeapRegion::GrainWords * _max_survivor_regions);
 }
 
-#ifndef PRODUCT
-class HRSortIndexIsOKClosure: public HeapRegionClosure {
-  CollectionSetChooser* _chooser;
-public:
-  HRSortIndexIsOKClosure(CollectionSetChooser* chooser) :
-    _chooser(chooser) {}
-
-  bool doHeapRegion(HeapRegion* r) {
-    if (!r->continuesHumongous()) {
-      assert(_chooser->regionProperlyOrdered(r), "Ought to be.");
-    }
-    return false;
-  }
-};
-
-bool G1CollectorPolicy::assertMarkedBytesDataOK() {
-  HRSortIndexIsOKClosure cl(_collectionSetChooser);
-  _g1->heap_region_iterate(&cl);
-  return true;
-}
-#endif
-
 bool G1CollectorPolicy::force_initial_mark_if_outside_cycle(
                                                      GCCause::Cause gc_cause) {
   bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle();
@@ -2168,8 +2141,8 @@
       // We will skip any region that's currently used as an old GC
       // alloc region (we should not consider those for collection
       // before we fill them up).
-      if (_hrSorted->shouldAdd(r) && !_g1h->is_old_gc_alloc_region(r)) {
-        _hrSorted->addMarkedHeapRegion(r);
+      if (_hrSorted->should_add(r) && !_g1h->is_old_gc_alloc_region(r)) {
+        _hrSorted->add_region(r);
       }
     }
     return false;
@@ -2179,16 +2152,14 @@
 class ParKnownGarbageHRClosure: public HeapRegionClosure {
   G1CollectedHeap* _g1h;
   CollectionSetChooser* _hrSorted;
-  jint _marked_regions_added;
+  uint _marked_regions_added;
   size_t _reclaimable_bytes_added;
-  jint _chunk_size;
-  jint _cur_chunk_idx;
-  jint _cur_chunk_end; // Cur chunk [_cur_chunk_idx, _cur_chunk_end)
-  int _worker;
-  int _invokes;
+  uint _chunk_size;
+  uint _cur_chunk_idx;
+  uint _cur_chunk_end; // Cur chunk [_cur_chunk_idx, _cur_chunk_end)
 
   void get_new_chunk() {
-    _cur_chunk_idx = _hrSorted->getParMarkedHeapRegionChunk(_chunk_size);
+    _cur_chunk_idx = _hrSorted->claim_array_chunk(_chunk_size);
     _cur_chunk_end = _cur_chunk_idx + _chunk_size;
   }
   void add_region(HeapRegion* r) {
@@ -2196,7 +2167,7 @@
       get_new_chunk();
     }
     assert(_cur_chunk_idx < _cur_chunk_end, "postcondition");
-    _hrSorted->setMarkedHeapRegion(_cur_chunk_idx, r);
+    _hrSorted->set_region(_cur_chunk_idx, r);
     _marked_regions_added++;
     _reclaimable_bytes_added += r->reclaimable_bytes();
     _cur_chunk_idx++;
@@ -2204,104 +2175,79 @@
 
 public:
   ParKnownGarbageHRClosure(CollectionSetChooser* hrSorted,
-                           jint chunk_size,
-                           int worker) :
+                           uint chunk_size) :
       _g1h(G1CollectedHeap::heap()),
-      _hrSorted(hrSorted), _chunk_size(chunk_size), _worker(worker),
+      _hrSorted(hrSorted), _chunk_size(chunk_size),
       _marked_regions_added(0), _reclaimable_bytes_added(0),
-      _cur_chunk_idx(0), _cur_chunk_end(0), _invokes(0) { }
+      _cur_chunk_idx(0), _cur_chunk_end(0) { }
 
   bool doHeapRegion(HeapRegion* r) {
-    // We only include humongous regions in collection
-    // sets when concurrent mark shows that their contained object is
-    // unreachable.
-    _invokes++;
-
     // Do we have any marking information for this region?
     if (r->is_marked()) {
       // We will skip any region that's currently used as an old GC
       // alloc region (we should not consider those for collection
       // before we fill them up).
-      if (_hrSorted->shouldAdd(r) && !_g1h->is_old_gc_alloc_region(r)) {
+      if (_hrSorted->should_add(r) && !_g1h->is_old_gc_alloc_region(r)) {
         add_region(r);
       }
     }
     return false;
   }
-  jint marked_regions_added() { return _marked_regions_added; }
+  uint marked_regions_added() { return _marked_regions_added; }
   size_t reclaimable_bytes_added() { return _reclaimable_bytes_added; }
-  int invokes() { return _invokes; }
 };
 
 class ParKnownGarbageTask: public AbstractGangTask {
   CollectionSetChooser* _hrSorted;
-  jint _chunk_size;
+  uint _chunk_size;
   G1CollectedHeap* _g1;
 public:
-  ParKnownGarbageTask(CollectionSetChooser* hrSorted, jint chunk_size) :
+  ParKnownGarbageTask(CollectionSetChooser* hrSorted, uint chunk_size) :
     AbstractGangTask("ParKnownGarbageTask"),
     _hrSorted(hrSorted), _chunk_size(chunk_size),
     _g1(G1CollectedHeap::heap()) { }
 
   void work(uint worker_id) {
-    ParKnownGarbageHRClosure parKnownGarbageCl(_hrSorted,
-                                               _chunk_size,
-                                               worker_id);
+    ParKnownGarbageHRClosure parKnownGarbageCl(_hrSorted, _chunk_size);
+
     // Back to zero for the claim value.
     _g1->heap_region_par_iterate_chunked(&parKnownGarbageCl, worker_id,
                                          _g1->workers()->active_workers(),
                                          HeapRegion::InitialClaimValue);
-    jint regions_added = parKnownGarbageCl.marked_regions_added();
+    uint regions_added = parKnownGarbageCl.marked_regions_added();
     size_t reclaimable_bytes_added =
                                    parKnownGarbageCl.reclaimable_bytes_added();
-    _hrSorted->updateTotals(regions_added, reclaimable_bytes_added);
-    if (G1PrintParCleanupStats) {
-      gclog_or_tty->print_cr("     Thread %d called %d times, added %d regions to list.",
-                 worker_id, parKnownGarbageCl.invokes(), regions_added);
-    }
+    _hrSorted->update_totals(regions_added, reclaimable_bytes_added);
   }
 };
 
 void
 G1CollectorPolicy::record_concurrent_mark_cleanup_end(int no_of_gc_threads) {
-  double start_sec;
-  if (G1PrintParCleanupStats) {
-    start_sec = os::elapsedTime();
-  }
+  _collectionSetChooser->clear();
 
-  _collectionSetChooser->clearMarkedHeapRegions();
-  double clear_marked_end_sec;
-  if (G1PrintParCleanupStats) {
-    clear_marked_end_sec = os::elapsedTime();
-    gclog_or_tty->print_cr("  clear marked regions: %8.3f ms.",
-                           (clear_marked_end_sec - start_sec) * 1000.0);
-  }
-
+  uint region_num = _g1->n_regions();
   if (G1CollectedHeap::use_parallel_gc_threads()) {
-    const size_t OverpartitionFactor = 4;
-    size_t WorkUnit;
+    const uint OverpartitionFactor = 4;
+    uint WorkUnit;
     // The use of MinChunkSize = 8 in the original code
     // causes some assertion failures when the total number of
     // region is less than 8.  The code here tries to fix that.
     // Should the original code also be fixed?
     if (no_of_gc_threads > 0) {
-      const size_t MinWorkUnit =
-        MAX2(_g1->n_regions() / no_of_gc_threads, (size_t) 1U);
-      WorkUnit =
-        MAX2(_g1->n_regions() / (no_of_gc_threads * OverpartitionFactor),
-             MinWorkUnit);
+      const uint MinWorkUnit = MAX2(region_num / no_of_gc_threads, 1U);
+      WorkUnit = MAX2(region_num / (no_of_gc_threads * OverpartitionFactor),
+                      MinWorkUnit);
     } else {
       assert(no_of_gc_threads > 0,
         "The active gc workers should be greater than 0");
       // In a product build do something reasonable to avoid a crash.
-      const size_t MinWorkUnit =
-        MAX2(_g1->n_regions() / ParallelGCThreads, (size_t) 1U);
+      const uint MinWorkUnit = MAX2(region_num / (uint) ParallelGCThreads, 1U);
       WorkUnit =
-        MAX2(_g1->n_regions() / (ParallelGCThreads * OverpartitionFactor),
+        MAX2(region_num / (uint) (ParallelGCThreads * OverpartitionFactor),
              MinWorkUnit);
     }
-    _collectionSetChooser->prepareForAddMarkedHeapRegionsPar(_g1->n_regions(),
-                                                             WorkUnit);
+    _collectionSetChooser->prepare_for_par_region_addition(_g1->n_regions(),
+                                                           WorkUnit);
     ParKnownGarbageTask parKnownGarbageTask(_collectionSetChooser,
                                             (int) WorkUnit);
     _g1->workers()->run_task(&parKnownGarbageTask);
@@ -2312,20 +2258,10 @@
     KnownGarbageClosure knownGarbagecl(_collectionSetChooser);
     _g1->heap_region_iterate(&knownGarbagecl);
   }
-  double known_garbage_end_sec;
-  if (G1PrintParCleanupStats) {
-    known_garbage_end_sec = os::elapsedTime();
-    gclog_or_tty->print_cr("  compute known garbage: %8.3f ms.",
-                      (known_garbage_end_sec - clear_marked_end_sec) * 1000.0);
-  }
 
-  _collectionSetChooser->sortMarkedHeapRegions();
+  _collectionSetChooser->sort_regions();
+
   double end_sec = os::elapsedTime();
-  if (G1PrintParCleanupStats) {
-    gclog_or_tty->print_cr("  sorting: %8.3f ms.",
-                           (end_sec - known_garbage_end_sec) * 1000.0);
-  }
-
   double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0;
   _concurrent_mark_cleanup_times_ms->add(elapsed_time_ms);
   _cur_mark_stop_world_time_ms += elapsed_time_ms;
@@ -2541,13 +2477,13 @@
 bool G1CollectorPolicy::next_gc_should_be_mixed(const char* true_action_str,
                                                 const char* false_action_str) {
   CollectionSetChooser* cset_chooser = _collectionSetChooser;
-  if (cset_chooser->isEmpty()) {
+  if (cset_chooser->is_empty()) {
     ergo_verbose0(ErgoMixedGCs,
                   false_action_str,
                   ergo_format_reason("candidate old regions not available"));
     return false;
   }
-  size_t reclaimable_bytes = cset_chooser->remainingReclaimableBytes();
+  size_t reclaimable_bytes = cset_chooser->remaining_reclaimable_bytes();
   size_t capacity_bytes = _g1->capacity();
   double perc = (double) reclaimable_bytes * 100.0 / (double) capacity_bytes;
   double threshold = (double) G1HeapWastePercent;
@@ -2558,7 +2494,7 @@
               ergo_format_region("candidate old regions")
               ergo_format_byte_perc("reclaimable")
               ergo_format_perc("threshold"),
-              cset_chooser->remainingRegions(),
+              cset_chooser->remaining_regions(),
               reclaimable_bytes, perc, threshold);
     return false;
   }
@@ -2569,7 +2505,7 @@
                 ergo_format_region("candidate old regions")
                 ergo_format_byte_perc("reclaimable")
                 ergo_format_perc("threshold"),
-                cset_chooser->remainingRegions(),
+                cset_chooser->remaining_regions(),
                 reclaimable_bytes, perc, threshold);
   return true;
 }
@@ -2613,8 +2549,8 @@
   // pause are appended to the RHS of the young list, i.e.
   //   [Newly Young Regions ++ Survivors from last pause].
 
-  size_t survivor_region_length = young_list->survivor_length();
-  size_t eden_region_length = young_list->length() - survivor_region_length;
+  uint survivor_region_length = young_list->survivor_length();
+  uint eden_region_length = young_list->length() - survivor_region_length;
   init_cset_region_lengths(eden_region_length, survivor_region_length);
   hr = young_list->first_survivor_region();
   while (hr != NULL) {
@@ -2652,11 +2588,11 @@
 
   if (!gcs_are_young()) {
     CollectionSetChooser* cset_chooser = _collectionSetChooser;
-    assert(cset_chooser->verify(), "CSet Chooser verification - pre");
-    const size_t min_old_cset_length = cset_chooser->calcMinOldCSetLength();
-    const size_t max_old_cset_length = cset_chooser->calcMaxOldCSetLength();
+    cset_chooser->verify();
+    const uint min_old_cset_length = cset_chooser->calc_min_old_cset_length();
+    const uint max_old_cset_length = cset_chooser->calc_max_old_cset_length();
 
-    size_t expensive_region_num = 0;
+    uint expensive_region_num = 0;
     bool check_time_remaining = adaptive_young_list_length();
     HeapRegion* hr = cset_chooser->peek();
     while (hr != NULL) {
@@ -2741,7 +2677,7 @@
                     time_remaining_ms);
     }
 
-    assert(cset_chooser->verify(), "CSet Chooser verification - post");
+    cset_chooser->verify();
   }
 
   stop_incremental_cset_building();
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -128,19 +128,19 @@
     SizerNewRatio
   };
   SizerKind _sizer_kind;
-  size_t _min_desired_young_length;
-  size_t _max_desired_young_length;
+  uint _min_desired_young_length;
+  uint _max_desired_young_length;
   bool _adaptive_size;
-  size_t calculate_default_min_length(size_t new_number_of_heap_regions);
-  size_t calculate_default_max_length(size_t new_number_of_heap_regions);
+  uint calculate_default_min_length(uint new_number_of_heap_regions);
+  uint calculate_default_max_length(uint new_number_of_heap_regions);
 
 public:
   G1YoungGenSizer();
-  void heap_size_changed(size_t new_number_of_heap_regions);
-  size_t min_desired_young_length() {
+  void heap_size_changed(uint new_number_of_heap_regions);
+  uint min_desired_young_length() {
     return _min_desired_young_length;
   }
-  size_t max_desired_young_length() {
+  uint max_desired_young_length() {
     return _max_desired_young_length;
   }
   bool adaptive_young_list_length() {
@@ -175,7 +175,7 @@
 
   double _cur_collection_start_sec;
   size_t _cur_collection_pause_used_at_start_bytes;
-  size_t _cur_collection_pause_used_regions_at_start;
+  uint   _cur_collection_pause_used_regions_at_start;
   double _cur_collection_par_time_ms;
 
   double _cur_collection_code_root_fixup_time_ms;
@@ -233,13 +233,13 @@
   // indicates whether we are in young or mixed GC mode
   bool _gcs_are_young;
 
-  size_t _young_list_target_length;
-  size_t _young_list_fixed_length;
+  uint _young_list_target_length;
+  uint _young_list_fixed_length;
   size_t _prev_eden_capacity; // used for logging
 
   // The max number of regions we can extend the eden by while the GC
   // locker is active. This should be >= _young_list_target_length;
-  size_t _young_list_max_length;
+  uint _young_list_max_length;
 
   bool                  _last_gc_was_young;
 
@@ -257,7 +257,7 @@
   double                _gc_overhead_perc;
 
   double _reserve_factor;
-  size_t _reserve_regions;
+  uint _reserve_regions;
 
   bool during_marking() {
     return _during_marking;
@@ -288,22 +288,20 @@
 
   TruncatedSeq* _cost_per_byte_ms_during_cm_seq;
 
-  TruncatedSeq* _young_gc_eff_seq;
-
   G1YoungGenSizer* _young_gen_sizer;
 
-  size_t _eden_cset_region_length;
-  size_t _survivor_cset_region_length;
-  size_t _old_cset_region_length;
+  uint _eden_cset_region_length;
+  uint _survivor_cset_region_length;
+  uint _old_cset_region_length;
 
-  void init_cset_region_lengths(size_t eden_cset_region_length,
-                                size_t survivor_cset_region_length);
+  void init_cset_region_lengths(uint eden_cset_region_length,
+                                uint survivor_cset_region_length);
 
-  size_t eden_cset_region_length()     { return _eden_cset_region_length;     }
-  size_t survivor_cset_region_length() { return _survivor_cset_region_length; }
-  size_t old_cset_region_length()      { return _old_cset_region_length;      }
+  uint eden_cset_region_length()     { return _eden_cset_region_length;     }
+  uint survivor_cset_region_length() { return _survivor_cset_region_length; }
+  uint old_cset_region_length()      { return _old_cset_region_length;      }
 
-  size_t _free_regions_at_end_of_collection;
+  uint _free_regions_at_end_of_collection;
 
   size_t _recorded_rs_lengths;
   size_t _max_rs_lengths;
@@ -315,9 +313,6 @@
 
   size_t _rs_lengths_prediction;
 
-  size_t _known_garbage_bytes;
-  double _known_garbage_ratio;
-
   double sigma() { return _sigma; }
 
   // A function that prevents us putting too much stock in small sample
@@ -496,10 +491,10 @@
 
   void set_recorded_rs_lengths(size_t rs_lengths);
 
-  size_t cset_region_length()       { return young_cset_region_length() +
-                                             old_cset_region_length(); }
-  size_t young_cset_region_length() { return eden_cset_region_length() +
-                                             survivor_cset_region_length(); }
+  uint cset_region_length()       { return young_cset_region_length() +
+                                           old_cset_region_length(); }
+  uint young_cset_region_length() { return eden_cset_region_length() +
+                                           survivor_cset_region_length(); }
 
   void record_young_free_cset_time_ms(double time_ms) {
     _recorded_young_free_cset_time_ms = time_ms;
@@ -509,10 +504,6 @@
     _recorded_non_young_free_cset_time_ms = time_ms;
   }
 
-  double predict_young_gc_eff() {
-    return get_new_neg_prediction(_young_gc_eff_seq);
-  }
-
   double predict_survivor_regions_evac_time();
 
   void cset_regions_freed() {
@@ -522,20 +513,6 @@
     // also call it on any more surv rate groups
   }
 
-  void set_known_garbage_bytes(size_t known_garbage_bytes) {
-    _known_garbage_bytes = known_garbage_bytes;
-    size_t heap_bytes = _g1->capacity();
-    _known_garbage_ratio = (double) _known_garbage_bytes / (double) heap_bytes;
-  }
-
-  void decrease_known_garbage_bytes(size_t known_garbage_bytes) {
-    guarantee( _known_garbage_bytes >= known_garbage_bytes, "invariant" );
-
-    _known_garbage_bytes -= known_garbage_bytes;
-    size_t heap_bytes = _g1->capacity();
-    _known_garbage_ratio = (double) _known_garbage_bytes / (double) heap_bytes;
-  }
-
   G1MMUTracker* mmu_tracker() {
     return _mmu_tracker;
   }
@@ -720,12 +697,12 @@
   // Calculate and return the minimum desired young list target
   // length. This is the minimum desired young list length according
   // to the user's inputs.
-  size_t calculate_young_list_desired_min_length(size_t base_min_length);
+  uint calculate_young_list_desired_min_length(uint base_min_length);
 
   // Calculate and return the maximum desired young list target
   // length. This is the maximum desired young list length according
   // to the user's inputs.
-  size_t calculate_young_list_desired_max_length();
+  uint calculate_young_list_desired_max_length();
 
   // Calculate and return the maximum young list target length that
   // can fit into the pause time goal. The parameters are: rs_lengths
@@ -733,18 +710,18 @@
   // be, base_min_length is the alreay existing number of regions in
   // the young list, min_length and max_length are the desired min and
   // max young list length according to the user's inputs.
-  size_t calculate_young_list_target_length(size_t rs_lengths,
-                                            size_t base_min_length,
-                                            size_t desired_min_length,
-                                            size_t desired_max_length);
+  uint calculate_young_list_target_length(size_t rs_lengths,
+                                          uint base_min_length,
+                                          uint desired_min_length,
+                                          uint desired_max_length);
 
   // Check whether a given young length (young_length) fits into the
   // given target pause time and whether the prediction for the amount
   // of objects to be copied for the given length will fit into the
   // given free space (expressed by base_free_regions).  It is used by
   // calculate_young_list_target_length().
-  bool predict_will_fit(size_t young_length, double base_time_ms,
-                        size_t base_free_regions, double target_pause_time_ms);
+  bool predict_will_fit(uint young_length, double base_time_ms,
+                        uint base_free_regions, double target_pause_time_ms);
 
   // Count the number of bytes used in the CS.
   void count_CS_bytes_used();
@@ -773,7 +750,7 @@
   }
 
   // This should be called after the heap is resized.
-  void record_new_heap_size(size_t new_number_of_regions);
+  void record_new_heap_size(uint new_number_of_regions);
 
   void init();
 
@@ -1026,12 +1003,6 @@
   // exceeded the desired limit, return an amount to expand by.
   size_t expansion_amount();
 
-#ifndef PRODUCT
-  // Check any appropriate marked bytes info, asserting false if
-  // something's wrong, else returning "true".
-  bool assertMarkedBytesDataOK();
-#endif
-
   // Print tracing information.
   void print_tracing_info() const;
 
@@ -1048,18 +1019,18 @@
   }
 
   bool is_young_list_full() {
-    size_t young_list_length = _g1->young_list()->length();
-    size_t young_list_target_length = _young_list_target_length;
+    uint young_list_length = _g1->young_list()->length();
+    uint young_list_target_length = _young_list_target_length;
     return young_list_length >= young_list_target_length;
   }
 
   bool can_expand_young_list() {
-    size_t young_list_length = _g1->young_list()->length();
-    size_t young_list_max_length = _young_list_max_length;
+    uint young_list_length = _g1->young_list()->length();
+    uint young_list_max_length = _young_list_max_length;
     return young_list_length < young_list_max_length;
   }
 
-  size_t young_list_max_length() {
+  uint young_list_max_length() {
     return _young_list_max_length;
   }
 
@@ -1074,19 +1045,6 @@
     return _young_gen_sizer->adaptive_young_list_length();
   }
 
-  inline double get_gc_eff_factor() {
-    double ratio = _known_garbage_ratio;
-
-    double square = ratio * ratio;
-    // square = square * square;
-    double ret = square * 9.0 + 1.0;
-#if 0
-    gclog_or_tty->print_cr("ratio = %1.2lf, ret = %1.2lf", ratio, ret);
-#endif // 0
-    guarantee(0.0 <= ret && ret < 10.0, "invariant!");
-    return ret;
-  }
-
 private:
   //
   // Survivor regions policy.
@@ -1097,7 +1055,7 @@
   int _tenuring_threshold;
 
   // The limit on the number of regions allocated for survivors.
-  size_t _max_survivor_regions;
+  uint _max_survivor_regions;
 
   // For reporting purposes.
   size_t _eden_bytes_before_gc;
@@ -1105,7 +1063,7 @@
   size_t _capacity_before_gc;
 
   // The amount of survor regions after a collection.
-  size_t _recorded_survivor_regions;
+  uint _recorded_survivor_regions;
   // List of survivor regions.
   HeapRegion* _recorded_survivor_head;
   HeapRegion* _recorded_survivor_tail;
@@ -1127,9 +1085,9 @@
     return purpose == GCAllocForSurvived;
   }
 
-  static const size_t REGIONS_UNLIMITED = ~(size_t)0;
+  static const uint REGIONS_UNLIMITED = (uint) -1;
 
-  size_t max_regions(int purpose);
+  uint max_regions(int purpose);
 
   // The limit on regions for a particular purpose is reached.
   void note_alloc_region_limit_reached(int purpose) {
@@ -1146,7 +1104,7 @@
     _survivor_surv_rate_group->stop_adding_regions();
   }
 
-  void record_survivor_regions(size_t      regions,
+  void record_survivor_regions(uint regions,
                                HeapRegion* head,
                                HeapRegion* tail) {
     _recorded_survivor_regions = regions;
@@ -1154,12 +1112,11 @@
     _recorded_survivor_tail    = tail;
   }
 
-  size_t recorded_survivor_regions() {
+  uint recorded_survivor_regions() {
     return _recorded_survivor_regions;
   }
 
-  void record_thread_age_table(ageTable* age_table)
-  {
+  void record_thread_age_table(ageTable* age_table) {
     _survivors_age_table.merge_par(age_table);
   }
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1ErgoVerbose.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1ErgoVerbose.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -120,7 +120,7 @@
 
 // Single parameter format strings
 #define ergo_format_str(_name_)      ", " _name_ ": %s"
-#define ergo_format_region(_name_)   ", " _name_ ": "SIZE_FORMAT" regions"
+#define ergo_format_region(_name_)   ", " _name_ ": %u regions"
 #define ergo_format_byte(_name_)     ", " _name_ ": "SIZE_FORMAT" bytes"
 #define ergo_format_double(_name_)   ", " _name_ ": %1.2f"
 #define ergo_format_perc(_name_)     ", " _name_ ": %1.2f %%"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1Log.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc_implementation/g1/g1_globals.hpp"
+#include "gc_implementation/g1/g1Log.hpp"
+#include "runtime/globals.hpp"
+
+G1Log::LogLevel G1Log::_level = G1Log::LevelNone;
+
+// If G1LogLevel has not been set up we will use the values of PrintGC
+// and PrintGCDetails for the logging level.
+// - PrintGC maps to "fine".
+// - PrintGCDetails maps to "finer".
+void G1Log::init() {
+  if (G1LogLevel != NULL && G1LogLevel[0] != '\0') {
+    if (strncmp("none", G1LogLevel, 4) == 0 && G1LogLevel[4] == '\0') {
+      _level = LevelNone;
+    } else if (strncmp("fine", G1LogLevel, 4) == 0 && G1LogLevel[4] == '\0') {
+      _level = LevelFine;
+    } else if (strncmp("finer", G1LogLevel, 5) == 0 && G1LogLevel[5] == '\0') {
+      _level = LevelFiner;
+    } else if (strncmp("finest", G1LogLevel, 6) == 0 && G1LogLevel[6] == '\0') {
+      _level = LevelFinest;
+    } else {
+      warning("Unknown logging level '%s', should be one of 'fine', 'finer' or 'finest'.", G1LogLevel);
+    }
+  } else {
+    if (PrintGCDetails) {
+      _level = LevelFiner;
+    } else if (PrintGC) {
+      _level = LevelFine;
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1Log.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1LOG_HPP
+#define SHARE_VM_GC_IMPLEMENTATION_G1_G1LOG_HPP
+
+#include "memory/allocation.hpp"
+
+class G1Log : public AllStatic {
+  typedef enum {
+    LevelNone,
+    LevelFine,
+    LevelFiner,
+    LevelFinest
+  } LogLevel;
+
+  static LogLevel _level;
+
+ public:
+  inline static bool fine() {
+    return _level >= LevelFine;
+  }
+
+  inline static bool finer() {
+    return _level >= LevelFiner;
+  }
+
+  inline static bool finest() {
+    return _level == LevelFinest;
+  }
+
+  static void init();
+};
+
+#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1LOG_HPP
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -29,6 +29,7 @@
 #include "classfile/vmSymbols.hpp"
 #include "code/codeCache.hpp"
 #include "code/icBuffer.hpp"
+#include "gc_implementation/g1/g1Log.hpp"
 #include "gc_implementation/g1/g1MarkSweep.hpp"
 #include "memory/gcLocker.hpp"
 #include "memory/genCollectedHeap.hpp"
@@ -126,7 +127,7 @@
 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
                                     bool clear_all_softrefs) {
   // Recursively traverse all live objects and mark them
-  TraceTime tm("phase 1", PrintGC && Verbose, true, gclog_or_tty);
+  TraceTime tm("phase 1", G1Log::fine() && Verbose, true, gclog_or_tty);
   GenMarkSweep::trace(" 1");
 
   SharedHeap* sh = SharedHeap::heap();
@@ -192,8 +193,7 @@
     // fail. At the end of the GC, the orginal mark word values
     // (including hash values) are restored to the appropriate
     // objects.
-    Universe::heap()->verify(/* allow dirty */ true,
-                             /* silent      */ false,
+    Universe::heap()->verify(/* silent      */ false,
                              /* option      */ VerifyOption_G1UseMarkWord);
 
     G1CollectedHeap* g1h = G1CollectedHeap::heap();
@@ -291,7 +291,7 @@
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
   Generation* pg = g1h->perm_gen();
 
-  TraceTime tm("phase 2", PrintGC && Verbose, true, gclog_or_tty);
+  TraceTime tm("phase 2", G1Log::fine() && Verbose, true, gclog_or_tty);
   GenMarkSweep::trace("2");
 
   FindFirstRegionClosure cl;
@@ -335,7 +335,7 @@
   Generation* pg = g1h->perm_gen();
 
   // Adjust the pointers to reflect the new locations
-  TraceTime tm("phase 3", PrintGC && Verbose, true, gclog_or_tty);
+  TraceTime tm("phase 3", G1Log::fine() && Verbose, true, gclog_or_tty);
   GenMarkSweep::trace("3");
 
   SharedHeap* sh = SharedHeap::heap();
@@ -399,7 +399,7 @@
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
   Generation* pg = g1h->perm_gen();
 
-  TraceTime tm("phase 4", PrintGC && Verbose, true, gclog_or_tty);
+  TraceTime tm("phase 4", G1Log::fine() && Verbose, true, gclog_or_tty);
   GenMarkSweep::trace("4");
 
   pg->compact();
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -177,19 +177,19 @@
   // values we read here are possible (i.e., at a STW phase at the end
   // of a GC).
 
-  size_t young_list_length = g1->young_list()->length();
-  size_t survivor_list_length = g1->g1_policy()->recorded_survivor_regions();
+  uint young_list_length = g1->young_list()->length();
+  uint survivor_list_length = g1->g1_policy()->recorded_survivor_regions();
   assert(young_list_length >= survivor_list_length, "invariant");
-  size_t eden_list_length = young_list_length - survivor_list_length;
+  uint eden_list_length = young_list_length - survivor_list_length;
   // Max length includes any potential extensions to the young gen
   // we'll do when the GC locker is active.
-  size_t young_list_max_length = g1->g1_policy()->young_list_max_length();
+  uint young_list_max_length = g1->g1_policy()->young_list_max_length();
   assert(young_list_max_length >= survivor_list_length, "invariant");
-  size_t eden_list_max_length = young_list_max_length - survivor_list_length;
+  uint eden_list_max_length = young_list_max_length - survivor_list_length;
 
   _overall_used = g1->used_unlocked();
-  _eden_used = eden_list_length * HeapRegion::GrainBytes;
-  _survivor_used = survivor_list_length * HeapRegion::GrainBytes;
+  _eden_used = (size_t) eden_list_length * HeapRegion::GrainBytes;
+  _survivor_used = (size_t) survivor_list_length * HeapRegion::GrainBytes;
   _young_region_num = young_list_length;
   _old_used = subtract_up_to_zero(_overall_used, _eden_used + _survivor_used);
 
@@ -207,7 +207,7 @@
   committed -= _survivor_committed + _old_committed;
 
   // Next, calculate and remove the committed size for the eden.
-  _eden_committed = eden_list_max_length * HeapRegion::GrainBytes;
+  _eden_committed = (size_t) eden_list_max_length * HeapRegion::GrainBytes;
   // Somewhat defensive: be robust in case there are inaccuracies in
   // the calculations
   _eden_committed = MIN2(_eden_committed, committed);
@@ -237,10 +237,10 @@
   // When a new eden region is allocated, only the eden_used size is
   // affected (since we have recalculated everything else at the last GC).
 
-  size_t young_region_num = g1h()->young_list()->length();
+  uint young_region_num = g1h()->young_list()->length();
   if (young_region_num > _young_region_num) {
-    size_t diff = young_region_num - _young_region_num;
-    _eden_used += diff * HeapRegion::GrainBytes;
+    uint diff = young_region_num - _young_region_num;
+    _eden_used += (size_t) diff * HeapRegion::GrainBytes;
     // Somewhat defensive: cap the eden used size to make sure it
     // never exceeds the committed size.
     _eden_used = MIN2(_eden_used, _eden_committed);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -147,7 +147,7 @@
   size_t _overall_committed;
   size_t _overall_used;
 
-  size_t _young_region_num;
+  uint   _young_region_num;
   size_t _young_gen_committed;
   size_t _eden_committed;
   size_t _eden_used;
--- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -26,7 +26,6 @@
 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1_GLOBALS_HPP
 
 #include "runtime/globals.hpp"
-
 //
 // Defines all globals flags used by the garbage-first compiler.
 //
@@ -128,9 +127,6 @@
             "Prints the liveness information for all regions in the heap "  \
             "at the end of a marking cycle.")                               \
                                                                             \
-  develop(bool, G1PrintParCleanupStats, false,                              \
-          "When true, print extra stats about parallel cleanup.")           \
-                                                                            \
   product(intx, G1UpdateBufferSize, 256,                                    \
           "Size of an update buffer")                                       \
                                                                             \
@@ -309,7 +305,10 @@
                                                                             \
   develop(uintx, G1OldCSetRegionThresholdPercent, 10,                       \
           "An upper bound for the number of old CSet regions expressed "    \
-          "as a percentage of the heap size.")
+          "as a percentage of the heap size.")                              \
+                                                                            \
+  experimental(ccstr, G1LogLevel, NULL,                                     \
+          "Log level for G1 logging: fine, finer, finest")
 
 G1_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_EXPERIMENTAL_FLAG, DECLARE_NOTPRODUCT_FLAG, DECLARE_MANAGEABLE_FLAG, DECLARE_PRODUCT_RW_FLAG)
 
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -334,7 +334,7 @@
 
   guarantee(GrainWords == 0, "we should only set it once");
   GrainWords = GrainBytes >> LogHeapWordSize;
-  guarantee((size_t)(1 << LogOfHRGrainWords) == GrainWords, "sanity");
+  guarantee((size_t) 1 << LogOfHRGrainWords == GrainWords, "sanity");
 
   guarantee(CardsPerRegion == 0, "we should only set it once");
   CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
@@ -370,7 +370,6 @@
     _claimed = InitialClaimValue;
   }
   zero_marked_bytes();
-  set_sort_index(-1);
 
   _offsets.resize(HeapRegion::GrainWords);
   init_top_at_mark_start();
@@ -482,17 +481,16 @@
 #endif // _MSC_VER
 
 
-HeapRegion::
-HeapRegion(size_t hrs_index, G1BlockOffsetSharedArray* sharedOffsetArray,
-           MemRegion mr, bool is_zeroed)
-  : G1OffsetTableContigSpace(sharedOffsetArray, mr, is_zeroed),
+HeapRegion::HeapRegion(uint hrs_index,
+                       G1BlockOffsetSharedArray* sharedOffsetArray,
+                       MemRegion mr, bool is_zeroed) :
+    G1OffsetTableContigSpace(sharedOffsetArray, mr, is_zeroed),
     _hrs_index(hrs_index),
     _humongous_type(NotHumongous), _humongous_start_region(NULL),
     _in_collection_set(false),
     _next_in_special_set(NULL), _orig_end(NULL),
     _claimed(InitialClaimValue), _evacuation_failed(false),
-    _prev_marked_bytes(0), _next_marked_bytes(0), _sort_index(-1),
-    _gc_efficiency(0.0),
+    _prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0),
     _young_type(NotYoung), _next_young_region(NULL),
     _next_dirty_cards_region(NULL), _next(NULL), _pending_removal(false),
 #ifdef ASSERT
@@ -779,16 +777,15 @@
   G1OffsetTableContigSpace::print_on(st);
 }
 
-void HeapRegion::verify(bool allow_dirty) const {
+void HeapRegion::verify() const {
   bool dummy = false;
-  verify(allow_dirty, VerifyOption_G1UsePrevMarking, /* failures */ &dummy);
+  verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy);
 }
 
 // This really ought to be commoned up into OffsetTableContigSpace somehow.
 // We would need a mechanism to make that code skip dead objects.
 
-void HeapRegion::verify(bool allow_dirty,
-                        VerifyOption vo,
+void HeapRegion::verify(VerifyOption vo,
                         bool* failures) const {
   G1CollectedHeap* g1 = G1CollectedHeap::heap();
   *failures = false;
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -52,12 +52,15 @@
 class HeapRegion;
 class HeapRegionSetBase;
 
-#define HR_FORMAT SIZE_FORMAT":(%s)["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]"
+#define HR_FORMAT "%u:(%s)["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]"
 #define HR_FORMAT_PARAMS(_hr_) \
                 (_hr_)->hrs_index(), \
                 (_hr_)->is_survivor() ? "S" : (_hr_)->is_young() ? "E" : "-", \
                 (_hr_)->bottom(), (_hr_)->top(), (_hr_)->end()
 
+// sentinel value for hrs_index
+#define G1_NULL_HRS_INDEX ((uint) -1)
+
 // A dirty card to oop closure for heap regions. It
 // knows how to get the G1 heap and how to use the bitmap
 // in the concurrent marker used by G1 to filter remembered
@@ -235,7 +238,7 @@
 
  protected:
   // The index of this region in the heap region sequence.
-  size_t  _hrs_index;
+  uint  _hrs_index;
 
   HumongousType _humongous_type;
   // For a humongous region, region in which it starts.
@@ -278,12 +281,8 @@
   size_t _prev_marked_bytes;    // Bytes known to be live via last completed marking.
   size_t _next_marked_bytes;    // Bytes known to be live via in-progress marking.
 
-  // See "sort_index" method.  -1 means is not in the array.
-  int _sort_index;
-
-  // <PREDICTION>
+  // The calculated GC efficiency of the region.
   double _gc_efficiency;
-  // </PREDICTION>
 
   enum YoungType {
     NotYoung,                   // a region is not young
@@ -342,7 +341,7 @@
 
  public:
   // If "is_zeroed" is "true", the region "mr" can be assumed to contain zeros.
-  HeapRegion(size_t hrs_index,
+  HeapRegion(uint hrs_index,
              G1BlockOffsetSharedArray* sharedOffsetArray,
              MemRegion mr, bool is_zeroed);
 
@@ -389,7 +388,7 @@
 
   // If this region is a member of a HeapRegionSeq, the index in that
   // sequence, otherwise -1.
-  size_t hrs_index() const { return _hrs_index; }
+  uint hrs_index() const { return _hrs_index; }
 
   // The number of bytes marked live in the region in the last marking phase.
   size_t marked_bytes()    { return _prev_marked_bytes; }
@@ -626,16 +625,6 @@
   // last mark phase ended.
   bool is_marked() { return _prev_top_at_mark_start != bottom(); }
 
-  // If "is_marked()" is true, then this is the index of the region in
-  // an array constructed at the end of marking of the regions in a
-  // "desirability" order.
-  int sort_index() {
-    return _sort_index;
-  }
-  void set_sort_index(int i) {
-    _sort_index = i;
-  }
-
   void init_top_at_conc_mark_count() {
     _top_at_conc_mark_count = bottom();
   }
@@ -823,10 +812,10 @@
   // Currently there is only one place where this is called with
   // vo == UseMarkWord, which is to verify the marking during a
   // full GC.
-  void verify(bool allow_dirty, VerifyOption vo, bool *failures) const;
+  void verify(VerifyOption vo, bool *failures) const;
 
   // Override; it uses the "prev" marking information
-  virtual void verify(bool allow_dirty) const;
+  virtual void verify() const;
 };
 
 // HeapRegionClosure is used for iterating over regions.
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -577,7 +577,7 @@
 #endif
 
 void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, int tid) {
-  size_t cur_hrs_ind = hr()->hrs_index();
+  size_t cur_hrs_ind = (size_t) hr()->hrs_index();
 
 #if HRRS_VERBOSE
   gclog_or_tty->print_cr("ORT::add_reference_work(" PTR_FORMAT "->" PTR_FORMAT ").",
@@ -841,7 +841,7 @@
 #endif
 
   // Set the corresponding coarse bit.
-  size_t max_hrs_index = max->hr()->hrs_index();
+  size_t max_hrs_index = (size_t) max->hr()->hrs_index();
   if (!_coarse_map.at(max_hrs_index)) {
     _coarse_map.at_put(max_hrs_index, true);
     _n_coarse_entries++;
@@ -866,17 +866,20 @@
 void OtherRegionsTable::scrub(CardTableModRefBS* ctbs,
                               BitMap* region_bm, BitMap* card_bm) {
   // First eliminated garbage regions from the coarse map.
-  if (G1RSScrubVerbose)
-    gclog_or_tty->print_cr("Scrubbing region "SIZE_FORMAT":",
-                           hr()->hrs_index());
+  if (G1RSScrubVerbose) {
+    gclog_or_tty->print_cr("Scrubbing region %u:", hr()->hrs_index());
+  }
 
   assert(_coarse_map.size() == region_bm->size(), "Precondition");
-  if (G1RSScrubVerbose)
-    gclog_or_tty->print("   Coarse map: before = %d...", _n_coarse_entries);
+  if (G1RSScrubVerbose) {
+    gclog_or_tty->print("   Coarse map: before = "SIZE_FORMAT"...",
+                        _n_coarse_entries);
+  }
   _coarse_map.set_intersection(*region_bm);
   _n_coarse_entries = _coarse_map.count_one_bits();
-  if (G1RSScrubVerbose)
-    gclog_or_tty->print_cr("   after = %d.", _n_coarse_entries);
+  if (G1RSScrubVerbose) {
+    gclog_or_tty->print_cr("   after = "SIZE_FORMAT".", _n_coarse_entries);
+  }
 
   // Now do the fine-grained maps.
   for (size_t i = 0; i < _max_fine_entries; i++) {
@@ -885,23 +888,27 @@
     while (cur != NULL) {
       PosParPRT* nxt = cur->next();
       // If the entire region is dead, eliminate.
-      if (G1RSScrubVerbose)
-        gclog_or_tty->print_cr("     For other region "SIZE_FORMAT":",
+      if (G1RSScrubVerbose) {
+        gclog_or_tty->print_cr("     For other region %u:",
                                cur->hr()->hrs_index());
-      if (!region_bm->at(cur->hr()->hrs_index())) {
+      }
+      if (!region_bm->at((size_t) cur->hr()->hrs_index())) {
         *prev = nxt;
         cur->set_next(NULL);
         _n_fine_entries--;
-        if (G1RSScrubVerbose)
+        if (G1RSScrubVerbose) {
           gclog_or_tty->print_cr("          deleted via region map.");
+        }
         PosParPRT::free(cur);
       } else {
         // Do fine-grain elimination.
-        if (G1RSScrubVerbose)
+        if (G1RSScrubVerbose) {
           gclog_or_tty->print("          occ: before = %4d.", cur->occupied());
+        }
         cur->scrub(ctbs, card_bm);
-        if (G1RSScrubVerbose)
+        if (G1RSScrubVerbose) {
           gclog_or_tty->print_cr("          after = %4d.", cur->occupied());
+        }
         // Did that empty the table completely?
         if (cur->occupied() == 0) {
           *prev = nxt;
@@ -1003,7 +1010,7 @@
 
 void OtherRegionsTable::clear_incoming_entry(HeapRegion* from_hr) {
   MutexLockerEx x(&_m, Mutex::_no_safepoint_check_flag);
-  size_t hrs_ind = from_hr->hrs_index();
+  size_t hrs_ind = (size_t) from_hr->hrs_index();
   size_t ind = hrs_ind & _mod_max_fine_entries_mask;
   if (del_single_region_table(ind, from_hr)) {
     assert(!_coarse_map.at(hrs_ind), "Inv");
@@ -1011,7 +1018,7 @@
     _coarse_map.par_at_put(hrs_ind, 0);
   }
   // Check to see if any of the fcc entries come from here.
-  size_t hr_ind = hr()->hrs_index();
+  size_t hr_ind = (size_t) hr()->hrs_index();
   for (int tid = 0; tid < HeapRegionRemSet::num_par_rem_sets(); tid++) {
     int fcc_ent = _from_card_cache[tid][hr_ind];
     if (fcc_ent != -1) {
@@ -1223,7 +1230,7 @@
     if ((size_t)_coarse_cur_region_index < _coarse_map->size()) {
       _coarse_cur_region_cur_card = 0;
       HeapWord* r_bot =
-        _g1h->region_at(_coarse_cur_region_index)->bottom();
+        _g1h->region_at((uint) _coarse_cur_region_index)->bottom();
       _cur_region_card_offset = _bosa->index_for(r_bot);
     } else {
       return false;
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -329,13 +329,13 @@
 
   // Declare the heap size (in # of regions) to the HeapRegionRemSet(s).
   // (Uses it to initialize from_card_cache).
-  static void init_heap(size_t max_regions) {
-    OtherRegionsTable::init_from_card_cache(max_regions);
+  static void init_heap(uint max_regions) {
+    OtherRegionsTable::init_from_card_cache((size_t) max_regions);
   }
 
   // Declares that only regions i s.t. 0 <= i < new_n_regs are in use.
-  static void shrink_heap(size_t new_n_regs) {
-    OtherRegionsTable::shrink_from_card_cache(new_n_regs);
+  static void shrink_heap(uint new_n_regs) {
+    OtherRegionsTable::shrink_from_card_cache((size_t) new_n_regs);
   }
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -31,16 +31,15 @@
 
 // Private
 
-size_t HeapRegionSeq::find_contiguous_from(size_t from, size_t num) {
-  size_t len = length();
+uint HeapRegionSeq::find_contiguous_from(uint from, uint num) {
+  uint len = length();
   assert(num > 1, "use this only for sequences of length 2 or greater");
   assert(from <= len,
-         err_msg("from: "SIZE_FORMAT" should be valid and <= than "SIZE_FORMAT,
-                 from, len));
+         err_msg("from: %u should be valid and <= than %u", from, len));
 
-  size_t curr = from;
-  size_t first = G1_NULL_HRS_INDEX;
-  size_t num_so_far = 0;
+  uint curr = from;
+  uint first = G1_NULL_HRS_INDEX;
+  uint num_so_far = 0;
   while (curr < len && num_so_far < num) {
     if (at(curr)->is_empty()) {
       if (first == G1_NULL_HRS_INDEX) {
@@ -60,7 +59,7 @@
     // we found enough space for the humongous object
     assert(from <= first && first < len, "post-condition");
     assert(first < curr && (curr - first) == num, "post-condition");
-    for (size_t i = first; i < first + num; ++i) {
+    for (uint i = first; i < first + num; ++i) {
       assert(at(i)->is_empty(), "post-condition");
     }
     return first;
@@ -73,10 +72,10 @@
 // Public
 
 void HeapRegionSeq::initialize(HeapWord* bottom, HeapWord* end,
-                               size_t max_length) {
-  assert((size_t) bottom % HeapRegion::GrainBytes == 0,
+                               uint max_length) {
+  assert((uintptr_t) bottom % HeapRegion::GrainBytes == 0,
          "bottom should be heap region aligned");
-  assert((size_t) end % HeapRegion::GrainBytes == 0,
+  assert((uintptr_t) end % HeapRegion::GrainBytes == 0,
          "end should be heap region aligned");
 
   _length = 0;
@@ -88,8 +87,8 @@
   _max_length = max_length;
 
   _regions = NEW_C_HEAP_ARRAY(HeapRegion*, max_length);
-  memset(_regions, 0, max_length * sizeof(HeapRegion*));
-  _regions_biased = _regions - ((size_t) bottom >> _region_shift);
+  memset(_regions, 0, (size_t) max_length * sizeof(HeapRegion*));
+  _regions_biased = _regions - ((uintx) bottom >> _region_shift);
 
   assert(&_regions[0] == &_regions_biased[addr_to_index_biased(bottom)],
          "bottom should be included in the region with index 0");
@@ -105,7 +104,7 @@
   assert(_heap_bottom <= next_bottom, "invariant");
   while (next_bottom < new_end) {
     assert(next_bottom < _heap_end, "invariant");
-    size_t index = length();
+    uint index = length();
 
     assert(index < _max_length, "otherwise we cannot expand further");
     if (index == 0) {
@@ -139,9 +138,9 @@
   return MemRegion(old_end, next_bottom);
 }
 
-size_t HeapRegionSeq::free_suffix() {
-  size_t res = 0;
-  size_t index = length();
+uint HeapRegionSeq::free_suffix() {
+  uint res = 0;
+  uint index = length();
   while (index > 0) {
     index -= 1;
     if (!at(index)->is_empty()) {
@@ -152,27 +151,24 @@
   return res;
 }
 
-size_t HeapRegionSeq::find_contiguous(size_t num) {
+uint HeapRegionSeq::find_contiguous(uint num) {
   assert(num > 1, "use this only for sequences of length 2 or greater");
   assert(_next_search_index <= length(),
-         err_msg("_next_search_indeex: "SIZE_FORMAT" "
-                 "should be valid and <= than "SIZE_FORMAT,
+         err_msg("_next_search_index: %u should be valid and <= than %u",
                  _next_search_index, length()));
 
-  size_t start = _next_search_index;
-  size_t res = find_contiguous_from(start, num);
+  uint start = _next_search_index;
+  uint res = find_contiguous_from(start, num);
   if (res == G1_NULL_HRS_INDEX && start > 0) {
     // Try starting from the beginning. If _next_search_index was 0,
     // no point in doing this again.
     res = find_contiguous_from(0, num);
   }
   if (res != G1_NULL_HRS_INDEX) {
-    assert(res < length(),
-           err_msg("res: "SIZE_FORMAT" should be valid", res));
+    assert(res < length(), err_msg("res: %u should be valid", res));
     _next_search_index = res + num;
     assert(_next_search_index <= length(),
-           err_msg("_next_search_indeex: "SIZE_FORMAT" "
-                   "should be valid and <= than "SIZE_FORMAT,
+           err_msg("_next_search_index: %u should be valid and <= than %u",
                    _next_search_index, length()));
   }
   return res;
@@ -183,20 +179,20 @@
 }
 
 void HeapRegionSeq::iterate_from(HeapRegion* hr, HeapRegionClosure* blk) const {
-  size_t hr_index = 0;
+  uint hr_index = 0;
   if (hr != NULL) {
-    hr_index = (size_t) hr->hrs_index();
+    hr_index = hr->hrs_index();
   }
 
-  size_t len = length();
-  for (size_t i = hr_index; i < len; i += 1) {
+  uint len = length();
+  for (uint i = hr_index; i < len; i += 1) {
     bool res = blk->doHeapRegion(at(i));
     if (res) {
       blk->incomplete();
       return;
     }
   }
-  for (size_t i = 0; i < hr_index; i += 1) {
+  for (uint i = 0; i < hr_index; i += 1) {
     bool res = blk->doHeapRegion(at(i));
     if (res) {
       blk->incomplete();
@@ -206,7 +202,7 @@
 }
 
 MemRegion HeapRegionSeq::shrink_by(size_t shrink_bytes,
-                                   size_t* num_regions_deleted) {
+                                   uint* num_regions_deleted) {
   // Reset this in case it's currently pointing into the regions that
   // we just removed.
   _next_search_index = 0;
@@ -218,7 +214,7 @@
   assert(_allocated_length > 0, "we should have at least one region committed");
 
   // around the loop, i will be the next region to be removed
-  size_t i = length() - 1;
+  uint i = length() - 1;
   assert(i > 0, "we should never remove all regions");
   // [last_start, end) is the MemRegion that covers the regions we will remove.
   HeapWord* end = at(i)->end();
@@ -249,29 +245,24 @@
 #ifndef PRODUCT
 void HeapRegionSeq::verify_optional() {
   guarantee(_length <= _allocated_length,
-            err_msg("invariant: _length: "SIZE_FORMAT" "
-                    "_allocated_length: "SIZE_FORMAT,
+            err_msg("invariant: _length: %u _allocated_length: %u",
                     _length, _allocated_length));
   guarantee(_allocated_length <= _max_length,
-            err_msg("invariant: _allocated_length: "SIZE_FORMAT" "
-                    "_max_length: "SIZE_FORMAT,
+            err_msg("invariant: _allocated_length: %u _max_length: %u",
                     _allocated_length, _max_length));
   guarantee(_next_search_index <= _length,
-            err_msg("invariant: _next_search_index: "SIZE_FORMAT" "
-                    "_length: "SIZE_FORMAT,
+            err_msg("invariant: _next_search_index: %u _length: %u",
                     _next_search_index, _length));
 
   HeapWord* prev_end = _heap_bottom;
-  for (size_t i = 0; i < _allocated_length; i += 1) {
+  for (uint i = 0; i < _allocated_length; i += 1) {
     HeapRegion* hr = _regions[i];
-    guarantee(hr != NULL, err_msg("invariant: i: "SIZE_FORMAT, i));
+    guarantee(hr != NULL, err_msg("invariant: i: %u", i));
     guarantee(hr->bottom() == prev_end,
-              err_msg("invariant i: "SIZE_FORMAT" "HR_FORMAT" "
-                      "prev_end: "PTR_FORMAT,
+              err_msg("invariant i: %u "HR_FORMAT" prev_end: "PTR_FORMAT,
                       i, HR_FORMAT_PARAMS(hr), prev_end));
     guarantee(hr->hrs_index() == i,
-              err_msg("invariant: i: "SIZE_FORMAT" hrs_index(): "SIZE_FORMAT,
-                      i, hr->hrs_index()));
+              err_msg("invariant: i: %u hrs_index(): %u", i, hr->hrs_index()));
     if (i < _length) {
       // Asserts will fire if i is >= _length
       HeapWord* addr = hr->bottom();
@@ -290,8 +281,8 @@
       prev_end = hr->end();
     }
   }
-  for (size_t i = _allocated_length; i < _max_length; i += 1) {
-    guarantee(_regions[i] == NULL, err_msg("invariant i: "SIZE_FORMAT, i));
+  for (uint i = _allocated_length; i < _max_length; i += 1) {
+    guarantee(_regions[i] == NULL, err_msg("invariant i: %u", i));
   }
 }
 #endif // PRODUCT
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -29,8 +29,6 @@
 class HeapRegionClosure;
 class FreeRegionList;
 
-#define G1_NULL_HRS_INDEX ((size_t) -1)
-
 // This class keeps track of the region metadata (i.e., HeapRegion
 // instances). They are kept in the _regions array in address
 // order. A region's index in the array corresponds to its index in
@@ -65,7 +63,7 @@
   HeapRegion** _regions_biased;
 
   // The number of regions committed in the heap.
-  size_t _length;
+  uint _length;
 
   // The address of the first reserved word in the heap.
   HeapWord* _heap_bottom;
@@ -74,32 +72,32 @@
   HeapWord* _heap_end;
 
   // The log of the region byte size.
-  size_t _region_shift;
+  uint _region_shift;
 
   // A hint for which index to start searching from for humongous
   // allocations.
-  size_t _next_search_index;
+  uint _next_search_index;
 
   // The number of regions for which we have allocated HeapRegions for.
-  size_t _allocated_length;
+  uint _allocated_length;
 
   // The maximum number of regions in the heap.
-  size_t _max_length;
+  uint _max_length;
 
   // Find a contiguous set of empty regions of length num, starting
   // from the given index.
-  size_t find_contiguous_from(size_t from, size_t num);
+  uint find_contiguous_from(uint from, uint num);
 
   // Map a heap address to a biased region index. Assume that the
   // address is valid.
-  inline size_t addr_to_index_biased(HeapWord* addr) const;
+  inline uintx addr_to_index_biased(HeapWord* addr) const;
 
-  void increment_length(size_t* length) {
+  void increment_length(uint* length) {
     assert(*length < _max_length, "pre-condition");
     *length += 1;
   }
 
-  void decrement_length(size_t* length) {
+  void decrement_length(uint* length) {
     assert(*length > 0, "pre-condition");
     *length -= 1;
   }
@@ -108,11 +106,11 @@
   // Empty contructor, we'll initialize it with the initialize() method.
   HeapRegionSeq() { }
 
-  void initialize(HeapWord* bottom, HeapWord* end, size_t max_length);
+  void initialize(HeapWord* bottom, HeapWord* end, uint max_length);
 
   // Return the HeapRegion at the given index. Assume that the index
   // is valid.
-  inline HeapRegion* at(size_t index) const;
+  inline HeapRegion* at(uint index) const;
 
   // If addr is within the committed space return its corresponding
   // HeapRegion, otherwise return NULL.
@@ -123,10 +121,10 @@
   inline HeapRegion* addr_to_region_unsafe(HeapWord* addr) const;
 
   // Return the number of regions that have been committed in the heap.
-  size_t length() const { return _length; }
+  uint length() const { return _length; }
 
   // Return the maximum number of regions in the heap.
-  size_t max_length() const { return _max_length; }
+  uint max_length() const { return _max_length; }
 
   // Expand the sequence to reflect that the heap has grown from
   // old_end to new_end. Either create new HeapRegions, or re-use
@@ -139,12 +137,12 @@
 
   // Return the number of contiguous regions at the end of the sequence
   // that are available for allocation.
-  size_t free_suffix();
+  uint free_suffix();
 
   // Find a contiguous set of empty regions of length num and return
   // the index of the first region or G1_NULL_HRS_INDEX if the
   // search was unsuccessful.
-  size_t find_contiguous(size_t num);
+  uint find_contiguous(uint num);
 
   // Apply blk->doHeapRegion() on all committed regions in address order,
   // terminating the iteration early if doHeapRegion() returns true.
@@ -159,7 +157,7 @@
   // sequence. Return a MemRegion that corresponds to the address
   // range of the uncommitted regions. Assume shrink_bytes is page and
   // heap region aligned.
-  MemRegion shrink_by(size_t shrink_bytes, size_t* num_regions_deleted);
+  MemRegion shrink_by(size_t shrink_bytes, uint* num_regions_deleted);
 
   // Do some sanity checking.
   void verify_optional() PRODUCT_RETURN;
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,11 +28,11 @@
 #include "gc_implementation/g1/heapRegion.hpp"
 #include "gc_implementation/g1/heapRegionSeq.hpp"
 
-inline size_t HeapRegionSeq::addr_to_index_biased(HeapWord* addr) const {
+inline uintx HeapRegionSeq::addr_to_index_biased(HeapWord* addr) const {
   assert(_heap_bottom <= addr && addr < _heap_end,
          err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT" end: "PTR_FORMAT,
                  addr, _heap_bottom, _heap_end));
-  size_t index = (size_t) addr >> _region_shift;
+  uintx index = (uintx) addr >> _region_shift;
   return index;
 }
 
@@ -40,7 +40,7 @@
   assert(_heap_bottom <= addr && addr < _heap_end,
          err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT" end: "PTR_FORMAT,
                  addr, _heap_bottom, _heap_end));
-  size_t index_biased = addr_to_index_biased(addr);
+  uintx index_biased = addr_to_index_biased(addr);
   HeapRegion* hr = _regions_biased[index_biased];
   assert(hr != NULL, "invariant");
   return hr;
@@ -55,7 +55,7 @@
   return NULL;
 }
 
-inline HeapRegion* HeapRegionSeq::at(size_t index) const {
+inline HeapRegion* HeapRegionSeq::at(uint index) const {
   assert(index < length(), "pre-condition");
   HeapRegion* hr = _regions[index];
   assert(hr != NULL, "sanity");
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,28 +25,26 @@
 #include "precompiled.hpp"
 #include "gc_implementation/g1/heapRegionSet.inline.hpp"
 
-size_t HeapRegionSetBase::_unrealistically_long_length = 0;
+uint HeapRegionSetBase::_unrealistically_long_length = 0;
 HRSPhase HeapRegionSetBase::_phase = HRSPhaseNone;
 
 //////////////////// HeapRegionSetBase ////////////////////
 
-void HeapRegionSetBase::set_unrealistically_long_length(size_t len) {
+void HeapRegionSetBase::set_unrealistically_long_length(uint len) {
   guarantee(_unrealistically_long_length == 0, "should only be set once");
   _unrealistically_long_length = len;
 }
 
-size_t HeapRegionSetBase::calculate_region_num(HeapRegion* hr) {
+uint HeapRegionSetBase::calculate_region_num(HeapRegion* hr) {
   assert(hr->startsHumongous(), "pre-condition");
   assert(hr->capacity() % HeapRegion::GrainBytes == 0, "invariant");
-  size_t region_num = hr->capacity() >> HeapRegion::LogOfHRGrainBytes;
+  uint region_num = (uint) (hr->capacity() >> HeapRegion::LogOfHRGrainBytes);
   assert(region_num > 0, "sanity");
   return region_num;
 }
 
 void HeapRegionSetBase::fill_in_ext_msg(hrs_ext_msg* msg, const char* message) {
-  msg->append("[%s] %s "
-              "ln: "SIZE_FORMAT" rn: "SIZE_FORMAT" "
-              "cy: "SIZE_FORMAT" ud: "SIZE_FORMAT,
+  msg->append("[%s] %s ln: %u rn: %u cy: "SIZE_FORMAT" ud: "SIZE_FORMAT,
               name(), message, length(), region_num(),
               total_capacity_bytes(), total_used_bytes());
   fill_in_ext_msg_extra(msg);
@@ -170,13 +168,11 @@
          hrs_ext_msg(this, "verification should be in progress"));
 
   guarantee(length() == _calc_length,
-            hrs_err_msg("[%s] length: "SIZE_FORMAT" should be == "
-                        "calc length: "SIZE_FORMAT,
+            hrs_err_msg("[%s] length: %u should be == calc length: %u",
                         name(), length(), _calc_length));
 
   guarantee(region_num() == _calc_region_num,
-            hrs_err_msg("[%s] region num: "SIZE_FORMAT" should be == "
-                        "calc region num: "SIZE_FORMAT,
+            hrs_err_msg("[%s] region num: %u should be == calc region num: %u",
                         name(), region_num(), _calc_region_num));
 
   guarantee(total_capacity_bytes() == _calc_total_capacity_bytes,
@@ -211,8 +207,8 @@
   out->print_cr("    humongous         : %s", BOOL_TO_STR(regions_humongous()));
   out->print_cr("    empty             : %s", BOOL_TO_STR(regions_empty()));
   out->print_cr("  Attributes");
-  out->print_cr("    length            : "SIZE_FORMAT_W(14), length());
-  out->print_cr("    region num        : "SIZE_FORMAT_W(14), region_num());
+  out->print_cr("    length            : %14u", length());
+  out->print_cr("    region num        : %14u", region_num());
   out->print_cr("    total capacity    : "SIZE_FORMAT_W(14)" bytes",
                 total_capacity_bytes());
   out->print_cr("    total used        : "SIZE_FORMAT_W(14)" bytes",
@@ -243,14 +239,12 @@
   if (proxy_set->is_empty()) return;
 
   assert(proxy_set->length() <= _length,
-         hrs_err_msg("[%s] proxy set length: "SIZE_FORMAT" "
-                     "should be <= length: "SIZE_FORMAT,
+         hrs_err_msg("[%s] proxy set length: %u should be <= length: %u",
                      name(), proxy_set->length(), _length));
   _length -= proxy_set->length();
 
   assert(proxy_set->region_num() <= _region_num,
-         hrs_err_msg("[%s] proxy set region num: "SIZE_FORMAT" "
-                     "should be <= region num: "SIZE_FORMAT,
+         hrs_err_msg("[%s] proxy set region num: %u should be <= region num: %u",
                      name(), proxy_set->region_num(), _region_num));
   _region_num -= proxy_set->region_num();
 
@@ -369,17 +363,17 @@
   verify_optional();
 }
 
-void HeapRegionLinkedList::remove_all_pending(size_t target_count) {
+void HeapRegionLinkedList::remove_all_pending(uint target_count) {
   hrs_assert_mt_safety_ok(this);
   assert(target_count > 1, hrs_ext_msg(this, "pre-condition"));
   assert(!is_empty(), hrs_ext_msg(this, "pre-condition"));
 
   verify_optional();
-  DEBUG_ONLY(size_t old_length = length();)
+  DEBUG_ONLY(uint old_length = length();)
 
   HeapRegion* curr = _head;
   HeapRegion* prev = NULL;
-  size_t count = 0;
+  uint count = 0;
   while (curr != NULL) {
     hrs_assert_region_ok(this, curr, this);
     HeapRegion* next = curr->next();
@@ -387,7 +381,7 @@
     if (curr->pending_removal()) {
       assert(count < target_count,
              hrs_err_msg("[%s] should not come across more regions "
-                         "pending for removal than target_count: "SIZE_FORMAT,
+                         "pending for removal than target_count: %u",
                          name(), target_count));
 
       if (prev == NULL) {
@@ -422,12 +416,11 @@
   }
 
   assert(count == target_count,
-         hrs_err_msg("[%s] count: "SIZE_FORMAT" should be == "
-                     "target_count: "SIZE_FORMAT, name(), count, target_count));
+         hrs_err_msg("[%s] count: %u should be == target_count: %u",
+                     name(), count, target_count));
   assert(length() + target_count == old_length,
          hrs_err_msg("[%s] new length should be consistent "
-                     "new length: "SIZE_FORMAT" old length: "SIZE_FORMAT" "
-                     "target_count: "SIZE_FORMAT,
+                     "new length: %u old length: %u target_count: %u",
                      name(), length(), old_length, target_count));
 
   verify_optional();
@@ -444,16 +437,16 @@
   HeapRegion* curr  = _head;
   HeapRegion* prev1 = NULL;
   HeapRegion* prev0 = NULL;
-  size_t      count = 0;
+  uint        count = 0;
   while (curr != NULL) {
     verify_next_region(curr);
 
     count += 1;
     guarantee(count < _unrealistically_long_length,
-              hrs_err_msg("[%s] the calculated length: "SIZE_FORMAT" "
+              hrs_err_msg("[%s] the calculated length: %u "
                           "seems very long, is there maybe a cycle? "
                           "curr: "PTR_FORMAT" prev0: "PTR_FORMAT" "
-                          "prev1: "PTR_FORMAT" length: "SIZE_FORMAT,
+                          "prev1: "PTR_FORMAT" length: %u",
                           name(), count, curr, prev0, prev1, length()));
 
     prev1 = prev0;
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -62,20 +62,20 @@
   friend class VMStructs;
 
 protected:
-  static size_t calculate_region_num(HeapRegion* hr);
+  static uint calculate_region_num(HeapRegion* hr);
 
-  static size_t _unrealistically_long_length;
+  static uint _unrealistically_long_length;
 
   // The number of regions added to the set. If the set contains
   // only humongous regions, this reflects only 'starts humongous'
   // regions and does not include 'continues humongous' ones.
-  size_t _length;
+  uint _length;
 
   // The total number of regions represented by the set. If the set
   // does not contain humongous regions, this should be the same as
   // _length. If the set contains only humongous regions, this will
   // include the 'continues humongous' regions.
-  size_t _region_num;
+  uint _region_num;
 
   // We don't keep track of the total capacity explicitly, we instead
   // recalculate it based on _region_num and the heap region size.
@@ -86,8 +86,8 @@
   const char* _name;
 
   bool        _verify_in_progress;
-  size_t      _calc_length;
-  size_t      _calc_region_num;
+  uint        _calc_length;
+  uint        _calc_region_num;
   size_t      _calc_total_capacity_bytes;
   size_t      _calc_total_used_bytes;
 
@@ -153,18 +153,18 @@
   HeapRegionSetBase(const char* name);
 
 public:
-  static void set_unrealistically_long_length(size_t len);
+  static void set_unrealistically_long_length(uint len);
 
   const char* name() { return _name; }
 
-  size_t length() { return _length; }
+  uint length() { return _length; }
 
   bool is_empty() { return _length == 0; }
 
-  size_t region_num() { return _region_num; }
+  uint region_num() { return _region_num; }
 
   size_t total_capacity_bytes() {
-    return region_num() << HeapRegion::LogOfHRGrainBytes;
+    return (size_t) region_num() << HeapRegion::LogOfHRGrainBytes;
   }
 
   size_t total_used_bytes() { return _total_used_bytes; }
@@ -341,7 +341,7 @@
   // of regions that are pending for removal in the list, and
   // target_count should be > 1 (currently, we never need to remove a
   // single region using this).
-  void remove_all_pending(size_t target_count);
+  void remove_all_pending(uint target_count);
 
   virtual void verify();
 
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,15 +54,15 @@
   assert(_length > 0, hrs_ext_msg(this, "pre-condition"));
   _length -= 1;
 
-  size_t region_num_diff;
+  uint region_num_diff;
   if (!hr->isHumongous()) {
     region_num_diff = 1;
   } else {
     region_num_diff = calculate_region_num(hr);
   }
   assert(region_num_diff <= _region_num,
-         hrs_err_msg("[%s] region's region num: "SIZE_FORMAT" "
-                     "should be <= region num: "SIZE_FORMAT,
+         hrs_err_msg("[%s] region's region num: %u "
+                     "should be <= region num: %u",
                      name(), region_num_diff, _region_num));
   _region_num -= region_num_diff;
 
--- a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -481,8 +481,7 @@
 
 bool SparsePRT::add_card(RegionIdx_t region_id, CardIdx_t card_index) {
 #if SPARSE_PRT_VERBOSE
-  gclog_or_tty->print_cr("  Adding card %d from region %d to region "
-                         SIZE_FORMAT" sparse.",
+  gclog_or_tty->print_cr("  Adding card %d from region %d to region %u sparse.",
                          card_index, region_id, _hr->hrs_index());
 #endif
   if (_next->occupied_entries() * 2 > _next->capacity()) {
@@ -534,7 +533,7 @@
   _next = new RSHashTable(last->capacity() * 2);
 
 #if SPARSE_PRT_VERBOSE
-  gclog_or_tty->print_cr("  Expanded sparse table for "SIZE_FORMAT" to %d.",
+  gclog_or_tty->print_cr("  Expanded sparse table for %u to %d.",
                          _hr->hrs_index(), _next->capacity());
 #endif
   for (size_t i = 0; i < last->capacity(); i++) {
--- a/hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -34,7 +34,7 @@
   static_field(HeapRegion, GrainBytes, size_t)                                \
                                                                               \
   nonstatic_field(HeapRegionSeq,   _regions, HeapRegion**)                    \
-  nonstatic_field(HeapRegionSeq,   _length,  size_t)                          \
+  nonstatic_field(HeapRegionSeq,   _length,  uint)                            \
                                                                               \
   nonstatic_field(G1CollectedHeap, _hrs,                HeapRegionSeq)        \
   nonstatic_field(G1CollectedHeap, _g1_committed,       MemRegion)            \
@@ -50,8 +50,8 @@
   nonstatic_field(G1MonitoringSupport, _old_committed,      size_t)           \
   nonstatic_field(G1MonitoringSupport, _old_used,           size_t)           \
                                                                               \
-  nonstatic_field(HeapRegionSetBase,   _length,             size_t)           \
-  nonstatic_field(HeapRegionSetBase,   _region_num,         size_t)           \
+  nonstatic_field(HeapRegionSetBase,   _length,             uint)             \
+  nonstatic_field(HeapRegionSetBase,   _region_num,         uint)             \
   nonstatic_field(HeapRegionSetBase,   _total_used_bytes,   size_t)           \
 
 
--- a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -26,6 +26,7 @@
 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
+#include "gc_implementation/g1/g1Log.hpp"
 #include "gc_implementation/g1/vm_operations_g1.hpp"
 #include "gc_implementation/shared/isGCActiveMark.hpp"
 #include "gc_implementation/g1/vm_operations_g1.hpp"
@@ -223,9 +224,9 @@
 }
 
 void VM_CGC_Operation::doit() {
-  gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
-  TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
-  TraceTime t(_printGCMessage, PrintGC, true, gclog_or_tty);
+  gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps);
+  TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
+  TraceTime t(_printGCMessage, G1Log::fine(), true, gclog_or_tty);
   SharedHeap* sh = SharedHeap::heap();
   // This could go away if CollectedHeap gave access to _gc_is_active...
   if (sh != NULL) {
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -42,7 +42,7 @@
 
  protected:
   template <class T> void do_oop_work(T* p) {
-    oop obj = oopDesc::load_decode_heap_oop_not_null(p);
+    oop obj = oopDesc::load_decode_heap_oop(p);
     if (_young_gen->is_in_reserved(obj) &&
         !_card_table->addr_is_marked_imprecise(p)) {
       // Don't overwrite the first missing card mark
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -911,23 +911,23 @@
 }
 
 
-void ParallelScavengeHeap::verify(bool allow_dirty, bool silent, VerifyOption option /* ignored */) {
+void ParallelScavengeHeap::verify(bool silent, VerifyOption option /* ignored */) {
   // Why do we need the total_collections()-filter below?
   if (total_collections() > 0) {
     if (!silent) {
       gclog_or_tty->print("permanent ");
     }
-    perm_gen()->verify(allow_dirty);
+    perm_gen()->verify();
 
     if (!silent) {
       gclog_or_tty->print("tenured ");
     }
-    old_gen()->verify(allow_dirty);
+    old_gen()->verify();
 
     if (!silent) {
       gclog_or_tty->print("eden ");
     }
-    young_gen()->verify(allow_dirty);
+    young_gen()->verify();
   }
 }
 
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -257,7 +257,7 @@
   virtual void gc_threads_do(ThreadClosure* tc) const;
   virtual void print_tracing_info() const;
 
-  void verify(bool allow_dirty, bool silent, VerifyOption option /* ignored */);
+  void verify(bool silent, VerifyOption option /* ignored */);
 
   void print_heap_change(size_t prev_used);
 
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -477,8 +477,8 @@
 }
 #endif
 
-void PSOldGen::verify(bool allow_dirty) {
-  object_space()->verify(allow_dirty);
+void PSOldGen::verify() {
+  object_space()->verify();
 }
 class VerifyObjectStartArrayClosure : public ObjectClosure {
   PSOldGen* _gen;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -174,7 +174,7 @@
   virtual void print_on(outputStream* st) const;
   void print_used_change(size_t prev_used) const;
 
-  void verify(bool allow_dirty);
+  void verify();
   void verify_object_start_array();
 
   // These should not used
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -937,10 +937,10 @@
   }
 }
 
-void PSYoungGen::verify(bool allow_dirty) {
-  eden_space()->verify(allow_dirty);
-  from_space()->verify(allow_dirty);
-  to_space()->verify(allow_dirty);
+void PSYoungGen::verify() {
+  eden_space()->verify();
+  from_space()->verify();
+  to_space()->verify();
 }
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -181,7 +181,7 @@
   void print_used_change(size_t prev_used) const;
   virtual const char* name() const { return "PSYoungGen"; }
 
-  void verify(bool allow_dirty);
+  void verify();
 
   // Space boundary invariant checker
   void space_invariants() PRODUCT_RETURN;
--- a/hotspot/src/share/vm/gc_implementation/shared/immutableSpace.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/immutableSpace.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -70,7 +70,7 @@
 
 #endif
 
-void ImmutableSpace::verify(bool allow_dirty) {
+void ImmutableSpace::verify() {
   HeapWord* p = bottom();
   HeapWord* t = end();
   HeapWord* prev_p = NULL;
--- a/hotspot/src/share/vm/gc_implementation/shared/immutableSpace.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/immutableSpace.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -65,7 +65,7 @@
   // Debugging
   virtual void print() const            PRODUCT_RETURN;
   virtual void print_short() const      PRODUCT_RETURN;
-  virtual void verify(bool allow_dirty);
+  virtual void verify();
 };
 
 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_IMMUTABLESPACE_HPP
--- a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -891,12 +891,12 @@
   }
 }
 
-void MutableNUMASpace::verify(bool allow_dirty) {
+void MutableNUMASpace::verify() {
   // This can be called after setting an arbitary value to the space's top,
   // so an object can cross the chunk boundary. We ensure the parsablity
   // of the space and just walk the objects in linear fashion.
   ensure_parsability();
-  MutableSpace::verify(allow_dirty);
+  MutableSpace::verify();
 }
 
 // Scan pages and gather stats about page placement and size.
--- a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -225,7 +225,7 @@
   // Debugging
   virtual void print_on(outputStream* st) const;
   virtual void print_short_on(outputStream* st) const;
-  virtual void verify(bool allow_dirty);
+  virtual void verify();
 
   virtual void set_top(HeapWord* value);
 };
--- a/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -246,7 +246,7 @@
                  bottom(), top(), end());
 }
 
-void MutableSpace::verify(bool allow_dirty) {
+void MutableSpace::verify() {
   HeapWord* p = bottom();
   HeapWord* t = top();
   HeapWord* prev_p = NULL;
--- a/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -141,7 +141,7 @@
   virtual void print_on(outputStream* st) const;
   virtual void print_short() const;
   virtual void print_short_on(outputStream* st) const;
-  virtual void verify(bool allow_dirty);
+  virtual void verify();
 };
 
 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_MUTABLESPACE_HPP
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -659,7 +659,7 @@
   }
 
   // Heap verification
-  virtual void verify(bool allow_dirty, bool silent, VerifyOption option) = 0;
+  virtual void verify(bool silent, VerifyOption option) = 0;
 
   // Non product verification and debugging.
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/memory/compactingPermGenGen.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/compactingPermGenGen.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -444,11 +444,11 @@
 }
 
 
-void CompactingPermGenGen::verify(bool allow_dirty) {
-  the_space()->verify(allow_dirty);
+void CompactingPermGenGen::verify() {
+  the_space()->verify();
   if (!SharedSkipVerify && spec()->enable_shared_spaces()) {
-    ro_space()->verify(allow_dirty);
-    rw_space()->verify(allow_dirty);
+    ro_space()->verify();
+    rw_space()->verify();
   }
 }
 
--- a/hotspot/src/share/vm/memory/compactingPermGenGen.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/compactingPermGenGen.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -230,7 +230,7 @@
                                       void* new_vtable_start,
                                       void* obj);
 
-  void verify(bool allow_dirty);
+  void verify();
 
   // Serialization
   static void initialize_oops() KERNEL_RETURN;
--- a/hotspot/src/share/vm/memory/defNewGeneration.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -939,10 +939,10 @@
   }
 }
 
-void DefNewGeneration::verify(bool allow_dirty) {
-  eden()->verify(allow_dirty);
-  from()->verify(allow_dirty);
-    to()->verify(allow_dirty);
+void DefNewGeneration::verify() {
+  eden()->verify();
+  from()->verify();
+    to()->verify();
 }
 
 void DefNewGeneration::print_on(outputStream* st) const {
--- a/hotspot/src/share/vm/memory/defNewGeneration.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/defNewGeneration.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -340,7 +340,7 @@
   // PrintHeapAtGC support.
   void print_on(outputStream* st) const;
 
-  void verify(bool allow_dirty);
+  void verify();
 
   bool promo_failure_scan_is_complete() const {
     return _promo_failure_scan_stack.is_empty();
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1247,18 +1247,18 @@
   return _gens[level]->gc_stats();
 }
 
-void GenCollectedHeap::verify(bool allow_dirty, bool silent, VerifyOption option /* ignored */) {
+void GenCollectedHeap::verify(bool silent, VerifyOption option /* ignored */) {
   if (!silent) {
     gclog_or_tty->print("permgen ");
   }
-  perm_gen()->verify(allow_dirty);
+  perm_gen()->verify();
   for (int i = _n_gens-1; i >= 0; i--) {
     Generation* g = _gens[i];
     if (!silent) {
       gclog_or_tty->print(g->name());
       gclog_or_tty->print(" ");
     }
-    g->verify(allow_dirty);
+    g->verify();
   }
   if (!silent) {
     gclog_or_tty->print("remset ");
--- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -357,7 +357,7 @@
   void prepare_for_verify();
 
   // Override.
-  void verify(bool allow_dirty, bool silent, VerifyOption option);
+  void verify(bool silent, VerifyOption option);
 
   // Override.
   virtual void print_on(outputStream* st) const;
--- a/hotspot/src/share/vm/memory/generation.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/generation.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -696,8 +696,8 @@
   the_space()->set_top_for_allocations();
 }
 
-void OneContigSpaceCardGeneration::verify(bool allow_dirty) {
-  the_space()->verify(allow_dirty);
+void OneContigSpaceCardGeneration::verify() {
+  the_space()->verify();
 }
 
 void OneContigSpaceCardGeneration::print_on(outputStream* st)  const {
--- a/hotspot/src/share/vm/memory/generation.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/generation.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -599,7 +599,7 @@
   virtual void print() const;
   virtual void print_on(outputStream* st) const;
 
-  virtual void verify(bool allow_dirty) = 0;
+  virtual void verify() = 0;
 
   struct StatRecord {
     int invocations;
@@ -753,7 +753,7 @@
 
   virtual void record_spaces_top();
 
-  virtual void verify(bool allow_dirty);
+  virtual void verify();
   virtual void print_on(outputStream* st) const;
 };
 
--- a/hotspot/src/share/vm/memory/oopFactory.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/oopFactory.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -127,9 +127,12 @@
 klassOop oopFactory::new_instanceKlass(Symbol* name, int vtable_len, int itable_len,
                                        int static_field_size,
                                        unsigned int nonstatic_oop_map_count,
+                                       AccessFlags access_flags,
                                        ReferenceType rt, TRAPS) {
   instanceKlassKlass* ikk = instanceKlassKlass::cast(Universe::instanceKlassKlassObj());
-  return ikk->allocate_instance_klass(name, vtable_len, itable_len, static_field_size, nonstatic_oop_map_count, rt, CHECK_NULL);
+  return ikk->allocate_instance_klass(name, vtable_len, itable_len,
+                                      static_field_size, nonstatic_oop_map_count,
+                                      access_flags, rt, CHECK_NULL);
 }
 
 
--- a/hotspot/src/share/vm/memory/oopFactory.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/oopFactory.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,6 +77,7 @@
                                            int vtable_len, int itable_len,
                                            int static_field_size,
                                            unsigned int nonstatic_oop_map_count,
+                                           AccessFlags access_flags,
                                            ReferenceType rt, TRAPS);
 
   // Methods
--- a/hotspot/src/share/vm/memory/space.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/space.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -531,7 +531,7 @@
               bottom(), top(), _offsets.threshold(), end());
 }
 
-void ContiguousSpace::verify(bool allow_dirty) const {
+void ContiguousSpace::verify() const {
   HeapWord* p = bottom();
   HeapWord* t = top();
   HeapWord* prev_p = NULL;
@@ -965,27 +965,12 @@
   initialize(mr, SpaceDecorator::Clear, SpaceDecorator::Mangle);
 }
 
-
-class VerifyOldOopClosure : public OopClosure {
- public:
-  oop  _the_obj;
-  bool _allow_dirty;
-  void do_oop(oop* p) {
-    _the_obj->verify_old_oop(p, _allow_dirty);
-  }
-  void do_oop(narrowOop* p) {
-    _the_obj->verify_old_oop(p, _allow_dirty);
-  }
-};
-
 #define OBJ_SAMPLE_INTERVAL 0
 #define BLOCK_SAMPLE_INTERVAL 100
 
-void OffsetTableContigSpace::verify(bool allow_dirty) const {
+void OffsetTableContigSpace::verify() const {
   HeapWord* p = bottom();
   HeapWord* prev_p = NULL;
-  VerifyOldOopClosure blk;      // Does this do anything?
-  blk._allow_dirty = allow_dirty;
   int objs = 0;
   int blocks = 0;
 
@@ -1007,8 +992,6 @@
 
     if (objs == OBJ_SAMPLE_INTERVAL) {
       oop(p)->verify();
-      blk._the_obj = oop(p);
-      oop(p)->oop_iterate(&blk);
       objs = 0;
     } else {
       objs++;
--- a/hotspot/src/share/vm/memory/space.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/space.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -306,7 +306,7 @@
   }
 
   // Debugging
-  virtual void verify(bool allow_dirty) const = 0;
+  virtual void verify() const = 0;
 };
 
 // A MemRegionClosure (ResourceObj) whose "do_MemRegion" function applies an
@@ -948,7 +948,7 @@
   }
 
   // Debugging
-  virtual void verify(bool allow_dirty) const;
+  virtual void verify() const;
 
   // Used to increase collection frequency.  "factor" of 0 means entire
   // space.
@@ -1100,7 +1100,7 @@
   virtual void print_on(outputStream* st) const;
 
   // Debugging
-  void verify(bool allow_dirty) const;
+  void verify() const;
 
   // Shared space support
   void serialize_block_offset_array_offsets(SerializeOopClosure* soc);
--- a/hotspot/src/share/vm/memory/universe.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/universe.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1326,7 +1326,7 @@
   st->print_cr("}");
 }
 
-void Universe::verify(bool allow_dirty, bool silent, VerifyOption option) {
+void Universe::verify(bool silent, VerifyOption option) {
   if (SharedSkipVerify) {
     return;
   }
@@ -1350,7 +1350,7 @@
   if (!silent) gclog_or_tty->print("[Verifying ");
   if (!silent) gclog_or_tty->print("threads ");
   Threads::verify();
-  heap()->verify(allow_dirty, silent, option);
+  heap()->verify(silent, option);
 
   if (!silent) gclog_or_tty->print("syms ");
   SymbolTable::verify();
--- a/hotspot/src/share/vm/memory/universe.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/memory/universe.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -412,7 +412,7 @@
 
   // Debugging
   static bool verify_in_progress() { return _verify_in_progress; }
-  static void verify(bool allow_dirty = true, bool silent = false,
+  static void verify(bool silent = false,
                      VerifyOption option = VerifyOption_Default );
   static int  verify_count()       { return _verify_count; }
   // The default behavior is to call print_on() on gclog_or_tty.
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -567,8 +567,18 @@
   ol.notify_all(CHECK);
 }
 
+// The embedded _implementor field can only record one implementor.
+// When there are more than one implementors, the _implementor field
+// is set to the interface klassOop itself. Following are the possible
+// values for the _implementor field:
+//   NULL                  - no implementor
+//   implementor klassOop  - one implementor
+//   self                  - more than one implementor
+//
+// The _implementor field only exists for interfaces.
 void instanceKlass::add_implementor(klassOop k) {
   assert(Compile_lock->owned_by_self(), "");
+  assert(is_interface(), "not interface");
   // Filter out my subinterfaces.
   // (Note: Interfaces are never on the subklass list.)
   if (instanceKlass::cast(k)->is_interface()) return;
@@ -583,17 +593,13 @@
     // Any supers of the super have the same (or fewer) transitive_interfaces.
     return;
 
-  // Update number of implementors
-  int i = _nof_implementors++;
-
-  // Record this implementor, if there are not too many already
-  if (i < implementors_limit) {
-    assert(_implementors[i] == NULL, "should be exactly one implementor");
-    oop_store_without_check((oop*)&_implementors[i], k);
-  } else if (i == implementors_limit) {
-    // clear out the list on first overflow
-    for (int i2 = 0; i2 < implementors_limit; i2++)
-      oop_store_without_check((oop*)&_implementors[i2], NULL);
+  klassOop ik = implementor();
+  if (ik == NULL) {
+    set_implementor(k);
+  } else if (ik != this->as_klassOop()) {
+    // There is already an implementor. Use itself as an indicator of
+    // more than one implementors.
+    set_implementor(this->as_klassOop());
   }
 
   // The implementor also implements the transitive_interfaces
@@ -603,9 +609,9 @@
 }
 
 void instanceKlass::init_implementor() {
-  for (int i = 0; i < implementors_limit; i++)
-    oop_store_without_check((oop*)&_implementors[i], NULL);
-  _nof_implementors = 0;
+  if (is_interface()) {
+    set_implementor(NULL);
+  }
 }
 
 
@@ -1849,24 +1855,22 @@
 void instanceKlass::follow_weak_klass_links(
   BoolObjectClosure* is_alive, OopClosure* keep_alive) {
   assert(is_alive->do_object_b(as_klassOop()), "this oop should be live");
-  if (ClassUnloading) {
-    for (int i = 0; i < implementors_limit; i++) {
-      klassOop impl = _implementors[i];
-      if (impl == NULL)  break;  // no more in the list
-      if (!is_alive->do_object_b(impl)) {
-        // remove this guy from the list by overwriting him with the tail
-        int lasti = --_nof_implementors;
-        assert(lasti >= i && lasti < implementors_limit, "just checking");
-        _implementors[i] = _implementors[lasti];
-        _implementors[lasti] = NULL;
-        --i; // rerun the loop at this index
+
+  if (is_interface()) {
+    if (ClassUnloading) {
+      klassOop impl = implementor();
+      if (impl != NULL) {
+        if (!is_alive->do_object_b(impl)) {
+          // remove this guy
+          *start_of_implementor() = NULL;
+        }
       }
-    }
-  } else {
-    for (int i = 0; i < implementors_limit; i++) {
-      keep_alive->do_oop(&adr_implementors()[i]);
+    } else {
+      assert(adr_implementor() != NULL, "just checking");
+      keep_alive->do_oop(adr_implementor());
     }
   }
+
   Klass::follow_weak_klass_links(is_alive, keep_alive);
 }
 
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,8 +56,6 @@
 //    [methods                    ]
 //    [local interfaces           ]
 //    [transitive interfaces      ]
-//    [number of implementors     ]
-//    [implementors               ] klassOop[2]
 //    [fields                     ]
 //    [constants                  ]
 //    [class loader               ]
@@ -77,9 +75,9 @@
 //    [oop map cache (stack maps) ]
 //    [EMBEDDED Java vtable             ] size in words = vtable_len
 //    [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
-//
-//    The embedded nonstatic oop-map blocks are short pairs (offset, length) indicating
-//    where oops are located in instances of this klass.
+//      The embedded nonstatic oop-map blocks are short pairs (offset, length)
+//      indicating where oops are located in instances of this klass.
+//    [EMBEDDED implementor of the interface] only exist for interface
 
 
 // forward declaration for class -- see below for definition
@@ -153,10 +151,6 @@
   oop* oop_block_beg() const { return adr_array_klasses(); }
   oop* oop_block_end() const { return adr_methods_default_annotations() + 1; }
 
-  enum {
-    implementors_limit = 2              // how many implems can we track?
-  };
-
  protected:
   //
   // The oop block.  See comment in klass.hpp before making changes.
@@ -200,8 +194,6 @@
   // and EnclosingMethod attributes the _inner_classes array length is
   // number_of_inner_classes * 4 + enclosing_method_attribute_size.
   typeArrayOop    _inner_classes;
-  // Implementors of this interface (not valid if it overflows)
-  klassOop        _implementors[implementors_limit];
   // Annotations for this class, or null if none.
   typeArrayOop    _class_annotations;
   // Annotation objects (byte arrays) for fields, or null if no annotations.
@@ -257,7 +249,6 @@
   nmethodBucket*  _dependencies;         // list of dependent nmethods
   nmethod*        _osr_nmethods_head;    // Head of list of on-stack replacement nmethods for this class
   BreakpointInfo* _breakpoints;          // bpt lists, managed by methodOop
-  int             _nof_implementors;     // No of implementors of this interface (zero if not an interface)
   // Array of interesting part(s) of the previous version(s) of this
   // instanceKlass. See PreviousVersionWalker below.
   GrowableArray<PreviousVersionNode *>* _previous_versions;
@@ -278,6 +269,13 @@
   // embedded Java itables follows here
   // embedded static fields follows here
   // embedded nonstatic oop-map blocks follows here
+  // embedded implementor of this interface follows here
+  //   The embedded implementor only exists if the current klass is an
+  //   iterface. The possible values of the implementor fall into following
+  //   three cases:
+  //     NULL: no implementor.
+  //     A klassOop that's not itself: one implementor.
+  //     Itsef: more than one implementors.
 
   friend class instanceKlassKlass;
   friend class SystemDictionary;
@@ -644,19 +642,40 @@
 
   // support for stub routines
   static ByteSize init_state_offset()  { return in_ByteSize(sizeof(klassOopDesc) + offset_of(instanceKlass, _init_state)); }
+  TRACE_DEFINE_OFFSET;
   static ByteSize init_thread_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(instanceKlass, _init_thread)); }
 
   // subclass/subinterface checks
   bool implements_interface(klassOop k) const;
 
-  // Access to implementors of an interface. We only store the count
-  // of implementors, and in case, there are only a few
-  // implementors, we store them in a short list.
-  // This accessor returns NULL if we walk off the end of the list.
-  klassOop implementor(int i) const {
-    return (i < implementors_limit)? _implementors[i]: (klassOop) NULL;
+  // Access to the implementor of an interface.
+  klassOop implementor() const
+  {
+    klassOop* k = start_of_implementor();
+    if (k == NULL) {
+      return NULL;
+    } else {
+      return *k;
+    }
   }
-  int  nof_implementors() const       { return _nof_implementors; }
+
+  void set_implementor(klassOop k) {
+    assert(is_interface(), "not interface");
+    oop* addr = (oop*)start_of_implementor();
+    oop_store_without_check(addr, k);
+  }
+
+  int  nof_implementors() const       {
+    klassOop k = implementor();
+    if (k == NULL) {
+      return 0;
+    } else if (k != this->as_klassOop()) {
+      return 1;
+    } else {
+      return 2;
+    }
+  }
+
   void add_implementor(klassOop k);  // k is a new class that implements this interface
   void init_implementor();           // initialize
 
@@ -693,7 +712,15 @@
 
   // Sizing (in words)
   static int header_size()            { return align_object_offset(oopDesc::header_size() + sizeof(instanceKlass)/HeapWordSize); }
-  int object_size() const             { return object_size(align_object_offset(vtable_length()) + align_object_offset(itable_length()) + nonstatic_oop_map_size()); }
+
+  int object_size() const
+  {
+    return object_size(align_object_offset(vtable_length()) +
+                       align_object_offset(itable_length()) +
+                       (is_interface() ?
+                        (align_object_offset(nonstatic_oop_map_size()) + (int)sizeof(klassOop)/HeapWordSize) :
+                        nonstatic_oop_map_size()));
+  }
   static int vtable_start_offset()    { return header_size(); }
   static int vtable_length_offset()   { return oopDesc::header_size() + offset_of(instanceKlass, _vtable_len) / HeapWordSize; }
   static int object_size(int extra)   { return align_object_size(header_size() + extra); }
@@ -710,6 +737,15 @@
     return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length()));
   }
 
+  klassOop* start_of_implementor() const {
+    if (is_interface()) {
+      return (klassOop*)(start_of_nonstatic_oop_maps() +
+                         nonstatic_oop_map_count());
+    } else {
+      return NULL;
+    }
+  };
+
   // Allocation profiling support
   juint alloc_size() const            { return _alloc_count * size_helper(); }
   void set_alloc_size(juint n)        {}
@@ -819,7 +855,7 @@
   oop* adr_host_klass() const        { return (oop*)&this->_host_klass;}
   oop* adr_signers() const           { return (oop*)&this->_signers;}
   oop* adr_inner_classes() const     { return (oop*)&this->_inner_classes;}
-  oop* adr_implementors() const      { return (oop*)&this->_implementors[0];}
+  oop* adr_implementor() const       { return (oop*)start_of_implementor(); }
   oop* adr_methods_jmethod_ids() const             { return (oop*)&this->_methods_jmethod_ids;}
   oop* adr_methods_cached_itable_indices() const   { return (oop*)&this->_methods_cached_itable_indices;}
   oop* adr_class_annotations() const   { return (oop*)&this->_class_annotations;}
--- a/hotspot/src/share/vm/oops/instanceKlassKlass.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlassKlass.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -111,7 +111,7 @@
   MarkSweep::mark_and_push(ik->adr_methods_parameter_annotations());
   MarkSweep::mark_and_push(ik->adr_methods_default_annotations());
 
-  // We do not follow adr_implementors() here. It is followed later
+  // We do not follow adr_implementor() here. It is followed later
   // in instanceKlass::follow_weak_klass_links()
 
   klassKlass::oop_follow_contents(obj);
@@ -180,8 +180,8 @@
   blk->do_oop(ik->adr_host_klass());
   blk->do_oop(ik->adr_signers());
   blk->do_oop(ik->adr_inner_classes());
-  for (int i = 0; i < instanceKlass::implementors_limit; i++) {
-    blk->do_oop(&ik->adr_implementors()[i]);
+  if (ik->is_interface()) {
+    blk->do_oop(ik->adr_implementor());
   }
   blk->do_oop(ik->adr_class_annotations());
   blk->do_oop(ik->adr_fields_annotations());
@@ -232,9 +232,9 @@
   if (mr.contains(adr)) blk->do_oop(adr);
   adr = ik->adr_inner_classes();
   if (mr.contains(adr)) blk->do_oop(adr);
-  adr = ik->adr_implementors();
-  for (int i = 0; i < instanceKlass::implementors_limit; i++) {
-    if (mr.contains(&adr[i])) blk->do_oop(&adr[i]);
+  if (ik->is_interface()) {
+    adr = ik->adr_implementor();
+    if (mr.contains(adr)) blk->do_oop(adr);
   }
   adr = ik->adr_class_annotations();
   if (mr.contains(adr)) blk->do_oop(adr);
@@ -273,8 +273,8 @@
   MarkSweep::adjust_pointer(ik->adr_host_klass());
   MarkSweep::adjust_pointer(ik->adr_signers());
   MarkSweep::adjust_pointer(ik->adr_inner_classes());
-  for (int i = 0; i < instanceKlass::implementors_limit; i++) {
-    MarkSweep::adjust_pointer(&ik->adr_implementors()[i]);
+  if (ik->is_interface()) {
+    MarkSweep::adjust_pointer(ik->adr_implementor());
   }
   MarkSweep::adjust_pointer(ik->adr_class_annotations());
   MarkSweep::adjust_pointer(ik->adr_fields_annotations());
@@ -328,6 +328,9 @@
   for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
     PSParallelCompact::adjust_pointer(cur_oop);
   }
+  if (ik->is_interface()) {
+    PSParallelCompact::adjust_pointer(ik->adr_implementor());
+  }
 
   OopClosure* closure = PSParallelCompact::adjust_root_pointer_closure();
   iterate_c_heap_oops(ik, closure);
@@ -342,11 +345,18 @@
 instanceKlassKlass::allocate_instance_klass(Symbol* name, int vtable_len, int itable_len,
                                             int static_field_size,
                                             unsigned nonstatic_oop_map_count,
+                                            AccessFlags access_flags,
                                             ReferenceType rt, TRAPS) {
 
   const int nonstatic_oop_map_size =
     instanceKlass::nonstatic_oop_map_size(nonstatic_oop_map_count);
-  int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + nonstatic_oop_map_size);
+  int size = align_object_offset(vtable_len) + align_object_offset(itable_len);
+  if (access_flags.is_interface()) {
+    size += align_object_offset(nonstatic_oop_map_size) + (int)sizeof(klassOop)/HeapWordSize;
+  } else {
+    size += nonstatic_oop_map_size;
+  }
+  size = instanceKlass::object_size(size);
 
   // Allocation
   KlassHandle h_this_klass(THREAD, as_klassOop());
@@ -378,6 +388,7 @@
     ik->set_itable_length(itable_len);
     ik->set_static_field_size(static_field_size);
     ik->set_nonstatic_oop_map_size(nonstatic_oop_map_size);
+    ik->set_access_flags(access_flags);
     assert(k()->size() == size, "wrong size for object");
 
     ik->set_array_klasses(NULL);
@@ -470,16 +481,12 @@
 
   if (ik->is_interface()) {
     st->print_cr(BULLET"nof implementors:  %d", ik->nof_implementors());
-    int print_impl = 0;
-    for (int i = 0; i < instanceKlass::implementors_limit; i++) {
-      if (ik->implementor(i) != NULL) {
-        if (++print_impl == 1)
-          st->print_cr(BULLET"implementor:    ");
-        st->print("   ");
-        ik->implementor(i)->print_value_on(st);
-      }
+    if (ik->nof_implementors() == 1) {
+      st->print_cr(BULLET"implementor:    ");
+      st->print("   ");
+      ik->implementor()->print_value_on(st);
+      st->cr();
     }
-    if (print_impl > 0)  st->cr();
   }
 
   st->print(BULLET"arrays:            "); ik->array_klasses()->print_value_on(st);     st->cr();
@@ -640,16 +647,12 @@
     }
 
     // Verify implementor fields
-    bool saw_null_impl = false;
-    for (int i = 0; i < instanceKlass::implementors_limit; i++) {
-      klassOop im = ik->implementor(i);
-      if (im == NULL) { saw_null_impl = true; continue; }
-      guarantee(!saw_null_impl, "non-nulls must preceded all nulls");
+    klassOop im = ik->implementor();
+    if (im != NULL) {
       guarantee(ik->is_interface(), "only interfaces should have implementor set");
-      guarantee(i < ik->nof_implementors(), "should only have one implementor");
       guarantee(im->is_perm(),  "should be in permspace");
       guarantee(im->is_klass(), "should be klass");
-      guarantee(!Klass::cast(klassOop(im))->is_interface(), "implementors cannot be interfaces");
+      guarantee(!Klass::cast(klassOop(im))->is_interface() || im == ik->as_klassOop(), "implementors cannot be interfaces");
     }
 
     // Verify local interfaces
--- a/hotspot/src/share/vm/oops/instanceKlassKlass.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlassKlass.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,7 @@
                                    int itable_len,
                                    int static_field_size,
                                    unsigned int nonstatic_oop_map_count,
+                                   AccessFlags access_flags,
                                    ReferenceType rt,
                                    TRAPS);
 
--- a/hotspot/src/share/vm/oops/instanceRefKlass.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/instanceRefKlass.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -497,36 +497,12 @@
 
   if (referent != NULL) {
     guarantee(referent->is_oop(), "referent field heap failed");
-    if (gch != NULL && !gch->is_in_young(obj)) {
-      // We do a specific remembered set check here since the referent
-      // field is not part of the oop mask and therefore skipped by the
-      // regular verify code.
-      if (UseCompressedOops) {
-        narrowOop* referent_addr = (narrowOop*)java_lang_ref_Reference::referent_addr(obj);
-        obj->verify_old_oop(referent_addr, true);
-      } else {
-        oop* referent_addr = (oop*)java_lang_ref_Reference::referent_addr(obj);
-        obj->verify_old_oop(referent_addr, true);
-      }
-    }
   }
   // Verify next field
   oop next = java_lang_ref_Reference::next(obj);
   if (next != NULL) {
     guarantee(next->is_oop(), "next field verify failed");
     guarantee(next->is_instanceRef(), "next field verify failed");
-    if (gch != NULL && !gch->is_in_young(obj)) {
-      // We do a specific remembered set check here since the next field is
-      // not part of the oop mask and therefore skipped by the regular
-      // verify code.
-      if (UseCompressedOops) {
-        narrowOop* next_addr = (narrowOop*)java_lang_ref_Reference::next_addr(obj);
-        obj->verify_old_oop(next_addr, true);
-      } else {
-        oop* next_addr = (oop*)java_lang_ref_Reference::next_addr(obj);
-        obj->verify_old_oop(next_addr, true);
-      }
-    }
   }
 }
 
--- a/hotspot/src/share/vm/oops/klass.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/klass.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -581,14 +581,6 @@
   guarantee(obj->klass()->is_klass(), "klass field is not a klass");
 }
 
-
-void Klass::oop_verify_old_oop(oop obj, oop* p, bool allow_dirty) {
-  /* $$$ I think this functionality should be handled by verification of
-  RememberedSet::verify_old_oop(obj, p, allow_dirty, false);
-  the card table. */
-}
-void Klass::oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty) { }
-
 #ifndef PRODUCT
 
 void Klass::verify_vtable_index(int i) {
--- a/hotspot/src/share/vm/oops/klass.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/klass.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -805,8 +805,6 @@
   // Verification
   virtual const char* internal_name() const = 0;
   virtual void oop_verify_on(oop obj, outputStream* st);
-  virtual void oop_verify_old_oop(oop obj, oop* p, bool allow_dirty);
-  virtual void oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty);
   // tells whether obj is partially constructed (gc during class loading)
   virtual bool oop_partially_loaded(oop obj) const { return false; }
   virtual void oop_set_partially_loaded(oop obj) {};
--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -545,10 +545,3 @@
     guarantee(oa->obj_at(index)->is_oop_or_null(), "should be oop");
   }
 }
-
-void objArrayKlass::oop_verify_old_oop(oop obj, oop* p, bool allow_dirty) {
-  /* $$$ move into remembered set verification?
-  RememberedSet::verify_old_oop(obj, p, allow_dirty, true);
-  */
-}
-void objArrayKlass::oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty) {}
--- a/hotspot/src/share/vm/oops/objArrayKlass.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -144,8 +144,6 @@
   // Verification
   const char* internal_name() const;
   void oop_verify_on(oop obj, outputStream* st);
-  void oop_verify_old_oop(oop obj, oop* p, bool allow_dirty);
-  void oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty);
 };
 
 #endif // SHARE_VM_OOPS_OBJARRAYKLASS_HPP
--- a/hotspot/src/share/vm/oops/oop.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/oop.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -107,16 +107,6 @@
   verify_on(tty);
 }
 
-
-// XXX verify_old_oop doesn't do anything (should we remove?)
-void oopDesc::verify_old_oop(oop* p, bool allow_dirty) {
-  blueprint()->oop_verify_old_oop(this, p, allow_dirty);
-}
-
-void oopDesc::verify_old_oop(narrowOop* p, bool allow_dirty) {
-  blueprint()->oop_verify_old_oop(this, p, allow_dirty);
-}
-
 bool oopDesc::partially_loaded() {
   return blueprint()->oop_partially_loaded(this);
 }
--- a/hotspot/src/share/vm/oops/oop.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/oops/oop.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -293,8 +293,6 @@
   // verification operations
   void verify_on(outputStream* st);
   void verify();
-  void verify_old_oop(oop* p, bool allow_dirty);
-  void verify_old_oop(narrowOop* p, bool allow_dirty);
 
   // tells whether this oop is partially constructed (gc during class loading)
   bool partially_loaded();
--- a/hotspot/src/share/vm/opto/library_call.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -175,7 +175,11 @@
   bool inline_unsafe_allocate();
   bool inline_unsafe_copyMemory();
   bool inline_native_currentThread();
-  bool inline_native_time_funcs(bool isNano);
+#ifdef TRACE_HAVE_INTRINSICS
+  bool inline_native_classID();
+  bool inline_native_threadID();
+#endif
+  bool inline_native_time_funcs(address method, const char* funcName);
   bool inline_native_isInterrupted();
   bool inline_native_Class_query(vmIntrinsics::ID id);
   bool inline_native_subtype_check();
@@ -638,10 +642,18 @@
   case vmIntrinsics::_isInterrupted:
     return inline_native_isInterrupted();
 
+#ifdef TRACE_HAVE_INTRINSICS
+  case vmIntrinsics::_classID:
+    return inline_native_classID();
+  case vmIntrinsics::_threadID:
+    return inline_native_threadID();
+  case vmIntrinsics::_counterTime:
+    return inline_native_time_funcs(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), "counterTime");
+#endif
   case vmIntrinsics::_currentTimeMillis:
-    return inline_native_time_funcs(false);
+    return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis");
   case vmIntrinsics::_nanoTime:
-    return inline_native_time_funcs(true);
+    return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime");
   case vmIntrinsics::_allocateInstance:
     return inline_unsafe_allocate();
   case vmIntrinsics::_copyMemory:
@@ -2840,14 +2852,63 @@
   return true;
 }
 
+#ifdef TRACE_HAVE_INTRINSICS
+/*
+ * oop -> myklass
+ * myklass->trace_id |= USED
+ * return myklass->trace_id & ~0x3
+ */
+bool LibraryCallKit::inline_native_classID() {
+  int nargs = 1 + 1;
+  null_check_receiver(callee());  // check then ignore argument(0)
+  _sp += nargs;
+  Node* cls = do_null_check(argument(1), T_OBJECT);
+  _sp -= nargs;
+  Node* kls = load_klass_from_mirror(cls, false, nargs, NULL, 0);
+  _sp += nargs;
+  kls = do_null_check(kls, T_OBJECT);
+  _sp -= nargs;
+  ByteSize offset = TRACE_ID_OFFSET;
+  Node* insp = basic_plus_adr(kls, in_bytes(offset));
+  Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG);
+  Node* bits = longcon(~0x03l); // ignore bit 0 & 1
+  Node* andl = _gvn.transform(new (C, 3) AndLNode(tvalue, bits));
+  Node* clsused = longcon(0x01l); // set the class bit
+  Node* orl = _gvn.transform(new (C, 3) OrLNode(tvalue, clsused));
+
+  const TypePtr *adr_type = _gvn.type(insp)->isa_ptr();
+  store_to_memory(control(), insp, orl, T_LONG, adr_type);
+  push_pair(andl);
+  return true;
+}
+
+bool LibraryCallKit::inline_native_threadID() {
+  Node* tls_ptr = NULL;
+  Node* cur_thr = generate_current_thread(tls_ptr);
+  Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset()));
+  Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS);
+  p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::thread_id_offset()));
+
+  Node* threadid = NULL;
+  size_t thread_id_size = OSThread::thread_id_size();
+  if (thread_id_size == (size_t) BytesPerLong) {
+    threadid = ConvL2I(make_load(control(), p, TypeLong::LONG, T_LONG));
+    push(threadid);
+  } else if (thread_id_size == (size_t) BytesPerInt) {
+    threadid = make_load(control(), p, TypeInt::INT, T_INT);
+    push(threadid);
+  } else {
+    ShouldNotReachHere();
+  }
+  return true;
+}
+#endif
+
 //------------------------inline_native_time_funcs--------------
 // inline code for System.currentTimeMillis() and System.nanoTime()
 // these have the same type and signature
-bool LibraryCallKit::inline_native_time_funcs(bool isNano) {
-  address funcAddr = isNano ? CAST_FROM_FN_PTR(address, os::javaTimeNanos) :
-                              CAST_FROM_FN_PTR(address, os::javaTimeMillis);
-  const char * funcName = isNano ? "nanoTime" : "currentTimeMillis";
-  const TypeFunc *tf = OptoRuntime::current_time_millis_Type();
+bool LibraryCallKit::inline_native_time_funcs(address funcAddr, const char* funcName) {
+  const TypeFunc *tf = OptoRuntime::void_long_Type();
   const TypePtr* no_memory_effects = NULL;
   Node* time = make_runtime_call(RC_LEAF, tf, funcAddr, funcName, no_memory_effects);
   Node* value = _gvn.transform(new (C, 1) ProjNode(time, TypeFunc::Parms+0));
--- a/hotspot/src/share/vm/opto/runtime.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/opto/runtime.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -709,9 +709,9 @@
   return TypeFunc::make(domain, range);
 }
 
-//-------------- currentTimeMillis
+//-------------- currentTimeMillis, currentTimeNanos, etc
 
-const TypeFunc* OptoRuntime::current_time_millis_Type() {
+const TypeFunc* OptoRuntime::void_long_Type() {
   // create input type (domain)
   const Type **fields = TypeTuple::fields(0);
   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields);
--- a/hotspot/src/share/vm/opto/runtime.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/opto/runtime.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -268,7 +268,7 @@
   static const TypeFunc* Math_DD_D_Type(); // mod,pow & friends
   static const TypeFunc* modf_Type();
   static const TypeFunc* l2f_Type();
-  static const TypeFunc* current_time_millis_Type();
+  static const TypeFunc* void_long_Type();
 
   static const TypeFunc* flush_windows_Type();
 
--- a/hotspot/src/share/vm/runtime/osThread.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/runtime/osThread.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -98,6 +98,7 @@
 
   // For java intrinsics:
   static ByteSize interrupted_offset()            { return byte_offset_of(OSThread, _interrupted); }
+  static ByteSize thread_id_offset()              { return byte_offset_of(OSThread, _thread_id); }
 
   // Platform dependent stuff
 #ifdef TARGET_OS_FAMILY_linux
--- a/hotspot/src/share/vm/runtime/thread.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -3468,13 +3468,13 @@
     create_vm_init_libraries();
   }
 
+  // Notify JVMTI agents that VM initialization is complete - nop if no agents.
+  JvmtiExport::post_vm_initialized();
+
   if (!TRACE_START()) {
     vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
   }
 
-  // Notify JVMTI agents that VM initialization is complete - nop if no agents.
-  JvmtiExport::post_vm_initialized();
-
   if (CleanChunkPoolAsync) {
     Chunk::start_chunk_pool_cleaner_task();
   }
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -292,8 +292,6 @@
   nonstatic_field(instanceKlass,               _method_ordering,                              typeArrayOop)                          \
   nonstatic_field(instanceKlass,               _local_interfaces,                             objArrayOop)                           \
   nonstatic_field(instanceKlass,               _transitive_interfaces,                        objArrayOop)                           \
-  nonstatic_field(instanceKlass,               _nof_implementors,                             int)                                   \
-  nonstatic_field(instanceKlass,               _implementors[0],                              klassOop)                              \
   nonstatic_field(instanceKlass,               _fields,                                       typeArrayOop)                          \
   nonstatic_field(instanceKlass,               _java_fields_count,                            u2)                                    \
   nonstatic_field(instanceKlass,               _constants,                                    constantPoolOop)                       \
@@ -2343,7 +2341,6 @@
   /* instanceKlass enum                */                                 \
   /*************************************/                                 \
                                                                           \
-  declare_constant(instanceKlass::implementors_limit)                     \
                                                                           \
   /*************************************/                                 \
   /* FieldInfo FieldOffset enum        */                                 \
--- a/hotspot/src/share/vm/runtime/vmThread.cpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/runtime/vmThread.cpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -304,7 +304,7 @@
     os::check_heap();
     // Silent verification so as not to pollute normal output,
     // unless we really asked for it.
-    Universe::verify(true, !(PrintGCDetails || Verbose));
+    Universe::verify(!(PrintGCDetails || Verbose));
   }
 
   CompileBroker::set_should_block();
--- a/hotspot/src/share/vm/trace/traceMacros.hpp	Mon Apr 23 16:55:12 2012 -0700
+++ b/hotspot/src/share/vm/trace/traceMacros.hpp	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,5 +43,9 @@
 #define TRACE_SET_KLASS_TRACE_ID(x1, x2) do { } while (0)
 #define TRACE_DEFINE_KLASS_METHODS typedef int ___IGNORED_hs_trace_type1
 #define TRACE_DEFINE_KLASS_TRACE_ID typedef int ___IGNORED_hs_trace_type2
+#define TRACE_DEFINE_OFFSET typedef int ___IGNORED_hs_trace_type3
+#define TRACE_ID_OFFSET in_ByteSize(0); ShouldNotReachHere()
+#define TRACE_TEMPLATES(template)
+#define TRACE_INTRINSICS(do_intrinsic, do_class, do_name, do_signature, do_alias)
 
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/7158988/FieldMonitor.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,249 @@
+/*
+ * Copyright 2012 SAP AG.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test FieldMonitor.java
+ * @bug 7158988
+ * @summary verify jvm does not crash while debugging
+ * @run shell TestFieldMonitor.sh
+ * @author axel.siebenborn@sap.com
+ */
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.sun.jdi.Bootstrap;
+import com.sun.jdi.Field;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.connect.Connector;
+import com.sun.jdi.connect.IllegalConnectorArgumentsException;
+import com.sun.jdi.connect.LaunchingConnector;
+import com.sun.jdi.connect.VMStartException;
+import com.sun.jdi.event.ClassPrepareEvent;
+import com.sun.jdi.event.Event;
+import com.sun.jdi.event.EventQueue;
+import com.sun.jdi.event.EventSet;
+import com.sun.jdi.event.ModificationWatchpointEvent;
+import com.sun.jdi.event.VMDeathEvent;
+import com.sun.jdi.event.VMDisconnectEvent;
+import com.sun.jdi.request.ClassPrepareRequest;
+import com.sun.jdi.request.EventRequest;
+import com.sun.jdi.request.EventRequestManager;
+import com.sun.jdi.request.ModificationWatchpointRequest;
+
+public class FieldMonitor {
+
+  public static final String CLASS_NAME = "TestPostFieldModification";
+  public static final String FIELD_NAME = "value";
+  public static final String ARGUMENTS = "-Xshare:off -XX:+PrintGC";
+
+  public static void main(String[] args)
+      throws IOException, InterruptedException {
+
+    StringBuffer sb = new StringBuffer();
+
+    for (int i=0; i < args.length; i++) {
+        sb.append(' ');
+        sb.append(args[i]);
+    }
+    //VirtualMachine vm = launchTarget(sb.toString());
+    VirtualMachine vm = launchTarget(CLASS_NAME);
+
+    System.out.println("Vm launched");
+    // set watch field on already loaded classes
+    List<ReferenceType> referenceTypes = vm
+        .classesByName(CLASS_NAME);
+    for (ReferenceType refType : referenceTypes) {
+      addFieldWatch(vm, refType);
+    }
+    // watch for loaded classes
+    addClassWatch(vm);
+
+    // process events
+    EventQueue eventQueue = vm.eventQueue();
+    // resume the vm
+
+    Process process = vm.process();
+
+
+    // Copy target's output and error to our output and error.
+    Thread outThread = new StreamRedirectThread("out reader", process.getInputStream());
+    Thread errThread = new StreamRedirectThread("error reader", process.getErrorStream());
+
+    errThread.start();
+    outThread.start();
+
+
+    vm.resume();
+    boolean connected = true;
+    while (connected) {
+      EventSet eventSet = eventQueue.remove();
+      for (Event event : eventSet) {
+        if (event instanceof VMDeathEvent
+            || event instanceof VMDisconnectEvent) {
+          // exit
+          connected = false;
+        } else if (event instanceof ClassPrepareEvent) {
+          // watch field on loaded class
+          System.out.println("ClassPrepareEvent");
+          ClassPrepareEvent classPrepEvent = (ClassPrepareEvent) event;
+          ReferenceType refType = classPrepEvent
+              .referenceType();
+          addFieldWatch(vm, refType);
+        } else if (event instanceof ModificationWatchpointEvent) {
+          System.out.println("sleep for 500 ms");
+          Thread.sleep(500);
+          System.out.println("resume...");
+
+          ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event;
+          System.out.println("old="
+              + modEvent.valueCurrent());
+          System.out.println("new=" + modEvent.valueToBe());
+          System.out.println();
+        }
+      }
+      eventSet.resume();
+    }
+    // Shutdown begins when event thread terminates
+    try {
+        errThread.join(); // Make sure output is forwarded
+        outThread.join();
+    } catch (InterruptedException exc) {
+        // we don't interrupt
+    }
+  }
+
+  /**
+   * Find a com.sun.jdi.CommandLineLaunch connector
+   */
+  static LaunchingConnector findLaunchingConnector() {
+    List <Connector> connectors = Bootstrap.virtualMachineManager().allConnectors();
+    Iterator <Connector> iter = connectors.iterator();
+    while (iter.hasNext()) {
+      Connector connector = iter.next();
+      if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) {
+        return (LaunchingConnector)connector;
+      }
+    }
+    throw new Error("No launching connector");
+  }
+  /**
+   * Return the launching connector's arguments.
+   */
+ static Map <String,Connector.Argument> connectorArguments(LaunchingConnector connector, String mainArgs) {
+      Map<String,Connector.Argument> arguments = connector.defaultArguments();
+      for (String key : arguments.keySet()) {
+        System.out.println(key);
+      }
+
+      Connector.Argument mainArg = (Connector.Argument)arguments.get("main");
+      if (mainArg == null) {
+          throw new Error("Bad launching connector");
+      }
+      mainArg.setValue(mainArgs);
+
+      Connector.Argument optionsArg = (Connector.Argument)arguments.get("options");
+      if (optionsArg == null) {
+        throw new Error("Bad launching connector");
+      }
+      optionsArg.setValue(ARGUMENTS);
+      return arguments;
+  }
+
+ static VirtualMachine launchTarget(String mainArgs) {
+    LaunchingConnector connector = findLaunchingConnector();
+    Map  arguments = connectorArguments(connector, mainArgs);
+    try {
+        return (VirtualMachine) connector.launch(arguments);
+    } catch (IOException exc) {
+        throw new Error("Unable to launch target VM: " + exc);
+    } catch (IllegalConnectorArgumentsException exc) {
+        throw new Error("Internal error: " + exc);
+    } catch (VMStartException exc) {
+        throw new Error("Target VM failed to initialize: " +
+                        exc.getMessage());
+    }
+}
+
+
+  private static void addClassWatch(VirtualMachine vm) {
+    EventRequestManager erm = vm.eventRequestManager();
+    ClassPrepareRequest classPrepareRequest = erm
+        .createClassPrepareRequest();
+    classPrepareRequest.addClassFilter(CLASS_NAME);
+    classPrepareRequest.setEnabled(true);
+  }
+
+
+  private static void addFieldWatch(VirtualMachine vm,
+      ReferenceType refType) {
+    EventRequestManager erm = vm.eventRequestManager();
+    Field field = refType.fieldByName(FIELD_NAME);
+    ModificationWatchpointRequest modificationWatchpointRequest = erm
+        .createModificationWatchpointRequest(field);
+    modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
+    modificationWatchpointRequest.setEnabled(true);
+  }
+}
+
+class StreamRedirectThread extends Thread {
+
+  private final BufferedReader in;
+
+  private static final int BUFFER_SIZE = 2048;
+
+  /**
+   * Set up for copy.
+   * @param name  Name of the thread
+   * @param in    Stream to copy from
+   * @param out   Stream to copy to
+   */
+  StreamRedirectThread(String name, InputStream in) {
+    super(name);
+    this.in = new BufferedReader(new InputStreamReader(in));
+  }
+
+  /**
+   * Copy.
+   */
+  public void run() {
+    try {
+      String line;
+        while ((line = in.readLine ()) != null) {
+          System.out.println ("testvm: " + line);
+      }
+     System.out.flush();
+    } catch(IOException exc) {
+      System.err.println("Child I/O Transfer - " + exc);
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/7158988/TestFieldMonitor.sh	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,94 @@
+#!/bin/sh
+
+if [ "${TESTSRC}" = "" ]
+then TESTSRC=.
+fi
+
+if [ "${TESTJAVA}" = "" ]
+then
+  PARENT=`dirname \`which java\``
+  TESTJAVA=`dirname ${PARENT}`
+  echo "TESTJAVA not set, selecting " ${TESTJAVA}
+  echo "If this is incorrect, try setting the variable manually."
+fi
+
+if [ "${TESTCLASSES}" = "" ]
+then
+  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
+  exit 1
+fi
+
+BIT_FLAG=""
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+  SunOS | Linux )
+    NULL=/dev/null
+    PS=":"
+    FS="/"
+    ## for solaris, linux it's HOME
+    FILE_LOCATION=$HOME
+    if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" -a `uname -p`='sparc' ]
+    then
+        BIT_FLAG="-d64"
+    fi
+    ;;
+  Windows_95 | Windows_98 | Windows_ME )
+    NULL=NUL
+    PS=";"
+    FS="\\"
+    echo "Test skipped, only for WinNT"
+    exit 0
+    ;;
+  Windows_NT )
+    NULL=NUL
+    PS=";"
+    FS="\\"
+    ;;
+  * )
+    echo "Unrecognized system!"
+    exit 1;
+    ;;
+esac
+
+#CLASSPATH=.${PS}${TESTCLASSES} ; export CLASSPATH
+
+cp ${TESTSRC}${FS}*.java .
+
+${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -fullversion
+
+${TESTJAVA}${FS}bin${FS}javac -classpath .${PS}$TESTJAVA${FS}lib${FS}tools.jar *.java
+
+${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -classpath .${PS}$TESTJAVA${FS}lib${FS}tools.jar FieldMonitor > test.out 2>&1 &
+
+P_PID=$!
+
+sleep 60
+STATUS=0
+
+case "$OS" in
+    SunOS | Linux )
+        ps -ef | grep $P_PID | grep -v grep > ${NULL}
+        if [ $? = 0 ]; then
+            kill -9 $P_PID
+            STATUS=1
+        fi
+        ;;
+      * )
+        ps | grep -i "FieldMonitor" | grep -v grep > ${NULL}
+        if [ $? = 0 ]; then
+            C_PID=`ps | grep -i "FieldMonitor" | awk '{print $1}'`
+            kill -s 9 $C_PID
+            STATUS=1
+        fi
+        ;;
+esac
+
+grep "A fatal error has been detected" test.out > ${NULL}
+if [ $? = 0 ]; then
+    cat test.out
+    STATUS=1
+fi
+
+exit $STATUS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/7158988/TestPostFieldModification.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012 SAP AG.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public class TestPostFieldModification {
+
+  public String value;  // watch modification of value
+
+  public static void main(String[] args){
+
+    System.out.println("Start threads");
+    // this thread modifies the field 'value'
+    new Thread() {
+      TestPostFieldModification test = new TestPostFieldModification();
+      public void run() {
+        test.value="test";
+        for(int i = 0; i < 10; i++) {
+          test.value += new String("_test");
+        }
+      }
+    }.start();
+
+    // this thread is used to trigger a gc
+    Thread d = new Thread() {
+      public void run() {
+        while(true) {
+          try {
+            Thread.sleep(100);
+          } catch (InterruptedException e) {
+
+          }
+          System.gc();
+        }
+      }
+    };
+    d.setDaemon(true);
+    d.start();
+  }
+}
--- a/jdk/.hgtags	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/.hgtags	Wed Jul 05 18:09:02 2017 +0200
@@ -156,3 +156,4 @@
 ddfe5562f61f54ed2121ac0c73b688b94f3e66b5 jdk8-b32
 78cea258caaba3980ba186c426da82c8fe41bfd7 jdk8-b33
 29b680393f33bf953688c17d93aca7a870ca4024 jdk8-b34
+2e3e1356ffbddb2ae95c08da72830ba9ab8b3181 jdk8-b35
--- a/jdk/make/com/sun/tools/attach/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/com/sun/tools/attach/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 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
@@ -24,6 +24,8 @@
 #
 
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../../..
 PACKAGE = com.sun.tools.attach
 LIBRARY = attach
--- a/jdk/make/common/Defs-linux.gmk	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/common/Defs-linux.gmk	Wed Jul 05 18:09:02 2017 +0200
@@ -131,8 +131,9 @@
   # Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
   # JDK build to import .debuginfo or .diz files from the HotSpot build.
   # However, adding FDS support to the JDK build will occur in phases
-  # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS)
-  # is used to indicate that a particular library supports FDS.
+  # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+  # and PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS) is used to indicate that a
+  # particular library or program supports FDS.
 
   ifeq ($(OBJCOPY),)
     _JUNK_ := $(shell \
@@ -156,9 +157,7 @@
     _JUNK_ := $(shell \
       echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
 
-    # HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
-    # changes are promoted
-    ZIP_DEBUGINFO_FILES ?= 0
+    ZIP_DEBUGINFO_FILES ?= 1
 
     _JUNK_ := $(shell \
       echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
@@ -261,6 +260,17 @@
   CFLAGS_REQUIRED += $(DEBUG_FLAG)
 endif
 
+# If Full Debug Symbols is enabled, then we want the same debug and
+# optimization flags as used by FASTDEBUG.
+#
+ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+  ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+    ifeq ($(VARIANT), OPT)
+      CC_OPT = $(DEBUG_FLAG) $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
+    endif
+  endif
+endif
+
 CFLAGS_OPT      = $(CC_OPT)
 CFLAGS_DBG      = $(DEBUG_FLAG)
 CFLAGS_COMMON += $(CFLAGS_REQUIRED)
--- a/jdk/make/common/Defs-solaris.gmk	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/common/Defs-solaris.gmk	Wed Jul 05 18:09:02 2017 +0200
@@ -138,8 +138,9 @@
   # Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
   # JDK build to import .debuginfo or .diz files from the HotSpot build.
   # However, adding FDS support to the JDK build will occur in phases
-  # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS)
-  # is used to indicate that a particular library supports FDS.
+  # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+  # and PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS) is used to indicate that a
+  # particular library or program supports FDS.
 
   ifeq ($(OBJCOPY),)
     _JUNK_ := $(shell \
@@ -164,9 +165,7 @@
     _JUNK_ := $(shell \
       echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
 
-    # HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
-    # changes are promoted
-    ZIP_DEBUGINFO_FILES ?= 0
+    ZIP_DEBUGINFO_FILES ?= 1
 
     _JUNK_ := $(shell \
       echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
@@ -240,6 +239,21 @@
   CXXFLAGS_DEBUG_OPTION  = -g0 $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
 endif
 
+# If Full Debug Symbols is enabled, then we want the same debug and
+# optimization flags as used by FASTDEBUG. We also want all the
+# debug info in one place (-xs).
+#
+ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+  ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+    ifeq ($(VARIANT), OPT)
+      CC_OPT   = -g  -xs $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
+      CXX_OPT  = -g0 -xs $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
+    endif
+    CFLAGS_DEBUG_OPTION    += -xs
+    CXXFLAGS_DEBUG_OPTION  += -xs
+  endif
+endif
+
 CFLAGS_COMMON   = -L$(OBJDIR)
 
 # Do not allow C99 language features like declarations in code etc.
--- a/jdk/make/common/Defs-windows.gmk	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/common/Defs-windows.gmk	Wed Jul 05 18:09:02 2017 +0200
@@ -113,9 +113,7 @@
   echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")
 
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  # HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
-  # changes are promoted
-  ZIP_DEBUGINFO_FILES ?= 0
+  ZIP_DEBUGINFO_FILES ?= 1
 else
   ZIP_DEBUGINFO_FILES=0
 endif
--- a/jdk/make/common/Library.gmk	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/common/Library.gmk	Wed Jul 05 18:09:02 2017 +0200
@@ -181,8 +181,17 @@
 	$(CP) $(OBJDIR)/$(@F) $@
 	@$(call binary_file_verification,$@)
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+  ifeq ($(ZIP_DEBUGINFO_FILES),1)
+	(set -e ; \
+	 $(CD) $(OBJDIR) ; \
+	 $(ZIPEXE) -q $(LIBRARY).diz $(LIBRARY).map $(LIBRARY).pdb ; \
+	)
+	$(CP) $(OBJDIR)/$(LIBRARY).diz $(@D)
+	$(RM) $(OBJDIR)/$(LIBRARY).map $(OBJDIR)/$(LIBRARY).pdb
+  else
 	$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
 	$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
+  endif
 endif
 
 endif # LIBRARY
@@ -248,6 +257,37 @@
 ifeq ($(WRITE_LIBVERSION),true)
 	$(MCS) -d -a "$(FULL_VERSION)" $@
 endif # WRITE_LIBVERSION
+  ifneq ($(PLATFORM), macosx)
+    ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+      ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+	(set -e ; \
+	 $(CD) $(@D) ; \
+	 $(OBJCOPY) --only-keep-debug $(@F) $(LIBRARY).debuginfo ; \
+	 $(OBJCOPY) --add-gnu-debuglink=$(LIBRARY).debuginfo $(@F) ; \
+	)
+        ifeq ($(STRIP_POLICY),all_strip)
+	  $(STRIP) $@
+        else
+          ifeq ($(STRIP_POLICY),min_strip)
+            ifeq ($(PLATFORM), solaris)
+	      $(STRIP) -x $@
+            else
+              # assume Linux
+	      $(STRIP) -g $@
+            endif
+          # implied else here is no stripping at all
+          endif
+        endif
+        ifeq ($(ZIP_DEBUGINFO_FILES),1)
+	  (set -e ; \
+	   $(CD) $(@D) ; \
+	   $(ZIPEXE) -q $(LIBRARY).diz $(LIBRARY).debuginfo ; \
+	   $(RM) $(LIBRARY).debuginfo ; \
+	  )
+        endif
+      endif # LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+    endif # ENABLE_FULL_DEBUG_SYMBOLS
+  endif # PLATFORM-!macosx
 endif # LIBRARY
 
 endif # PLATFORM
--- a/jdk/make/common/Program.gmk	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/common/Program.gmk	Wed Jul 05 18:09:02 2017 +0200
@@ -189,6 +189,15 @@
 	$(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
   endif
 	@$(call binary_file_verification,$@)
+  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+    ifeq ($(ZIP_DEBUGINFO_FILES),1)
+	(set -e ; \
+	 $(CD) $(OBJDIR) ; \
+	 $(ZIPEXE) -q $(PROGRAM).diz $(PROGRAM).map $(PROGRAM).pdb ; \
+	 $(RM) $(PROGRAM).map $(PROGRAM).pdb ; \
+	)
+    endif
+  endif
 else
   #
   # Note that we have to link -lthread even when USE_PTHREADS is true.
@@ -232,6 +241,42 @@
 	-codesign -s openjdk_codesign $@
   endif
 	@$(call binary_file_verification,$@)
+  ifneq ($(PLATFORM), macosx)
+    ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+      ifeq ($(PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+	(set -e ; \
+	 $(CD) $(@D) ; \
+	 $(OBJCOPY) --only-keep-debug $(@F) $(@F).debuginfo ; \
+	 $(OBJCOPY) --add-gnu-debuglink=$(@F).debuginfo $(@F) ; \
+	)
+        ifeq ($(STRIP_POLICY),all_strip)
+	  $(STRIP) $@
+        else
+          ifeq ($(STRIP_POLICY),min_strip)
+            ifeq ($(PLATFORM), solaris)
+	      $(STRIP) -x $@
+            else
+              # assume Linux
+	      $(STRIP) -g $@
+            endif
+          # implied else here is no stripping at all
+          endif
+        endif
+        ifeq ($(ZIP_DEBUGINFO_FILES),1)
+	  (set -e ; \
+	   $(CD) $(@D) ; \
+	   $(ZIPEXE) -q $(@F).diz $(@F).debuginfo ; \
+	   $(RM) $(@F).debuginfo ; \
+	  )
+          # save ZIP'ed debug info with rest of the program's build artifacts
+	  $(MV) $@.diz $(OBJDIR)
+        else
+          # save debug info with rest of the program's build artifacts
+	  $(MV) $@.debuginfo $(OBJDIR)
+        endif
+      endif # PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS
+    endif # ENABLE_FULL_DEBUG_SYMBOLS
+  endif # PLATFORM-!macosx
 endif # PLATFORM
 
 clean:: 
@@ -240,12 +285,16 @@
 	$(RM) $(OBJDIR)/$(PROGRAM).ico
 	$(RM) $(OBJDIR)/$(PROGRAM).lcf
 	$(RM) $(OBJDIR)/$(PROGRAM).map
+	$(RM) $(OBJDIR)/$(PROGRAM).pdb
 	$(RM) $(OBJDIR)/$(PROGRAM).exp
 	$(RM) $(OBJDIR)/$(PROGRAM).lib
 	$(RM) $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
 	$(RM) $(OBJDIR)/$(PROGRAM).ilk
 	$(RM) *.pdb
+else
+	$(RM) $(OBJDIR)/$(PROGRAM).debuginfo
 endif
+	$(RM) $(OBJDIR)/$(PROGRAM).diz
 
 
 clobber:: 
--- a/jdk/make/common/Release.gmk	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/common/Release.gmk	Wed Jul 05 18:09:02 2017 +0200
@@ -873,7 +873,9 @@
 	   -o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" > $@
 else
 	$(FIND) $(JRE_IMAGE_DIR)/lib -type f -name \*.$(LIB_SUFFIX) >> $@
-	$(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
+# The FILE command reports .debuginfo files as "ELF", but we don't want
+# those files in the JRE_BIN_LIST file. EXE_SUFFIX is empty on non-Windows.
+	$(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
 	    | $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
 endif
 
@@ -1140,9 +1142,11 @@
 else
 	$(RM) $@
 	$(FIND) $(JDK_IMAGE_DIR)/jre/lib -type f -name \*.$(LIB_SUFFIX) >> $@
-	$(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f -name \*$(EXE_SUFFIX)` \
+# The FILE command reports .debuginfo files as "ELF", but we don't want
+# those files in the JDK_BIN_LIST file. EXE_SUFFIX is empty on non-Windows.
+	$(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
 	    | $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
-	file `$(FIND) $(JDK_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
+	file `$(FIND) $(JDK_IMAGE_DIR)/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
 	    | $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
 endif
 
--- a/jdk/make/java/instrument/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/java/instrument/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 # Makefile for building the Java Programming Language Instrumentation Services
 # agent, supporting java.lang.instrument
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 PACKAGE = sun.instrument
 LIBRARY = instrument
--- a/jdk/make/java/java/reflect/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/java/java/reflect/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -36,7 +36,7 @@
 #
 # Files to compile.
 #
-AUTO_FILES_JAVA_DIRS = java/lang/reflect sun/reflect
+AUTO_FILES_JAVA_DIRS = java/lang/reflect sun/reflect java/lang/annotation
 
 #
 # Install .lib file.
--- a/jdk/make/java/java_crw_demo/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/java/java_crw_demo/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 
 LIBRARY = java_crw_demo
--- a/jdk/make/java/java_hprof_demo/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/java/java_hprof_demo/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 LIBRARY = hprof
 PRODUCT = sun
--- a/jdk/make/java/main/java/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/java/main/java/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1996, 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
@@ -23,6 +23,8 @@
 # questions.
 #
 
+PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PROGRAM = java
 PRODUCT = java
--- a/jdk/make/java/management/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/java/management/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 PACKAGE = java.lang.management
 LIBRARY = management
--- a/jdk/make/java/npt/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/java/npt/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 
 # It's currently used by jpda and hprof.  Put it in base module for now.
--- a/jdk/make/java/verify/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/java/verify/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2011, 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
@@ -27,6 +27,8 @@
 # Build libverify.so
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 PRODUCT = java
 LIBRARY = verify
--- a/jdk/make/jpda/jdwp/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/jpda/jdwp/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
 # Makefile for building JDWP
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 PACKAGE = com.sun.tools.jdwp
 PRODUCT = jpda
--- a/jdk/make/jpda/transport/socket/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/jpda/transport/socket/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
 # Makefile for building the JDI back-end implementation
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 LIBRARY = dt_socket
 PRODUCT = jbug
--- a/jdk/make/launchers/Makefile.launcher	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/launchers/Makefile.launcher	Wed Jul 05 18:09:02 2017 +0200
@@ -27,6 +27,8 @@
 # Makefile for building simple launchers
 #
 
+PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ..
 PACKAGE = launcher
 PRODUCT = sun
--- a/jdk/make/mkdemo/jvmti/compiledMethodLoad/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/compiledMethodLoad/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 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
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = compiledMethodLoad
--- a/jdk/make/mkdemo/jvmti/gctest/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/gctest/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = gctest
--- a/jdk/make/mkdemo/jvmti/heapTracker/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/heapTracker/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = heapTracker
--- a/jdk/make/mkdemo/jvmti/heapViewer/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/heapViewer/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = heapViewer
--- a/jdk/make/mkdemo/jvmti/hprof/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/hprof/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = hprof
--- a/jdk/make/mkdemo/jvmti/minst/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/minst/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = minst
--- a/jdk/make/mkdemo/jvmti/mtrace/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/mtrace/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = mtrace
--- a/jdk/make/mkdemo/jvmti/versionCheck/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/versionCheck/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = versionCheck
--- a/jdk/make/mkdemo/jvmti/waiters/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/waiters/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = waiters
--- a/jdk/make/sun/font/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/sun/font/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -62,7 +62,7 @@
     java/text/Bidi.java \
     sun/font/FileFont.java \
     sun/font/FileFontStrike.java \
-    sun/font/FontManager.java \
+    sun/font/SunFontManager.java \
     sun/font/GlyphList.java \
     sun/font/NativeFont.java \
     sun/font/StrikeCache.java \
--- a/jdk/make/sun/font/t2k/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/sun/font/t2k/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -52,7 +52,6 @@
 FILES_export = \
     java/awt/Font.java \
     sun/font/FileFont.java \
-    sun/font/FontManager.java \
     sun/font/GlyphList.java \
     sun/font/NativeFont.java \
     sun/font/StrikeCache.java \
--- a/jdk/make/sun/tracing/dtrace/Makefile	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/make/sun/tracing/dtrace/Makefile	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,9 @@
 #
 # Makefile for building dtrace extension
 #
+
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PACKAGE = sun.tracing.dtrace
 LIBRARY = jsdt
--- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Wed Jul 05 18:09:02 2017 +0200
@@ -213,16 +213,8 @@
             SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
                 @Override
                 public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
-                    if (SunToolkit.isDispatchThreadForAppContext(getTarget())) {
-                        synchronized (getDelegateLock()) {
-                            if (getDelegate().isPaintingForPrint()) {
-                                return;
-                            }
-                        }
-                    }
-                    Rectangle res = SwingUtilities.convertRectangle(
-                            c, new Rectangle(x, y, w, h), getDelegate());
-                    repaintPeer(res);
+                    repaintPeer(SwingUtilities.convertRectangle(
+                            c, new Rectangle(x, y, w, h), getDelegate()));
                 }
             });
         }
@@ -616,6 +608,17 @@
                 windowLocation.y + locationInWindow.y);
     }
 
+    /**
+     * Returns the cursor of the peer, which is cursor of the target by default,
+     * but peer can override this behavior.
+     *
+     * @param p Point relative to the peer.
+     * @return Cursor of the peer or null if default cursor should be used.
+     */
+    protected Cursor getCursor(final Point p) {
+        return getTarget().getCursor();
+    }
+
     @Override
     public void setBackground(final Color c) {
         final Color oldBg = getBackground();
@@ -982,16 +985,23 @@
     // DropTargetPeer Method
     @Override
     public void addDropTarget(DropTarget dt) {
-        synchronized (dropTargetLock){
-            // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
-            // if it's the first (or last) one for the component. Otherwise this call is a no-op.
-            if (++fNumDropTargets == 1) {
-                // Having a non-null drop target would be an error but let's check just in case:
-                if (fDropTarget != null)
-                    System.err.println("CComponent.addDropTarget(): current drop target is non-null.");
+        LWWindowPeer winPeer = getWindowPeerOrSelf();
+        if (winPeer != null && winPeer != this) {
+            // We need to register the DropTarget in the
+            // peer of the window ancestor of the component
+            winPeer.addDropTarget(dt);
+        } else {
+            synchronized (dropTargetLock) {
+                // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
+                // if it's the first (or last) one for the component. Otherwise this call is a no-op.
+                if (++fNumDropTargets == 1) {
+                    // Having a non-null drop target would be an error but let's check just in case:
+                    if (fDropTarget != null)
+                        System.err.println("CComponent.addDropTarget(): current drop target is non-null.");
 
-                // Create a new drop target:
-                fDropTarget = CDropTarget.createDropTarget(dt, target, this);
+                    // Create a new drop target:
+                    fDropTarget = CDropTarget.createDropTarget(dt, target, this);
+                }
             }
         }
     }
@@ -999,17 +1009,24 @@
     // DropTargetPeer Method
     @Override
     public void removeDropTarget(DropTarget dt) {
-        synchronized (dropTargetLock){
-            // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
-            // if it's the first (or last) one for the component. Otherwise this call is a no-op.
-            if (--fNumDropTargets == 0) {
-                // Having a null drop target would be an error but let's check just in case:
-                if (fDropTarget != null) {
-                    // Dispose of the drop target:
-                    fDropTarget.dispose();
-                    fDropTarget = null;
-                } else
-                    System.err.println("CComponent.removeDropTarget(): current drop target is null.");
+        LWWindowPeer winPeer = getWindowPeerOrSelf();
+        if (winPeer != null && winPeer != this) {
+            // We need to unregister the DropTarget in the
+            // peer of the window ancestor of the component
+            winPeer.removeDropTarget(dt);
+        } else {
+            synchronized (dropTargetLock){
+                // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
+                // if it's the first (or last) one for the component. Otherwise this call is a no-op.
+                if (--fNumDropTargets == 0) {
+                    // Having a null drop target would be an error but let's check just in case:
+                    if (fDropTarget != null) {
+                        // Dispose of the drop target:
+                        fDropTarget.dispose();
+                        fDropTarget = null;
+                    } else
+                        System.err.println("CComponent.removeDropTarget(): current drop target is null.");
+                }
             }
         }
     }
--- a/jdk/src/macosx/classes/sun/lwawt/LWCursorManager.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWCursorManager.java	Wed Jul 05 18:09:02 2017 +0200
@@ -36,32 +36,34 @@
 
 public abstract class LWCursorManager {
 
-    // A flag to indicate if the update is scheduled, so we don't
-    // process it twice
-    private AtomicBoolean updatePending = new AtomicBoolean(false);
+    /**
+     * A flag to indicate if the update is scheduled, so we don't process it
+     * twice.
+     */
+    private final AtomicBoolean updatePending = new AtomicBoolean(false);
 
     protected LWCursorManager() {
     }
 
-    /*
+    /**
      * Sets the cursor to correspond the component currently under mouse.
      *
      * This method should not be executed on the toolkit thread as it
      * calls to user code (e.g. Container.findComponentAt).
      */
-    public void updateCursor() {
+    public final void updateCursor() {
         updatePending.set(false);
         updateCursorImpl();
     }
 
-    /*
+    /**
      * Schedules updating the cursor on the corresponding event dispatch
      * thread for the given window.
      *
      * This method is called on the toolkit thread as a result of a
      * native update cursor request (e.g. WM_SETCURSOR on Windows).
      */
-    public void updateCursorLater(LWWindowPeer window) {
+    public final void updateCursorLater(final LWWindowPeer window) {
         if (updatePending.compareAndSet(false, true)) {
             Runnable r = new Runnable() {
                 @Override
@@ -74,45 +76,58 @@
     }
 
     private void updateCursorImpl() {
-        LWWindowPeer windowUnderCursor = LWWindowPeer.getWindowUnderCursor();
-        Point cursorPos = getCursorPosition();
-        LWComponentPeer<?, ?> componentUnderCursor = null;
-        // TODO: it's possible to get the component under cursor directly as
-        // it's stored in LWWindowPee anyway (lastMouseEventPeer)
-        if (windowUnderCursor != null) {
-            componentUnderCursor = windowUnderCursor.findPeerAt(cursorPos.x, cursorPos.y);
+        final Point cursorPos = getCursorPosition();
+        final Component c = findComponent(cursorPos);
+        final Cursor cursor;
+        final Object peer = LWToolkit.targetToPeer(c);
+        if (peer instanceof LWComponentPeer) {
+            final LWComponentPeer<?, ?> lwpeer = (LWComponentPeer<?, ?>) peer;
+            final Point p = lwpeer.getLocationOnScreen();
+            cursor = lwpeer.getCursor(new Point(cursorPos.x - p.x,
+                                                cursorPos.y - p.y));
+        } else {
+            cursor = (c != null) ? c.getCursor() : null;
         }
-        Cursor cursor = null;
-        if (componentUnderCursor != null) {
-            Component c = componentUnderCursor.getTarget();
+        // TODO: default cursor for modal blocked windows
+        setCursor(cursor);
+    }
+
+    /**
+     * Returns the first visible, enabled and showing component under cursor.
+     *
+     * @param cursorPos Current cursor position.
+     * @return Component
+     */
+    private static final Component findComponent(final Point cursorPos) {
+        final LWComponentPeer<?, ?> peer = LWWindowPeer.getPeerUnderCursor();
+        Component c = null;
+        if (peer != null) {
+            c = peer.getTarget();
             if (c instanceof Container) {
-                Point p = componentUnderCursor.getLocationOnScreen();
-                c = ((Container)c).findComponentAt(cursorPos.x - p.x, cursorPos.y - p.y);
+                final Point p = peer.getLocationOnScreen();
+                c = ((Container) c).findComponentAt(cursorPos.x - p.x,
+                                                    cursorPos.y - p.y);
             }
-            // Traverse up to the first visible, enabled and showing component
             while (c != null) {
                 if (c.isVisible() && c.isEnabled() && (c.getPeer() != null)) {
                     break;
                 }
                 c = c.getParent();
             }
-            if (c != null) {
-                cursor = c.getCursor();
-            }
         }
-        // TODO: default cursor for modal blocked windows
-        setCursor(windowUnderCursor, cursor);
+        return c;
     }
 
-    /*
+    /**
      * Returns the current cursor position.
      */
     // TODO: make it public to reuse for MouseInfo
     protected abstract Point getCursorPosition();
 
-    /*
-     * Sets a cursor. The cursor can be null if the mouse is not over a Java window.
+    /**
+     * Sets a cursor. The cursor can be null if the mouse is not over a Java
+     * window.
+     * @param cursor the new {@code Cursor}.
      */
-    protected abstract void setCursor(LWWindowPeer windowUnderCursor, Cursor cursor);
-
+    protected abstract void setCursor(Cursor cursor);
 }
--- a/jdk/src/macosx/classes/sun/lwawt/LWRepaintArea.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWRepaintArea.java	Wed Jul 05 18:09:02 2017 +0200
@@ -39,12 +39,8 @@
     @Override
     protected void updateComponent(final Component comp, final Graphics g) {
         if (comp != null) {
-            final LWComponentPeer peer = (LWComponentPeer) comp.getPeer();
-            if (peer != null) {
-                peer.paintPeer(g);
-            }
             super.updateComponent(comp, g);
-            flushBuffers(peer);
+            flushBuffers((LWComponentPeer) comp.getPeer());
         }
     }
 
--- a/jdk/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java	Wed Jul 05 18:09:02 2017 +0200
@@ -27,6 +27,7 @@
 package sun.lwawt;
 
 import java.awt.Component;
+import java.awt.Cursor;
 import java.awt.Dimension;
 import java.awt.Point;
 import java.awt.TextArea;
@@ -72,6 +73,15 @@
     }
 
     @Override
+    protected Cursor getCursor(final Point p) {
+        final boolean isContains;
+        synchronized (getDelegateLock()) {
+            isContains = getDelegate().getViewport().getBounds().contains(p);
+        }
+        return isContains ? super.getCursor(p) : null;
+    }
+
+    @Override
     protected Component getDelegateFocusOwner() {
         return getTextComponent();
     }
--- a/jdk/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java	Wed Jul 05 18:09:02 2017 +0200
@@ -31,6 +31,7 @@
 import java.awt.TextField;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
 import java.awt.peer.TextFieldPeer;
 
 import javax.swing.JPasswordField;
@@ -97,6 +98,21 @@
                                   getText(), e.getWhen(), e.getModifiers()));
     }
 
+    /**
+     * Restoring native behavior. We should sets the selection range to zero,
+     * when component lost its focus.
+     *
+     * @param e the focus event
+     */
+    @Override
+    protected void handleJavaFocusEvent(final FocusEvent e) {
+        if (e.getID() == FocusEvent.FOCUS_LOST) {
+            // In order to de-select the selection
+            setCaretPosition(0);
+        }
+        super.handleJavaFocusEvent(e);
+    }
+
     private final class JTextAreaDelegate extends JPasswordField {
 
         // Empty non private constructor was added because access to this
--- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Wed Jul 05 18:09:02 2017 +0200
@@ -784,9 +784,8 @@
                 }
                 mouseClickButtons &= ~eventButtonMask;
             }
-
-            notifyUpdateCursor();
         }
+        notifyUpdateCursor();
     }
 
     public void dispatchMouseWheelEvent(long when, int x, int y, int modifiers,
@@ -1057,6 +1056,10 @@
         return lastMouseEventPeer != null ? lastMouseEventPeer.getWindowPeerOrSelf() : null;
     }
 
+    public static LWComponentPeer<?, ?> getPeerUnderCursor() {
+        return lastMouseEventPeer;
+    }
+
     public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
         if (focusLog.isLoggable(PlatformLogger.FINE)) {
             focusLog.fine("requesting native focus to " + this);
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java	Wed Jul 05 18:09:02 2017 +0200
@@ -25,24 +25,26 @@
 
 package sun.lwawt.macosx;
 
-import java.awt.*;
+import sun.lwawt.LWCursorManager;
+
+import java.awt.Cursor;
+import java.awt.Point;
 import java.awt.geom.Point2D;
 
-import sun.lwawt.*;
+final class CCursorManager extends LWCursorManager {
 
-public class CCursorManager extends LWCursorManager {
     private static native Point2D nativeGetCursorPosition();
     private static native void nativeSetBuiltInCursor(final int type, final String name);
     private static native void nativeSetCustomCursor(final long imgPtr, final double x, final double y);
 
     private static final int NAMED_CURSOR = -1;
 
-    private final static CCursorManager theInstance = new CCursorManager();
+    private static final CCursorManager theInstance = new CCursorManager();
     public static CCursorManager getInstance() {
         return theInstance;
     }
 
-    Cursor currentCursor;
+    private volatile Cursor currentCursor;
 
     private CCursorManager() { }
 
@@ -62,8 +64,11 @@
     }
 
     @Override
-    protected void setCursor(final LWWindowPeer windowUnderCursor, final Cursor cursor) {
-        if (cursor == currentCursor) return;
+    protected void setCursor(final Cursor cursor) {
+        if (cursor == currentCursor) {
+            return;
+        }
+        currentCursor = cursor;
 
         if (cursor == null) {
             nativeSetBuiltInCursor(Cursor.DEFAULT_CURSOR, null);
@@ -71,10 +76,12 @@
         }
 
         if (cursor instanceof CCustomCursor) {
-            final CCustomCursor customCursor = ((CCustomCursor)cursor);
+            final CCustomCursor customCursor = (CCustomCursor) cursor;
             final long imagePtr = customCursor.getImageData();
-            final Point hotSpot = customCursor.getHotSpot();
-            if(imagePtr != 0L) nativeSetCustomCursor(imagePtr, hotSpot.x, hotSpot.y);
+            if (imagePtr != 0L) {
+                final Point hotSpot = customCursor.getHotSpot();
+                nativeSetCustomCursor(imagePtr, hotSpot.x, hotSpot.y);
+            }
             return;
         }
 
@@ -94,13 +101,6 @@
         throw new RuntimeException("Unimplemented");
     }
 
-    static long getNativeWindow(final LWWindowPeer window) {
-        if (window == null) return 0;
-        final CPlatformWindow platformWindow = (CPlatformWindow)window.getPlatformWindow();
-        if (platformWindow == null) return 0;
-        return platformWindow.getNSWindowPtr();
-    }
-
     // package private methods to handle cursor change during drag-and-drop
     private boolean isDragging = false;
     private Point dragPos = null;
@@ -109,9 +109,7 @@
         if (isDragging) {
             throw new RuntimeException("Invalid Drag state in CCursorManager!");
         }
-
         isDragging = true;
-
         dragPos = new Point(x, y);
     }
 
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Wed Jul 05 18:09:02 2017 +0200
@@ -89,12 +89,19 @@
     }
 
     public void handleKeyEvent(int eventType, int modifierFlags, String characters,
+                               String charsIgnoringMods, boolean isRepeat, short keyCode,
+                               boolean needsKeyTyped) {
+        responder.handleKeyEvent(eventType, modifierFlags, charsIgnoringMods, keyCode, needsKeyTyped);
+    }
+
+    // REMIND: delete this method once 'deploy' changes for 7156194 is pushed
+    public void handleKeyEvent(int eventType, int modifierFlags, String characters,
                                String charsIgnoringMods, boolean isRepeat, short keyCode) {
-        responder.handleKeyEvent(eventType, modifierFlags, charsIgnoringMods, keyCode);
+        handleKeyEvent(eventType, modifierFlags, characters, charsIgnoringMods, isRepeat, keyCode, true);
     }
 
     public void handleInputEvent(String text) {
-        new RuntimeException("Not implemented");
+        responder.handleInputEvent(text);
     }
 
     public void handleFocusEvent(boolean focused) {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CImage.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CImage.java	Wed Jul 05 18:09:02 2017 +0200
@@ -29,10 +29,14 @@
 import java.awt.geom.Dimension2D;
 import java.awt.image.*;
 
+import java.util.Arrays;
+import java.util.List;
+
 import sun.awt.image.SunWritableRaster;
 
 public class CImage extends CFRetainedResource {
     private static native long nativeCreateNSImageFromArray(int[] buffer, int w, int h);
+    private static native long nativeCreateNSImageFromArrays(int[][] buffers, int w[], int h[]);
     private static native long nativeCreateNSImageFromFileContents(String file);
     private static native long nativeCreateNSImageOfFileFromLaunchServices(String file);
     private static native long nativeCreateNSImageFromImageName(String name);
@@ -93,8 +97,7 @@
             return createImageUsingNativeSize(nativeCreateNSImageFromImageName(name));
         }
 
-        // This is used to create a CImage from a Image
-        public CImage createFromImage(final Image image) {
+        private static int[] imageToArray(Image image) {
             if (image == null) return null;
 
             MediaTracker mt = new MediaTracker(new Label());
@@ -117,8 +120,50 @@
             g2.setComposite(AlphaComposite.Src);
             g2.drawImage(image, 0, 0, null);
             g2.dispose();
-            int[] buffer = ((DataBufferInt)bimg.getRaster().getDataBuffer()).getData();
-            return new CImage(nativeCreateNSImageFromArray(buffer, w, h));
+            return ((DataBufferInt)bimg.getRaster().getDataBuffer()).getData();
+        }
+
+        // This is used to create a CImage from a Image
+        public CImage createFromImage(final Image image) {
+            int[] buffer = imageToArray(image);
+            if (buffer == null) {
+                return null;
+            }
+            return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
+        }
+
+        public CImage createFromImages(List<Image> images) {
+            if (images == null || images.isEmpty()) {
+                return null;
+            }
+
+            int num = images.size();
+
+            int[][] buffers = new int[num][];
+            int[] w = new int[num];
+            int[] h = new int[num];
+
+            num = 0;
+
+            for (Image img : images) {
+                buffers[num] = imageToArray(img);
+                if (buffers[num] == null) {
+                    // Unable to process the image
+                    continue;
+                }
+                w[num] = img.getWidth(null);
+                h[num] = img.getHeight(null);
+                num++;
+            }
+
+            if (num == 0) {
+                return null;
+            }
+
+            return new CImage(nativeCreateNSImageFromArrays(
+                        Arrays.copyOf(buffers, num),
+                        Arrays.copyOf(w, num),
+                        Arrays.copyOf(h, num)));
         }
 
         static int getSelectorAsInt(final String fromString) {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Wed Jul 05 18:09:02 2017 +0200
@@ -117,7 +117,7 @@
      * Handles key events.
      */
     void handleKeyEvent(int eventType, int modifierFlags, String chars,
-                        short keyCode) {
+                        short keyCode, boolean needsKeyTyped) {
         boolean isFlagsChangedEvent =
             isNpapiCallback ? (eventType == CocoaConstants.NPCocoaEventFlagsChanged) :
                               (eventType == CocoaConstants.NSFlagsChanged);
@@ -158,11 +158,24 @@
                                            NSEvent.nsToJavaEventType(eventType);
         }
 
+        char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags);
+        // Some keys may generate a KEY_TYPED, but we can't determine
+        // what that character is. That's likely a bug, but for now we
+        // just check for CHAR_UNDEFINED.
+        if (javaChar == KeyEvent.CHAR_UNDEFINED) {
+            postsTyped = false;
+        }
+
+
         int jmodifiers = NSEvent.nsToJavaKeyModifiers(modifierFlags);
         long when = System.currentTimeMillis();
 
         peer.dispatchKeyEvent(jeventType, when, jmodifiers,
-                              jkeyCode, testChar, jkeyLocation);
+                              jkeyCode, javaChar, jkeyLocation);
+
+        // Current browser may be sending input events, so don't
+        // post the KEY_TYPED here.
+        postsTyped &= needsKeyTyped;
 
         // That's the reaction on the PRESSED (not RELEASED) event as it comes to
         // appear in MacOSX.
@@ -172,8 +185,23 @@
         boolean isMetaDown = (jmodifiers & KeyEvent.META_DOWN_MASK) != 0;
         if (jeventType == KeyEvent.KEY_PRESSED && postsTyped && !isMetaDown) {
             peer.dispatchKeyEvent(KeyEvent.KEY_TYPED, when, jmodifiers,
-                                  KeyEvent.VK_UNDEFINED, testChar,
+                                  KeyEvent.VK_UNDEFINED, javaChar,
                                   KeyEvent.KEY_LOCATION_UNKNOWN);
         }
     }
+
+    void handleInputEvent(String text) {
+        if (text != null) {
+            int index = 0, length = text.length();
+            char c;
+            while (index < length) {
+                c = text.charAt(index);
+                peer.dispatchKeyEvent(KeyEvent.KEY_TYPED,
+                                      System.currentTimeMillis(),
+                                      0, KeyEvent.VK_UNDEFINED, c,
+                                      KeyEvent.KEY_LOCATION_UNKNOWN);
+                index++;
+            }
+        }
+    }
 }
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Wed Jul 05 18:09:02 2017 +0200
@@ -199,7 +199,7 @@
 
     private void deliverKeyEvent(NSEvent event) {
         responder.handleKeyEvent(event.getType(), event.getModifierFlags(),
-                                 event.getCharactersIgnoringModifiers(), event.getKeyCode());
+                                 event.getCharactersIgnoringModifiers(), event.getKeyCode(), true);
     }
 
     private void deliverWindowDidExposeEvent() {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Jul 05 18:09:02 2017 +0200
@@ -661,11 +661,19 @@
     @Override
     public void setResizable(boolean resizable) {
         setStyleBits(RESIZABLE, resizable);
+
+        // Re-apply the size constraints and the size to ensure the space
+        // occupied by the grow box is counted properly
+        setMinimumSize(1, 1); // the method ignores its arguments
+
+        Rectangle bounds = peer.getBounds();
+        setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
     }
 
     @Override
     public void setMinimumSize(int width, int height) {
         //TODO width, height should be used
+        //NOTE: setResizable() calls setMinimumSize(1,1) relaying on the logic below
         final long nsWindowPtr = getNSWindowPtr();
         final Dimension min = target.getMinimumSize();
         final Dimension max = target.getMaximumSize();
@@ -802,11 +810,7 @@
         if (icons == null || icons.size() == 0) {
             return null;
         }
-
-        // TODO: need a walk-through to find the best image.
-        // The best mean with higher resolution. Otherwise an icon looks bad.
-        final Image image = icons.get(0);
-        return CImage.getCreator().createFromImage(image);
+        return CImage.getCreator().createFromImages(icons);
     }
 
     /*
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Wed Jul 05 18:09:02 2017 +0200
@@ -647,6 +647,15 @@
         return InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
     }
 
+    /**
+     * Tests whether specified key modifiers mask can be used to enter a printable
+     * character.
+     */
+    @Override
+    public boolean isPrintableCharacterModifiersMask(int mods) {
+        return ((mods & (InputEvent.META_MASK | InputEvent.CTRL_MASK)) == 0);
+    }
+
     // Extends PeerEvent because we want to pass long an ObjC mediator object and because we want these events to be posted early
     // Typically, rather than relying on the notifier to call notifyAll(), we use the mediator to stop the runloop
     public static class CPeerEvent extends PeerEvent {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java	Wed Jul 05 18:09:02 2017 +0200
@@ -245,6 +245,12 @@
      */
     public static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out);
 
+    /*
+     * There is a small number of NS characters that need to be converted
+     * into other characters before we pass them to AWT.
+     */
+    public static native char nsToJavaChar(char nsChar, int modifierFlags);
+
     public static boolean isPopupTrigger(int jmodifiers) {
         final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);
         final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0);
--- a/jdk/src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Jul 05 18:09:02 2017 +0200
@@ -4,7 +4,9 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * 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
@@ -40,7 +42,7 @@
      * Returns the default SelectorProvider.
      */
     public static SelectorProvider create() {
-            return new sun.nio.ch.PollSelectorProvider();
+        return new sun.nio.ch.KQueueSelectorProvider();
     }
 
 }
--- a/jdk/src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java	Wed Jul 05 18:09:02 2017 +0200
@@ -4,7 +4,9 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * 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
@@ -64,8 +66,8 @@
     static short FD_OFFSET;
     static short FILTER_OFFSET;
 
-    // kevent array size (just under 1K bytes)
-    static final int NUM_KEVENTS = 50;
+    // kevent array size
+    static final int NUM_KEVENTS = 128;
 
     // Are we in a 64-bit VM?
     static boolean is64bit = false;
--- a/jdk/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java	Wed Jul 05 18:09:02 2017 +0200
@@ -4,7 +4,9 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * 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
@@ -49,8 +51,8 @@
     // Count of registered descriptors (including interrupt)
     private int totalChannels;
 
-    // Map from file descriptors to selection keys
-    private HashMap<Integer,SelectionKeyImpl> fdToKey;
+    // Map from a file descriptor to an entry containing the selection key
+    private HashMap<Integer,MapEntry> fdMap;
 
     // True if this Selector has been closed
     private boolean closed = false;
@@ -59,6 +61,20 @@
     private Object interruptLock = new Object();
     private boolean interruptTriggered = false;
 
+    // used by updateSelectedKeys to handle cases where the same file
+    // descriptor is polled by more than one filter
+    private long updateCount;
+
+    // Used to map file descriptors to a selection key and "update count"
+    // (see updateSelectedKeys for usage).
+    private static class MapEntry {
+        SelectionKeyImpl ski;
+        long updateCount;
+        MapEntry(SelectionKeyImpl ski) {
+            this.ski = ski;
+        }
+    }
+
     /**
      * Package private constructor called by factory method in
      * the abstract superclass Selector.
@@ -70,7 +86,7 @@
         fd1 = (int)fds;
         kqueueWrapper = new KQueueArrayWrapper();
         kqueueWrapper.initInterrupt(fd0, fd1);
-        fdToKey = new HashMap<>();
+        fdMap = new HashMap<>();
         totalChannels = 1;
     }
 
@@ -82,8 +98,6 @@
         if (closed)
             throw new ClosedSelectorException();
         processDeregisterQueue();
-        if (timeout == 0  &&  totalChannels == 1)
-            return 0;
         try {
             begin();
             entries = kqueueWrapper.poll(timeout);
@@ -94,10 +108,9 @@
         return updateSelectedKeys(entries);
     }
 
-
     /**
-     * Update the keys whose fd's have been selected by the devpoll
-     * driver. Add the ready keys to the ready queue.
+     * Update the keys whose fd's have been selected by kqueue.
+     * Add the ready keys to the selected key set.
      * If the interrupt fd has been selected, drain it and clear the interrupt.
      */
     private int updateSelectedKeys(int entries)
@@ -106,24 +119,42 @@
         int numKeysUpdated = 0;
         boolean interrupted = false;
 
+        // A file descriptor may be registered with kqueue with more than one
+        // filter and so there may be more than one event for a fd. The update
+        // count in the MapEntry tracks when the fd was last updated and this
+        // ensures that the ready ops are updated rather than replaced by a
+        // second or subsequent event.
+        updateCount++;
+
         for (int i = 0; i < entries; i++) {
             int nextFD = kqueueWrapper.getDescriptor(i);
             if (nextFD == fd0) {
                 interrupted = true;
             } else {
-                SelectionKeyImpl ski = fdToKey.get(new Integer(nextFD));
-                // ski is null in the case of an interrupt
-                if (ski != null) {
+                MapEntry me = fdMap.get(Integer.valueOf(nextFD));
+
+                // entry is null in the case of an interrupt
+                if (me != null) {
                     int rOps = kqueueWrapper.getReventOps(i);
+                    SelectionKeyImpl ski = me.ski;
                     if (selectedKeys.contains(ski)) {
-                        if (ski.channel.translateAndSetReadyOps(rOps, ski)) {
-                            numKeysUpdated++;
+                        // first time this file descriptor has been encountered on this
+                        // update?
+                        if (me.updateCount != updateCount) {
+                            if (ski.channel.translateAndSetReadyOps(rOps, ski)) {
+                                numKeysUpdated++;
+                                me.updateCount = updateCount;
+                            }
+                        } else {
+                            // ready ops have already been set on this update
+                            ski.channel.translateAndUpdateReadyOps(rOps, ski);
                         }
                     } else {
                         ski.channel.translateAndSetReadyOps(rOps, ski);
-                        if ((ski.readyOps() & ski.interestOps()) != 0) {
+                        if ((ski.nioReadyOps() & ski.nioInterestOps()) != 0) {
                             selectedKeys.add(ski);
                             numKeysUpdated++;
+                            me.updateCount = updateCount;
                         }
                     }
                 }
@@ -137,7 +168,6 @@
                 interruptTriggered = false;
             }
         }
-
         return numKeysUpdated;
     }
 
@@ -145,6 +175,12 @@
     protected void implClose() throws IOException {
         if (!closed) {
             closed = true;
+
+            // prevent further wakeup
+            synchronized (interruptLock) {
+                interruptTriggered = true;
+            }
+
             FileDispatcherImpl.closeIntFD(fd0);
             FileDispatcherImpl.closeIntFD(fd1);
             if (kqueueWrapper != null) {
@@ -172,8 +208,10 @@
 
 
     protected void implRegister(SelectionKeyImpl ski) {
+        if (closed)
+            throw new ClosedSelectorException();
         int fd = IOUtil.fdVal(ski.channel.getFD());
-        fdToKey.put(new Integer(fd), ski);
+        fdMap.put(Integer.valueOf(fd), new MapEntry(ski));
         totalChannels++;
         keys.add(ski);
     }
@@ -181,7 +219,7 @@
 
     protected void implDereg(SelectionKeyImpl ski) throws IOException {
         int fd = ski.channel.getFDVal();
-        fdToKey.remove(new Integer(fd));
+        fdMap.remove(Integer.valueOf(fd));
         kqueueWrapper.release(fd);
         totalChannels--;
         keys.remove(ski);
@@ -194,6 +232,8 @@
 
 
     public void putEventOps(SelectionKeyImpl ski, int ops) {
+        if (closed)
+            throw new ClosedSelectorException();
         int fd = IOUtil.fdVal(ski.channel.getFD());
         kqueueWrapper.setInterest(fd, ops);
     }
--- a/jdk/src/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java	Wed Jul 05 18:09:02 2017 +0200
@@ -4,7 +4,9 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * 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
--- a/jdk/src/macosx/native/sun/awt/AWTEvent.m	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/AWTEvent.m	Wed Jul 05 18:09:02 2017 +0200
@@ -124,7 +124,7 @@
     {0x32, YES, KL_STANDARD, java_awt_event_KeyEvent_VK_BACK_QUOTE},
     {0x33, YES, KL_STANDARD, java_awt_event_KeyEvent_VK_BACK_SPACE},
     {0x34, YES, KL_NUMPAD,   java_awt_event_KeyEvent_VK_ENTER},
-    {0x35, NO,  KL_STANDARD, java_awt_event_KeyEvent_VK_ESCAPE},
+    {0x35, YES, KL_STANDARD, java_awt_event_KeyEvent_VK_ESCAPE},
     {0x36, NO,  KL_UNKNOWN,  java_awt_event_KeyEvent_VK_UNDEFINED},
     {0x37, NO,  KL_UNKNOWN,  java_awt_event_KeyEvent_VK_META},      // ****
     {0x38, NO,  KL_UNKNOWN,  java_awt_event_KeyEvent_VK_SHIFT},     // ****
@@ -308,6 +308,9 @@
  * Almost all unicode characters just go from NS to Java with no translation.
  *  For the few exceptions, we handle it here with this small table.
  */
+#define ALL_NS_KEY_MODIFIERS_MASK \
+    (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
+
 static struct _char {
     NSUInteger modifier;
     unichar nsChar;
@@ -315,17 +318,17 @@
 }
 const charTable[] = {
     // map enter on keypad to same as return key
-    {0,              NSEnterCharacter,          NSNewlineCharacter},
+    {0,                         NSEnterCharacter,          NSNewlineCharacter},
 
     // [3134616] return newline instead of carriage return
-    {0,              NSCarriageReturnCharacter, NSNewlineCharacter},
+    {0,                         NSCarriageReturnCharacter, NSNewlineCharacter},
 
     // "delete" means backspace in Java
-    {0,              NSDeleteCharacter,         NSBackspaceCharacter},
-    {0,              NSDeleteFunctionKey,     NSDeleteCharacter},
+    {ALL_NS_KEY_MODIFIERS_MASK, NSDeleteCharacter,         NSBackspaceCharacter},
+    {ALL_NS_KEY_MODIFIERS_MASK, NSDeleteFunctionKey,       NSDeleteCharacter},
 
     // back-tab is only differentiated from tab by Shift flag
-    {NSShiftKeyMask, NSBackTabCharacter,     NSTabCharacter},
+    {NSShiftKeyMask,            NSBackTabCharacter,        NSTabCharacter},
 
     {0, 0, 0}
 };
@@ -334,12 +337,8 @@
 NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
 {
     const struct _char *cur;
-    NSUInteger keyModifierFlags =
-        NSShiftKeyMask | NSControlKeyMask |
-        NSAlternateKeyMask | NSCommandKeyMask;
-
     // Mask off just the keyboard modifiers from the event modifier mask.
-    NSUInteger testableFlags = (modifiers & keyModifierFlags);
+    NSUInteger testableFlags = (modifiers & ALL_NS_KEY_MODIFIERS_MASK);
 
     // walk through table & find the match
     for (cur = charTable; cur->nsChar != 0 ; cur++) {
@@ -507,189 +506,6 @@
     return javaModifiers;
 }
 
-/*
- * Returns the correct java character for a key event.  Most unicode
- * characters don't require any fussing, but a few seem to need adjusting,
- * see nsCharToJavaChar.
- */
-static unichar
-GetJavaCharacter(NSEvent *event, unsigned int index)
-{
-    unichar returnValue = java_awt_event_KeyEvent_CHAR_UNDEFINED;
-    NSString *chars = nil;
-    unichar testChar = 0, testDeadChar = 0;
-    jint javaModifiers = NsKeyModifiersToJavaModifiers([event modifierFlags]);
-
-    switch ([event type]) {
-    case NSFlagsChanged:
-        // no character for modifier keys
-        returnValue = java_awt_event_KeyEvent_CHAR_UNDEFINED;
-        break;
-
-    case NSKeyDown:
-    case NSKeyUp:
-        chars = [event characters];
-        if ([chars length] > 0) {
-            testChar = [chars characterAtIndex:index];
-        }
-
-        if (javaModifiers == 0) {
-            // TODO: uses SPI...
-            //if (TSMGetDeadKeyState() != 0) {
-            //    testDeadChar = [self deadKeyCharacter];
-            //}
-        }
-
-        if (testChar != 0) {
-            returnValue = NsCharToJavaChar(testChar, [event modifierFlags]);
-        } else if (testDeadChar != 0) {
-            returnValue = NsCharToJavaChar(testDeadChar, [event modifierFlags]);
-        } else {
-            returnValue = java_awt_event_KeyEvent_CHAR_UNDEFINED;
-        }
-        break;
-
-    default:
-        //[NSException raise:@"AWT error" format:@"Attempt to get character code from non-key event!"];
-        break;
-    }
-
-    return returnValue;
-}
-
-/*
-static jchar
-GetDeadKeyCharacter(NSEvent *event)
-{
-    // If the current event is not a dead key, return 0.
-    // TODO: this uses SPI; it's an optimization but not strictly necessary
-    //if (TSMGetDeadKeyState() == 0) {
-    //    return 0;
-    //}
-
-    // AppKit does not track dead-key states directly, but TSM does. Even then,
-    // it's not necessarily all that accurate, because the dead key can change
-    // given some combination of modifier keys on certain layouts.
-    // As a result, finding the unicode value for the front end of the dead
-    // key is a bit of a heuristic.
-
-    // This algorithm was suggested by Aki Inoue.
-    // When you get a dead key, you need to simiulate what would happen in
-    // the current dead-key and modifier state if the user hit the spacebar.
-    // That will tell you the front end of the dead-key combination.
-
-    unichar returnValue = 0;
-    const UInt16 VIRTUAL_KEY_SPACE = 49;
-    UInt32 deadKeyState = 0;
-    UInt32 appkitFlags = [event modifierFlags];
-    UniCharCount actualStringLength;
-    UniChar unicodeInputString[16];
-    TISInputSourceRef keyLayout;
-    const void *chrData;
-
-    keyLayout = TISCopyCurrentKeyboardLayoutInputSource();
-    CFDataRef cfUchrData =
-        TISGetInputSourceProperty(keyLayout, kTISPropertyUnicodeKeyLayoutData);
-
-    if (cfUchrData == NULL) {
-        return returnValue;
-    }
-
-    // The actual 'uchr' table is inside the CFDataRef.
-    chrData = CFDataGetBytePtr(cfUchrData);
-
-    UInt8 keyboardType = LMGetKbdType();
-    UInt32 keyEventModifiers = 0;
-    if (appkitFlags & NSShiftKeyMask)      keyEventModifiers |= shiftKey;
-    if (appkitFlags & NSCommandKeyMask)    keyEventModifiers |= cmdKey;
-    if (appkitFlags & NSAlphaShiftKeyMask) keyEventModifiers |= alphaLock;
-    if (appkitFlags & NSControlKeyMask)    keyEventModifiers |= controlKey;
-    if (appkitFlags & NSAlternateKeyMask)  keyEventModifiers |= optionKey;
-
-    if (noErr == UCKeyTranslate(chrData,
-        VIRTUAL_KEY_SPACE,
-        ([event type] == NSKeyDown ? kUCKeyActionDown : kUCKeyActionUp),
-        keyEventModifiers,
-        keyboardType,
-        kUCKeyTranslateNoDeadKeysMask,
-        &deadKeyState,
-        16,
-        &actualStringLength,
-        unicodeInputString))
-    {
-        if (actualStringLength > 0) {
-            returnValue = unicodeInputString[0];
-        }
-    }
-
-    return returnValue;
-}
-*/
-
-
-// REMIND: The fix for MACOSX_PORT-539 introduces Java-level implementation
-// of the function below (see CPlatformResponder). Consider removing this code.
-
-void
-DeliverJavaKeyEvent(JNIEnv *env, NSEvent *event, jobject peer)
-{
-    jint javaKeyType = java_awt_event_KeyEvent_KEY_PRESSED;
-    jint javaKeyCode = java_awt_event_KeyEvent_VK_UNDEFINED;
-    jint javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN;
-    NSString *chars = nil;
-    BOOL postsTyped;
-    unichar testChar = java_awt_event_KeyEvent_CHAR_UNDEFINED;
-    unichar testDeadChar = 0;
-    jint javaModifiers = 0;
-
-    switch ([event type]) {
-    case NSFlagsChanged:
-        NsKeyModifiersToJavaKeyInfo([event modifierFlags],
-                                    [event keyCode],
-                                    &javaKeyCode,
-                                    &javaKeyLocation,
-                                    &javaKeyType);
-        break;
-
-    case NSKeyDown:
-    case NSKeyUp:
-        chars = [event charactersIgnoringModifiers];
-        if ([chars length] > 0) {
-            testChar = [chars characterAtIndex:0];
-        }
-
-        javaModifiers = NsKeyModifiersToJavaModifiers([event modifierFlags]);
-        if (javaModifiers == 0) {
-      // TODO: dead key chars
-//            testDeadChar = GetDeadKeyCharacter(event);
-        }
-
-        NsCharToJavaVirtualKeyCode(testChar, testDeadChar,
-                                   [event modifierFlags], [event keyCode],
-                                   &javaKeyCode, &javaKeyLocation, &postsTyped);
-        if( !postsTyped ) {
-            testChar = java_awt_event_KeyEvent_CHAR_UNDEFINED;
-        }
-
-        javaKeyType = ([event type] == NSKeyDown) ?
-            java_awt_event_KeyEvent_KEY_PRESSED :
-            java_awt_event_KeyEvent_KEY_RELEASED;
-        break;
-
-    default:
-        //[NSException raise:@"AWT error" format:@"Attempt to get virtual key code from non-key event!"];
-        break;
-    }
-
-    if (env != NULL) {
-        static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView");
-        static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_CPlatformView, "deliverKeyEvent", "(IICII)V");
-        JNFCallVoidMethod(env, peer, jm_deliverKeyEvent,
-                          javaKeyType, javaModifiers,
-                          testChar, javaKeyCode, javaKeyLocation);
-    }
-}
-
 jint GetJavaMouseModifiers(NSInteger button, NSUInteger modifierFlags)
 {
     // Mousing needs the key modifiers
@@ -726,217 +542,6 @@
     return modifiers;
 }
 
-/*
- * Converts an NSEvent button number to a MouseEvent constant.
- */
-static jint
-NSButtonToJavaButton(NSInteger nsButtonNumber)
-{
-    jint jbutton = java_awt_event_MouseEvent_NOBUTTON;
-
-    if (nsButtonNumber == 0) { // left
-        jbutton = java_awt_event_MouseEvent_BUTTON1;
-    } else if (nsButtonNumber == 1) { // right
-        jbutton = java_awt_event_MouseEvent_BUTTON3;
-    } else if (nsButtonNumber == 2) { // middle
-        jbutton = java_awt_event_MouseEvent_BUTTON2;
-    }
-
-    return jbutton;
-}
-
-
-static BOOL isDragging = NO;
-
-void
-DeliverMouseClickedEvent(JNIEnv *env, NSEvent *event, jobject peer)
-{
-    NSPoint pt = [event locationInWindow];
-    NSPoint pOnScreen = [NSEvent mouseLocation];
-    jint etype = java_awt_event_MouseEvent_MOUSE_CLICKED;
-    jint modifiers = GetJavaMouseModifiers([event buttonNumber], [event modifierFlags]);
-    jint clickCount = [event clickCount];
-    jint button = NSButtonToJavaButton([event buttonNumber]);
-
-    if (env != NULL) {
-        static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView");
-        static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_CPlatformView,
-                                "deliverMouseEvent", "(IIIIFFFF)V");
-        JNFCallVoidMethod(env, peer, jm_deliverMouseEvent,
-                          etype, modifiers,
-                          clickCount, button,
-                          pt.x, pt.y,
-                          pOnScreen.x, pOnScreen.y);
-    }
-}
-
-/*
- * After every key down event, this is called to make the matching
- * KEY_TYPED (if this key posts those).  We use the same NSEvent for it,
- * but create a KEY_TYPED java event this time.
- * If this key doesn't post typed, we don't post the event.
- *
- * TODO: some duplicated effort here; could just fold it
- * into DeliverJavaKeyEvent...
- */
-static void
-DeliverKeyTypedEvents(JNIEnv *env, NSEvent *nsEvent, jobject peer)
-{
-    if (peer == NULL) {
-        return;
-    }
-
-    jint javaKeyCode, javaKeyLocation;
-    BOOL postsTyped = NO;
-    unichar testChar, testDeadChar = 0;
-    jint javaModifiers = NsKeyModifiersToJavaModifiers([nsEvent modifierFlags]);
-
-    if (javaModifiers == 0) {
-        testDeadChar = [nsEvent deadKeyCharacter];
-    }
-
-    NSString *theChars = [nsEvent characters];
-    unsigned i, stringLength = [theChars length];
-
-    for (i = 0; i < stringLength; i++) {
-        testChar = [theChars characterAtIndex:i];
-        NsCharToJavaVirtualKeyCode(testChar, testDeadChar,
-                                   [nsEvent modifierFlags], [nsEvent keyCode],
-                                   &javaKeyCode, &javaKeyLocation, &postsTyped);
-
-        if (postsTyped) {
-            // Some keys may generate a KEY_TYPED, but we can't determine
-            // what that character is. That's likely a bug, but for now we
-            // just check for CHAR_UNDEFINED.
-            unichar theChar = GetJavaCharacter(nsEvent, i);
-            if (theChar != java_awt_event_KeyEvent_CHAR_UNDEFINED) {
-                if (env != NULL) {
-                    static JNF_CLASS_CACHE(jc_CPlatformView,
-                                           "sun/lwawt/macosx/CPlatformView");
-                    static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_CPlatformView,
-                                            "deliverKeyEvent", "(IICII)V");
-                    JNFCallVoidMethod(env, peer, jm_deliverKeyEvent,
-                                      java_awt_event_KeyEvent_KEY_TYPED,
-                                      javaModifiers,
-                                      theChar,
-                                      java_awt_event_KeyEvent_VK_UNDEFINED,
-                                      java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN);
-                }
-            }
-        }
-    }
-}
-
-/*
- * There are a couple of extra events that Java expects to get that don't
- * actually correspond to a direct NSEvent, KEY_TYPED and MOUSE_CLICKED are
- * both extra events that are sort of redundant with ordinary
- * key downs and mouse ups.  In this extra message, we take the original
- * input event and if necessary, cons up a special follow-on event which
- * we dispatch over to Java.
- *
- * For Java, keyDown's generate a KeyPressed (for each hardware key as it
- * goes down) and then a "logical KeyTyped" event for the key event. (So
- * a shift-a generates two presses, one keytyped of "A", and then two
- * releases).  The standard event utility function converts a key down to
- * a key pressed. When appropriate, we need to cons up another event
- * (KEY_TYPED) to follow a keyDown.
- *
- * Java expects you to send a clicked event if you got a down & up, with no
- * intervening drag. So in addition to the MOUSE_RELEASED event that a
- * mouseUp is translated to, we also have to cons up a MOUSE_CLICKED event
- * for that case. Mike Paquette, god of Window Server event handling,
- * confirmed this fact about how to determine if a mouse up event had an
- * intervening drag:
- * An initial mouse-down gets a click count of 1. Subsequent left or right
- * mouse-downs within the space/time tolerance limits increment the click
- * count.  A mouse-up will have the clickCount of the last mouseDown if
- * mouse is not outside the tolerance limits, but 0 otherwise.  Thus, a
- * down-up sequence without any intervening drag will have a click count
- * of 0 in the mouse-up event.  NOTE: The problem with this is that
- * clickCount goes to zero after some point in time. So a long, click &
- * hold without moving and then release the mouse doesn't create a
- * MOUSE_CLICK event as it should. Java AWT now tracks the drag state itself.
- *
- * As another add-on, we also check for the status of mouse-motion events
- * after a mouse-down, so we know whether to generate mouse-dragged events
- * during this down sequence.
- */
-void
-SendAdditionalJavaEvents(JNIEnv *env, NSEvent *nsEvent, jobject peer)
-{
-    AWT_ASSERT_APPKIT_THREAD;
-
-    NSEventType type = [nsEvent type];
-    switch (type) {
-    case NSKeyDown:
-        break;
-
-    case NSLeftMouseUp:
-    case NSRightMouseUp:
-    case NSOtherMouseUp:
-        // TODO: we may need to pull in changedDragToMove here...
-        //if (!isDragging && ([NSViewAWT changedDragToMove]==NO)) {
-        if (!isDragging) {
-            // got down/up pair with no dragged in between; ignores drag events
-            // that have been morphed to move events
-            DeliverMouseClickedEvent(env, nsEvent, peer);
-        }
-        break;
-
-// TODO: to be implemented...
-#if 0
-    case NSLeftMouseDragged:
-    case NSRightMouseDragged:
-    case NSOtherMouseDragged:
-        //
-        // During a drag, the AppKit does not send mouseEnter and mouseExit
-        // events.  It turns out that doing a hitTest causes the window's
-        // view hierarchy to be locked from drawing and that, of course,
-        // slows everything way down.  Synthesize mouseEnter and mouseExit
-        // then forward.
-        //
-        NSView *hitView = [[source model] hitTest:[nsEvent locationInWindow]];
-
-        if ((hitView != nil) &&
-            ([hitView conformsToProtocol:@protocol(AWTPeerControl)]))
-        {
-            if (sLastMouseDraggedView == nil) {
-                sLastMouseDraggedView = hitView;
-            }
-            else if (hitView != sLastMouseDraggedView) {
-                // We know sLastMouseDraggedView is a AWTPeerControl.
-                jobject lastPeer =
-                    [(id <AWTPeerControl>)sLastMouseDraggedView peer];
-
-                // Send mouseExit to sLastMouseDraggedView
-                jobject exitEvent =
-                    makeMouseEvent(env, nsEvent, lastPeer,
-                                   sLastMouseDraggedView,
-                                   java_awt_event_MouseEvent_MOUSE_EXITED);
-                pushEventForward(exitEvent, env);
-                (*env)->DeleteLocalRef(env, exitEvent);
-
-                // Send mouseEnter to hitView
-                jobject enterEvent =
-                    makeMouseEvent(env, nsEvent, peer, hitView,
-                                   java_awt_event_MouseEvent_MOUSE_ENTERED);
-                pushEventForward(enterEvent, env);
-
-                (*env)->DeleteLocalRef(env, enterEvent);
-
-                // Set sLastMouseDraggedView = hitView
-                sLastMouseDraggedView = hitView;
-            }
-        }
-        break;
-#endif
-
-    default:
-        break;
-    }
-}
-
 jlong UTC(NSEvent *event) {
     struct timeval tv;
     if (gettimeofday(&tv, NULL) == 0) {
@@ -1069,3 +674,23 @@
 
 JNF_COCOA_EXIT(env);
 }
+
+/*
+ * Class:     sun_lwawt_macosx_event_NSEvent
+ * Method:    nsToJavaChar
+ * Signature: (CI)C
+ */
+JNIEXPORT jint JNICALL
+Java_sun_lwawt_macosx_event_NSEvent_nsToJavaChar
+(JNIEnv *env, jclass cls, char nsChar, jint modifierFlags)
+{
+    jchar javaChar = 0;
+    
+JNF_COCOA_ENTER(env);
+    
+    javaChar = NsCharToJavaChar(nsChar, modifierFlags);
+
+JNF_COCOA_EXIT(env);
+    
+    return javaChar;
+}
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.h	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.h	Wed Jul 05 18:09:02 2017 +0200
@@ -39,7 +39,6 @@
 @private
     JNFWeakJObjectWrapper *javaPlatformWindow;
     CMenuBar *javaMenuBar;
-    NSWindow *growBoxWindow;
     NSSize javaMinSize;
     NSSize javaMaxSize;
     jint styleBits;
@@ -47,7 +46,6 @@
 
 @property (nonatomic, retain) JNFWeakJObjectWrapper *javaPlatformWindow;
 @property (nonatomic, retain) CMenuBar *javaMenuBar;
-@property (nonatomic, retain) NSWindow *growBoxWindow;
 @property (nonatomic) NSSize javaMinSize;
 @property (nonatomic) NSSize javaMaxSize;
 @property (nonatomic) jint styleBits;
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.m	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m	Wed Jul 05 18:09:02 2017 +0200
@@ -40,7 +40,6 @@
 #import "ThreadUtilities.h"
 #import "OSVersion.h"
 
-
 #define MASK(KEY) \
     (sun_lwawt_macosx_CPlatformWindow_ ## KEY)
 
@@ -50,31 +49,12 @@
 #define SET(BITS, KEY, VALUE) \
     BITS = VALUE ? BITS | MASK(KEY) : BITS & ~MASK(KEY)
 
-
 static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow");
 
-@interface JavaResizeGrowBoxOverlayWindow : NSWindow { }
-
-@end
-
-@implementation JavaResizeGrowBoxOverlayWindow
-
-- (BOOL) accessibilityIsIgnored
-{
-    return YES;
-}
-
-- (NSArray *)accessibilityChildrenAttribute
-{
-    return nil;
-}
-@end
-
 @implementation AWTWindow
 
 @synthesize javaPlatformWindow;
 @synthesize javaMenuBar;
-@synthesize growBoxWindow;
 @synthesize javaMinSize;
 @synthesize javaMaxSize;
 @synthesize styleBits;
@@ -154,24 +134,6 @@
 
 }
 
-- (BOOL) shouldShowGrowBox {
-    return isSnowLeopardOrLower() && IS(self.styleBits, RESIZABLE);
-}
-
-- (NSImage *) createGrowBoxImage {
-    NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(12, 12)];
-    JRSUIControlRef growBoxWidget = JRSUIControlCreate(FALSE);
-    JRSUIControlSetWidget(growBoxWidget, kJRSUI_Widget_growBoxTextured);
-    JRSUIControlSetWindowType(growBoxWidget, kJRSUI_WindowType_utility);
-    JRSUIRendererRef renderer = JRSUIRendererCreate();
-    [image lockFocus]; // sets current graphics context to that of the image
-    JRSUIControlDraw(renderer, growBoxWidget, [[NSGraphicsContext currentContext] graphicsPort], CGRectMake(0, 1, 11, 11));
-    [image unlockFocus];
-    JRSUIRendererRelease(renderer);
-    JRSUIControlRelease(growBoxWidget);
-    return image;
-}
-
 - (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
                     styleBits:(jint)bits
                     frameRect:(NSRect)rect
@@ -205,28 +167,6 @@
     [self setReleasedWhenClosed:NO];
     [self setPreservesContentDuringLiveResize:YES];
 
-    if ([self shouldShowGrowBox]) {
-        NSImage *growBoxImage = [self createGrowBoxImage];
-        growBoxWindow = [[JavaResizeGrowBoxOverlayWindow alloc] initWithContentRect:NSMakeRect(0, 0, [growBoxImage size].width, [growBoxImage size].height) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
-        [self.growBoxWindow setIgnoresMouseEvents:YES];
-        [self.growBoxWindow setOpaque:NO];
-        [self.growBoxWindow setBackgroundColor:[NSColor clearColor]];
-        [self.growBoxWindow setHasShadow:NO];
-        [self.growBoxWindow setReleasedWhenClosed:NO];
-
-        NSImageView *imageView = [[NSImageView alloc] initWithFrame:[self.growBoxWindow frame]];
-        [imageView setEditable:NO];
-        [imageView setAnimates:NO];
-        [imageView setAllowsCutCopyPaste:NO];
-        [self.growBoxWindow setContentView:imageView];
-        [imageView setImage:growBoxImage];
-        [growBoxImage release];
-        [imageView release];
-
-        [self addChildWindow:self.growBoxWindow ordered:NSWindowAbove];
-        [self adjustGrowBoxWindow];
-    } else growBoxWindow = nil;
-
     return self;
 }
 
@@ -235,7 +175,6 @@
 
     JNIEnv *env = [ThreadUtilities getJNIEnv];
     [self.javaPlatformWindow setJObject:nil withEnv:env];
-    self.growBoxWindow = nil;
 
     [super dealloc];
 }
@@ -321,14 +260,6 @@
 
 // NSWindowDelegate methods
 
-- (void) adjustGrowBoxWindow {
-    if (self.growBoxWindow != nil) {
-        NSRect parentRect = [self frame];
-        parentRect.origin.x += (parentRect.size.width - [self.growBoxWindow frame].size.width);
-        [self.growBoxWindow setFrameOrigin:parentRect.origin];
-    }
-}
-
 - (void) _deliverMoveResizeEvent {
 AWT_ASSERT_APPKIT_THREAD;
 
@@ -342,8 +273,6 @@
         // TODO: create generic AWT assert
     }
 
-    [self adjustGrowBoxWindow];
-
     NSRect frame = ConvertNSScreenRect(env, [self frame]);
 
     static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIII)V");
@@ -548,6 +477,31 @@
         }
         [super sendEvent:event];
 }
+
+- (void)constrainSize:(NSSize*)size {
+    float minWidth = 0.f, minHeight = 0.f;
+
+    if (IS(self.styleBits, DECORATED)) {
+        NSRect frame = [self frame];
+        NSRect contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[self styleMask]];
+
+        float top = frame.size.height - contentRect.size.height;
+        float left = contentRect.origin.x - frame.origin.x;
+        float bottom = contentRect.origin.y - frame.origin.y;
+        float right = frame.size.width - (contentRect.size.width + left);
+
+        // Speculative estimation: 80 - enough for window decorations controls
+        minWidth += left + right + 80;
+        minHeight += top + bottom;
+    }
+
+    minWidth = MAX(1.f, minWidth);
+    minHeight = MAX(1.f, minHeight);
+
+    size->width = MAX(size->width, minWidth);
+    size->height = MAX(size->height, minHeight);
+}
+
 @end // AWTWindow
 
 
@@ -703,6 +657,8 @@
         AWT_ASSERT_APPKIT_THREAD;
 
         NSRect rect = ConvertNSScreenRect(NULL, jrect);
+        [window constrainSize:&rect.size];
+
         [window setFrame:rect display:YES];
 
         // only start tracking events if pointer is above the toplevel
@@ -734,13 +690,16 @@
     if (maxW < 1) maxW = 1;
     if (maxH < 1) maxH = 1;
 
-    NSSize min = { minW, minH };
-    NSSize max = { maxW, maxH };
-
     AWTWindow *window = OBJC(windowPtr);
     [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
         AWT_ASSERT_APPKIT_THREAD;
 
+        NSSize min = { minW, minH };
+        NSSize max = { maxW, maxH };
+
+        [window constrainSize:&min];
+        [window constrainSize:&max];
+
         window.javaMinSize = min;
         window.javaMaxSize = max;
         [window updateMinMaxSize:IS(window.styleBits, RESIZABLE)];
@@ -830,7 +789,6 @@
         AWT_ASSERT_APPKIT_THREAD;
 
         [window setAlphaValue:alpha];
-        [window.growBoxWindow setAlphaValue:alpha];
     }];
 
 JNF_COCOA_EXIT(env);
--- a/jdk/src/macosx/native/sun/awt/CDropTarget.m	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/CDropTarget.m	Wed Jul 05 18:09:02 2017 +0200
@@ -648,6 +648,10 @@
     if (sDraggingError == FALSE) {
         sDraggingLocation = [sender draggingLocation];
         NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil];
+        // The y coordinate that comes in the NSDraggingInfo seems to be reversed - probably
+        // has to do something with the type of view it comes to.
+        // This is the earliest place where we can correct it.
+        javaLocation.y = fView.window.frame.size.height - javaLocation.y;
 
         jint actions = [DnDUtilities mapNSDragOperationMaskToJava:[sender draggingSourceOperationMask]];
         jint dropAction = sJavaDropOperation;
--- a/jdk/src/macosx/native/sun/awt/CImage.m	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/CImage.m	Wed Jul 05 18:09:02 2017 +0200
@@ -70,19 +70,8 @@
     [oldContext release];
 }
 
-/*
- * Class:     sun_lwawt_macosx_CImage
- * Method:    nativeCreateNSImageFromArray
- * Signature: ([III)J
- */
-JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArray
-(JNIEnv *env, jclass klass, jintArray buffer, jint width, jint height)
+static NSBitmapImageRep* CImage_CreateImageRep(JNIEnv *env, jintArray buffer, jint width, jint height)
 {
-    jlong result = 0L;
-
-JNF_COCOA_ENTER(env);
-AWT_ASSERT_ANY_THREAD;
-
     NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
                                                                          pixelsWide:width
                                                                          pixelsHigh:height
@@ -105,15 +94,83 @@
 
     (*env)->ReleasePrimitiveArrayCritical(env, buffer, src, JNI_ABORT);
 
-    NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
-    [nsImage addRepresentation:imageRep];
-    [imageRep release];
+    return imageRep;
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CImage
+ * Method:    nativeCreateNSImageFromArray
+ * Signature: ([III)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArray
+(JNIEnv *env, jclass klass, jintArray buffer, jint width, jint height)
+{
+    jlong result = 0L;
 
-    if (nsImage != nil) {
-        CFRetain(nsImage); // GC
+JNF_COCOA_ENTER(env);
+AWT_ASSERT_ANY_THREAD;
+
+    NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
+    if (imageRep) {
+        NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
+        [nsImage addRepresentation:imageRep];
+        [imageRep release];
+
+        if (nsImage != nil) {
+            CFRetain(nsImage); // GC
+        }
+
+        result = ptr_to_jlong(nsImage);
     }
 
-    result = ptr_to_jlong(nsImage);
+JNF_COCOA_EXIT(env);
+
+    return result;
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CImage
+ * Method:    nativeCreateNSImageFromArrays
+ * Signature: ([[I[I[I)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArrays
+(JNIEnv *env, jclass klass, jobjectArray buffers, jintArray widths, jintArray heights)
+{
+    jlong result = 0L;
+
+JNF_COCOA_ENTER(env);
+AWT_ASSERT_ANY_THREAD;
+
+    jsize num = (*env)->GetArrayLength(env, buffers);
+    NSMutableArray * reps = [NSMutableArray arrayWithCapacity: num];
+
+    jint * ws = (*env)->GetIntArrayElements(env, widths, NULL);
+    jint * hs = (*env)->GetIntArrayElements(env, heights, NULL);
+
+    jsize i;
+    for (i = 0; i < num; i++) {
+        jintArray buffer = (*env)->GetObjectArrayElement(env, buffers, i);
+
+        NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, ws[i], hs[i]);
+        if (imageRep) {
+            [reps addObject: imageRep];
+        }
+    }
+
+    (*env)->ReleaseIntArrayElements(env, heights, hs, JNI_ABORT);
+    (*env)->ReleaseIntArrayElements(env, widths, ws, JNI_ABORT);
+
+    if ([reps count]) {
+        NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0, 0)];
+        [nsImage addRepresentations: reps];
+        [reps release];
+
+        if (nsImage != nil) {
+            CFRetain(nsImage); // GC
+        }
+
+        result = ptr_to_jlong(nsImage);
+    }
 
 JNF_COCOA_EXIT(env);
 
--- a/jdk/src/macosx/native/sun/nio/ch/KQueueArrayWrapper.c	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/macosx/native/sun/nio/ch/KQueueArrayWrapper.c	Wed Jul 05 18:09:02 2017 +0200
@@ -4,7 +4,9 @@
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * 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
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java	Wed Jul 05 18:09:02 2017 +0200
@@ -114,6 +114,23 @@
             String value = token.substring(index + 1,
                                            token.length() - 1); // Remove comma delimiter
 
+            /*
+             * for values enclosed in quotes (single and/or double quotes)
+             * strip off enclosing quote chars
+             * needed for quote enclosed delimited substrings
+             */
+            if (name.equals("options")) {
+                StringBuilder sb = new StringBuilder();
+                for (String s : splitStringAtNonEnclosedWhiteSpace(value)) {
+                    while (isEnclosed(s, "\"") || isEnclosed(s, "'")) {
+                        s = s.substring(1, s.length() - 1);
+                    }
+                    sb.append(s);
+                    sb.append(" ");
+                }
+                value = sb.toString();
+            }
+
             Connector.Argument argument = arguments.get(name);
             if (argument == null) {
                 throw new IllegalArgumentException
@@ -136,6 +153,152 @@
         return arguments;
     }
 
+    private static boolean isEnclosed(String value, String enclosingChar) {
+        if (value.indexOf(enclosingChar) == 0) {
+            int lastIndex = value.lastIndexOf(enclosingChar);
+            if (lastIndex > 0 && lastIndex  == value.length() - 1) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static List<String> splitStringAtNonEnclosedWhiteSpace(String value) throws IllegalArgumentException {
+        List<String> al = new ArrayList<String>();
+        char[] arr;
+        int startPosition = 0;
+        int endPosition = 0;
+        final char SPACE = ' ';
+        final char DOUBLEQ = '"';
+        final char SINGLEQ = '\'';
+
+        /*
+         * An "open" or "active" enclosing state is where
+         * the first valid start quote qualifier is found,
+         * and there is a search in progress for the
+         * relevant end matching quote
+         *
+         * enclosingTargetChar set to SPACE
+         * is used to signal a non open enclosing state
+         */
+        char enclosingTargetChar = SPACE;
+
+        if (value == null) {
+            throw new IllegalArgumentException
+                (MessageOutput.format("value string is null"));
+        }
+
+        // split parameter string into individual chars
+        arr = value.toCharArray();
+
+        for (int i = 0; i < arr.length; i++) {
+            switch (arr[i]) {
+                case SPACE: {
+                    // do nothing for spaces
+                    // unless last in array
+                    if (isLastChar(arr, i)) {
+                        endPosition = i;
+                        // break for substring creation
+                        break;
+                    }
+                    continue;
+                }
+                case DOUBLEQ:
+                case SINGLEQ: {
+                    if (enclosingTargetChar == arr[i]) {
+                        // potential match to close open enclosing
+                        if (isNextCharWhitespace(arr, i)) {
+                            // if peek next is whitespace
+                            // then enclosing is a valid substring
+                            endPosition = i;
+                            // reset enclosing target char
+                            enclosingTargetChar = SPACE;
+                            // break for substring creation
+                            break;
+                        }
+                    }
+                    if (enclosingTargetChar == SPACE) {
+                        // no open enclosing state
+                        // handle as normal char
+                        if (isPreviousCharWhitespace(arr, i)) {
+                            startPosition = i;
+                            // peek forward for end candidates
+                            if (value.indexOf(arr[i], i + 1) >= 0) {
+                                // set open enclosing state by
+                                // setting up the target char
+                                enclosingTargetChar = arr[i];
+                            } else {
+                                // no more target chars left to match
+                                // end enclosing, handle as normal char
+                                if (isNextCharWhitespace(arr, i)) {
+                                    endPosition = i;
+                                    // break for substring creation
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                    continue;
+                }
+                default: {
+                    // normal non-space, non-" and non-' chars
+                    if (enclosingTargetChar == SPACE) {
+                        // no open enclosing state
+                        if (isPreviousCharWhitespace(arr, i)) {
+                            // start of space delim substring
+                            startPosition = i;
+                        }
+                        if (isNextCharWhitespace(arr, i)) {
+                            // end of space delim substring
+                            endPosition = i;
+                            // break for substring creation
+                            break;
+                        }
+                    }
+                    continue;
+                }
+            }
+
+            // break's end up here
+            if (startPosition > endPosition) {
+                throw new IllegalArgumentException
+                    (MessageOutput.format("Illegal option values"));
+            }
+
+            // extract substring and add to List<String>
+            al.add(value.substring(startPosition, ++endPosition));
+
+            // set new start position
+            i = startPosition = endPosition;
+
+        } // for loop
+
+        return al;
+    }
+
+    static private boolean isPreviousCharWhitespace(char[] arr, int curr_pos) {
+        return isCharWhitespace(arr, curr_pos - 1);
+    }
+
+    static private boolean isNextCharWhitespace(char[] arr, int curr_pos) {
+        return isCharWhitespace(arr, curr_pos + 1);
+    }
+
+    static private boolean isCharWhitespace(char[] arr, int pos) {
+        if (pos < 0 || pos >= arr.length) {
+            // outside arraybounds is considered an implicit space
+            return true;
+        }
+        if (arr[pos] == ' ') {
+            return true;
+        }
+        return false;
+    }
+
+    static private boolean isLastChar(char[] arr, int pos) {
+        return (pos + 1 == arr.length);
+    }
+
     VMConnection(String connectSpec, int traceFlags) {
         String nameString;
         String argString;
--- a/jdk/src/share/classes/java/net/HttpCookie.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/net/HttpCookie.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -616,9 +616,6 @@
      *   would be accepted.</li>
      *   <li>A Set-Cookie2 with Domain=.com or Domain=.com., will always be
      *   rejected, because there is no embedded dot.</li>
-     *   <li>A Set-Cookie2 with Domain=ajax.com will be accepted, and the
-     *   value for Domain will be taken to be .ajax.com, because a dot
-     *   gets prepended to the value.</li>
      *   <li>A Set-Cookie2 from request-host example for Domain=.local will
      *   be accepted, because the effective host name for the request-
      *   host is example.local, and example.local domain-matches .local.</li>
--- a/jdk/src/share/classes/java/nio/file/Files.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/nio/file/Files.java	Wed Jul 05 18:09:02 2017 +0200
@@ -269,7 +269,7 @@
      *     WritableByteChannel wbc = Files.newByteChannel(path, EnumSet.of(CREATE,APPEND));
      *
      *     // create file with initial permissions, opening it for both reading and writing
-     *     {@code FileAttribute<<SetPosixFilePermission>> perms = ...}
+     *     {@code FileAttribute<Set<PosixFilePermission>> perms = ...}
      *     SeekableByteChannel sbc = Files.newByteChannel(path, EnumSet.of(CREATE_NEW,READ,WRITE), perms);
      * </pre>
      *
--- a/jdk/src/share/classes/java/security/CodeSource.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/security/CodeSource.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -114,7 +114,7 @@
      *
      * @return a hash code value for this object.
      */
-
+    @Override
     public int hashCode() {
         if (location != null)
             return location.hashCode();
@@ -133,6 +133,7 @@
      *
      * @return true if the objects are considered equal, false otherwise.
      */
+    @Override
     public boolean equals(Object obj) {
         if (obj == this)
             return true;
@@ -231,10 +232,10 @@
 
     /**
      * Returns true if this CodeSource object "implies" the specified CodeSource.
-     * <P>
-     * More specifically, this method makes the following checks, in order.
+     * <p>
+     * More specifically, this method makes the following checks.
      * If any fail, it returns false. If they all succeed, it returns true.<p>
-     * <ol>
+     * <ul>
      * <li> <i>codesource</i> must not be null.
      * <li> If this object's certificates are not null, then all
      * of this object's certificates must be present in <i>codesource</i>'s
@@ -242,14 +243,14 @@
      * <li> If this object's location (getLocation()) is not null, then the
      * following checks are made against this object's location and
      * <i>codesource</i>'s:<p>
-     *   <ol>
+     *   <ul>
      *     <li>  <i>codesource</i>'s location must not be null.
      *
      *     <li>  If this object's location
      *           equals <i>codesource</i>'s location, then return true.
      *
      *     <li>  This object's protocol (getLocation().getProtocol()) must be
-     *           equal to <i>codesource</i>'s protocol.
+     *           equal to <i>codesource</i>'s protocol, ignoring case.
      *
      *     <li>  If this object's host (getLocation().getHost()) is not null,
      *           then the SocketPermission
@@ -258,7 +259,8 @@
      *
      *     <li>  If this object's port (getLocation().getPort()) is not
      *           equal to -1 (that is, if a port is specified), it must equal
-     *           <i>codesource</i>'s port.
+     *           <i>codesource</i>'s port or default port
+     *           (codesource.getLocation().getDefaultPort()).
      *
      *     <li>  If this object's file (getLocation().getFile()) doesn't equal
      *           <i>codesource</i>'s file, then the following checks are made:
@@ -275,8 +277,8 @@
      *     <li>  If this object's reference (getLocation().getRef()) is
      *           not null, it must equal <i>codesource</i>'s reference.
      *
-     *   </ol>
-     * </ol>
+     *   </ul>
+     * </ul>
      * <p>
      * For example, the codesource objects with the following locations
      * and null certificates all imply
@@ -369,85 +371,88 @@
      *
      * @param that CodeSource to compare against
      */
-    private boolean matchLocation(CodeSource that)
-        {
-            if (location == null) {
-                return true;
-            }
+    private boolean matchLocation(CodeSource that) {
+        if (location == null)
+            return true;
 
-            if ((that == null) || (that.location == null))
-                return false;
+        if ((that == null) || (that.location == null))
+            return false;
+
+        if (location.equals(that.location))
+            return true;
 
-            if (location.equals(that.location))
-                return true;
+        if (!location.getProtocol().equalsIgnoreCase(that.location.getProtocol()))
+            return false;
 
-            if (!location.getProtocol().equals(that.location.getProtocol()))
+        int thisPort = location.getPort();
+        if (thisPort != -1) {
+            int thatPort = that.location.getPort();
+            int port = thatPort != -1 ? thatPort
+                                      : that.location.getDefaultPort();
+            if (thisPort != port)
                 return false;
-
-            String thisHost = location.getHost();
-            String thatHost = that.location.getHost();
+        }
 
-            if (thisHost != null) {
-                if (("".equals(thisHost) || "localhost".equals(thisHost)) &&
-                    ("".equals(thatHost) || "localhost".equals(thatHost))) {
-                    // ok
-                } else if (!thisHost.equals(thatHost)) {
-                    if (thatHost == null) {
-                        return false;
-                    }
-                    if (this.sp == null) {
-                        this.sp = new SocketPermission(thisHost, "resolve");
-                    }
-                    if (that.sp == null) {
-                        that.sp = new SocketPermission(thatHost, "resolve");
-                    }
-                    if (!this.sp.implies(that.sp)) {
-                        return false;
-                    }
-                }
+        if (location.getFile().endsWith("/-")) {
+            // Matches the directory and (recursively) all files
+            // and subdirectories contained in that directory.
+            // For example, "/a/b/-" implies anything that starts with
+            // "/a/b/"
+            String thisPath = location.getFile().substring(0,
+                                            location.getFile().length()-1);
+            if (!that.location.getFile().startsWith(thisPath))
+                return false;
+        } else if (location.getFile().endsWith("/*")) {
+            // Matches the directory and all the files contained in that
+            // directory.
+            // For example, "/a/b/*" implies anything that starts with
+            // "/a/b/" but has no further slashes
+            int last = that.location.getFile().lastIndexOf('/');
+            if (last == -1)
+                return false;
+            String thisPath = location.getFile().substring(0,
+                                            location.getFile().length()-1);
+            String thatPath = that.location.getFile().substring(0, last+1);
+            if (!thatPath.equals(thisPath))
+                return false;
+        } else {
+            // Exact matches only.
+            // For example, "/a/b" and "/a/b/" both imply "/a/b/"
+            if ((!that.location.getFile().equals(location.getFile()))
+                && (!that.location.getFile().equals(location.getFile()+"/"))) {
+                return false;
             }
-
-            if (location.getPort() != -1) {
-                if (location.getPort() != that.location.getPort())
-                    return false;
-            }
+        }
 
-            if (location.getFile().endsWith("/-")) {
-                // Matches the directory and (recursively) all files
-                // and subdirectories contained in that directory.
-                // For example, "/a/b/-" implies anything that starts with
-                // "/a/b/"
-                String thisPath = location.getFile().substring(0,
-                                                location.getFile().length()-1);
-                if (!that.location.getFile().startsWith(thisPath))
+        if (location.getRef() != null
+            && !location.getRef().equals(that.location.getRef())) {
+            return false;
+        }
+
+        String thisHost = location.getHost();
+        String thatHost = that.location.getHost();
+        if (thisHost != null) {
+            if (("".equals(thisHost) || "localhost".equals(thisHost)) &&
+                ("".equals(thatHost) || "localhost".equals(thatHost))) {
+                // ok
+            } else if (!thisHost.equals(thatHost)) {
+                if (thatHost == null) {
                     return false;
-            } else if (location.getFile().endsWith("/*")) {
-                // Matches the directory and all the files contained in that
-                // directory.
-                // For example, "/a/b/*" implies anything that starts with
-                // "/a/b/" but has no further slashes
-                int last = that.location.getFile().lastIndexOf('/');
-                if (last == -1)
-                    return false;
-                String thisPath = location.getFile().substring(0,
-                                                location.getFile().length()-1);
-                String thatPath = that.location.getFile().substring(0, last+1);
-                if (!thatPath.equals(thisPath))
-                    return false;
-            } else {
-                // Exact matches only.
-                // For example, "/a/b" and "/a/b/" both imply "/a/b/"
-                if ((!that.location.getFile().equals(location.getFile()))
-                && (!that.location.getFile().equals(location.getFile()+"/"))) {
+                }
+                if (this.sp == null) {
+                    this.sp = new SocketPermission(thisHost, "resolve");
+                }
+                if (that.sp == null) {
+                    that.sp = new SocketPermission(thatHost, "resolve");
+                }
+                if (!this.sp.implies(that.sp)) {
                     return false;
                 }
             }
-
-            if (location.getRef() == null)
-                return true;
-            else
-                return location.getRef().equals(that.location.getRef());
         }
+        // everything matches
+        return true;
+    }
 
     /**
      * Returns a string describing this CodeSource, telling its
@@ -455,6 +460,7 @@
      *
      * @return information about this CodeSource.
      */
+    @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
         sb.append("(");
--- a/jdk/src/share/classes/java/util/AbstractCollection.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/AbstractCollection.java	Wed Jul 05 18:09:02 2017 +0200
@@ -170,6 +170,7 @@
      * @throws ArrayStoreException  {@inheritDoc}
      * @throws NullPointerException {@inheritDoc}
      */
+    @SuppressWarnings("unchecked")
     public <T> T[] toArray(T[] a) {
         // Estimate size of array; be prepared to see more or fewer elements
         int size = size();
@@ -180,13 +181,21 @@
 
         for (int i = 0; i < r.length; i++) {
             if (! it.hasNext()) { // fewer elements than expected
-                if (a != r)
+                if (a == r) {
+                    r[i] = null; // null-terminate
+                } else if (a.length < i) {
                     return Arrays.copyOf(r, i);
-                r[i] = null; // null-terminate
-                return r;
+                } else {
+                    System.arraycopy(r, 0, a, 0, i);
+                    if (a.length > i) {
+                        a[i] = null;
+                    }
+                }
+                return a;
             }
             r[i] = (T)it.next();
         }
+        // more elements than expected
         return it.hasNext() ? finishToArray(r, it) : r;
     }
 
@@ -208,6 +217,7 @@
      * @return array containing the elements in the given array, plus any
      *         further elements returned by the iterator, trimmed to size
      */
+    @SuppressWarnings("unchecked")
     private static <T> T[] finishToArray(T[] r, Iterator<?> it) {
         int i = r.length;
         while (it.hasNext()) {
--- a/jdk/src/share/classes/java/util/AbstractList.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/AbstractList.java	Wed Jul 05 18:09:02 2017 +0200
@@ -516,7 +516,7 @@
             return false;
 
         ListIterator<E> e1 = listIterator();
-        ListIterator e2 = ((List) o).listIterator();
+        ListIterator<?> e2 = ((List<?>) o).listIterator();
         while (e1.hasNext() && e2.hasNext()) {
             E o1 = e1.next();
             Object o2 = e2.next();
--- a/jdk/src/share/classes/java/util/AbstractMap.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/AbstractMap.java	Wed Jul 05 18:09:02 2017 +0200
@@ -443,7 +443,7 @@
 
         if (!(o instanceof Map))
             return false;
-        Map<K,V> m = (Map<K,V>) o;
+        Map<?,?> m = (Map<?,?>) o;
         if (m.size() != size())
             return false;
 
@@ -534,7 +534,7 @@
      * @return a shallow copy of this map
      */
     protected Object clone() throws CloneNotSupportedException {
-        AbstractMap<K,V> result = (AbstractMap<K,V>)super.clone();
+        AbstractMap<?,?> result = (AbstractMap<?,?>)super.clone();
         result.keySet = null;
         result.values = null;
         return result;
@@ -652,7 +652,7 @@
         public boolean equals(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry e = (Map.Entry)o;
+            Map.Entry<?,?> e = (Map.Entry<?,?>)o;
             return eq(key, e.getKey()) && eq(value, e.getValue());
         }
 
@@ -783,7 +783,7 @@
         public boolean equals(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry e = (Map.Entry)o;
+            Map.Entry<?,?> e = (Map.Entry<?,?>)o;
             return eq(key, e.getKey()) && eq(value, e.getValue());
         }
 
--- a/jdk/src/share/classes/java/util/AbstractSet.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/AbstractSet.java	Wed Jul 05 18:09:02 2017 +0200
@@ -88,7 +88,7 @@
 
         if (!(o instanceof Set))
             return false;
-        Collection c = (Collection) o;
+        Collection<?> c = (Collection<?>) o;
         if (c.size() != size())
             return false;
         try {
--- a/jdk/src/share/classes/java/util/ArrayDeque.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/ArrayDeque.java	Wed Jul 05 18:09:02 2017 +0200
@@ -813,7 +813,8 @@
      */
     public ArrayDeque<E> clone() {
         try {
-            ArrayDeque<E> result = (ArrayDeque<E>) super.clone();
+            @SuppressWarnings("unchecked")
+                ArrayDeque<E> result = (ArrayDeque<E>) super.clone();
             result.elements = Arrays.copyOf(elements, elements.length);
             return result;
 
@@ -849,6 +850,7 @@
     /**
      * Deserialize this deque.
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream s)
             throws IOException, ClassNotFoundException {
         s.defaultReadObject();
--- a/jdk/src/share/classes/java/util/ArrayList.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/ArrayList.java	Wed Jul 05 18:09:02 2017 +0200
@@ -300,8 +300,7 @@
      */
     public Object clone() {
         try {
-            @SuppressWarnings("unchecked")
-                ArrayList<E> v = (ArrayList<E>) super.clone();
+            ArrayList<?> v = (ArrayList<?>) super.clone();
             v.elementData = Arrays.copyOf(elementData, size);
             v.modCount = 0;
             return v;
--- a/jdk/src/share/classes/java/util/Arrays.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/Arrays.java	Wed Jul 05 18:09:02 2017 +0200
@@ -560,6 +560,7 @@
      * off is the offset to generate corresponding low, high in src
      * To be removed in a future release.
      */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     private static void mergeSort(Object[] src,
                                   Object[] dest,
                                   int low,
@@ -746,6 +747,7 @@
      * off is the offset into src corresponding to low in dest
      * To be removed in a future release.
      */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
     private static void mergeSort(Object[] src,
                                   Object[] dest,
                                   int low, int high, int off,
@@ -1477,8 +1479,10 @@
 
         while (low <= high) {
             int mid = (low + high) >>> 1;
-            Comparable midVal = (Comparable)a[mid];
-            int cmp = midVal.compareTo(key);
+            @SuppressWarnings("rawtypes")
+                Comparable midVal = (Comparable)a[mid];
+            @SuppressWarnings("unchecked")
+                int cmp = midVal.compareTo(key);
 
             if (cmp < 0)
                 low = mid + 1;
@@ -2215,6 +2219,7 @@
      * @throws NullPointerException if <tt>original</tt> is null
      * @since 1.6
      */
+    @SuppressWarnings("unchecked")
     public static <T> T[] copyOf(T[] original, int newLength) {
         return (T[]) copyOf(original, newLength, original.getClass());
     }
@@ -2242,6 +2247,7 @@
      * @since 1.6
      */
     public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) {
+        @SuppressWarnings("unchecked")
         T[] copy = ((Object)newType == (Object)Object[].class)
             ? (T[]) new Object[newLength]
             : (T[]) Array.newInstance(newType.getComponentType(), newLength);
@@ -2470,8 +2476,9 @@
      * @throws NullPointerException if <tt>original</tt> is null
      * @since 1.6
      */
+    @SuppressWarnings("unchecked")
     public static <T> T[] copyOfRange(T[] original, int from, int to) {
-        return copyOfRange(original, from, to, (Class<T[]>) original.getClass());
+        return copyOfRange(original, from, to, (Class<? extends T[]>) original.getClass());
     }
 
     /**
@@ -2509,6 +2516,7 @@
         int newLength = to - from;
         if (newLength < 0)
             throw new IllegalArgumentException(from + " > " + to);
+        @SuppressWarnings("unchecked")
         T[] copy = ((Object)newType == (Object)Object[].class)
             ? (T[]) new Object[newLength]
             : (T[]) Array.newInstance(newType.getComponentType(), newLength);
@@ -2851,6 +2859,7 @@
             return a.clone();
         }
 
+        @SuppressWarnings("unchecked")
         public <T> T[] toArray(T[] a) {
             int size = size();
             if (a.length < size)
@@ -3634,7 +3643,7 @@
             if (element == null) {
                 buf.append("null");
             } else {
-                Class eClass = element.getClass();
+                Class<?> eClass = element.getClass();
 
                 if (eClass.isArray()) {
                     if (eClass == byte[].class)
--- a/jdk/src/share/classes/java/util/Calendar.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/Calendar.java	Wed Jul 05 18:09:02 2017 +0200
@@ -840,7 +840,7 @@
      * of a Locale.
      */
     private static final ConcurrentMap<Locale, int[]> cachedLocaleData
-        = new ConcurrentHashMap<Locale, int[]>(3);
+        = new ConcurrentHashMap<>(3);
 
     // Special values of stamp[]
     /**
@@ -1499,7 +1499,7 @@
         DateFormatSymbols symbols = DateFormatSymbols.getInstance(locale);
         String[] strings = getFieldStrings(field, style, symbols);
         if (strings != null) {
-            Map<String,Integer> names = new HashMap<String,Integer>();
+            Map<String,Integer> names = new HashMap<>();
             for (int i = 0; i < strings.length; i++) {
                 if (strings[i].length() == 0) {
                     continue;
--- a/jdk/src/share/classes/java/util/Collections.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/Collections.java	Wed Jul 05 18:09:02 2017 +0200
@@ -150,6 +150,7 @@
      *         detects that the natural ordering of the list elements is
      *         found to violate the {@link Comparable} contract
      */
+    @SuppressWarnings("unchecked")
     public static <T extends Comparable<? super T>> void sort(List<T> list) {
         Object[] a = list.toArray();
         Arrays.sort(a);
@@ -212,13 +213,14 @@
      * @throws IllegalArgumentException (optional) if the comparator is
      *         found to violate the {@link Comparator} contract
      */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public static <T> void sort(List<T> list, Comparator<? super T> c) {
         Object[] a = list.toArray();
         Arrays.sort(a, (Comparator)c);
-        ListIterator i = list.listIterator();
+        ListIterator<T> i = list.listIterator();
         for (int j=0; j<a.length; j++) {
             i.next();
-            i.set(a[j]);
+            i.set((T)a[j]);
         }
     }
 
@@ -357,9 +359,10 @@
      *         or the search key is not mutually comparable with the
      *         elements of the list using this comparator.
      */
+    @SuppressWarnings("unchecked")
     public static <T> int binarySearch(List<? extends T> list, T key, Comparator<? super T> c) {
         if (c==null)
-            return binarySearch((List) list, key);
+            return binarySearch((List<? extends Comparable<? super T>>) list, key);
 
         if (list instanceof RandomAccess || list.size()<BINARYSEARCH_THRESHOLD)
             return Collections.indexedBinarySearch(list, key, c);
@@ -406,9 +409,6 @@
         return -(low + 1);  // key not found
     }
 
-    private interface SelfComparable extends Comparable<SelfComparable> {}
-
-
     /**
      * Reverses the order of the elements in the specified list.<p>
      *
@@ -418,12 +418,16 @@
      * @throws UnsupportedOperationException if the specified list or
      *         its list-iterator does not support the <tt>set</tt> operation.
      */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
     public static void reverse(List<?> list) {
         int size = list.size();
         if (size < REVERSE_THRESHOLD || list instanceof RandomAccess) {
             for (int i=0, mid=size>>1, j=size-1; i<mid; i++, j--)
                 swap(list, i, j);
         } else {
+            // instead of using a raw type here, it's possible to capture
+            // the wildcard but it will require a call to a supplementary
+            // private method
             ListIterator fwd = list.listIterator();
             ListIterator rev = list.listIterator(size);
             for (int i=0, mid=list.size()>>1; i<mid; i++) {
@@ -493,6 +497,7 @@
      * @throws UnsupportedOperationException if the specified list or its
      *         list-iterator does not support the <tt>set</tt> operation.
      */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
     public static void shuffle(List<?> list, Random rnd) {
         int size = list.size();
         if (size < SHUFFLE_THRESHOLD || list instanceof RandomAccess) {
@@ -506,6 +511,9 @@
                 swap(arr, i-1, rnd.nextInt(i));
 
             // Dump array back into list
+            // instead of using a raw type here, it's possible to capture
+            // the wildcard but it will require a call to a supplementary
+            // private method
             ListIterator it = list.listIterator();
             for (int i=0; i<arr.length; i++) {
                 it.next();
@@ -527,7 +535,11 @@
      *         || j &lt; 0 || j &gt;= list.size()).
      * @since 1.4
      */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
     public static void swap(List<?> list, int i, int j) {
+        // instead of using a raw type here, it's possible to capture
+        // the wildcard but it will require a call to a supplementary
+        // private method
         final List l = list;
         l.set(i, l.set(j, l.get(i)));
     }
@@ -657,9 +669,10 @@
      * @throws NoSuchElementException if the collection is empty.
      * @see Comparable
      */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp) {
         if (comp==null)
-            return (T)min((Collection<SelfComparable>) (Collection) coll);
+            return (T)min((Collection) coll);
 
         Iterator<? extends T> i = coll.iterator();
         T candidate = i.next();
@@ -727,9 +740,10 @@
      * @throws NoSuchElementException if the collection is empty.
      * @see Comparable
      */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp) {
         if (comp==null)
-            return (T)max((Collection<SelfComparable>) (Collection) coll);
+            return (T)max((Collection) coll);
 
         Iterator<? extends T> i = coll.iterator();
         T candidate = i.next();
@@ -1389,7 +1403,9 @@
             extends UnmodifiableSet<Map.Entry<K,V>> {
             private static final long serialVersionUID = 7854390611657943733L;
 
+            @SuppressWarnings({ "unchecked", "rawtypes" })
             UnmodifiableEntrySet(Set<? extends Map.Entry<? extends K, ? extends V>> s) {
+                // Need to cast to raw in order to work around a limitation in the type system
                 super((Set)s);
             }
             public Iterator<Map.Entry<K,V>> iterator() {
@@ -1408,13 +1424,15 @@
                 };
             }
 
+            @SuppressWarnings("unchecked")
             public Object[] toArray() {
                 Object[] a = c.toArray();
                 for (int i=0; i<a.length; i++)
-                    a[i] = new UnmodifiableEntry<>((Map.Entry<K,V>)a[i]);
+                    a[i] = new UnmodifiableEntry<>((Map.Entry<? extends K, ? extends V>)a[i]);
                 return a;
             }
 
+            @SuppressWarnings("unchecked")
             public <T> T[] toArray(T[] a) {
                 // We don't pass a to c.toArray, to avoid window of
                 // vulnerability wherein an unscrupulous multithreaded client
@@ -1422,7 +1440,7 @@
                 Object[] arr = c.toArray(a.length==0 ? a : Arrays.copyOf(a, 0));
 
                 for (int i=0; i<arr.length; i++)
-                    arr[i] = new UnmodifiableEntry<>((Map.Entry<K,V>)arr[i]);
+                    arr[i] = new UnmodifiableEntry<>((Map.Entry<? extends K, ? extends V>)arr[i]);
 
                 if (arr.length > a.length)
                     return (T[])arr;
@@ -1464,7 +1482,7 @@
 
                 if (!(o instanceof Set))
                     return false;
-                Set s = (Set) o;
+                Set<?> s = (Set<?>) o;
                 if (s.size() != c.size())
                     return false;
                 return containsAll(s); // Invokes safe containsAll() above
@@ -1493,7 +1511,7 @@
                         return true;
                     if (!(o instanceof Map.Entry))
                         return false;
-                    Map.Entry t = (Map.Entry)o;
+                    Map.Entry<?,?> t = (Map.Entry<?,?>)o;
                     return eq(e.getKey(),   t.getKey()) &&
                            eq(e.getValue(), t.getValue());
                 }
--- a/jdk/src/share/classes/java/util/ComparableTimSort.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/ComparableTimSort.java	Wed Jul 05 18:09:02 2017 +0200
@@ -114,7 +114,6 @@
 
         // Allocate temp storage (which may be increased later if necessary)
         int len = a.length;
-        @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
         Object[] newArray = new Object[len < 2 * INITIAL_TMP_STORAGE_LENGTH ?
                                        len >>> 1 : INITIAL_TMP_STORAGE_LENGTH];
         tmp = newArray;
@@ -209,14 +208,13 @@
      * @param start the index of the first element in the range that is
      *        not already known to be sorted ({@code lo <= start <= hi})
      */
-    @SuppressWarnings("fallthrough")
+    @SuppressWarnings({ "fallthrough", "rawtypes", "unchecked" })
     private static void binarySort(Object[] a, int lo, int hi, int start) {
         assert lo <= start && start <= hi;
         if (start == lo)
             start++;
         for ( ; start < hi; start++) {
-            @SuppressWarnings("unchecked")
-            Comparable<Object> pivot = (Comparable) a[start];
+            Comparable pivot = (Comparable) a[start];
 
             // Set left (and right) to the index where a[start] (pivot) belongs
             int left = lo;
@@ -279,7 +277,7 @@
      * @return  the length of the run beginning at the specified position in
      *          the specified array
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     private static int countRunAndMakeAscending(Object[] a, int lo, int hi) {
         assert lo < hi;
         int runHi = lo + 1;
@@ -614,7 +612,7 @@
      *        (must be aBase + aLen)
      * @param len2  length of second run to be merged (must be > 0)
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     private void mergeLo(int base1, int len1, int base2, int len2) {
         assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
 
@@ -731,7 +729,7 @@
      *        (must be aBase + aLen)
      * @param len2  length of second run to be merged (must be > 0)
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     private void mergeHi(int base1, int len1, int base2, int len2) {
         assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
 
@@ -865,7 +863,6 @@
             else
                 newSize = Math.min(newSize, a.length >>> 1);
 
-            @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
             Object[] newArray = new Object[newSize];
             tmp = newArray;
         }
--- a/jdk/src/share/classes/java/util/Currency.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/Currency.java	Wed Jul 05 18:09:02 2017 +0200
@@ -404,7 +404,7 @@
     public static Set<Currency> getAvailableCurrencies() {
         synchronized(Currency.class) {
             if (available == null) {
-                available = new HashSet<Currency>(256);
+                available = new HashSet<>(256);
 
                 // Add simple currencies first
                 for (char c1 = 'A'; c1 <= 'Z'; c1 ++) {
--- a/jdk/src/share/classes/java/util/EnumMap.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/EnumMap.java	Wed Jul 05 18:09:02 2017 +0200
@@ -120,11 +120,12 @@
         return (value == null ? NULL : value);
     }
 
+    @SuppressWarnings("unchecked")
     private V unmaskNull(Object value) {
-        return (V) (value == NULL ? null : value);
+        return (V)(value == NULL ? null : value);
     }
 
-    private static final Enum[] ZERO_LENGTH_ENUM_ARRAY = new Enum[0];
+    private static final Enum<?>[] ZERO_LENGTH_ENUM_ARRAY = new Enum<?>[0];
 
     /**
      * Creates an empty enum map with the specified key type.
@@ -218,12 +219,12 @@
      *            key
      */
     public boolean containsKey(Object key) {
-        return isValidKey(key) && vals[((Enum)key).ordinal()] != null;
+        return isValidKey(key) && vals[((Enum<?>)key).ordinal()] != null;
     }
 
     private boolean containsMapping(Object key, Object value) {
         return isValidKey(key) &&
-            maskNull(value).equals(vals[((Enum)key).ordinal()]);
+            maskNull(value).equals(vals[((Enum<?>)key).ordinal()]);
     }
 
     /**
@@ -243,7 +244,7 @@
      */
     public V get(Object key) {
         return (isValidKey(key) ?
-                unmaskNull(vals[((Enum)key).ordinal()]) : null);
+                unmaskNull(vals[((Enum<?>)key).ordinal()]) : null);
     }
 
     // Modification Operations
@@ -285,7 +286,7 @@
     public V remove(Object key) {
         if (!isValidKey(key))
             return null;
-        int index = ((Enum)key).ordinal();
+        int index = ((Enum<?>)key).ordinal();
         Object oldValue = vals[index];
         vals[index] = null;
         if (oldValue != null)
@@ -296,7 +297,7 @@
     private boolean removeMapping(Object key, Object value) {
         if (!isValidKey(key))
             return false;
-        int index = ((Enum)key).ordinal();
+        int index = ((Enum<?>)key).ordinal();
         if (maskNull(value).equals(vals[index])) {
             vals[index] = null;
             size--;
@@ -314,7 +315,7 @@
             return false;
 
         // Cheaper than instanceof Enum followed by getDeclaringClass
-        Class keyClass = key.getClass();
+        Class<?> keyClass = key.getClass();
         return keyClass == keyType || keyClass.getSuperclass() == keyType;
     }
 
@@ -331,8 +332,7 @@
      */
     public void putAll(Map<? extends K, ? extends V> m) {
         if (m instanceof EnumMap) {
-            EnumMap<? extends K, ? extends V> em =
-                (EnumMap<? extends K, ? extends V>)m;
+            EnumMap<?, ?> em = (EnumMap<?, ?>)m;
             if (em.keyType != keyType) {
                 if (em.isEmpty())
                     return;
@@ -476,13 +476,13 @@
         public boolean contains(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry entry = (Map.Entry)o;
+            Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
             return containsMapping(entry.getKey(), entry.getValue());
         }
         public boolean remove(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry entry = (Map.Entry)o;
+            Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
             return removeMapping(entry.getKey(), entry.getValue());
         }
         public int size() {
@@ -610,7 +610,7 @@
                 if (!(o instanceof Map.Entry))
                     return false;
 
-                Map.Entry e = (Map.Entry)o;
+                Map.Entry<?,?> e = (Map.Entry<?,?>)o;
                 V ourValue = unmaskNull(vals[index]);
                 Object hisValue = e.getValue();
                 return (e.getKey() == keyUniverse[index] &&
@@ -655,11 +655,11 @@
         if (this == o)
             return true;
         if (o instanceof EnumMap)
-            return equals((EnumMap)o);
+            return equals((EnumMap<?,?>)o);
         if (!(o instanceof Map))
             return false;
 
-        Map<K,V> m = (Map<K,V>)o;
+        Map<?,?> m = (Map<?,?>)o;
         if (size != m.size())
             return false;
 
@@ -680,7 +680,7 @@
         return true;
     }
 
-    private boolean equals(EnumMap em) {
+    private boolean equals(EnumMap<?,?> em) {
         if (em.keyType != keyType)
             return size == 0 && em.size == 0;
 
@@ -721,6 +721,7 @@
      *
      * @return a shallow copy of this enum map
      */
+    @SuppressWarnings("unchecked")
     public EnumMap<K, V> clone() {
         EnumMap<K, V> result = null;
         try {
@@ -736,7 +737,7 @@
      * Throws an exception if e is not of the correct type for this enum set.
      */
     private void typeCheck(K key) {
-        Class keyClass = key.getClass();
+        Class<?> keyClass = key.getClass();
         if (keyClass != keyType && keyClass.getSuperclass() != keyType)
             throw new ClassCastException(keyClass + " != " + keyType);
     }
@@ -785,6 +786,7 @@
      * Reconstitute the <tt>EnumMap</tt> instance from a stream (i.e.,
      * deserialize it).
      */
+    @SuppressWarnings("unchecked")
     private void readObject(java.io.ObjectInputStream s)
         throws java.io.IOException, ClassNotFoundException
     {
--- a/jdk/src/share/classes/java/util/EnumSet.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/EnumSet.java	Wed Jul 05 18:09:02 2017 +0200
@@ -88,11 +88,11 @@
     /**
      * All of the values comprising T.  (Cached for performance.)
      */
-    final Enum[] universe;
+    final Enum<?>[] universe;
 
-    private static Enum[] ZERO_LENGTH_ENUM_ARRAY = new Enum[0];
+    private static Enum<?>[] ZERO_LENGTH_ENUM_ARRAY = new Enum<?>[0];
 
-    EnumSet(Class<E>elementType, Enum[] universe) {
+    EnumSet(Class<E>elementType, Enum<?>[] universe) {
         this.elementType = elementType;
         this.universe    = universe;
     }
@@ -105,7 +105,7 @@
      * @throws NullPointerException if <tt>elementType</tt> is null
      */
     public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType) {
-        Enum[] universe = getUniverse(elementType);
+        Enum<?>[] universe = getUniverse(elementType);
         if (universe == null)
             throw new ClassCastException(elementType + " not an enum");
 
@@ -358,6 +358,7 @@
      *
      * @return a copy of this set
      */
+    @SuppressWarnings("unchecked")
     public EnumSet<E> clone() {
         try {
             return (EnumSet<E>) super.clone();
@@ -375,7 +376,7 @@
      * Throws an exception if e is not of the correct type for this enum set.
      */
     final void typeCheck(E e) {
-        Class eClass = e.getClass();
+        Class<?> eClass = e.getClass();
         if (eClass != elementType && eClass.getSuperclass() != elementType)
             throw new ClassCastException(eClass + " != " + elementType);
     }
@@ -413,16 +414,19 @@
          *
          * @serial
          */
-        private final Enum[] elements;
+        private final Enum<?>[] elements;
 
         SerializationProxy(EnumSet<E> set) {
             elementType = set.elementType;
             elements = set.toArray(ZERO_LENGTH_ENUM_ARRAY);
         }
 
+        // instead of cast to E, we should perhaps use elementType.cast()
+        // to avoid injection of forged stream, but it will slow the implementation
+        @SuppressWarnings("unchecked")
         private Object readResolve() {
             EnumSet<E> result = EnumSet.noneOf(elementType);
-            for (Enum e : elements)
+            for (Enum<?> e : elements)
                 result.add((E)e);
             return result;
         }
--- a/jdk/src/share/classes/java/util/HashMap.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/HashMap.java	Wed Jul 05 18:09:02 2017 +0200
@@ -146,7 +146,7 @@
     /**
      * The table, resized as necessary. Length MUST Always be a power of two.
      */
-    transient Entry[] table;
+    transient Entry<?,?>[] table;
 
     /**
      * The number of key-value mappings contained in this map.
@@ -311,16 +311,17 @@
      *
      * @see #put(Object, Object)
      */
+    @SuppressWarnings("unchecked")
     public V get(Object key) {
         if (key == null)
-            return getForNullKey();
+            return (V)getForNullKey();
         int hash = hash(key.hashCode());
-        for (Entry<K,V> e = table[indexFor(hash, table.length)];
+        for (Entry<?,?> e = table[indexFor(hash, table.length)];
              e != null;
              e = e.next) {
             Object k;
             if (e.hash == hash && ((k = e.key) == key || key.equals(k)))
-                return e.value;
+                return (V)e.value;
         }
         return null;
     }
@@ -332,8 +333,8 @@
      * operations (get and put), but incorporated with conditionals in
      * others.
      */
-    private V getForNullKey() {
-        for (Entry<K,V> e = table[0]; e != null; e = e.next) {
+    private Object getForNullKey() {
+        for (Entry<?,?> e = table[0]; e != null; e = e.next) {
             if (e.key == null)
                 return e.value;
         }
@@ -357,15 +358,16 @@
      * HashMap.  Returns null if the HashMap contains no mapping
      * for the key.
      */
+    @SuppressWarnings("unchecked")
     final Entry<K,V> getEntry(Object key) {
         int hash = (key == null) ? 0 : hash(key.hashCode());
-        for (Entry<K,V> e = table[indexFor(hash, table.length)];
+        for (Entry<?,?> e = table[indexFor(hash, table.length)];
              e != null;
              e = e.next) {
             Object k;
             if (e.hash == hash &&
                 ((k = e.key) == key || (key != null && key.equals(k))))
-                return e;
+                return (Entry<K,V>)e;
         }
         return null;
     }
@@ -388,7 +390,9 @@
             return putForNullKey(value);
         int hash = hash(key.hashCode());
         int i = indexFor(hash, table.length);
-        for (Entry<K,V> e = table[i]; e != null; e = e.next) {
+        @SuppressWarnings("unchecked")
+        Entry<K,V> e = (Entry<K,V>)table[i];
+        for(; e != null; e = e.next) {
             Object k;
             if (e.hash == hash && ((k = e.key) == key || key.equals(k))) {
                 V oldValue = e.value;
@@ -407,7 +411,9 @@
      * Offloaded version of put for null keys
      */
     private V putForNullKey(V value) {
-        for (Entry<K,V> e = table[0]; e != null; e = e.next) {
+        @SuppressWarnings("unchecked")
+        Entry<K,V> e = (Entry<K,V>)table[0];
+        for(; e != null; e = e.next) {
             if (e.key == null) {
                 V oldValue = e.value;
                 e.value = value;
@@ -435,7 +441,8 @@
          * clone or deserialize.  It will only happen for construction if the
          * input Map is a sorted map whose ordering is inconsistent w/ equals.
          */
-        for (Entry<K,V> e = table[i]; e != null; e = e.next) {
+        for (@SuppressWarnings("unchecked")
+             Entry<?,V> e = (Entry<?,V>)table[i]; e != null; e = e.next) {
             Object k;
             if (e.hash == hash &&
                 ((k = e.key) == key || (key != null && key.equals(k)))) {
@@ -467,14 +474,14 @@
      *        is irrelevant).
      */
     void resize(int newCapacity) {
-        Entry[] oldTable = table;
+        Entry<?,?>[] oldTable = table;
         int oldCapacity = oldTable.length;
         if (oldCapacity == MAXIMUM_CAPACITY) {
             threshold = Integer.MAX_VALUE;
             return;
         }
 
-        Entry[] newTable = new Entry[newCapacity];
+        Entry<?,?>[] newTable = new Entry<?,?>[newCapacity];
         transfer(newTable);
         table = newTable;
         threshold = (int)(newCapacity * loadFactor);
@@ -483,17 +490,18 @@
     /**
      * Transfers all entries from current table to newTable.
      */
-    void transfer(Entry[] newTable) {
-        Entry[] src = table;
+    @SuppressWarnings("unchecked")
+    void transfer(Entry<?,?>[] newTable) {
+        Entry<?,?>[] src = table;
         int newCapacity = newTable.length;
         for (int j = 0; j < src.length; j++) {
-            Entry<K,V> e = src[j];
+            Entry<K,V> e = (Entry<K,V>)src[j];
             if (e != null) {
                 src[j] = null;
                 do {
                     Entry<K,V> next = e.next;
                     int i = indexFor(e.hash, newCapacity);
-                    e.next = newTable[i];
+                    e.next = (Entry<K,V>)newTable[i];
                     newTable[i] = e;
                     e = next;
                 } while (e != null);
@@ -560,7 +568,8 @@
     final Entry<K,V> removeEntryForKey(Object key) {
         int hash = (key == null) ? 0 : hash(key.hashCode());
         int i = indexFor(hash, table.length);
-        Entry<K,V> prev = table[i];
+        @SuppressWarnings("unchecked")
+            Entry<K,V> prev = (Entry<K,V>)table[i];
         Entry<K,V> e = prev;
 
         while (e != null) {
@@ -591,11 +600,12 @@
         if (!(o instanceof Map.Entry))
             return null;
 
-        Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
+        Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
         Object key = entry.getKey();
         int hash = (key == null) ? 0 : hash(key.hashCode());
         int i = indexFor(hash, table.length);
-        Entry<K,V> prev = table[i];
+        @SuppressWarnings("unchecked")
+            Entry<K,V> prev = (Entry<K,V>)table[i];
         Entry<K,V> e = prev;
 
         while (e != null) {
@@ -623,7 +633,7 @@
      */
     public void clear() {
         modCount++;
-        Entry[] tab = table;
+        Entry<?,?>[] tab = table;
         for (int i = 0; i < tab.length; i++)
             tab[i] = null;
         size = 0;
@@ -641,9 +651,9 @@
         if (value == null)
             return containsNullValue();
 
-        Entry[] tab = table;
+        Entry<?,?>[] tab = table;
         for (int i = 0; i < tab.length ; i++)
-            for (Entry e = tab[i] ; e != null ; e = e.next)
+            for (Entry<?,?> e = tab[i] ; e != null ; e = e.next)
                 if (value.equals(e.value))
                     return true;
         return false;
@@ -653,9 +663,9 @@
      * Special-case code for containsValue with null argument
      */
     private boolean containsNullValue() {
-        Entry[] tab = table;
+        Entry<?,?>[] tab = table;
         for (int i = 0; i < tab.length ; i++)
-            for (Entry e = tab[i] ; e != null ; e = e.next)
+            for (Entry<?,?> e = tab[i] ; e != null ; e = e.next)
                 if (e.value == null)
                     return true;
         return false;
@@ -667,6 +677,7 @@
      *
      * @return a shallow copy of this map
      */
+    @SuppressWarnings("unchecked")
     public Object clone() {
         HashMap<K,V> result = null;
         try {
@@ -674,7 +685,7 @@
         } catch (CloneNotSupportedException e) {
             // assert false;
         }
-        result.table = new Entry[table.length];
+        result.table = new Entry<?,?>[table.length];
         result.entrySet = null;
         result.modCount = 0;
         result.size = 0;
@@ -717,7 +728,7 @@
         public final boolean equals(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry e = (Map.Entry)o;
+            Map.Entry<?,?> e = (Map.Entry<?,?>)o;
             Object k1 = getKey();
             Object k2 = e.getKey();
             if (k1 == k2 || (k1 != null && k1.equals(k2))) {
@@ -762,7 +773,8 @@
      * Subclass overrides this to alter the behavior of put method.
      */
     void addEntry(int hash, K key, V value, int bucketIndex) {
-        Entry<K,V> e = table[bucketIndex];
+        @SuppressWarnings("unchecked")
+            Entry<K,V> e = (Entry<K,V>)table[bucketIndex];
         table[bucketIndex] = new Entry<>(hash, key, value, e);
         if (size++ >= threshold)
             resize(2 * table.length);
@@ -777,21 +789,22 @@
      * clone, and readObject.
      */
     void createEntry(int hash, K key, V value, int bucketIndex) {
-        Entry<K,V> e = table[bucketIndex];
+        @SuppressWarnings("unchecked")
+            Entry<K,V> e = (Entry<K,V>)table[bucketIndex];
         table[bucketIndex] = new Entry<>(hash, key, value, e);
         size++;
     }
 
     private abstract class HashIterator<E> implements Iterator<E> {
-        Entry<K,V> next;        // next entry to return
+        Entry<?,?> next;        // next entry to return
         int expectedModCount;   // For fast-fail
         int index;              // current slot
-        Entry<K,V> current;     // current entry
+        Entry<?,?> current;     // current entry
 
         HashIterator() {
             expectedModCount = modCount;
             if (size > 0) { // advance to first entry
-                Entry[] t = table;
+                Entry<?,?>[] t = table;
                 while (index < t.length && (next = t[index++]) == null)
                     ;
             }
@@ -801,20 +814,21 @@
             return next != null;
         }
 
+        @SuppressWarnings("unchecked")
         final Entry<K,V> nextEntry() {
             if (modCount != expectedModCount)
                 throw new ConcurrentModificationException();
-            Entry<K,V> e = next;
+            Entry<?,?> e = next;
             if (e == null)
                 throw new NoSuchElementException();
 
             if ((next = e.next) == null) {
-                Entry[] t = table;
+                Entry<?,?>[] t = table;
                 while (index < t.length && (next = t[index++]) == null)
                     ;
             }
             current = e;
-            return e;
+            return (Entry<K,V>)e;
         }
 
         public void remove() {
@@ -965,7 +979,7 @@
         public boolean contains(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry<K,V> e = (Map.Entry<K,V>) o;
+            Map.Entry<?,?> e = (Map.Entry<?,?>) o;
             Entry<K,V> candidate = getEntry(e.getKey());
             return candidate != null && candidate.equals(e);
         }
@@ -1039,8 +1053,10 @@
 
         // Read the keys and values, and put the mappings in the HashMap
         for (int i=0; i<size; i++) {
-            K key = (K) s.readObject();
-            V value = (V) s.readObject();
+            @SuppressWarnings("unchecked")
+                K key = (K) s.readObject();
+            @SuppressWarnings("unchecked")
+                V value = (V) s.readObject();
             putForCreate(key, value);
         }
     }
--- a/jdk/src/share/classes/java/util/HashSet.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/HashSet.java	Wed Jul 05 18:09:02 2017 +0200
@@ -247,6 +247,7 @@
      *
      * @return a shallow copy of this set
      */
+    @SuppressWarnings("unchecked")
     public Object clone() {
         try {
             HashSet<E> newSet = (HashSet<E>) super.clone();
@@ -296,7 +297,7 @@
         // Read in HashMap capacity and load factor and create backing HashMap
         int capacity = s.readInt();
         float loadFactor = s.readFloat();
-        map = (((HashSet)this) instanceof LinkedHashSet ?
+        map = (((HashSet<?>)this) instanceof LinkedHashSet ?
                new LinkedHashMap<E,Object>(capacity, loadFactor) :
                new HashMap<E,Object>(capacity, loadFactor));
 
@@ -305,7 +306,8 @@
 
         // Read in all elements in the proper order.
         for (int i=0; i<size; i++) {
-            E e = (E) s.readObject();
+            @SuppressWarnings("unchecked")
+                E e = (E) s.readObject();
             map.put(e, PRESENT);
         }
     }
--- a/jdk/src/share/classes/java/util/Hashtable.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/Hashtable.java	Wed Jul 05 18:09:02 2017 +0200
@@ -129,7 +129,7 @@
     /**
      * The hash table data.
      */
-    private transient Entry[] table;
+    private transient Entry<?,?>[] table;
 
     /**
      * The total number of entries in the hash table.
@@ -182,7 +182,7 @@
         if (initialCapacity==0)
             initialCapacity = 1;
         this.loadFactor = loadFactor;
-        table = new Entry[initialCapacity];
+        table = new Entry<?,?>[initialCapacity];
         threshold = (int)(initialCapacity * loadFactor);
     }
 
@@ -288,9 +288,9 @@
             throw new NullPointerException();
         }
 
-        Entry tab[] = table;
+        Entry<?,?> tab[] = table;
         for (int i = tab.length ; i-- > 0 ;) {
-            for (Entry<K,V> e = tab[i] ; e != null ; e = e.next) {
+            for (Entry<?,?> e = tab[i] ; e != null ; e = e.next) {
                 if (e.value.equals(value)) {
                     return true;
                 }
@@ -326,10 +326,10 @@
      * @see     #contains(Object)
      */
     public synchronized boolean containsKey(Object key) {
-        Entry tab[] = table;
+        Entry<?,?> tab[] = table;
         int hash = key.hashCode();
         int index = (hash & 0x7FFFFFFF) % tab.length;
-        for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
+        for (Entry<?,?> e = tab[index] ; e != null ; e = e.next) {
             if ((e.hash == hash) && e.key.equals(key)) {
                 return true;
             }
@@ -352,13 +352,14 @@
      * @throws NullPointerException if the specified key is null
      * @see     #put(Object, Object)
      */
+    @SuppressWarnings("unchecked")
     public synchronized V get(Object key) {
-        Entry tab[] = table;
+        Entry<?,?> tab[] = table;
         int hash = key.hashCode();
         int index = (hash & 0x7FFFFFFF) % tab.length;
-        for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
+        for (Entry<?,?> e = tab[index] ; e != null ; e = e.next) {
             if ((e.hash == hash) && e.key.equals(key)) {
-                return e.value;
+                return (V)e.value;
             }
         }
         return null;
@@ -379,9 +380,10 @@
      * number of keys in the hashtable exceeds this hashtable's capacity
      * and load factor.
      */
+    @SuppressWarnings("unchecked")
     protected void rehash() {
         int oldCapacity = table.length;
-        Entry[] oldMap = table;
+        Entry<?,?>[] oldMap = table;
 
         // overflow-conscious code
         int newCapacity = (oldCapacity << 1) + 1;
@@ -391,19 +393,19 @@
                 return;
             newCapacity = MAX_ARRAY_SIZE;
         }
-        Entry[] newMap = new Entry[newCapacity];
+        Entry<?,?>[] newMap = new Entry<?,?>[newCapacity];
 
         modCount++;
         threshold = (int)(newCapacity * loadFactor);
         table = newMap;
 
         for (int i = oldCapacity ; i-- > 0 ;) {
-            for (Entry<K,V> old = oldMap[i] ; old != null ; ) {
+            for (Entry<K,V> old = (Entry<K,V>)oldMap[i] ; old != null ; ) {
                 Entry<K,V> e = old;
                 old = old.next;
 
                 int index = (e.hash & 0x7FFFFFFF) % newCapacity;
-                e.next = newMap[index];
+                e.next = (Entry<K,V>)newMap[index];
                 newMap[index] = e;
             }
         }
@@ -433,13 +435,15 @@
         }
 
         // Makes sure the key is not already in the hashtable.
-        Entry tab[] = table;
+        Entry<?,?> tab[] = table;
         int hash = key.hashCode();
         int index = (hash & 0x7FFFFFFF) % tab.length;
-        for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
-            if ((e.hash == hash) && e.key.equals(key)) {
-                V old = e.value;
-                e.value = value;
+        @SuppressWarnings("unchecked")
+        Entry<K,V> entry = (Entry<K,V>)tab[index];
+        for(; entry != null ; entry = entry.next) {
+            if ((entry.hash == hash) && entry.key.equals(key)) {
+                V old = entry.value;
+                entry.value = value;
                 return old;
             }
         }
@@ -454,7 +458,8 @@
         }
 
         // Creates the new entry.
-        Entry<K,V> e = tab[index];
+        @SuppressWarnings("unchecked")
+        Entry<K,V> e = (Entry<K,V>)tab[index];
         tab[index] = new Entry<>(hash, key, value, e);
         count++;
         return null;
@@ -470,10 +475,12 @@
      * @throws  NullPointerException  if the key is <code>null</code>
      */
     public synchronized V remove(Object key) {
-        Entry tab[] = table;
+        Entry<?,?> tab[] = table;
         int hash = key.hashCode();
         int index = (hash & 0x7FFFFFFF) % tab.length;
-        for (Entry<K,V> e = tab[index], prev = null ; e != null ; prev = e, e = e.next) {
+        @SuppressWarnings("unchecked")
+        Entry<K,V> e = (Entry<K,V>)tab[index];
+        for(Entry<K,V> prev = null ; e != null ; prev = e, e = e.next) {
             if ((e.hash == hash) && e.key.equals(key)) {
                 modCount++;
                 if (prev != null) {
@@ -508,7 +515,7 @@
      * Clears this hashtable so that it contains no keys.
      */
     public synchronized void clear() {
-        Entry tab[] = table;
+        Entry<?,?> tab[] = table;
         modCount++;
         for (int index = tab.length; --index >= 0; )
             tab[index] = null;
@@ -524,11 +531,11 @@
      */
     public synchronized Object clone() {
         try {
-            Hashtable<K,V> t = (Hashtable<K,V>) super.clone();
-            t.table = new Entry[table.length];
+            Hashtable<?,?> t = (Hashtable<?,?>)super.clone();
+            t.table = new Entry<?,?>[table.length];
             for (int i = table.length ; i-- > 0 ; ) {
                 t.table[i] = (table[i] != null)
-                    ? (Entry<K,V>) table[i].clone() : null;
+                    ? (Entry<?,?>) table[i].clone() : null;
             }
             t.keySet = null;
             t.entrySet = null;
@@ -675,13 +682,13 @@
         public boolean contains(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry entry = (Map.Entry)o;
+            Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
             Object key = entry.getKey();
-            Entry[] tab = table;
+            Entry<?,?>[] tab = table;
             int hash = key.hashCode();
             int index = (hash & 0x7FFFFFFF) % tab.length;
 
-            for (Entry e = tab[index]; e != null; e = e.next)
+            for (Entry<?,?> e = tab[index]; e != null; e = e.next)
                 if (e.hash==hash && e.equals(entry))
                     return true;
             return false;
@@ -690,14 +697,15 @@
         public boolean remove(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
-            K key = entry.getKey();
-            Entry[] tab = table;
+            Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
+            Object key = entry.getKey();
+            Entry<?,?>[] tab = table;
             int hash = key.hashCode();
             int index = (hash & 0x7FFFFFFF) % tab.length;
 
-            for (Entry<K,V> e = tab[index], prev = null; e != null;
-                 prev = e, e = e.next) {
+            @SuppressWarnings("unchecked")
+            Entry<K,V> e = (Entry<K,V>)tab[index];
+            for(Entry<K,V> prev = null; e != null; prev = e, e = e.next) {
                 if (e.hash==hash && e.equals(entry)) {
                     modCount++;
                     if (prev != null)
@@ -776,7 +784,7 @@
 
         if (!(o instanceof Map))
             return false;
-        Map<K,V> t = (Map<K,V>) o;
+        Map<?,?> t = (Map<?,?>) o;
         if (t.size() != size())
             return false;
 
@@ -826,9 +834,9 @@
             return h;  // Returns zero
 
         loadFactor = -loadFactor;  // Mark hashCode computation in progress
-        Entry[] tab = table;
+        Entry<?,?>[] tab = table;
         for (int i = 0; i < tab.length; i++)
-            for (Entry e = tab[i]; e != null; e = e.next)
+            for (Entry<?,?> e = tab[i]; e != null; e = e.next)
                 h += e.key.hashCode() ^ e.value.hashCode();
         loadFactor = -loadFactor;  // Mark hashCode computation complete
 
@@ -859,7 +867,7 @@
 
             // Stack copies of the entries in the table
             for (int index = 0; index < table.length; index++) {
-                Entry entry = table[index];
+                Entry<?,?> entry = table[index];
 
                 while (entry != null) {
                     entryStack =
@@ -899,14 +907,15 @@
             length--;
         if (origlength > 0 && length > origlength)
             length = origlength;
-
-        Entry[] table = new Entry[length];
+        Entry<?,?>[] table = new Entry<?,?>[length];
         count = 0;
 
         // Read the number of elements and then all the key/value objects
         for (; elements > 0; elements--) {
-            K key = (K)s.readObject();
-            V value = (V)s.readObject();
+            @SuppressWarnings("unchecked")
+                K key = (K)s.readObject();
+            @SuppressWarnings("unchecked")
+                V value = (V)s.readObject();
             // synch could be eliminated for performance
             reconstitutionPut(table, key, value);
         }
@@ -924,7 +933,7 @@
      * because we are creating a new instance. Also, no return value
      * is needed.
      */
-    private void reconstitutionPut(Entry[] tab, K key, V value)
+    private void reconstitutionPut(Entry<?,?>[] tab, K key, V value)
         throws StreamCorruptedException
     {
         if (value == null) {
@@ -934,13 +943,14 @@
         // This should not happen in deserialized version.
         int hash = key.hashCode();
         int index = (hash & 0x7FFFFFFF) % tab.length;
-        for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
+        for (Entry<?,?> e = tab[index] ; e != null ; e = e.next) {
             if ((e.hash == hash) && e.key.equals(key)) {
                 throw new java.io.StreamCorruptedException();
             }
         }
         // Creates the new entry.
-        Entry<K,V> e = tab[index];
+        @SuppressWarnings("unchecked")
+            Entry<K,V> e = (Entry<K,V>)tab[index];
         tab[index] = new Entry<>(hash, key, value, e);
         count++;
     }
@@ -961,6 +971,7 @@
             this.next = next;
         }
 
+        @SuppressWarnings("unchecked")
         protected Object clone() {
             return new Entry<>(hash, key, value,
                                   (next==null ? null : (Entry<K,V>) next.clone()));
@@ -988,7 +999,7 @@
         public boolean equals(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry e = (Map.Entry)o;
+            Map.Entry<?,?> e = (Map.Entry<?,?>)o;
 
             return (key==null ? e.getKey()==null : key.equals(e.getKey())) &&
                (value==null ? e.getValue()==null : value.equals(e.getValue()));
@@ -1016,10 +1027,10 @@
      * by passing an Enumeration.
      */
     private class Enumerator<T> implements Enumeration<T>, Iterator<T> {
-        Entry[] table = Hashtable.this.table;
+        Entry<?,?>[] table = Hashtable.this.table;
         int index = table.length;
-        Entry<K,V> entry = null;
-        Entry<K,V> lastReturned = null;
+        Entry<?,?> entry = null;
+        Entry<?,?> lastReturned = null;
         int type;
 
         /**
@@ -1041,9 +1052,9 @@
         }
 
         public boolean hasMoreElements() {
-            Entry<K,V> e = entry;
+            Entry<?,?> e = entry;
             int i = index;
-            Entry[] t = table;
+            Entry<?,?>[] t = table;
             /* Use locals for faster loop iteration */
             while (e == null && i > 0) {
                 e = t[--i];
@@ -1053,10 +1064,11 @@
             return e != null;
         }
 
+        @SuppressWarnings("unchecked")
         public T nextElement() {
-            Entry<K,V> et = entry;
+            Entry<?,?> et = entry;
             int i = index;
-            Entry[] t = table;
+            Entry<?,?>[] t = table;
             /* Use locals for faster loop iteration */
             while (et == null && i > 0) {
                 et = t[--i];
@@ -1064,7 +1076,7 @@
             entry = et;
             index = i;
             if (et != null) {
-                Entry<K,V> e = lastReturned = entry;
+                Entry<?,?> e = lastReturned = entry;
                 entry = e.next;
                 return type == KEYS ? (T)e.key : (type == VALUES ? (T)e.value : (T)e);
             }
@@ -1091,11 +1103,12 @@
                 throw new ConcurrentModificationException();
 
             synchronized(Hashtable.this) {
-                Entry[] tab = Hashtable.this.table;
+                Entry<?,?>[] tab = Hashtable.this.table;
                 int index = (lastReturned.hash & 0x7FFFFFFF) % tab.length;
 
-                for (Entry<K,V> e = tab[index], prev = null; e != null;
-                     prev = e, e = e.next) {
+                @SuppressWarnings("unchecked")
+                Entry<K,V> e = (Entry<K,V>)tab[index];
+                for(Entry<K,V> prev = null; e != null; prev = e, e = e.next) {
                     if (e == lastReturned) {
                         modCount++;
                         expectedModCount++;
--- a/jdk/src/share/classes/java/util/IdentityHashMap.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/IdentityHashMap.java	Wed Jul 05 18:09:02 2017 +0200
@@ -327,6 +327,7 @@
      *
      * @see #put(Object, Object)
      */
+    @SuppressWarnings("unchecked")
     public V get(Object key) {
         Object k = maskNull(key);
         Object[] tab = table;
@@ -431,7 +432,8 @@
         Object item;
         while ( (item = tab[i]) != null) {
             if (item == k) {
-                V oldValue = (V) tab[i + 1];
+                @SuppressWarnings("unchecked")
+                    V oldValue = (V) tab[i + 1];
                 tab[i + 1] = value;
                 return oldValue;
             }
@@ -524,7 +526,8 @@
             if (item == k) {
                 modCount++;
                 size--;
-                V oldValue = (V) tab[i + 1];
+                @SuppressWarnings("unchecked")
+                    V oldValue = (V) tab[i + 1];
                 tab[i + 1] = null;
                 tab[i] = null;
                 closeDeletion(i);
@@ -638,7 +641,7 @@
         if (o == this) {
             return true;
         } else if (o instanceof IdentityHashMap) {
-            IdentityHashMap m = (IdentityHashMap) o;
+            IdentityHashMap<?,?> m = (IdentityHashMap<?,?>) o;
             if (m.size() != size)
                 return false;
 
@@ -650,7 +653,7 @@
             }
             return true;
         } else if (o instanceof Map) {
-            Map m = (Map)o;
+            Map<?,?> m = (Map<?,?>)o;
             return entrySet().equals(m.entrySet());
         } else {
             return false;  // o is not a Map
@@ -698,7 +701,7 @@
      */
     public Object clone() {
         try {
-            IdentityHashMap<K,V> m = (IdentityHashMap<K,V>) super.clone();
+            IdentityHashMap<?,?> m = (IdentityHashMap<?,?>) super.clone();
             m.entrySet = null;
             m.table = table.clone();
             return m;
@@ -768,7 +771,7 @@
             int len = tab.length;
 
             int d = deletedSlot;
-            K key = (K) tab[d];
+            Object key = tab[d];
             tab[d] = null;        // vacate the slot
             tab[d + 1] = null;
 
@@ -818,12 +821,14 @@
     }
 
     private class KeyIterator extends IdentityHashMapIterator<K> {
+        @SuppressWarnings("unchecked")
         public K next() {
             return (K) unmaskNull(traversalTable[nextIndex()]);
         }
     }
 
     private class ValueIterator extends IdentityHashMapIterator<V> {
+        @SuppressWarnings("unchecked")
         public V next() {
             return (V) traversalTable[nextIndex() + 1];
         }
@@ -854,16 +859,19 @@
                 this.index = index;
             }
 
+            @SuppressWarnings("unchecked")
             public K getKey() {
                 checkIndexForEntryUse();
                 return (K) unmaskNull(traversalTable[index]);
             }
 
+            @SuppressWarnings("unchecked")
             public V getValue() {
                 checkIndexForEntryUse();
                 return (V) traversalTable[index+1];
             }
 
+            @SuppressWarnings("unchecked")
             public V setValue(V value) {
                 checkIndexForEntryUse();
                 V oldValue = (V) traversalTable[index+1];
@@ -880,7 +888,7 @@
 
                 if (!(o instanceof Map.Entry))
                     return false;
-                Map.Entry e = (Map.Entry)o;
+                Map.Entry<?,?> e = (Map.Entry<?,?>)o;
                 return (e.getKey() == unmaskNull(traversalTable[index]) &&
                        e.getValue() == traversalTable[index+1]);
             }
@@ -1109,13 +1117,13 @@
         public boolean contains(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry entry = (Map.Entry)o;
+            Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
             return containsMapping(entry.getKey(), entry.getValue());
         }
         public boolean remove(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry entry = (Map.Entry)o;
+            Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
             return removeMapping(entry.getKey(), entry.getValue());
         }
         public int size() {
@@ -1213,8 +1221,10 @@
 
         // Read the keys and values, and put the mappings in the table
         for (int i=0; i<size; i++) {
-            K key = (K) s.readObject();
-            V value = (V) s.readObject();
+            @SuppressWarnings("unchecked")
+                K key = (K) s.readObject();
+            @SuppressWarnings("unchecked")
+                V value = (V) s.readObject();
             putForCreate(key, value);
         }
     }
@@ -1226,7 +1236,7 @@
     private void putForCreate(K key, V value)
         throws IOException
     {
-        K k = (K)maskNull(key);
+        Object k = maskNull(key);
         Object[] tab = table;
         int len = tab.length;
         int i = hash(k, len);
--- a/jdk/src/share/classes/java/util/IllegalFormatConversionException.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/IllegalFormatConversionException.java	Wed Jul 05 18:09:02 2017 +0200
@@ -40,7 +40,7 @@
     private static final long serialVersionUID = 17000126L;
 
     private char c;
-    private Class arg;
+    private Class<?> arg;
 
     /**
      * Constructs an instance of this class with the mismatched conversion and
--- a/jdk/src/share/classes/java/util/JumboEnumSet.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/JumboEnumSet.java	Wed Jul 05 18:09:02 2017 +0200
@@ -46,7 +46,7 @@
     // Redundant - maintained for performance
     private int size = 0;
 
-    JumboEnumSet(Class<E>elementType, Enum[] universe) {
+    JumboEnumSet(Class<E>elementType, Enum<?>[] universe) {
         super(elementType, universe);
         elements = new long[(universe.length + 63) >>> 6];
     }
@@ -127,6 +127,7 @@
             return unseen != 0;
         }
 
+        @Override
         public E next() {
             if (!hasNext())
                 throw new NoSuchElementException();
@@ -176,11 +177,11 @@
     public boolean contains(Object e) {
         if (e == null)
             return false;
-        Class eClass = e.getClass();
+        Class<?> eClass = e.getClass();
         if (eClass != elementType && eClass.getSuperclass() != elementType)
             return false;
 
-        int eOrdinal = ((Enum)e).ordinal();
+        int eOrdinal = ((Enum<?>)e).ordinal();
         return (elements[eOrdinal >>> 6] & (1L << eOrdinal)) != 0;
     }
 
@@ -217,10 +218,10 @@
     public boolean remove(Object e) {
         if (e == null)
             return false;
-        Class eClass = e.getClass();
+        Class<?> eClass = e.getClass();
         if (eClass != elementType && eClass.getSuperclass() != elementType)
             return false;
-        int eOrdinal = ((Enum)e).ordinal();
+        int eOrdinal = ((Enum<?>)e).ordinal();
         int eWordNum = eOrdinal >>> 6;
 
         long oldElements = elements[eWordNum];
@@ -246,7 +247,7 @@
         if (!(c instanceof JumboEnumSet))
             return super.containsAll(c);
 
-        JumboEnumSet es = (JumboEnumSet)c;
+        JumboEnumSet<?> es = (JumboEnumSet<?>)c;
         if (es.elementType != elementType)
             return es.isEmpty();
 
@@ -268,7 +269,7 @@
         if (!(c instanceof JumboEnumSet))
             return super.addAll(c);
 
-        JumboEnumSet es = (JumboEnumSet)c;
+        JumboEnumSet<?> es = (JumboEnumSet<?>)c;
         if (es.elementType != elementType) {
             if (es.isEmpty())
                 return false;
@@ -294,7 +295,7 @@
         if (!(c instanceof JumboEnumSet))
             return super.removeAll(c);
 
-        JumboEnumSet es = (JumboEnumSet)c;
+        JumboEnumSet<?> es = (JumboEnumSet<?>)c;
         if (es.elementType != elementType)
             return false;
 
@@ -348,7 +349,7 @@
         if (!(o instanceof JumboEnumSet))
             return super.equals(o);
 
-        JumboEnumSet es = (JumboEnumSet)o;
+        JumboEnumSet<?> es = (JumboEnumSet<?>)o;
         if (es.elementType != elementType)
             return size == 0 && es.size == 0;
 
--- a/jdk/src/share/classes/java/util/LinkedHashMap.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/LinkedHashMap.java	Wed Jul 05 18:09:02 2017 +0200
@@ -246,11 +246,12 @@
      * by superclass resize.  It is overridden for performance, as it is
      * faster to iterate using our linked list.
      */
+    @SuppressWarnings("unchecked")
     void transfer(HashMap.Entry[] newTable) {
         int newCapacity = newTable.length;
         for (Entry<K,V> e = header.after; e != header; e = e.after) {
             int index = indexFor(e.hash, newCapacity);
-            e.next = newTable[index];
+            e.next = (HashMap.Entry<K,V>)newTable[index];
             newTable[index] = e;
         }
     }
@@ -267,11 +268,11 @@
     public boolean containsValue(Object value) {
         // Overridden to take advantage of faster iterator
         if (value==null) {
-            for (Entry e = header.after; e != header; e = e.after)
+            for (Entry<?,?> e = header.after; e != header; e = e.after)
                 if (e.value==null)
                     return true;
         } else {
-            for (Entry e = header.after; e != header; e = e.after)
+            for (Entry<?,?> e = header.after; e != header; e = e.after)
                 if (value.equals(e.value))
                     return true;
         }
@@ -437,7 +438,8 @@
      * table or remove the eldest entry.
      */
     void createEntry(int hash, K key, V value, int bucketIndex) {
-        HashMap.Entry<K,V> old = table[bucketIndex];
+        @SuppressWarnings("unchecked")
+            HashMap.Entry<K,V> old = (HashMap.Entry<K,V>)table[bucketIndex];
         Entry<K,V> e = new Entry<>(hash, key, value, old);
         table[bucketIndex] = e;
         e.addBefore(header);
--- a/jdk/src/share/classes/java/util/Observable.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/Observable.java	Wed Jul 05 18:09:02 2017 +0200
@@ -61,12 +61,12 @@
  */
 public class Observable {
     private boolean changed = false;
-    private Vector obs;
+    private Vector<Observer> obs;
 
     /** Construct an Observable with zero Observers. */
 
     public Observable() {
-        obs = new Vector();
+        obs = new Vector<>();
     }
 
     /**
--- a/jdk/src/share/classes/java/util/PriorityQueue.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/PriorityQueue.java	Wed Jul 05 18:09:02 2017 +0200
@@ -449,6 +449,7 @@
      *         this queue
      * @throws NullPointerException if the specified array is null
      */
+    @SuppressWarnings("unchecked")
     public <T> T[] toArray(T[] a) {
         if (a.length < size)
             // Make a new array of a's runtime type, but my contents:
@@ -514,6 +515,7 @@
                 (forgetMeNot != null && !forgetMeNot.isEmpty());
         }
 
+        @SuppressWarnings("unchecked")
         public E next() {
             if (expectedModCount != modCount)
                 throw new ConcurrentModificationException();
@@ -571,8 +573,10 @@
             return null;
         int s = --size;
         modCount++;
-        E result = (E) queue[0];
-        E x = (E) queue[s];
+        @SuppressWarnings("unchecked")
+            E result = (E) queue[0];
+        @SuppressWarnings("unchecked")
+            E x = (E) queue[s];
         queue[s] = null;
         if (s != 0)
             siftDown(0, x);
@@ -598,7 +602,8 @@
         if (s == i) // removed last element
             queue[i] = null;
         else {
-            E moved = (E) queue[s];
+            @SuppressWarnings("unchecked")
+                E moved = (E) queue[s];
             queue[s] = null;
             siftDown(i, moved);
             if (queue[i] == moved) {
@@ -629,6 +634,7 @@
             siftUpComparable(k, x);
     }
 
+    @SuppressWarnings("unchecked")
     private void siftUpComparable(int k, E x) {
         Comparable<? super E> key = (Comparable<? super E>) x;
         while (k > 0) {
@@ -645,8 +651,9 @@
     private void siftUpUsingComparator(int k, E x) {
         while (k > 0) {
             int parent = (k - 1) >>> 1;
-            Object e = queue[parent];
-            if (comparator.compare(x, (E) e) >= 0)
+            @SuppressWarnings("unchecked")
+                E e = (E) queue[parent];
+            if (comparator.compare(x, e) >= 0)
                 break;
             queue[k] = e;
             k = parent;
@@ -669,6 +676,7 @@
             siftDownComparable(k, x);
     }
 
+    @SuppressWarnings("unchecked")
     private void siftDownComparable(int k, E x) {
         Comparable<? super E> key = (Comparable<? super E>)x;
         int half = size >>> 1;        // loop while a non-leaf
@@ -687,6 +695,7 @@
         queue[k] = key;
     }
 
+    @SuppressWarnings("unchecked")
     private void siftDownUsingComparator(int k, E x) {
         int half = size >>> 1;
         while (k < half) {
@@ -708,6 +717,7 @@
      * Establishes the heap invariant (described above) in the entire tree,
      * assuming nothing about the order of the elements prior to the call.
      */
+    @SuppressWarnings("unchecked")
     private void heapify() {
         for (int i = (size >>> 1) - 1; i >= 0; i--)
             siftDown(i, (E) queue[i]);
--- a/jdk/src/share/classes/java/util/Properties.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/Properties.java	Wed Jul 05 18:09:02 2017 +0200
@@ -824,7 +824,7 @@
         bw.write("#" + new Date().toString());
         bw.newLine();
         synchronized (this) {
-            for (Enumeration e = keys(); e.hasMoreElements();) {
+            for (Enumeration<?> e = keys(); e.hasMoreElements();) {
                 String key = (String)e.nextElement();
                 String val = (String)get(key);
                 key = saveConvert(key, true, escUnicode);
@@ -987,7 +987,7 @@
      * @see     #stringPropertyNames
      */
     public Enumeration<?> propertyNames() {
-        Hashtable h = new Hashtable();
+        Hashtable<String,Object> h = new Hashtable<>();
         enumerate(h);
         return h.keys();
     }
@@ -1026,10 +1026,10 @@
      */
     public void list(PrintStream out) {
         out.println("-- listing properties --");
-        Hashtable h = new Hashtable();
+        Hashtable<String,Object> h = new Hashtable<>();
         enumerate(h);
-        for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
-            String key = (String)e.nextElement();
+        for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
+            String key = e.nextElement();
             String val = (String)h.get(key);
             if (val.length() > 40) {
                 val = val.substring(0, 37) + "...";
@@ -1054,10 +1054,10 @@
      */
     public void list(PrintWriter out) {
         out.println("-- listing properties --");
-        Hashtable h = new Hashtable();
+        Hashtable<String,Object> h = new Hashtable<>();
         enumerate(h);
-        for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
-            String key = (String)e.nextElement();
+        for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
+            String key = e.nextElement();
             String val = (String)h.get(key);
             if (val.length() > 40) {
                 val = val.substring(0, 37) + "...";
@@ -1072,11 +1072,11 @@
      * @throws ClassCastException if any of the property keys
      *         is not of String type.
      */
-    private synchronized void enumerate(Hashtable h) {
+    private synchronized void enumerate(Hashtable<String,Object> h) {
         if (defaults != null) {
             defaults.enumerate(h);
         }
-        for (Enumeration e = keys() ; e.hasMoreElements() ;) {
+        for (Enumeration<?> e = keys() ; e.hasMoreElements() ;) {
             String key = (String)e.nextElement();
             h.put(key, get(key));
         }
@@ -1091,7 +1091,7 @@
         if (defaults != null) {
             defaults.enumerateStringProperties(h);
         }
-        for (Enumeration e = keys() ; e.hasMoreElements() ;) {
+        for (Enumeration<?> e = keys() ; e.hasMoreElements() ;) {
             Object k = e.nextElement();
             Object v = get(k);
             if (k instanceof String && v instanceof String) {
--- a/jdk/src/share/classes/java/util/PropertyPermission.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/PropertyPermission.java	Wed Jul 05 18:09:02 2017 +0200
@@ -442,7 +442,7 @@
      * Key is property name; value is PropertyPermission.
      * Not serialized; see serialization section at end of class.
      */
-    private transient Map<String, Permission> perms;
+    private transient Map<String, PropertyPermission> perms;
 
     /**
      * Boolean saying if "*" is in the collection.
@@ -488,7 +488,7 @@
         String propName = pp.getName();
 
         synchronized (this) {
-            PropertyPermission existing = (PropertyPermission) perms.get(propName);
+            PropertyPermission existing = perms.get(propName);
 
             if (existing != null) {
                 int oldMask = existing.getMask();
@@ -499,7 +499,7 @@
                     perms.put(propName, new PropertyPermission(propName, actions));
                 }
             } else {
-                perms.put(propName, permission);
+                perms.put(propName, pp);
             }
         }
 
@@ -533,7 +533,7 @@
         // short circuit if the "*" Permission was added
         if (all_allowed) {
             synchronized (this) {
-                x = (PropertyPermission) perms.get("*");
+                x = perms.get("*");
             }
             if (x != null) {
                 effective |= x.getMask();
@@ -550,7 +550,7 @@
         //System.out.println("check "+name);
 
         synchronized (this) {
-            x = (PropertyPermission) perms.get(name);
+            x = perms.get(name);
         }
 
         if (x != null) {
@@ -570,7 +570,7 @@
             name = name.substring(0, last+1) + "*";
             //System.out.println("check "+name);
             synchronized (this) {
-                x = (PropertyPermission) perms.get(name);
+                x = perms.get(name);
             }
 
             if (x != null) {
@@ -592,11 +592,15 @@
      *
      * @return an enumeration of all the PropertyPermission objects.
      */
-
+    @SuppressWarnings("unchecked")
     public Enumeration<Permission> elements() {
         // Convert Iterator of Map values into an Enumeration
         synchronized (this) {
-            return Collections.enumeration(perms.values());
+            /**
+             * Casting to rawtype since Enumeration<PropertyPermission>
+             * cannot be directly cast to Enumeration<Permission>
+             */
+            return (Enumeration)Collections.enumeration(perms.values());
         }
     }
 
@@ -633,7 +637,8 @@
         // Don't call out.defaultWriteObject()
 
         // Copy perms into a Hashtable
-        Hashtable<String, Permission> permissions = new Hashtable<>(perms.size()*2);
+        Hashtable<String, Permission> permissions =
+            new Hashtable<>(perms.size()*2);
         synchronized (this) {
             permissions.putAll(perms);
         }
@@ -661,8 +666,8 @@
 
         // Get permissions
         @SuppressWarnings("unchecked")
-        Hashtable<String, Permission> permissions =
-            (Hashtable<String, Permission>)gfields.get("permissions", null);
+        Hashtable<String, PropertyPermission> permissions =
+            (Hashtable<String, PropertyPermission>)gfields.get("permissions", null);
         perms = new HashMap<>(permissions.size()*2);
         perms.putAll(permissions);
     }
--- a/jdk/src/share/classes/java/util/RegularEnumSet.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/RegularEnumSet.java	Wed Jul 05 18:09:02 2017 +0200
@@ -41,7 +41,7 @@
      */
     private long elements = 0L;
 
-    RegularEnumSet(Class<E>elementType, Enum[] universe) {
+    RegularEnumSet(Class<E>elementType, Enum<?>[] universe) {
         super(elementType, universe);
     }
 
@@ -96,6 +96,7 @@
             return unseen != 0;
         }
 
+        @SuppressWarnings("unchecked")
         public E next() {
             if (unseen == 0)
                 throw new NoSuchElementException();
@@ -139,11 +140,11 @@
     public boolean contains(Object e) {
         if (e == null)
             return false;
-        Class eClass = e.getClass();
+        Class<?> eClass = e.getClass();
         if (eClass != elementType && eClass.getSuperclass() != elementType)
             return false;
 
-        return (elements & (1L << ((Enum)e).ordinal())) != 0;
+        return (elements & (1L << ((Enum<?>)e).ordinal())) != 0;
     }
 
     // Modification Operations
@@ -160,7 +161,7 @@
         typeCheck(e);
 
         long oldElements = elements;
-        elements |= (1L << ((Enum)e).ordinal());
+        elements |= (1L << ((Enum<?>)e).ordinal());
         return elements != oldElements;
     }
 
@@ -173,12 +174,12 @@
     public boolean remove(Object e) {
         if (e == null)
             return false;
-        Class eClass = e.getClass();
+        Class<?> eClass = e.getClass();
         if (eClass != elementType && eClass.getSuperclass() != elementType)
             return false;
 
         long oldElements = elements;
-        elements &= ~(1L << ((Enum)e).ordinal());
+        elements &= ~(1L << ((Enum<?>)e).ordinal());
         return elements != oldElements;
     }
 
@@ -197,7 +198,7 @@
         if (!(c instanceof RegularEnumSet))
             return super.containsAll(c);
 
-        RegularEnumSet es = (RegularEnumSet)c;
+        RegularEnumSet<?> es = (RegularEnumSet<?>)c;
         if (es.elementType != elementType)
             return es.isEmpty();
 
@@ -216,7 +217,7 @@
         if (!(c instanceof RegularEnumSet))
             return super.addAll(c);
 
-        RegularEnumSet es = (RegularEnumSet)c;
+        RegularEnumSet<?> es = (RegularEnumSet<?>)c;
         if (es.elementType != elementType) {
             if (es.isEmpty())
                 return false;
@@ -242,7 +243,7 @@
         if (!(c instanceof RegularEnumSet))
             return super.removeAll(c);
 
-        RegularEnumSet es = (RegularEnumSet)c;
+        RegularEnumSet<?> es = (RegularEnumSet<?>)c;
         if (es.elementType != elementType)
             return false;
 
@@ -295,7 +296,7 @@
         if (!(o instanceof RegularEnumSet))
             return super.equals(o);
 
-        RegularEnumSet es = (RegularEnumSet)o;
+        RegularEnumSet<?> es = (RegularEnumSet<?>)o;
         if (es.elementType != elementType)
             return elements == 0 && es.elements == 0;
         return es.elements == elements;
--- a/jdk/src/share/classes/java/util/ResourceBundle.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/ResourceBundle.java	Wed Jul 05 18:09:02 2017 +0200
@@ -294,7 +294,8 @@
     /**
      * Queue for reference objects referring to class loaders or bundles.
      */
-    private static final ReferenceQueue<Object> referenceQueue = new ReferenceQueue<>();
+    private static final ReferenceQueue<Object> referenceQueue =
+        new ReferenceQueue<>();
 
     /**
      * The parent bundle of this bundle.
@@ -417,7 +418,7 @@
      * caller's caller.
      */
     private static ClassLoader getLoader() {
-        Class[] stack = getClassContext();
+        Class<?>[] stack = getClassContext();
         /* Magic number 2 identifies our caller's caller */
         Class<?> c = stack[2];
         ClassLoader cl = (c == null) ? null : c.getClassLoader();
@@ -434,7 +435,7 @@
         return cl;
     }
 
-    private static native Class[] getClassContext();
+    private static native Class<?>[] getClassContext();
 
     /**
      * A wrapper of ClassLoader.getSystemClassLoader().
--- a/jdk/src/share/classes/java/util/ServiceLoader.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/ServiceLoader.java	Wed Jul 05 18:09:02 2017 +0200
@@ -218,20 +218,20 @@
         reload();
     }
 
-    private static void fail(Class service, String msg, Throwable cause)
+    private static void fail(Class<?> service, String msg, Throwable cause)
         throws ServiceConfigurationError
     {
         throw new ServiceConfigurationError(service.getName() + ": " + msg,
                                             cause);
     }
 
-    private static void fail(Class service, String msg)
+    private static void fail(Class<?> service, String msg)
         throws ServiceConfigurationError
     {
         throw new ServiceConfigurationError(service.getName() + ": " + msg);
     }
 
-    private static void fail(Class service, URL u, int line, String msg)
+    private static void fail(Class<?> service, URL u, int line, String msg)
         throws ServiceConfigurationError
     {
         fail(service, u + ":" + line + ": " + msg);
@@ -240,7 +240,7 @@
     // Parse a single line from the given configuration file, adding the name
     // on the line to the names list.
     //
-    private int parseLine(Class service, URL u, BufferedReader r, int lc,
+    private int parseLine(Class<?> service, URL u, BufferedReader r, int lc,
                           List<String> names)
         throws IOException, ServiceConfigurationError
     {
@@ -286,7 +286,7 @@
     //         If an I/O error occurs while reading from the given URL, or
     //         if a configuration-file format error is detected
     //
-    private Iterator<String> parse(Class service, URL u)
+    private Iterator<String> parse(Class<?> service, URL u)
         throws ServiceConfigurationError
     {
         InputStream in = null;
--- a/jdk/src/share/classes/java/util/TimeZone.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/TimeZone.java	Wed Jul 05 18:09:02 2017 +0200
@@ -428,7 +428,7 @@
         // The structure is:
         //   Map(key=id, value=SoftReference(Map(key=locale, value=displaynames)))
         private static final Map<String, SoftReference<Map<Locale, String[]>>> CACHE =
-            new ConcurrentHashMap<String, SoftReference<Map<Locale, String[]>>>();
+            new ConcurrentHashMap<>();
     }
 
     private static final String[] getDisplayNames(String id, Locale locale) {
@@ -452,9 +452,9 @@
 
         String[] names = TimeZoneNameUtility.retrieveDisplayNames(id, locale);
         if (names != null) {
-            Map<Locale, String[]> perLocale = new ConcurrentHashMap<Locale, String[]>();
+            Map<Locale, String[]> perLocale = new ConcurrentHashMap<>();
             perLocale.put(locale, names);
-            ref = new SoftReference<Map<Locale, String[]>>(perLocale);
+            ref = new SoftReference<>(perLocale);
             displayNames.put(id, ref);
         }
         return names;
--- a/jdk/src/share/classes/java/util/TreeMap.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/TreeMap.java	Wed Jul 05 18:09:02 2017 +0200
@@ -307,7 +307,7 @@
     public void putAll(Map<? extends K, ? extends V> map) {
         int mapSize = map.size();
         if (size==0 && mapSize!=0 && map instanceof SortedMap) {
-            Comparator c = ((SortedMap)map).comparator();
+            Comparator<?> c = ((SortedMap<?,?>)map).comparator();
             if (c == comparator || (c != null && c.equals(comparator))) {
                 ++modCount;
                 try {
@@ -340,7 +340,8 @@
             return getEntryUsingComparator(key);
         if (key == null)
             throw new NullPointerException();
-        Comparable<? super K> k = (Comparable<? super K>) key;
+        @SuppressWarnings("unchecked")
+            Comparable<? super K> k = (Comparable<? super K>) key;
         Entry<K,V> p = root;
         while (p != null) {
             int cmp = k.compareTo(p.key);
@@ -361,7 +362,8 @@
      * worthwhile here.)
      */
     final Entry<K,V> getEntryUsingComparator(Object key) {
-        K k = (K) key;
+        @SuppressWarnings("unchecked")
+            K k = (K) key;
         Comparator<? super K> cpr = comparator;
         if (cpr != null) {
             Entry<K,V> p = root;
@@ -554,7 +556,8 @@
         else {
             if (key == null)
                 throw new NullPointerException();
-            Comparable<? super K> k = (Comparable<? super K>) key;
+            @SuppressWarnings("unchecked")
+                Comparable<? super K> k = (Comparable<? super K>) key;
             do {
                 parent = t;
                 cmp = k.compareTo(t.key);
@@ -618,9 +621,9 @@
      * @return a shallow copy of this map
      */
     public Object clone() {
-        TreeMap<K,V> clone = null;
+        TreeMap<?,?> clone;
         try {
-            clone = (TreeMap<K,V>) super.clone();
+            clone = (TreeMap<?,?>) super.clone();
         } catch (CloneNotSupportedException e) {
             throw new InternalError(e);
         }
@@ -803,7 +806,7 @@
      */
     public NavigableSet<K> navigableKeySet() {
         KeySet<K> nks = navigableKeySet;
-        return (nks != null) ? nks : (navigableKeySet = new KeySet(this));
+        return (nks != null) ? nks : (navigableKeySet = new KeySet<>(this));
     }
 
     /**
@@ -859,9 +862,9 @@
     public NavigableMap<K, V> descendingMap() {
         NavigableMap<K, V> km = descendingMap;
         return (km != null) ? km :
-            (descendingMap = new DescendingSubMap(this,
-                                                  true, null, true,
-                                                  true, null, true));
+            (descendingMap = new DescendingSubMap<>(this,
+                                                    true, null, true,
+                                                    true, null, true));
     }
 
     /**
@@ -874,9 +877,9 @@
      */
     public NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive,
                                     K toKey,   boolean toInclusive) {
-        return new AscendingSubMap(this,
-                                   false, fromKey, fromInclusive,
-                                   false, toKey,   toInclusive);
+        return new AscendingSubMap<>(this,
+                                     false, fromKey, fromInclusive,
+                                     false, toKey,   toInclusive);
     }
 
     /**
@@ -888,9 +891,9 @@
      * @since 1.6
      */
     public NavigableMap<K,V> headMap(K toKey, boolean inclusive) {
-        return new AscendingSubMap(this,
-                                   true,  null,  true,
-                                   false, toKey, inclusive);
+        return new AscendingSubMap<>(this,
+                                     true,  null,  true,
+                                     false, toKey, inclusive);
     }
 
     /**
@@ -902,9 +905,9 @@
      * @since 1.6
      */
     public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive) {
-        return new AscendingSubMap(this,
-                                   false, fromKey, inclusive,
-                                   true,  null,    true);
+        return new AscendingSubMap<>(this,
+                                     false, fromKey, inclusive,
+                                     true,  null,    true);
     }
 
     /**
@@ -978,8 +981,8 @@
         public boolean contains(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
-            V value = entry.getValue();
+            Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
+            Object value = entry.getValue();
             Entry<K,V> p = getEntry(entry.getKey());
             return p != null && valEquals(p.getValue(), value);
         }
@@ -987,8 +990,8 @@
         public boolean remove(Object o) {
             if (!(o instanceof Map.Entry))
                 return false;
-            Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
-            V value = entry.getValue();
+            Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
+            Object value = entry.getValue();
             Entry<K,V> p = getEntry(entry.getKey());
             if (p != null && valEquals(p.getValue(), value)) {
                 deleteEntry(p);
@@ -1023,21 +1026,21 @@
     }
 
     static final class KeySet<E> extends AbstractSet<E> implements NavigableSet<E> {
-        private final NavigableMap<E, Object> m;
-        KeySet(NavigableMap<E,Object> map) { m = map; }
+        private final NavigableMap<E, ?> m;
+        KeySet(NavigableMap<E,?> map) { m = map; }
 
         public Iterator<E> iterator() {
             if (m instanceof TreeMap)
-                return ((TreeMap<E,Object>)m).keyIterator();
+                return ((TreeMap<E,?>)m).keyIterator();
             else
-                return (Iterator<E>)(((TreeMap.NavigableSubMap)m).keyIterator());
+                return ((TreeMap.NavigableSubMap<E,?>)m).keyIterator();
         }
 
         public Iterator<E> descendingIterator() {
             if (m instanceof TreeMap)
-                return ((TreeMap<E,Object>)m).descendingKeyIterator();
+                return ((TreeMap<E,?>)m).descendingKeyIterator();
             else
-                return (Iterator<E>)(((TreeMap.NavigableSubMap)m).descendingKeyIterator());
+                return ((TreeMap.NavigableSubMap<E,?>)m).descendingKeyIterator();
         }
 
         public int size() { return m.size(); }
@@ -1052,11 +1055,11 @@
         public E last() { return m.lastKey(); }
         public Comparator<? super E> comparator() { return m.comparator(); }
         public E pollFirst() {
-            Map.Entry<E,Object> e = m.pollFirstEntry();
+            Map.Entry<E,?> e = m.pollFirstEntry();
             return (e == null) ? null : e.getKey();
         }
         public E pollLast() {
-            Map.Entry<E,Object> e = m.pollLastEntry();
+            Map.Entry<E,?> e = m.pollLastEntry();
             return (e == null) ? null : e.getKey();
         }
         public boolean remove(Object o) {
@@ -1085,7 +1088,7 @@
             return tailSet(fromElement, true);
         }
         public NavigableSet<E> descendingSet() {
-            return new KeySet(m.descendingMap());
+            return new KeySet<>(m.descendingMap());
         }
     }
 
@@ -1184,6 +1187,7 @@
     /**
      * Compares two keys using the correct comparison method for this TreeMap.
      */
+    @SuppressWarnings("unchecked")
     final int compare(Object k1, Object k2) {
         return comparator==null ? ((Comparable<? super K>)k1).compareTo((K)k2)
             : comparator.compare((K)k1, (K)k2);
@@ -1488,7 +1492,7 @@
         public final NavigableSet<K> navigableKeySet() {
             KeySet<K> nksv = navigableKeySetView;
             return (nksv != null) ? nksv :
-                (navigableKeySetView = new TreeMap.KeySet(this));
+                (navigableKeySetView = new TreeMap.KeySet<>(this));
         }
 
         public final Set<K> keySet() {
@@ -1522,7 +1526,7 @@
                 if (size == -1 || sizeModCount != m.modCount) {
                     sizeModCount = m.modCount;
                     size = 0;
-                    Iterator i = iterator();
+                    Iterator<?> i = iterator();
                     while (i.hasNext()) {
                         size++;
                         i.next();
@@ -1539,11 +1543,11 @@
             public boolean contains(Object o) {
                 if (!(o instanceof Map.Entry))
                     return false;
-                Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
-                K key = entry.getKey();
+                Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
+                Object key = entry.getKey();
                 if (!inRange(key))
                     return false;
-                TreeMap.Entry node = m.getEntry(key);
+                TreeMap.Entry<?,?> node = m.getEntry(key);
                 return node != null &&
                     valEquals(node.getValue(), entry.getValue());
             }
@@ -1551,8 +1555,8 @@
             public boolean remove(Object o) {
                 if (!(o instanceof Map.Entry))
                     return false;
-                Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
-                K key = entry.getKey();
+                Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
+                Object key = entry.getKey();
                 if (!inRange(key))
                     return false;
                 TreeMap.Entry<K,V> node = m.getEntry(key);
@@ -1709,34 +1713,34 @@
                 throw new IllegalArgumentException("fromKey out of range");
             if (!inRange(toKey, toInclusive))
                 throw new IllegalArgumentException("toKey out of range");
-            return new AscendingSubMap(m,
-                                       false, fromKey, fromInclusive,
-                                       false, toKey,   toInclusive);
+            return new AscendingSubMap<>(m,
+                                         false, fromKey, fromInclusive,
+                                         false, toKey,   toInclusive);
         }
 
         public NavigableMap<K,V> headMap(K toKey, boolean inclusive) {
             if (!inRange(toKey, inclusive))
                 throw new IllegalArgumentException("toKey out of range");
-            return new AscendingSubMap(m,
-                                       fromStart, lo,    loInclusive,
-                                       false,     toKey, inclusive);
+            return new AscendingSubMap<>(m,
+                                         fromStart, lo,    loInclusive,
+                                         false,     toKey, inclusive);
         }
 
         public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive) {
             if (!inRange(fromKey, inclusive))
                 throw new IllegalArgumentException("fromKey out of range");
-            return new AscendingSubMap(m,
-                                       false, fromKey, inclusive,
-                                       toEnd, hi,      hiInclusive);
+            return new AscendingSubMap<>(m,
+                                         false, fromKey, inclusive,
+                                         toEnd, hi,      hiInclusive);
         }
 
         public NavigableMap<K,V> descendingMap() {
             NavigableMap<K,V> mv = descendingMapView;
             return (mv != null) ? mv :
                 (descendingMapView =
-                 new DescendingSubMap(m,
-                                      fromStart, lo, loInclusive,
-                                      toEnd,     hi, hiInclusive));
+                 new DescendingSubMap<>(m,
+                                        fromStart, lo, loInclusive,
+                                        toEnd,     hi, hiInclusive));
         }
 
         Iterator<K> keyIterator() {
@@ -1790,34 +1794,34 @@
                 throw new IllegalArgumentException("fromKey out of range");
             if (!inRange(toKey, toInclusive))
                 throw new IllegalArgumentException("toKey out of range");
-            return new DescendingSubMap(m,
-                                        false, toKey,   toInclusive,
-                                        false, fromKey, fromInclusive);
+            return new DescendingSubMap<>(m,
+                                          false, toKey,   toInclusive,
+                                          false, fromKey, fromInclusive);
         }
 
         public NavigableMap<K,V> headMap(K toKey, boolean inclusive) {
             if (!inRange(toKey, inclusive))
                 throw new IllegalArgumentException("toKey out of range");
-            return new DescendingSubMap(m,
-                                        false, toKey, inclusive,
-                                        toEnd, hi,    hiInclusive);
+            return new DescendingSubMap<>(m,
+                                          false, toKey, inclusive,
+                                          toEnd, hi,    hiInclusive);
         }
 
         public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive) {
             if (!inRange(fromKey, inclusive))
                 throw new IllegalArgumentException("fromKey out of range");
-            return new DescendingSubMap(m,
-                                        fromStart, lo, loInclusive,
-                                        false, fromKey, inclusive);
+            return new DescendingSubMap<>(m,
+                                          fromStart, lo, loInclusive,
+                                          false, fromKey, inclusive);
         }
 
         public NavigableMap<K,V> descendingMap() {
             NavigableMap<K,V> mv = descendingMapView;
             return (mv != null) ? mv :
                 (descendingMapView =
-                 new AscendingSubMap(m,
-                                     fromStart, lo, loInclusive,
-                                     toEnd,     hi, hiInclusive));
+                 new AscendingSubMap<>(m,
+                                       fromStart, lo, loInclusive,
+                                       toEnd,     hi, hiInclusive));
         }
 
         Iterator<K> keyIterator() {
@@ -1862,9 +1866,9 @@
         private boolean fromStart = false, toEnd = false;
         private K fromKey, toKey;
         private Object readResolve() {
-            return new AscendingSubMap(TreeMap.this,
-                                       fromStart, fromKey, true,
-                                       toEnd, toKey, false);
+            return new AscendingSubMap<>(TreeMap.this,
+                                         fromStart, fromKey, true,
+                                         toEnd, toKey, false);
         }
         public Set<Map.Entry<K,V>> entrySet() { throw new InternalError(); }
         public K lastKey() { throw new InternalError(); }
@@ -2331,12 +2335,12 @@
      * @param defaultVal if non-null, this default value is used for
      *        each value in the map.  If null, each value is read from
      *        iterator or stream, as described above.
-     * @throws IOException propagated from stream reads. This cannot
+     * @throws java.io.IOException propagated from stream reads. This cannot
      *         occur if str is null.
      * @throws ClassNotFoundException propagated from readObject.
      *         This cannot occur if str is null.
      */
-    private void buildFromSorted(int size, Iterator it,
+    private void buildFromSorted(int size, Iterator<?> it,
                                  java.io.ObjectInputStream str,
                                  V defaultVal)
         throws  java.io.IOException, ClassNotFoundException {
@@ -2359,9 +2363,10 @@
      * @param redLevel the level at which nodes should be red.
      *        Must be equal to computeRedLevel for tree of this size.
      */
+    @SuppressWarnings("unchecked")
     private final Entry<K,V> buildFromSorted(int level, int lo, int hi,
                                              int redLevel,
-                                             Iterator it,
+                                             Iterator<?> it,
                                              java.io.ObjectInputStream str,
                                              V defaultVal)
         throws  java.io.IOException, ClassNotFoundException {
@@ -2391,9 +2396,9 @@
         V value;
         if (it != null) {
             if (defaultVal==null) {
-                Map.Entry<K,V> entry = (Map.Entry<K,V>)it.next();
-                key = entry.getKey();
-                value = entry.getValue();
+                Map.Entry<?,?> entry = (Map.Entry<?,?>)it.next();
+                key = (K)entry.getKey();
+                value = (V)entry.getValue();
             } else {
                 key = (K)it.next();
                 value = defaultVal;
--- a/jdk/src/share/classes/java/util/TreeSet.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/TreeSet.java	Wed Jul 05 18:09:02 2017 +0200
@@ -302,7 +302,7 @@
             m instanceof TreeMap) {
             SortedSet<? extends E> set = (SortedSet<? extends E>) c;
             TreeMap<E,Object> map = (TreeMap<E, Object>) m;
-            Comparator<? super E> cc = (Comparator<? super E>) set.comparator();
+            Comparator<?> cc = set.comparator();
             Comparator<? super E> mc = map.comparator();
             if (cc==mc || (cc != null && cc.equals(mc))) {
                 map.addAllForTreeSet(set, PRESENT);
@@ -469,8 +469,9 @@
      *
      * @return a shallow copy of this set
      */
+    @SuppressWarnings("unchecked")
     public Object clone() {
-        TreeSet<E> clone = null;
+        TreeSet<E> clone;
         try {
             clone = (TreeSet<E>) super.clone();
         } catch (CloneNotSupportedException e) {
@@ -519,14 +520,11 @@
         s.defaultReadObject();
 
         // Read in Comparator
-        Comparator<? super E> c = (Comparator<? super E>) s.readObject();
+        @SuppressWarnings("unchecked")
+            Comparator<? super E> c = (Comparator<? super E>) s.readObject();
 
         // Create backing TreeMap
-        TreeMap<E,Object> tm;
-        if (c==null)
-            tm = new TreeMap<>();
-        else
-            tm = new TreeMap<>(c);
+        TreeMap<E,Object> tm = new TreeMap<>(c);
         m = tm;
 
         // Read in size
--- a/jdk/src/share/classes/java/util/WeakHashMap.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/WeakHashMap.java	Wed Jul 05 18:09:02 2017 +0200
@@ -186,7 +186,7 @@
 
     @SuppressWarnings("unchecked")
     private Entry<K,V>[] newTable(int n) {
-        return (Entry<K,V>[]) new Entry[n];
+        return (Entry<K,V>[]) new Entry<?,?>[n];
     }
 
     /**
--- a/jdk/src/share/classes/java/util/regex/Matcher.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/regex/Matcher.java	Wed Jul 05 18:09:02 2017 +0200
@@ -759,16 +759,19 @@
             char nextChar = replacement.charAt(cursor);
             if (nextChar == '\\') {
                 cursor++;
+                if (cursor == replacement.length())
+                    throw new IllegalArgumentException(
+                        "character to be escaped is missing");
                 nextChar = replacement.charAt(cursor);
                 result.append(nextChar);
                 cursor++;
             } else if (nextChar == '$') {
                 // Skip past $
                 cursor++;
-                // A StringIndexOutOfBoundsException is thrown if
-                // this "$" is the last character in replacement
-                // string in current implementation, a IAE might be
-                // more appropriate.
+                // Throw IAE if this "$" is the last character in replacement
+                if (cursor == replacement.length())
+                   throw new IllegalArgumentException(
+                        "Illegal group reference: group index is missing");
                 nextChar = replacement.charAt(cursor);
                 int refNum = -1;
                 if (nextChar == '{') {
--- a/jdk/src/share/classes/javax/swing/BorderFactory.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/BorderFactory.java	Wed Jul 05 18:09:02 2017 +0200
@@ -371,7 +371,7 @@
     /**
      * Creates a new titled border with the specified title,
      * the default border type (determined by the current look and feel),
-     * the default text position (sitting on the top line),
+     * the default text position (determined by the current look and feel),
      * the default justification (leading), and the default
      * font and text color (determined by the current look and feel).
      *
@@ -385,7 +385,7 @@
     /**
      * Creates a new titled border with an empty title,
      * the specified border object,
-     * the default text position (sitting on the top line),
+     * the default text position (determined by the current look and feel),
      * the default justification (leading), and the default
      * font and text color (determined by the current look and feel).
      *
@@ -400,7 +400,7 @@
 
     /**
      * Adds a title to an existing border,
-     * with default positioning (sitting on the top line),
+     * with default positioning (determined by the current look and feel),
      * default justification (leading) and the default
      * font and text color (determined by the current look and feel).
      *
@@ -439,7 +439,8 @@
      *<li><code>TitledBorder.ABOVE_BOTTOM</code>
      *<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)
      *<li><code>TitledBorder.BELOW_BOTTOM</code>
-     *<li><code>TitledBorder.DEFAULT_POSITION</code> (top)
+     *<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position
+     *  is determined by the current look and feel)
      *</ul>
      * @return the <code>TitledBorder</code> object
      */
@@ -477,7 +478,8 @@
      *<li><code>TitledBorder.ABOVE_BOTTOM</code>
      *<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)
      *<li><code>TitledBorder.BELOW_BOTTOM</code>
-     *<li><code>TitledBorder.DEFAULT_POSITION</code> (top)
+     *<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position
+     *  is determined by the current look and feel)
      *</ul>
      * @param titleFont           a Font object specifying the title font
      * @return the TitledBorder object
@@ -516,7 +518,8 @@
      *<li><code>TitledBorder.ABOVE_BOTTOM</code>
      *<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)
      *<li><code>TitledBorder.BELOW_BOTTOM</code>
-     *<li><code>TitledBorder.DEFAULT_POSITION</code> (top)
+     *<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position
+     *  is determined by the current look and feel)
      *</ul>
      * @param titleFont   a <code>Font</code> object specifying the title font
      * @param titleColor  a <code>Color</code> object specifying the title color
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboPopup.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboPopup.java	Wed Jul 05 18:09:02 2017 +0200
@@ -26,13 +26,9 @@
 package javax.swing.plaf.synth;
 
 import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.plaf.basic.*;
+import javax.swing.plaf.ComboBoxUI;
+import javax.swing.plaf.basic.BasicComboPopup;
 import java.awt.*;
-import java.awt.event.*;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-import java.io.Serializable;
 
 
 /**
@@ -52,6 +48,7 @@
      *
      * @see #createList
      */
+    @Override
     protected void configureList() {
         list.setFont( comboBox.getFont() );
         list.setCellRenderer( comboBox.getRenderer() );
@@ -67,4 +64,27 @@
         }
         installListListeners();
     }
+
+    /**
+     * @inheritDoc
+     *
+     * Overridden to take into account any popup insets specified in
+     * SynthComboBoxUI
+     */
+    @Override
+    protected Rectangle computePopupBounds(int px, int py, int pw, int ph) {
+        ComboBoxUI ui = comboBox.getUI();
+        if (ui instanceof SynthComboBoxUI) {
+            SynthComboBoxUI sui = (SynthComboBoxUI) ui;
+            if (sui.popupInsets != null) {
+                Insets i = sui.popupInsets;
+                return super.computePopupBounds(
+                        px + i.left,
+                        py + i.top,
+                        pw - i.left - i.right,
+                        ph - i.top - i.bottom);
+            }
+        }
+        return super.computePopupBounds(px, py, pw, ph);
+    }
 }
--- a/jdk/src/share/classes/javax/swing/text/AbstractDocument.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/text/AbstractDocument.java	Wed Jul 05 18:09:02 2017 +0200
@@ -31,7 +31,6 @@
 
 import javax.swing.UIManager;
 import javax.swing.undo.*;
-import javax.swing.event.ChangeListener;
 import javax.swing.event.*;
 import javax.swing.tree.TreeNode;
 
@@ -698,28 +697,31 @@
             return;
         }
         DocumentFilter filter = getDocumentFilter();
+        InsertStringResult insertStringResult = null;
 
         writeLock();
+
         try {
             if (filter != null) {
                 filter.insertString(getFilterBypass(), offs, str, a);
-            }
-            else {
-                handleInsertString(offs, str, a);
+            } else {
+                insertStringResult = handleInsertString(offs, str, a);
             }
         } finally {
             writeUnlock();
         }
+
+        processInsertStringResult(insertStringResult);
     }
 
     /**
      * Performs the actual work of inserting the text; it is assumed the
      * caller has obtained a write lock before invoking this.
      */
-    void handleInsertString(int offs, String str, AttributeSet a)
-                         throws BadLocationException {
+    private InsertStringResult handleInsertString(int offs, String str, AttributeSet a)
+            throws BadLocationException {
         if ((str == null) || (str.length() == 0)) {
-            return;
+            return null;
         }
         UndoableEdit u = data.insertString(offs, str);
         DefaultDocumentEvent e =
@@ -746,12 +748,29 @@
         insertUpdate(e, a);
         // Mark the edit as done.
         e.end();
-        fireInsertUpdate(e);
+
+        InsertStringResult result = new InsertStringResult();
+
+        result.documentEvent = e;
+
         // only fire undo if Content implementation supports it
         // undo for the composed text is not supported for now
-        if (u != null &&
-            (a == null || !a.isDefined(StyleConstants.ComposedTextAttribute))) {
-            fireUndoableEditUpdate(new UndoableEditEvent(this, e));
+        if (u != null && (a == null || !a.isDefined(StyleConstants.ComposedTextAttribute))) {
+            result.undoableEditEvent = new UndoableEditEvent(this, e);
+        }
+
+        return result;
+    }
+
+    private void processInsertStringResult(InsertStringResult insertStringResult) {
+        if (insertStringResult == null) {
+            return;
+        }
+
+        fireInsertUpdate(insertStringResult.documentEvent);
+
+        if (insertStringResult.undoableEditEvent != null) {
+            fireUndoableEditUpdate(insertStringResult.undoableEditEvent);
         }
     }
 
@@ -2947,12 +2966,10 @@
      */
     class UndoRedoDocumentEvent implements DocumentEvent {
         private DefaultDocumentEvent src = null;
-        private boolean isUndo;
         private EventType type = null;
 
         public UndoRedoDocumentEvent(DefaultDocumentEvent src, boolean isUndo) {
             this.src = src;
-            this.isUndo = isUndo;
             if(isUndo) {
                 if(src.getType().equals(EventType.INSERT)) {
                     type = EventType.REMOVE;
@@ -3106,13 +3123,23 @@
         public void insertString(int offset, String string,
                                  AttributeSet attr) throws
                                         BadLocationException {
-            handleInsertString(offset, string, attr);
+            InsertStringResult insertStringResult = handleInsertString(offset, string, attr);
+
+            processInsertStringResult(insertStringResult);
         }
 
         public void replace(int offset, int length, String text,
                             AttributeSet attrs) throws BadLocationException {
             handleRemove(offset, length);
-            handleInsertString(offset, text, attrs);
+
+            InsertStringResult insertStringResult = handleInsertString(offset, text, attrs);
+
+            processInsertStringResult(insertStringResult);
         }
     }
+
+    private static class InsertStringResult {
+        DefaultDocumentEvent documentEvent;
+        UndoableEditEvent undoableEditEvent;
+    }
 }
--- a/jdk/src/share/classes/javax/swing/text/DefaultEditorKit.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/text/DefaultEditorKit.java	Wed Jul 05 18:09:02 2017 +0200
@@ -24,6 +24,8 @@
  */
 package javax.swing.text;
 
+import sun.awt.SunToolkit;
+
 import java.io.*;
 import java.awt.*;
 import java.awt.event.ActionEvent;
@@ -869,11 +871,18 @@
                 }
                 String content = e.getActionCommand();
                 int mod = e.getModifiers();
-                if ((content != null) && (content.length() > 0) &&
-                    ((mod & ActionEvent.ALT_MASK) == (mod & ActionEvent.CTRL_MASK))) {
-                    char c = content.charAt(0);
-                    if ((c >= 0x20) && (c != 0x7F)) {
-                        target.replaceSelection(content);
+                if ((content != null) && (content.length() > 0)) {
+                    boolean isPrintableMask = true;
+                    Toolkit tk = Toolkit.getDefaultToolkit();
+                    if (tk instanceof SunToolkit) {
+                        isPrintableMask = ((SunToolkit)tk).isPrintableCharacterModifiersMask(mod);
+                    }
+
+                    if (isPrintableMask) {
+                        char c = content.charAt(0);
+                        if ((c >= 0x20) && (c != 0x7F)) {
+                            target.replaceSelection(content);
+                        }
                     }
                 }
             }
--- a/jdk/src/share/classes/sun/awt/AppContext.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/awt/AppContext.java	Wed Jul 05 18:09:02 2017 +0200
@@ -46,6 +46,7 @@
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * The AppContext is a table referenced by ThreadGroup which stores
@@ -194,6 +195,15 @@
         return isDisposed;
     }
 
+    /*
+     * The total number of AppContexts, system-wide.  This number is
+     * incremented at the beginning of the constructor, and decremented
+     * at the end of dispose().  getAppContext() checks to see if this
+     * number is 1.  If so, it returns the sole AppContext without
+     * checking Thread.currentThread().
+     */
+    private static final AtomicInteger numAppContexts = new AtomicInteger(0);
+
     static {
         // On the main Thread, we get the ThreadGroup, make a corresponding
         // AppContext, and instantiate the Java EventQueue.  This way, legacy
@@ -209,22 +219,12 @@
                     parentThreadGroup = currentThreadGroup.getParent();
                 }
                 mainAppContext = new AppContext(currentThreadGroup);
-                numAppContexts = 1;
                 return null;
             }
         });
     }
 
     /*
-     * The total number of AppContexts, system-wide.  This number is
-     * incremented at the beginning of the constructor, and decremented
-     * at the end of dispose().  getAppContext() checks to see if this
-     * number is 1.  If so, it returns the sole AppContext without
-     * checking Thread.currentThread().
-     */
-    private static volatile int numAppContexts;
-
-    /*
      * The context ClassLoader that was used to create this AppContext.
      */
     private final ClassLoader contextClassLoader;
@@ -243,7 +243,7 @@
      * @since   1.2
      */
     AppContext(ThreadGroup threadGroup) {
-        numAppContexts++;
+        numAppContexts.incrementAndGet();
 
         this.threadGroup = threadGroup;
         threadGroup2appContext.put(threadGroup, this);
@@ -278,7 +278,7 @@
      * @since   1.2
      */
     public final static AppContext getAppContext() {
-        if (numAppContexts == 1)   // If there's only one system-wide,
+        if (numAppContexts.get() == 1)   // If there's only one system-wide,
             return mainAppContext; // return the main system AppContext.
 
         AppContext appContext = threadAppContext.get();
@@ -513,7 +513,7 @@
             this.table.clear(); // Clear out the Hashtable to ease garbage collection
         }
 
-        numAppContexts--;
+        numAppContexts.decrementAndGet();
 
         mostRecentKeyValue = null;
     }
@@ -804,7 +804,7 @@
                 return getAppContext().isDisposed();
             }
             public boolean isMainAppContext() {
-                return (numAppContexts == 1);
+                return (numAppContexts.get() == 1);
             }
         });
     }
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1126,6 +1126,16 @@
     }
 
     /**
+     * Tests whether specified key modifiers mask can be used to enter a printable
+     * character. This is a default implementation of this method, which reflects
+     * the way things work on Windows: here, pressing ctrl + alt allows user to enter
+     * characters from the extended character set (like euro sign or math symbols)
+     */
+    public boolean isPrintableCharacterModifiersMask(int mods) {
+        return ((mods & InputEvent.ALT_MASK) == (mods & InputEvent.CTRL_MASK));
+    }
+
+    /**
      * Returns a new input method window, with behavior as specified in
      * {@link java.awt.im.spi.InputMethodContext#createInputMethodWindow}.
      * If the inputContext is not null, the window should return it from its
--- a/jdk/src/share/classes/sun/awt/image/ImageWatched.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/awt/image/ImageWatched.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -143,6 +143,7 @@
         if (iw != null && !isWatcher(iw)) {
             watcherList = new WeakLink(iw, watcherList);
         }
+        watcherList = watcherList.removeWatcher(null);
     }
 
     public synchronized boolean isWatcher(ImageObserver iw) {
--- a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -970,7 +970,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             ResourceManager.afterUdpClose();
 
             // if member of mulitcast group then invalidate all keys
--- a/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -261,7 +261,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             long th = thread;
             if (th != 0)
                 NativeThread.signal(th);
--- a/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -816,7 +816,8 @@
             // channel from using the old fd, which might be recycled in the
             // meantime and allocated to an entirely different channel.
             //
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
 
             // Signal native threads, if needed.  If a target thread is not
             // currently blocked in an I/O operation then no harm is done since
--- a/jdk/src/share/classes/sun/nio/cs/ext/SJIS_0213.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/nio/cs/ext/SJIS_0213.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,8 @@
 import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CoderResult;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Arrays;
 import sun.nio.cs.CharsetMapping;
 
@@ -73,8 +75,12 @@
         return new Encoder(this);
     }
 
-    static CharsetMapping mapping =
-        CharsetMapping.get(SJIS_0213.class.getResourceAsStream("sjis0213.dat"));
+    static CharsetMapping mapping = AccessController.doPrivileged(
+        new PrivilegedAction<CharsetMapping>() {
+            public CharsetMapping run() {
+                return CharsetMapping.get(SJIS_0213.class.getResourceAsStream("sjis0213.dat"));
+            }
+        });
 
     protected static class Decoder extends CharsetDecoder {
         protected static final char UNMAPPABLE = CharsetMapping.UNMAPPABLE_DECODING;
--- a/jdk/src/share/classes/sun/security/ec/ECParameters.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/security/ec/ECParameters.java	Wed Jul 05 18:09:02 2017 +0200
@@ -87,8 +87,8 @@
         if ((data.length == 0) || (data[0] != 4)) {
             throw new IOException("Only uncompressed point format supported");
         }
-        int n = (curve.getField().getFieldSize() + 7 ) >> 3;
-        if (data.length != (n * 2) + 1) {
+        int n = data.length / 2;
+        if (n > ((curve.getField().getFieldSize() + 7 ) >> 3)) {
             throw new IOException("Point does not match field size");
         }
         byte[] xb = new byte[n];
--- a/jdk/src/share/classes/sun/security/krb5/Credentials.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/security/krb5/Credentials.java	Wed Jul 05 18:09:02 2017 +0200
@@ -330,12 +330,17 @@
         CredentialsCache ccache =
             CredentialsCache.getInstance(princ, ticketCache);
 
-        if (ccache == null)
+        if (ccache == null) {
             return null;
+        }
 
         sun.security.krb5.internal.ccache.Credentials tgtCred  =
             ccache.getDefaultCreds();
 
+        if (tgtCred == null) {
+            return null;
+        }
+
         if (EType.isSupported(tgtCred.getEType())) {
             return tgtCred.setKrbCreds();
         } else {
@@ -375,19 +380,21 @@
             cache = CredentialsCache.getInstance();
         }
         if (cache != null) {
-            if (DEBUG) {
-                System.out.println(">>> KrbCreds found the default ticket " +
-                                   "granting ticket in credential cache.");
-            }
             sun.security.krb5.internal.ccache.Credentials temp =
                 cache.getDefaultCreds();
-            if (EType.isSupported(temp.getEType())) {
-                result = temp.setKrbCreds();
-            } else {
+            if (temp != null) {
                 if (DEBUG) {
-                    System.out.println(
-                        ">>> unsupported key type found the default TGT: " +
-                        temp.getEType());
+                    System.out.println(">>> KrbCreds found the default ticket"
+                            + " granting ticket in credential cache.");
+                }
+                if (EType.isSupported(temp.getEType())) {
+                    result = temp.setKrbCreds();
+                } else {
+                    if (DEBUG) {
+                        System.out.println(
+                            ">>> unsupported key type found the default TGT: " +
+                            temp.getEType());
+                    }
                 }
             }
         }
--- a/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -91,9 +91,20 @@
         // however they like; if we buffered here, they couldn't.
         try {
             do {
+                boolean holdRecord = false;
                 int howmuch;
                 if (isFirstRecordOfThePayload && c.needToSplitPayload()) {
                     howmuch = Math.min(0x01, r.availableDataBytes());
+                     /*
+                      * Nagle's algorithm (TCP_NODELAY) was coming into
+                      * play here when writing short (split) packets.
+                      * Signal to the OutputRecord code to internally
+                      * buffer this small packet until the next outbound
+                      * packet (of any type) is written.
+                      */
+                     if ((len != 1) && (howmuch == 1)) {
+                         holdRecord = true;
+                     }
                 } else {
                     howmuch = Math.min(len, r.availableDataBytes());
                 }
@@ -108,7 +119,7 @@
                     off += howmuch;
                     len -= howmuch;
                 }
-                c.writeRecord(r);
+                c.writeRecord(r, holdRecord);
                 c.checkWrite();
             } while (len > 0);
         } catch (Exception e) {
--- a/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -155,8 +155,9 @@
      * data to be generated/output before the exception is ever
      * generated.
      */
-    void writeBuffer(OutputStream s, byte [] buf, int off, int len)
-            throws IOException {
+    @Override
+    void writeBuffer(OutputStream s, byte [] buf, int off, int len,
+            int debugOffset) throws IOException {
         /*
          * Copy data out of buffer, it's ready to go.
          */
@@ -196,7 +197,8 @@
             // compress();              // eventually
             addMAC(writeMAC);
             encrypt(writeCipher);
-            write((OutputStream)null);  // send down for processing
+            write((OutputStream)null, false,  // send down for processing
+                (ByteArrayOutputStream)null);
         }
         return;
     }
--- a/jdk/src/share/classes/sun/security/ssl/OutputRecord.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/OutputRecord.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 
 import java.io.*;
 import java.nio.*;
+import java.util.Arrays;
 
 import javax.net.ssl.SSLException;
 import sun.misc.HexDumpEncoder;
@@ -227,6 +228,24 @@
     }
 
     /*
+     * Increases the capacity if necessary to ensure that it can hold
+     * at least the number of elements specified by the minimum
+     * capacity argument.
+     *
+     * Note that the increased capacity is only can be used for held
+     * record buffer. Please DO NOT update the availableDataBytes()
+     * according to the expended buffer capacity.
+     *
+     * @see availableDataBytes()
+     */
+    private void ensureCapacity(int minCapacity) {
+        // overflow-conscious code
+        if (minCapacity > buf.length) {
+            buf = Arrays.copyOf(buf, minCapacity);
+        }
+    }
+
+    /*
      * Return the type of SSL record that's buffered here.
      */
     final byte contentType() {
@@ -243,7 +262,9 @@
      * that synchronization be done elsewhere.  Also, this does its work
      * in a single low level write, for efficiency.
      */
-    void write(OutputStream s) throws IOException {
+    void write(OutputStream s, boolean holdRecord,
+            ByteArrayOutputStream heldRecordBuffer) throws IOException {
+
         /*
          * Don't emit content-free records.  (Even change cipher spec
          * messages have a byte of data!)
@@ -300,7 +321,49 @@
         }
         firstMessage = false;
 
-        writeBuffer(s, buf, 0, count);
+        /*
+         * The upper levels may want us to delay sending this packet so
+         * multiple TLS Records can be sent in one (or more) TCP packets.
+         * If so, add this packet to the heldRecordBuffer.
+         *
+         * NOTE:  all writes have been synchronized by upper levels.
+         */
+        int debugOffset = 0;
+        if (holdRecord) {
+            /*
+             * If holdRecord is true, we must have a heldRecordBuffer.
+             *
+             * Don't worry about the override of writeBuffer(), because
+             * when holdRecord is true, the implementation in this class
+             * will be used.
+             */
+            writeBuffer(heldRecordBuffer, buf, 0, count, debugOffset);
+        } else {
+            // It's time to send, do we have buffered data?
+            // May or may not have a heldRecordBuffer.
+            if (heldRecordBuffer != null && heldRecordBuffer.size() > 0) {
+                int heldLen = heldRecordBuffer.size();
+
+                // Ensure the capacity of this buffer.
+                ensureCapacity(count + heldLen);
+
+                // Slide everything in the buffer to the right.
+                System.arraycopy(buf, 0, buf, heldLen, count);
+
+                // Prepend the held record to the buffer.
+                System.arraycopy(
+                    heldRecordBuffer.toByteArray(), 0, buf, 0, heldLen);
+                count += heldLen;
+
+                // Clear the held buffer.
+                heldRecordBuffer.reset();
+
+                // The held buffer has been dumped, set the debug dump offset.
+                debugOffset = heldLen;
+            }
+            writeBuffer(s, buf, 0, count, debugOffset);
+        }
+
         reset();
     }
 
@@ -309,15 +372,17 @@
      * we'll override this method and let it take the appropriate
      * action.
      */
-    void writeBuffer(OutputStream s, byte [] buf, int off, int len)
-            throws IOException {
+    void writeBuffer(OutputStream s, byte [] buf, int off, int len,
+            int debugOffset) throws IOException {
         s.write(buf, off, len);
         s.flush();
 
+        // Output only the record from the specified debug offset.
         if (debug != null && Debug.isOn("packet")) {
             try {
                 HexDumpEncoder hd = new HexDumpEncoder();
-                ByteBuffer bb = ByteBuffer.wrap(buf, off, len);
+                ByteBuffer bb = ByteBuffer.wrap(
+                        buf, off + debugOffset, len - debugOffset);
 
                 System.out.println("[Raw write]: length = " +
                     bb.remaining());
--- a/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -374,6 +374,12 @@
      */
     private boolean isFirstAppOutputRecord = true;
 
+    /*
+     * If AppOutputStream needs to delay writes of small packets, we
+     * will use this to store the data until we actually do the write.
+     */
+    private ByteArrayOutputStream heldRecordBuffer = null;
+
     //
     // CONSTRUCTORS AND INITIALIZATION CODE
     //
@@ -654,13 +660,24 @@
     //
 
     /*
+     * AppOutputStream calls may need to buffer multiple outbound
+     * application packets.
+     *
+     * All other writeRecord() calls will not buffer, so do not hold
+     * these records.
+     */
+    void writeRecord(OutputRecord r) throws IOException {
+        writeRecord(r, false);
+    }
+
+    /*
      * Record Output. Application data can't be sent until the first
      * handshake establishes a session.
      *
      * NOTE:  we let empty records be written as a hook to force some
      * TCP-level activity, notably handshaking, to occur.
      */
-    void writeRecord(OutputRecord r) throws IOException {
+    void writeRecord(OutputRecord r, boolean holdRecord) throws IOException {
         /*
          * The loop is in case of HANDSHAKE --> ERROR transitions, etc
          */
@@ -731,7 +748,7 @@
                 try {
                     if (writeLock.tryLock(getSoLinger(), TimeUnit.SECONDS)) {
                         try {
-                            writeRecordInternal(r);
+                            writeRecordInternal(r, holdRecord);
                         } finally {
                             writeLock.unlock();
                         }
@@ -779,7 +796,7 @@
             } else {
                 writeLock.lock();
                 try {
-                    writeRecordInternal(r);
+                    writeRecordInternal(r, holdRecord);
                 } finally {
                     writeLock.unlock();
                 }
@@ -787,11 +804,29 @@
         }
     }
 
-    private void writeRecordInternal(OutputRecord r) throws IOException {
+    private void writeRecordInternal(OutputRecord r,
+            boolean holdRecord) throws IOException {
+
         // r.compress(c);
         r.addMAC(writeMAC);
         r.encrypt(writeCipher);
-        r.write(sockOutput);
+
+        if (holdRecord) {
+            // If we were requested to delay the record due to possibility
+            // of Nagle's being active when finally got to writing, and
+            // it's actually not, we don't really need to delay it.
+            if (getTcpNoDelay()) {
+                holdRecord = false;
+            } else {
+                // We need to hold the record, so let's provide
+                // a per-socket place to do it.
+                if (heldRecordBuffer == null) {
+                    // Likely only need 37 bytes.
+                    heldRecordBuffer = new ByteArrayOutputStream(40);
+                }
+            }
+        }
+        r.write(sockOutput, holdRecord, heldRecordBuffer);
 
         /*
          * Check the sequence number state
--- a/jdk/src/share/classes/sun/tools/java/ClassPath.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/tools/java/ClassPath.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -141,7 +141,7 @@
         } else {
             StringBuilder sb = new StringBuilder(patharray[0]);
             for (int i = 1; i < patharray.length; i++) {
-                sb.append(File.separator);
+                sb.append(File.pathSeparatorChar);
                 sb.append(patharray[i]);
             }
             this.pathstr = sb.toString();
--- a/jdk/src/share/classes/sun/tools/jcmd/JCmd.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/classes/sun/tools/jcmd/JCmd.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *com.sun.tools.attach.AttachNotSupportedException
 
@@ -142,17 +142,20 @@
         // Cast to HotSpotVirtualMachine as this is an
         // implementation specific method.
         HotSpotVirtualMachine hvm = (HotSpotVirtualMachine) vm;
-        try (InputStream in = hvm.executeJCmd(command);) {
-            // read to EOF and just print output
-            byte b[] = new byte[256];
-            int n;
-            do {
-                n = in.read(b);
-                if (n > 0) {
-                    String s = new String(b, 0, n, "UTF-8");
-                    System.out.print(s);
-                }
-            } while (n > 0);
+        String lines[] = command .split("\\n");
+        for (String line : lines) {
+            try (InputStream in = hvm.executeJCmd(line);) {
+                // read to EOF and just print output
+                byte b[] = new byte[256];
+                int n;
+                do {
+                    n = in.read(b);
+                    if (n > 0) {
+                        String s = new String(b, 0, n, "UTF-8");
+                        System.out.print(s);
+                    }
+                } while (n > 0);
+            }
         }
         vm.detach();
     }
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java	Wed Jul 05 18:09:02 2017 +0200
@@ -78,7 +78,7 @@
         }
         try {
             // only support legacy JAR URL syntax  jar:{uri}!/{entry} for now
-            String spec = uri.getSchemeSpecificPart();
+            String spec = uri.getRawSchemeSpecificPart();
             int sep = spec.indexOf("!/");
             if (sep != -1)
                 spec = spec.substring(0, sep);
--- a/jdk/src/share/lib/security/java.security	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/lib/security/java.security	Wed Jul 05 18:09:02 2017 +0200
@@ -123,7 +123,7 @@
 # passed to checkPackageAccess unless the
 # corresponding RuntimePermission ("accessClassInPackage."+package) has
 # been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
 
 #
 # List of comma-separated packages that start with or equal this string
--- a/jdk/src/share/lib/security/java.security-macosx	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/lib/security/java.security-macosx	Wed Jul 05 18:09:02 2017 +0200
@@ -124,7 +124,7 @@
 # passed to checkPackageAccess unless the
 # corresponding RuntimePermission ("accessClassInPackage."+package) has
 # been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
 
 #
 # List of comma-separated packages that start with or equal this string
--- a/jdk/src/share/lib/security/java.security-solaris	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/lib/security/java.security-solaris	Wed Jul 05 18:09:02 2017 +0200
@@ -125,7 +125,7 @@
 # passed to checkPackageAccess unless the
 # corresponding RuntimePermission ("accessClassInPackage."+package) has
 # been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
 
 #
 # List of comma-separated packages that start with or equal this string
--- a/jdk/src/share/lib/security/java.security-windows	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/lib/security/java.security-windows	Wed Jul 05 18:09:02 2017 +0200
@@ -124,7 +124,7 @@
 # passed to checkPackageAccess unless the
 # corresponding RuntimePermission ("accessClassInPackage."+package) has
 # been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
 
 #
 # List of comma-separated packages that start with or equal this string
--- a/jdk/src/share/native/sun/font/sunFont.c	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/share/native/sun/font/sunFont.c	Wed Jul 05 18:09:02 2017 +0200
@@ -29,7 +29,7 @@
 #include "jlong.h"
 #include "sunfontids.h"
 #include "fontscalerdefs.h"
-#include "sun_font_FontManager.h"
+#include "sun_font_SunFontManager.h"
 #include "sun_font_NullFontScaler.h"
 #include "sun_font_StrikeCache.h"
 
--- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Wed Jul 05 18:09:02 2017 +0200
@@ -82,7 +82,7 @@
 
     boolean paintPending = false;
     boolean isLayouting = false;
-    boolean enabled;
+    private boolean enabled;
 
     // Actually used only by XDecoratedPeer
     protected int boundsOperation;
@@ -128,9 +128,6 @@
     }
     void postInit(XCreateWindowParams params) {
         super.postInit(params);
-        Color c;
-        Font  f;
-        Cursor cursor;
 
         pSetCursor(target.getCursor());
 
@@ -143,19 +140,7 @@
             reshape(r.x, r.y, r.width, r.height);
         }
 
-        enabled = target.isEnabled();
-
-        // If any of our heavyweight ancestors are disable, we should be too
-        // See 6176875 for more information
-        Component comp = target;
-        while( !(comp == null || comp instanceof Window) ) {
-            comp = comp.getParent();
-            if( comp != null && !comp.isEnabled() && !comp.isLightweight() ){
-                setEnabled(false);
-                break;
-            }
-        }
-        enableLog.fine("Initial enable state: {0}", Boolean.valueOf(enabled));
+        setEnabled(target.isEnabled());
 
         if (target.isVisible()) {
             setVisible(true);
@@ -384,45 +369,48 @@
         setVisible(false);
     }
 
-
     /**
      * @see java.awt.peer.ComponentPeer
      */
-    public void setEnabled(boolean value) {
-        enableLog.fine("{0}ing {1}", (value?"Enabl":"Disabl"), this);
-        boolean repaintNeeded = (enabled != value);
-        enabled = value;
+    public void setEnabled(final boolean value) {
+        if (enableLog.isLoggable(PlatformLogger.FINE)) {
+            enableLog.fine("{0}ing {1}", (value ? "Enabl" : "Disabl"), this);
+        }
+        boolean status = value;
+        // If any of our heavyweight ancestors are disable, we should be too
+        // See 6176875 for more information
+        final Container cp = SunToolkit.getNativeContainer(target);
+        if (cp != null) {
+            status &= ((XComponentPeer) cp.getPeer()).isEnabled();
+        }
+        synchronized (getStateLock()) {
+            if (enabled == status) {
+                return;
+            }
+            enabled = status;
+        }
+
         if (target instanceof Container) {
-            Component list[] = ((Container)target).getComponents();
-            for (int i = 0; i < list.length; ++i) {
-                boolean childEnabled = list[i].isEnabled();
-                ComponentPeer p = list[i].getPeer();
-                if ( p != null ) {
-                    p.setEnabled(value && childEnabled);
+            final Component[] list = ((Container) target).getComponents();
+            for (final Component child : list) {
+                final ComponentPeer p = child.getPeer();
+                if (p != null) {
+                    p.setEnabled(status && child.isEnabled());
                 }
             }
         }
-        if (repaintNeeded) {
-            repaint();
-        }
+        repaint();
     }
 
     //
     // public so aw/Window can call it
     //
-    public boolean isEnabled() {
-        return enabled;
+    public final boolean isEnabled() {
+        synchronized (getStateLock()) {
+            return enabled;
+        }
     }
 
-
-
-    public void enable() {
-        setEnabled(true);
-    }
-
-    public void disable() {
-        setEnabled(false);
-    }
     @Override
     public void paint(final Graphics g) {
         super.paint(g);
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java	Wed Jul 05 18:09:02 2017 +0200
@@ -69,20 +69,26 @@
     }
 
     public void drawLine(SunGraphics2D sg2d, int x1, int y1, int x2, int y2) {
-        try {
-            SunToolkit.awtLock();
-
-            validateSurface(sg2d);
-            int transx = sg2d.transX;
-            int transy = sg2d.transY;
+        Region compClip = sg2d.getCompClip();
+        int transX1 = x1 + sg2d.transX;
+        int transY1 = y1 + sg2d.transY;
+        int transX2 = x2 + sg2d.transX;
+        int transY2 = y2 + sg2d.transY;
 
-            XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData;
+        // Non clipped fast path
+        if (compClip.contains(transX1, transY1)
+                && compClip.contains(transX2, transY2)) {
+            try {
+                SunToolkit.awtLock();
 
-            tileManager.addLine(x1 + transx, y1 + transy,
-                                x2 + transx, y2 + transy);
-            tileManager.fillMask(xrsd);
-        } finally {
-            SunToolkit.awtUnlock();
+                validateSurface(sg2d);
+                tileManager.addLine(transX1, transY1, transX2, transY2);
+                tileManager.fillMask((XRSurfaceData) sg2d.surfaceData);
+            } finally {
+                SunToolkit.awtUnlock();
+            }
+        } else {
+            draw(sg2d, new Line2D.Float(x1, y1, x2, y2));
         }
     }
 
--- a/jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,7 +84,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             long th = thread;
             if (th != 0)
                 NativeThread.signal(th);
--- a/jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,7 +84,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             long th = thread;
             if (th != 0)
                 NativeThread.signal(th);
--- a/jdk/src/solaris/native/com/sun/management/MacosxOperatingSystem.c	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/solaris/native/com/sun/management/MacosxOperatingSystem.c	Wed Jul 05 18:09:02 2017 +0200
@@ -25,16 +25,136 @@
 
 #include "com_sun_management_UnixOperatingSystem.h"
 
+#include <sys/time.h>
+#include <mach/mach.h>
+#include <mach/task_info.h>
+
+
 JNIEXPORT jdouble JNICALL
 Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
 (JNIEnv *env, jobject dummy)
 {
-  return -1.0; // not available
+    // This code is influenced by the darwin top source
+
+    kern_return_t kr;
+    mach_msg_type_number_t count;
+    host_cpu_load_info_data_t load;
+
+    static jlong last_used  = 0;
+    static jlong last_total = 0;
+
+    count = HOST_CPU_LOAD_INFO_COUNT;
+    kr = host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, (host_info_t)&load, &count);
+    if (kr != KERN_SUCCESS) {
+        return -1;
+    }
+
+    jlong used  = load.cpu_ticks[CPU_STATE_USER] + load.cpu_ticks[CPU_STATE_NICE] + load.cpu_ticks[CPU_STATE_SYSTEM];
+    jlong total = used + load.cpu_ticks[CPU_STATE_IDLE];
+
+    if (last_used == 0 || last_total == 0) {
+        // First call, just set the last values
+        last_used  = used;
+        last_total = total;
+        // return 0 since we have no data, not -1 which indicates error
+        return 0;
+    }
+
+    jlong used_delta  = used - last_used;
+    jlong total_delta = total - last_total;
+
+    jdouble cpu = (jdouble) used_delta / total_delta;
+
+    last_used  = used;
+    last_total = total;
+
+    return cpu;
 }
 
+
+#define TIME_VALUE_TO_TIMEVAL(a, r) do {  \
+     (r)->tv_sec = (a)->seconds;          \
+     (r)->tv_usec = (a)->microseconds;    \
+} while (0)
+
+
+#define TIME_VALUE_TO_MICROSECONDS(TV) \
+     ((TV).tv_sec * 1000 * 1000 + (TV).tv_usec)
+
+
 JNIEXPORT jdouble JNICALL
 Java_com_sun_management_UnixOperatingSystem_getProcessCpuLoad
 (JNIEnv *env, jobject dummy)
 {
-  return -1.0; // not available
-}
+    // This code is influenced by the darwin top source
+
+    struct task_basic_info_64 task_info_data;
+    struct task_thread_times_info thread_info_data;
+    struct timeval user_timeval, system_timeval, task_timeval;
+    struct timeval now;
+    mach_port_t task = mach_task_self();
+    kern_return_t kr;
+
+    static jlong last_task_time = 0;
+    static jlong last_time      = 0;
+
+    mach_msg_type_number_t thread_info_count = TASK_THREAD_TIMES_INFO_COUNT;
+    kr = task_info(task,
+            TASK_THREAD_TIMES_INFO,
+            (task_info_t)&thread_info_data,
+            &thread_info_count);
+    if (kr != KERN_SUCCESS) {
+        // Most likely cause: |task| is a zombie.
+        return -1;
+    }
+
+    mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT;
+    kr = task_info(task,
+            TASK_BASIC_INFO_64,
+            (task_info_t)&task_info_data,
+            &count);
+    if (kr != KERN_SUCCESS) {
+        // Most likely cause: |task| is a zombie.
+        return -1;
+    }
+
+    /* Set total_time. */
+    // thread info contains live time...
+    TIME_VALUE_TO_TIMEVAL(&thread_info_data.user_time, &user_timeval);
+    TIME_VALUE_TO_TIMEVAL(&thread_info_data.system_time, &system_timeval);
+    timeradd(&user_timeval, &system_timeval, &task_timeval);
+
+    // ... task info contains terminated time.
+    TIME_VALUE_TO_TIMEVAL(&task_info_data.user_time, &user_timeval);
+    TIME_VALUE_TO_TIMEVAL(&task_info_data.system_time, &system_timeval);
+    timeradd(&user_timeval, &task_timeval, &task_timeval);
+    timeradd(&system_timeval, &task_timeval, &task_timeval);
+
+    if (gettimeofday(&now, NULL) < 0) {
+       return -1;
+    }
+    jint ncpus      = JVM_ActiveProcessorCount();
+    jlong time      = TIME_VALUE_TO_MICROSECONDS(now) * ncpus;
+    jlong task_time = TIME_VALUE_TO_MICROSECONDS(task_timeval);
+
+    if ((last_task_time == 0) || (last_time == 0)) {
+        // First call, just set the last values.
+        last_task_time = task_time;
+        last_time      = time;
+        // return 0 since we have no data, not -1 which indicates error
+        return 0;
+    }
+
+    jlong task_time_delta = task_time - last_task_time;
+    jlong time_delta      = time - last_time;
+    if (time_delta == 0) {
+        return -1;
+    }
+
+    jdouble cpu = (jdouble) task_time_delta / time_delta;
+
+    last_task_time = task_time;
+    last_time      = time;
+
+    return cpu;
+ }
--- a/jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c	Wed Jul 05 18:09:02 2017 +0200
@@ -34,6 +34,13 @@
 #include <sys/stat.h>
 #if defined(_ALLBSD_SOURCE)
 #include <sys/sysctl.h>
+#ifdef __APPLE__
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <mach/mach.h>
+#include <sys/proc_info.h>
+#include <libproc.h>
+#endif
 #else
 #include <sys/swap.h>
 #endif
@@ -150,6 +157,13 @@
     avail = (jlong)si.freeswap * si.mem_unit;
 
     return available ? avail : total;
+#elif defined(__APPLE__)
+    struct xsw_usage vmusage;
+    size_t size = sizeof(vmusage);
+    if (sysctlbyname("vm.swapusage", &vmusage, &size, NULL, 0) != 0) {
+        throw_internal_error(env, "sysctlbyname failed");
+    }
+    return available ? (jlong)vmusage.xsu_avail : (jlong)vmusage.xsu_total;
 #else /* _ALLBSD_SOURCE */
     /*
      * XXXBSD: there's no way available to get swap info in
@@ -216,6 +230,15 @@
 
     fclose(fp);
     return (jlong)vsize;
+#elif defined(__APPLE__)
+    struct task_basic_info t_info;
+    mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
+
+    kern_return_t res = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
+    if (res != KERN_SUCCESS) {
+        throw_internal_error(env, "task_info failed");
+    }
+    return t_info.virtual_size;
 #else /* _ALLBSD_SOURCE */
     /*
      * XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
@@ -243,6 +266,17 @@
 Java_com_sun_management_UnixOperatingSystem_getProcessCpuTime
   (JNIEnv *env, jobject mbean)
 {
+#ifdef __APPLE__
+    struct rusage usage;
+    if (getrusage(RUSAGE_SELF, &usage) != 0) {
+        throw_internal_error(env, "getrusage failed");
+        return -1;
+    }
+    jlong microsecs =
+        usage.ru_utime.tv_sec * 1000 * 1000 + usage.ru_utime.tv_usec +
+        usage.ru_stime.tv_sec * 1000 * 1000 + usage.ru_stime.tv_usec;
+    return microsecs * 1000;
+#else
     jlong clk_tck, ns_per_clock_tick;
     jlong cpu_time_ns;
     struct tms time;
@@ -267,19 +301,32 @@
     cpu_time_ns = ((jlong)time.tms_utime + (jlong) time.tms_stime) *
                       ns_per_clock_tick;
     return cpu_time_ns;
+#endif
 }
 
 JNIEXPORT jlong JNICALL
 Java_com_sun_management_UnixOperatingSystem_getFreePhysicalMemorySize
   (JNIEnv *env, jobject mbean)
 {
-#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+    mach_msg_type_number_t count;
+    vm_statistics_data_t vm_stats;
+    kern_return_t res;
+
+    count = HOST_VM_INFO_COUNT;
+    res = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vm_stats, &count);
+    if (res != KERN_SUCCESS) {
+        throw_internal_error(env, "host_statistics failed");
+        return -1;
+    }
+    return (jlong)vm_stats.free_count * page_size;
+#elif defined(_ALLBSD_SOURCE)
     /*
      * XXBSDL no way to do it in FreeBSD
      */
     // throw_internal_error(env, "unimplemented in FreeBSD")
     return (128 * MB);
-#else
+#else // solaris / linux
     jlong num_avail_physical_pages = sysconf(_SC_AVPHYS_PAGES);
     return (num_avail_physical_pages * page_size);
 #endif
@@ -290,28 +337,75 @@
   (JNIEnv *env, jobject mbean)
 {
 #ifdef _ALLBSD_SOURCE
-    jlong result;
+    jlong result = 0;
     int mib[2];
     size_t rlen;
 
     mib[0] = CTL_HW;
-    mib[1] = HW_PHYSMEM;
+    mib[1] = HW_MEMSIZE;
     rlen = sizeof(result);
-    if (sysctl(mib, 2, &result, &rlen, NULL, 0) == -1)
-        result = 256 * MB;
-
-    return (result);
-#else
+    if (sysctl(mib, 2, &result, &rlen, NULL, 0) != 0) {
+        throw_internal_error(env, "sysctl failed");
+        return -1;
+    }
+    return result;
+#else // solaris / linux
     jlong num_physical_pages = sysconf(_SC_PHYS_PAGES);
     return (num_physical_pages * page_size);
 #endif
 }
 
+
+
 JNIEXPORT jlong JNICALL
 Java_com_sun_management_UnixOperatingSystem_getOpenFileDescriptorCount
   (JNIEnv *env, jobject mbean)
 {
-#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+    // This code is influenced by the darwin lsof source
+    pid_t my_pid;
+    struct proc_bsdinfo bsdinfo;
+    struct proc_fdinfo *fds;
+    int nfiles;
+    kern_return_t kres;
+    int res;
+    size_t fds_size;
+
+    kres = pid_for_task(mach_task_self(), &my_pid);
+    if (res != KERN_SUCCESS) {
+        throw_internal_error(env, "pid_for_task failed");
+        return -1;
+    }
+
+    // get the maximum number of file descriptors
+    res = proc_pidinfo(my_pid, PROC_PIDTBSDINFO, 0, &bsdinfo, PROC_PIDTBSDINFO_SIZE);
+    if (res <= 0) {
+        throw_internal_error(env, "proc_pidinfo with PROC_PIDTBSDINFO failed");
+        return -1;
+    }
+
+    // allocate memory to hold the fd information (we don't acutally use this information
+    // but need it to get the number of open files)
+    fds_size = bsdinfo.pbi_nfiles * sizeof(struct proc_fdinfo);
+    fds = malloc(fds_size);
+    if (fds == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "could not allocate space for file descriptors");
+        return -1;
+    }
+
+    // get the list of open files - the return value is the number of bytes
+    // proc_pidinfo filled in
+    res = proc_pidinfo(my_pid, PROC_PIDLISTFDS, 0, fds, fds_size);
+    if (res <= 0) {
+        free(fds);
+        throw_internal_error(env, "proc_pidinfo failed for PROC_PIDLISTFDS");
+        return -1;
+    }
+    nfiles = res / sizeof(struct proc_fdinfo);
+    free(fds);
+
+    return nfiles;
+#elif defined(_ALLBSD_SOURCE)
     /*
      * XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
      */
--- a/jdk/src/solaris/native/sun/awt/fontpath.c	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/solaris/native/sun/awt/fontpath.c	Wed Jul 05 18:09:02 2017 +0200
@@ -583,9 +583,6 @@
 }
 
 #include <dlfcn.h>
-#if !(defined(__linux__) || defined(MACOSX))
-#include <link.h>
-#endif
 
 #include "fontconfig.h"
 
--- a/jdk/src/solaris/native/sun/java2d/opengl/OGLFuncs_md.h	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/solaris/native/sun/java2d/opengl/OGLFuncs_md.h	Wed Jul 05 18:09:02 2017 +0200
@@ -28,7 +28,7 @@
 
 #include <stdlib.h>
 #ifndef MACOSX
-#include <link.h>
+#include <dlfcn.h>
 #endif
 #include "jvm_md.h"
 #include "J2D_GL/glx.h"
--- a/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c	Wed Jul 05 18:09:02 2017 +0200
@@ -70,7 +70,6 @@
 
 #ifdef __solaris__
 /* Solaris 10 will not have these symbols at runtime */
-#include <link.h>
 
 typedef Picture (*XRenderCreateLinearGradientFuncType)
                                      (Display *dpy,
--- a/jdk/test/ProblemList.txt	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/ProblemList.txt	Wed Jul 05 18:09:02 2017 +0200
@@ -161,6 +161,26 @@
 # Need to be marked othervm, or changed to be samevm safe
 com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java generic-all
 
+# 7162111
+demo/jvmti/mtrace/TraceJFrame.java                              macosx-all
+javax/script/CauseExceptionTest.java                            macosx-all
+javax/script/GetInterfaceTest.java                              macosx-all
+javax/script/JavaScriptScopeTest.java                           macosx-all
+javax/script/NullUndefinedVarTest.java                          macosx-all
+javax/script/PluggableContextTest.java                          macosx-all
+javax/script/ProviderTest.sh                                    macosx-all
+javax/script/RhinoExceptionTest.java                            macosx-all
+javax/script/StringWriterPrintTest.java                         macosx-all
+javax/script/Test1.java                                         macosx-all
+javax/script/Test2.java                                         macosx-all
+javax/script/Test3.java                                         macosx-all
+javax/script/Test4.java                                         macosx-all
+javax/script/Test5.java                                         macosx-all
+javax/script/Test6.java                                         macosx-all
+javax/script/Test7.java                                         macosx-all
+javax/script/Test8.java                                         macosx-all
+javax/script/UnescapedBracketRegExTest.java                     macosx-all
+javax/script/VersionTest.java                                   macosx-all
 ############################################################################
 
 # jdk_net
@@ -202,6 +222,8 @@
 sun/net/www/protocol/http/B6299712.java                         macosx-all
 java/net/CookieHandler/CookieManagerTest.java                   macosx-all
 
+# JPRT needs to set 127.0.0.1 in proxy bypass list
+java/net/URLClassLoader/closetest/CloseTest.java                macosx-all
 ############################################################################
 
 # jdk_io
@@ -252,6 +274,9 @@
 # 7132247
 java/rmi/registry/readTest/readTest.sh				windows-all
 
+# 7142596
+java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java generic-all
+
 ############################################################################
 
 # jdk_security
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh	Wed Jul 05 18:09:02 2017 +0200
@@ -83,6 +83,13 @@
        total_swap=`free -b | grep -i swap | awk '{print $2}'`
        runOne GetTotalSwapSpaceSize $total_swap 
        ;;
+     Darwin )
+       # $ sysctl -n vm.swapusage 
+       # total = 8192.00M  used = 7471.11M  free = 720.89M  (encrypted)
+       swap=`/usr/sbin/sysctl -n vm.swapusage | awk '{ print $3 }' | awk -F . '{ print $1 }'` || exit 2
+       total_swap=`expr $swap \* 1024 \* 1024` || exit 2
+       runOne GetTotalSwapSpaceSize $total_swap
+       ;;
     * )
        runOne GetTotalSwapSpaceSize "sanity-only"
        ;;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/zipfs/ZFSTests.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7156873
+   @summary ZipFileSystem regression tests
+ */
+
+
+import java.net.URI;
+import java.nio.file.*;
+import java.util.Map;
+import java.util.HashMap;
+
+public class ZFSTests {
+
+    public static void main(String[] args) throws Throwable {
+        test7156873();
+    }
+
+    static void test7156873() throws Throwable {
+        String DIRWITHSPACE = "testdir with spaces";
+        Path dir = Paths.get(DIRWITHSPACE);
+        Path path = Paths.get(DIRWITHSPACE, "file.zip");
+        try {
+            Files.createDirectory(dir);
+            URI uri = URI.create("jar:" + path.toUri());
+            Map<String, Object> env = new HashMap<String, Object>();
+            env.put("create", "true");
+            try (FileSystem fs = FileSystems.newFileSystem(uri, env)) {}
+        } finally {
+            Files.deleteIfExists(path);
+            Files.deleteIfExists(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Component/7097771/bug7097771.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import sun.awt.SunToolkit;
+import test.java.awt.regtesthelpers.Util;
+
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Frame;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+/*
+  @test
+  @bug 7097771
+  @summary setEnabled does not work for components in disabled containers.
+  @author sergey.bylokhov@oracle.com: area=awt.component
+  @library ../../regtesthelpers
+  @build Util
+  @run main bug7097771
+*/
+public final class bug7097771 extends Frame implements ActionListener {
+
+    private static volatile boolean action;
+
+    public static void main(final String[] args) throws AWTException {
+        final bug7097771 frame = new bug7097771();
+        frame.setSize(300, 300);
+        frame.setLocationRelativeTo(null);
+        final Button button = new Button();
+        button.addActionListener(frame);
+        frame.add(button);
+        frame.setVisible(true);
+        sleep();
+        frame.setEnabled(false);
+        button.setEnabled(false);
+        button.setEnabled(true);
+        sleep();
+        Util.clickOnComp(button, new Robot());
+        sleep();
+        frame.dispose();
+        if (action) {
+            throw new RuntimeException("Button is not disabled.");
+        }
+    }
+
+    @Override
+    public void actionPerformed(final ActionEvent e) {
+        action = true;
+    }
+
+    private static void sleep() {
+        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        try {
+            Thread.sleep(1000);
+        } catch (InterruptedException ignored) {
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/TestWrapped.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * test
+ * @bug 6282388
+ * @summary Tests that AWT use correct toolkit to be wrapped into HeadlessToolkit
+ * @author artem.ananiev@sun.com: area=awt.headless
+ * @run shell WrappedToolkitTest.sh
+ */
+
+import java.awt.*;
+
+import java.lang.reflect.*;
+
+import sun.awt.*;
+
+public class TestWrapped
+{
+    public static void main(String[] args)
+    {
+        try
+        {
+        if (args.length != 1) {
+            System.err.println("No correct toolkit class name is specified, test is not run");
+            System.exit(0);
+        }
+
+        String correctToolkitClassName = args[0];
+        Toolkit tk = Toolkit.getDefaultToolkit();
+        Class tkClass = tk.getClass();
+        if (!tkClass.getName().equals("sun.awt.HeadlessToolkit"))
+        {
+            System.err.println(tkClass.getName());
+            System.err.println("Error: default toolkit is not an instance of HeadlessToolkit");
+            System.exit(-1);
+        }
+
+        Field f = tkClass.getDeclaredField("tk");
+        f.setAccessible(true);
+        Class wrappedClass = f.get(tk).getClass();
+        if (!wrappedClass.getName().equals(correctToolkitClassName)) {
+            System.err.println(wrappedClass.getName());
+            System.err.println("Error: wrapped toolkit is not an instance of " + correctToolkitClassName);
+            System.exit(-1);
+        }
+        }
+        catch (Exception z)
+        {
+            z.printStackTrace(System.err);
+            System.exit(-1);
+        }
+
+        System.exit(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,179 @@
+#!/bin/ksh -p
+
+#
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+#   @test
+#   @bug 6282388
+#   @summary Tests that AWT use correct toolkit to be wrapped into HeadlessToolkit
+#   @author artem.ananiev@sun.com: area=awt.headless
+#   @compile TestWrapped.java
+#   @run shell WrappedToolkitTest.sh
+
+# Beginning of subroutines:
+status=1
+
+#Call this from anywhere to fail the test with an error message
+# usage: fail "reason why the test failed"
+fail() 
+ { echo "The test failed :-("
+   echo "$*" 1>&2
+   echo "exit status was $status"
+   exit $status
+ } #end of fail()
+
+#Call this from anywhere to pass the test with a message
+# usage: pass "reason why the test passed if applicable"
+pass() 
+ { echo "The test passed!!!"
+   echo "$*" 1>&2
+   exit 0
+ } #end of pass()
+
+# end of subroutines
+
+
+# The beginning of the script proper
+
+# Checking for proper OS
+OS=`uname -s`
+case "$OS" in
+   SunOS )
+      VAR="One value for Sun"
+      DEFAULT_JDK=/usr/local/java/jdk1.2/solaris
+      FILESEP="/"
+      ;;
+
+   Linux )
+      VAR="A different value for Linux"
+      DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386
+      FILESEP="/"
+      ;;
+
+   Windows* | CYGWIN* )
+      VAR="A different value for Win32"
+      DEFAULT_JDK=/usr/local/java/jdk1.2/win32
+      FILESEP="\\"
+      ;;
+
+   # catch all other OSs
+   * )
+      echo "Unrecognized system!  $OS"
+      fail "Unrecognized system!  $OS"
+      ;;
+esac
+
+# check that some executable or other file you need is available, abort if not
+#  note that the name of the executable is in the fail string as well.
+# this is how to check for presence of the compiler, etc.
+#RESOURCE=`whence SomeProgramOrFileNeeded`
+#if [ "${RESOURCE}" = "" ] ; 
+#   then fail "Need SomeProgramOrFileNeeded to perform the test" ; 
+#fi
+
+# Want this test to run standalone as well as in the harness, so do the 
+#  following to copy the test's directory into the harness's scratch directory 
+#  and set all appropriate variables:
+
+if [ -z "${TESTJAVA}" ] ; then
+   # TESTJAVA is not set, so the test is running stand-alone.
+   # TESTJAVA holds the path to the root directory of the build of the JDK
+   # to be tested.  That is, any java files run explicitly in this shell
+   # should use TESTJAVA in the path to the java interpreter.
+   # So, we'll set this to the JDK spec'd on the command line.  If none
+   # is given on the command line, tell the user that and use a cheesy
+   # default.
+   # THIS IS THE JDK BEING TESTED.
+   if [ -n "$1" ] ;
+      then TESTJAVA=$1
+      else echo "no JDK specified on command line so using default!"
+     TESTJAVA=$DEFAULT_JDK
+   fi
+   TESTSRC=.
+   TESTCLASSES=.
+   STANDALONE=1;
+fi
+echo "JDK under test is: $TESTJAVA"
+
+#Deal with .class files:
+if [ -n "${STANDALONE}" ] ; then
+   # then compile all .java files (if there are any) into .class files
+   if [ -a *.java ]; then
+      ${TESTJAVA}/bin/javac$ ./*.java ;
+   fi
+   # else in harness so copy all the class files from where jtreg put them
+   # over to the scratch directory this test is running in. 
+   else cp ${TESTCLASSES}/*.class . ;
+fi
+
+#if in test harness, then copy the entire directory that the test is in over 
+# to the scratch directory.  This catches any support files needed by the test.
+if [ -z "${STANDALONE}" ] ; 
+   then cp ${TESTSRC}/* . 
+fi
+
+#Just before executing anything, make sure it has executable permission!
+chmod 777 ./*
+
+###############  YOUR TEST CODE HERE!!!!!!!  #############
+
+case "$OS" in
+  Windows* | CYGWIN* )
+    ${TESTJAVA}/bin/java -Djava.awt.headless=true \
+                         TestWrapped sun.awt.windows.WToolkit
+    status=$?
+    if [ ! $status -eq "0" ]; then
+      fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.windows.WToolkit";
+    fi
+    ${TESTJAVA}/bin/java -Djava.awt.headless=true \
+                         -Dawt.toolkit=sun.awt.windows.WToolkit \
+                         TestWrapped sun.awt.windows.WToolkit
+    status=$?
+    if [ ! $status -eq "0" ]; then
+      fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.windows.WToolkit";
+    fi
+    ;;
+
+  SunOS | Linux )
+    ${TESTJAVA}/bin/java -Djava.awt.headless=true \
+                         -Dawt.toolkit=sun.awt.X11.XToolkit \
+                         TestWrapped sun.awt.X11.XToolkit
+    status=$?
+    if [ ! $status -eq "0" ]; then
+      fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.xawt.XToolkit";
+    fi
+    AWT_TOOLKIT=XToolkit ${TESTJAVA}/bin/java -Djava.awt.headless=true \
+                                              TestWrapped sun.awt.X11.XToolkit
+    status=$?
+    if [ ! $status -eq "0" ]; then
+      fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.xawt.XToolkit";
+    fi
+    ;;
+
+esac
+
+pass "All the tests are PASSED";
+
+#For additional examples of how to write platform independent KSH scripts,
+# see the jtreg file itself.  It is a KSH script for both Solaris and Win32
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7146431
+ * @summary Test that internal JAXP packages cannot be accessed
+ */
+
+public class CheckPackageAccess {
+
+    public static void main(String[] args) throws Exception {
+
+        String[] pkgs = new String[] {
+            "com.sun.org.apache.xerces.internal.utils.",
+            "com.sun.org.apache.xalan.internal.utils." };
+        SecurityManager sm = new SecurityManager();
+        System.setSecurityManager(sm);
+        for (String pkg : pkgs) {
+            System.out.println("Checking package access for " + pkg);
+            try {
+                sm.checkPackageAccess(pkg);
+                throw new Exception("Expected SecurityException not thrown");
+            } catch (SecurityException se) { }
+        }
+    }
+}
--- a/jdk/test/java/nio/channels/Selector/OpRead.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/java/nio/channels/Selector/OpRead.java	Wed Jul 05 18:09:02 2017 +0200
@@ -58,7 +58,10 @@
             boolean done = false;
             int failCount = 0;
             while (!done) {
-                if (selector.select() > 0) {
+                int nSelected = selector.select();
+                if (nSelected > 0) {
+                    if (nSelected > 1)
+                        throw new RuntimeException("More than one channel selected");
                     Set<SelectionKey> keys = selector.selectedKeys();
                     Iterator<SelectionKey> iterator = keys.iterator();
                     while (iterator.hasNext()) {
--- a/jdk/test/java/nio/charset/coders/StreamTimeout.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/java/nio/charset/coders/StreamTimeout.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -27,51 +27,56 @@
  *          when the underlying byte stream times out
  */
 
-import java.net.*;
-import java.io.*;
-
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.InterruptedIOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.ServerSocket;
+import java.net.Socket;
 
 public class StreamTimeout {
+    static final PrintStream log = System.err;
+    static String charset = "US-ASCII";
 
-    private static PrintStream log = System.err;
-
-    private static String charset = "US-ASCII";
+    private static class Client extends Thread implements Closeable {
+        private final Socket so;
 
-    private static Object lock = new Object();
-    private static synchronized void waitABit(int millisec) {
-        synchronized(lock) {
-            try {
-                lock.wait(millisec);
-            } catch (InterruptedException e) {
-                //ignore
-            }
+        Client(int port) throws IOException {
+            so = new Socket("127.0.0.1", port);
         }
-    }
 
-    private static class Client extends Thread {
+        @Override
         public void run() {
             try {
-                Socket so = new Socket("127.0.0.1", 22222);
                 Writer wr = new OutputStreamWriter(so.getOutputStream(),
-                                                   charset);
+                        charset);
                 wr.write("ab");
                 wr.flush();
             } catch (IOException x) {
                 log.print("Unexpected exception in writer: ");
                 x.printStackTrace();
-                System.exit(1);
             }
         }
+
+        @Override
+        public void close() throws IOException {
+            so.close();
+        }
     }
 
     private static void gobble(InputStream is, Reader rd,
-                               int ec, boolean force)
-        throws Exception
-    {
+            int ec, boolean force)
+                    throws Exception
+                    {
         int a = is.available();
         boolean r = rd.ready();
         log.print("" + a + " bytes available, "
-                  + "reader " + (r ? "" : "not ") + "ready");
+                + "reader " + (r ? "" : "not ") + "ready");
         if (!r && !force) {
             log.println();
             return;
@@ -84,10 +89,10 @@
             throw x;
         }
         log.println(", read() ==> "
-                    + (c >= 0 ? ("'" + (char)c + "'" ): "EOF"));
+                + (c >= 0 ? ("'" + (char)c + "'" ): "EOF"));
         if (c != ec)
             throw new Exception("Incorrect value read: Expected "
-                                + ec + ", read " + (char)c);
+                    + ec + ", read " + (char)c);
     }
 
     public static void main(String[] args) throws Exception {
@@ -95,43 +100,49 @@
         if (args.length > 0)
             charset = args[0];
 
-        ServerSocket ss = new ServerSocket(22222);
-        Thread cl = new Client();
-        cl.start();
-        Socket s = ss.accept();
-        s.setSoTimeout(150);
-        InputStream is = s.getInputStream();
-        Reader rd = new InputStreamReader(is, charset);
+        try(ServerSocket ss = new ServerSocket(0);
+            Client cl = new Client(ss.getLocalPort())) {
+
+            cl.start();
+
+            try(Socket s = ss.accept()) {
+                s.setSoTimeout(150);
 
-        while (is.available() <= 0)
-            Thread.yield();
+                try(InputStream is = s.getInputStream();
+                    Reader rd = new InputStreamReader(is, charset)) {
 
-        gobble(is, rd, 'a', false);
-        gobble(is, rd, 'b', false);
-        gobble(is, rd, -1, false);
+                    while (is.available() <= 0)
+                        Thread.yield();
+
+                    gobble(is, rd, 'a', false);
+                    gobble(is, rd, 'b', false);
+                    gobble(is, rd, -1, false);
 
-        boolean caught = false;
-        try {
-            gobble(is, rd, -1, true);
-        } catch (InterruptedIOException e) {
-            log.println("Read timed out, as expected");
-            caught = true;
-        }
-        if (!caught) {
-            log.println("Read did not time out, test inapplicable");
-            return;
-        }
+                    boolean caught = false;
+                    try {
+                        gobble(is, rd, -1, true);
+                    } catch (InterruptedIOException e) {
+                        log.println("Read timed out, as expected");
+                        caught = true;
+                    }
+                    if (!caught) {
+                        log.println("Read did not time out, test inapplicable");
+                        return;
+                    }
 
-        caught = false;
-        try {
-            gobble(is, rd, -1, true);
-        } catch (InterruptedIOException x) {
-            log.println("Second read timed out, as expected");
-            caught = true;
+                    caught = false;
+                    try {
+                        gobble(is, rd, -1, true);
+                    } catch (InterruptedIOException x) {
+                        log.println("Second read timed out, as expected");
+                        caught = true;
+                    }
+                    if (!caught)
+                        throw new Exception("Second read completed");
+                }
+            }
+
+            cl.join();
         }
-        if (!caught)
-            throw new Exception("Second read completed");
-
     }
-
 }
--- a/jdk/test/java/security/CodeSource/Implies.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/java/security/CodeSource/Implies.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,25 +23,42 @@
 
 /*
  * @test
- * @bug 4866847
- * @summary NullPointerException from CodeSource.matchLocation
+ * @bug 4866847 7152564 7155693
+ * @summary various CodeSource.implies tests
  */
 
 import java.security.CodeSource;
-import java.net.*;
+import java.net.URL;
 
 public class Implies {
     public static void main(String[] args) throws Exception {
         URL thisURL = new URL("http", "localhost", "file");
         URL thatURL = new URL("http", null, "file");
+        // should not throw NullPointerException
+        testImplies(thisURL, thatURL, false);
+
+        thisURL = new URL("http", "localhost", "dir/-");
+        thatURL = new URL("HTTP", "localhost", "dir/file");
+        // protocol check should ignore case
+        testImplies(thisURL, thatURL, true);
+
+        thisURL = new URL("http", "localhost", 80, "dir/-");
+        thatURL = new URL("HTTP", "localhost", "dir/file");
+        // port check should match default port of thatURL
+        testImplies(thisURL, thatURL, true);
+
+        System.out.println("test passed");
+    }
+
+    private static void testImplies(URL thisURL, URL thatURL, boolean result)
+        throws SecurityException
+    {
         CodeSource thisCs =
             new CodeSource(thisURL, (java.security.cert.Certificate[]) null);
         CodeSource thatCs =
             new CodeSource(thatURL, (java.security.cert.Certificate[]) null);
-
-        if (thisCs.implies(thatCs)) {
+        if (thisCs.implies(thatCs) != result) {
             throw new SecurityException("test failed");
         }
-        System.out.println("test passed");
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/AbstractCollection/ToArrayTest.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7121314
+ * @summary AbstractCollection.toArray(T[]) doesn't return the given array
+ *           in concurrent modification.
+ * @author Ulf Zibis, David Holmes
+ */
+
+import java.util.AbstractCollection;
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class ToArrayTest {
+
+    static class TestCollection<E> extends AbstractCollection<E> {
+        private final E[] elements;
+        private int[] sizes;
+        private int nextSize;
+
+        public TestCollection(E[] elements) {
+            this.elements = elements;
+            setSizeSequence(new int[] { elements.length });
+        }
+
+        /*
+         * Sets the values that size() will return on each use. The next
+         * call to size will return sizes[0], then sizes[1] etc. This allows us
+         * to emulate a concurrent change to the contents of the collection
+         * without having to perform concurrent changes. If sizes[n+1] contains
+         * a larger value, the collection will appear to have shrunk when
+         * iterated; if a smaller value then the collection will appear to have
+         * grown when iterated.
+         */
+        void setSizeSequence(int... sizes) {
+            this.sizes = sizes;
+            nextSize = 0;
+        }
+
+        /* can change collection's size after each invocation */
+        @Override
+        public int size() {
+            return sizes[nextSize == sizes.length - 1 ? nextSize : nextSize++];
+        }
+
+        @Override
+        public Iterator<E> iterator() {
+            return new Iterator<E>() {
+                int pos = 0;
+
+                public boolean hasNext() {
+                    return pos < sizes[nextSize];
+                }
+                public E next() {
+                    return elements[pos++];
+                }
+                public void remove() {
+                    throw new UnsupportedOperationException(
+                            "Not supported yet.");
+                }
+            };
+        }
+    }
+
+    static final Object[] OBJECTS = { new Object(), new Object(), new Object() };
+    static final TestCollection<?> CANDIDATE = new TestCollection<Object>(OBJECTS);
+    static final int CAP = OBJECTS.length; // capacity of the CANDIDATE
+    static final int LAST = CAP - 1; // last possible array index
+    Object[] a;
+    Object[] res;
+
+    int last() {
+        return a.length - 1;
+    }
+
+    protected void test() throws Throwable {
+        // Check array type conversion
+        res = new TestCollection<>(new Object[] { "1", "2" }).toArray(new String[0]);
+        check(res instanceof String[]);
+        check(res.length == 2);
+        check(res[1] == "2");
+
+        // Check incompatible type of target array
+        try {
+            res = CANDIDATE.toArray(new String[CAP]);
+            check(false);
+        } catch (Throwable t) {
+            check(t instanceof ArrayStoreException);
+        }
+
+        // Check more elements than a.length
+        a = new Object[CAP - 1]; // appears too small
+        res = CANDIDATE.toArray(a);
+        check(res != a);
+        check(res[LAST] != null);
+
+        // Check equal elements as a.length
+        a = new Object[CAP]; // appears to match
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] != null);
+
+        // Check equal elements as a.length
+        a = new Object[CAP + 1]; // appears too big
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] == null);
+
+        // Check less elements than expected, but more than a.length
+        a = new Object[CAP - 2]; // appears too small
+        CANDIDATE.setSizeSequence(CAP, CAP - 1);
+        res = CANDIDATE.toArray(a);
+        check(res != a);
+        check(res.length == CAP - 1);
+        check(res[LAST - 1] != null);
+
+        // Check less elements than expected, but equal as a.length
+        a = Arrays.copyOf(OBJECTS, CAP); // appears to match
+        CANDIDATE.setSizeSequence(CAP, CAP - 1);
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] == null);
+
+        // Check more elements than expected and more than a.length
+        a = new Object[CAP - 1]; // appears to match
+        CANDIDATE.setSizeSequence(CAP - 1, CAP);
+        res = CANDIDATE.toArray(a);
+        check(res != a);
+        check(res[LAST] != null);
+
+        // Check more elements than expected, but equal as a.length
+        a = new Object[CAP - 1]; // appears to match
+        CANDIDATE.setSizeSequence(CAP - 2, CAP - 1);
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] != null);
+
+        // Check more elements than expected, but less than a.length
+        a = Arrays.copyOf(OBJECTS, CAP); // appears to match
+        CANDIDATE.setSizeSequence(CAP - 2, CAP - 1);
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] == null);
+
+        test_7121314();
+    }
+
+    /*
+     * Major target of this testcase, bug 7121314.
+     */
+    protected void test_7121314() throws Throwable {
+        // Check equal elements as a.length, but less than expected
+        a = new Object[CAP - 1]; // appears too small
+        CANDIDATE.setSizeSequence(CAP, CAP - 1);
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] != null);
+
+        // Check less elements than a.length and less than expected
+        a = Arrays.copyOf(OBJECTS, CAP - 1); // appears too small
+        CANDIDATE.setSizeSequence(CAP, CAP - 2);
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] == null);
+
+    }
+
+    public static void main(String[] args) throws Throwable {
+        ToArrayTest testcase = new ToArrayTest();
+        try {
+            testcase.test();
+        } catch (Throwable t) {
+            unexpected(t);
+        }
+
+        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+        if (failed > 0) throw new Exception("Some tests failed");
+    }
+
+    //--------------------- 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 equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else {System.out.println(x + " not equal to " + y); fail(); }
+    }
+}
+
+
--- a/jdk/test/java/util/regex/RegExTest.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/java/util/regex/RegExTest.java	Wed Jul 05 18:09:02 2017 +0200
@@ -33,6 +33,7 @@
  * 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
  * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
  * 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
+ * 7067045
  */
 
 import java.util.regex.*;
@@ -852,6 +853,17 @@
         if (!result.equals(toSupplementaries("zzz\\t$\\$zzz")))
             failCount++;
 
+        // IAE should be thrown if backslash or '$' is the last character
+        // in replacement string
+        try {
+            "\uac00".replaceAll("\uac00", "$");
+            "\uac00".replaceAll("\uac00", "\\");
+            failCount++;
+        } catch (IllegalArgumentException iie) {
+        } catch (Exception e) {
+            failCount++;
+        }
+
         report("Literal replacement");
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/DirectAudio/bug6400879.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2006, 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.  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.
+ */
+
+/* @test
+   @bug 6400879
+   @bug 7100140
+   @summary Tests that Start/Stop sequence doesn't hang
+   @author Alexey Menkov
+   @run main bug6400879
+ */
+
+import javax.sound.sampled.*;
+
+public class bug6400879 extends Thread {
+
+    public static void main(String args[]) throws Exception {
+        bug6400879 pThis = new bug6400879();
+        //pThis.init();
+        pThis.setDaemon(true);
+        pThis.start();
+        monitor(pThis);
+    }
+
+    static final long BLOCK_TIMEOUT = 5000;    // 5 sec
+
+    // monitors that pThis doesn't hang
+    public static void monitor(bug6400879 pThis) throws Exception {
+        long prevLoop = -1;
+        long prevTime = currentTimeMillis();
+        while (pThis.isAlive()) {
+            if (pThis.loopCounter == prevLoop) {
+                if (currentTimeMillis() - prevTime > BLOCK_TIMEOUT) {
+                    // block!
+                    log("Test FAILED.");
+                    throw new RuntimeException("Test FAILED: thread has been blocked!");
+                }
+            } else {
+                prevLoop = pThis.loopCounter;
+                prevTime = currentTimeMillis();
+            }
+            delay(500);    // sleep for 0.5 sec
+        }
+        log("Test sucessfully passed.");
+    }
+
+    volatile long loopCounter = 0;
+    final long LOOPS_PER_LINE = 100;
+
+    public void run() {
+        SourceDataLine line = null;
+
+        DataLine.Info line_info = new DataLine.Info(SourceDataLine.class, null);
+        Line.Info infos[] = AudioSystem.getSourceLineInfo(line_info);
+
+        log("total " + infos.length + " lines");
+
+        for (int lineNum = 0; lineNum < infos.length; lineNum++) {
+            try {
+                line = (SourceDataLine)AudioSystem.getLine(infos[lineNum]);
+                log("testing line: " + line);
+                line.open(line.getFormat());
+                for (int i=0; i<LOOPS_PER_LINE; i++) {
+                    log("start->stop (" + i + ")");
+                    line.start();
+                    line.stop();
+                    log(" - OK");
+                    loopCounter++;
+                }
+                line.close();
+                line = null;
+            } catch (LineUnavailableException e1) {
+                log("LineUnavailableException caught, test okay.");
+                log(e1.getMessage());
+            } catch (SecurityException e2) {
+                log("SecurityException caught, test okay.");
+                log(e2.getMessage());
+            } catch (IllegalArgumentException e3) {
+                log("IllegalArgumentException caught, test okay.");
+                log(e3.getMessage());
+            }
+            if (line != null) {
+                line.close();
+                line = null;
+            }
+        }
+
+    }
+
+
+    // helper routines
+    static long startTime = currentTimeMillis();
+    static long currentTimeMillis() {
+        //return System.nanoTime() / 1000000L;
+        return System.currentTimeMillis();
+    }
+    static void log(String s) {
+        long time = currentTimeMillis() - startTime;
+        long ms = time % 1000;
+        time /= 1000;
+        long sec = time % 60;
+        time /= 60;
+        long min = time % 60;
+        time /= 60;
+        System.out.println(""
+                + (time < 10 ? "0" : "") + time
+                + ":" + (min < 10 ? "0" : "") + min
+                + ":" + (sec < 10 ? "0" : "") + sec
+                + "." + (ms < 10 ? "00" : (ms < 100 ? "0" : "")) + ms
+                + " (" + Thread.currentThread().getName() + ") " + s);
+    }
+    static void delay(int millis) {
+        try {
+            Thread.sleep(millis);
+        } catch (InterruptedException e) {}
+    }
+}
--- a/jdk/test/javax/sound/sampled/FileWriter/AlawEncoderSync.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/javax/sound/sampled/FileWriter/AlawEncoderSync.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,6 +1,32 @@
+/*
+ * Copyright (c) 2010, 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.  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.
+ */
+
 /**
  * @test
  * @bug 6938426
+ * @bug 7058852
  * @summary Tests that Alaw encoder works properly in multithreaded environment
  * @author Alex Menkov
  */
@@ -34,7 +60,7 @@
             threads[i].start();
         }
 
-        for (int i=1; i<THREAD_COUNT; i++) {
+        for (int i=0; i<THREAD_COUNT; i++) {
             try {
                 threads[i].join();
             } catch (InterruptedException ex) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/border/Test7149090.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7149090
+   @summary Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
+   @author Pavel Porvatov
+*/
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Test7149090 {
+    private static final Object[][] DEFAULT_TITLE_POSITIONS = {
+            {"Metal", TitledBorder.TOP},
+            {"Motif", TitledBorder.TOP},
+            {"Windows", TitledBorder.TOP},
+            {"Nimbus", TitledBorder.ABOVE_TOP},
+    };
+
+    public static void main(String[] args) throws Exception {
+        for (UIManager.LookAndFeelInfo lookAndFeel : UIManager.getInstalledLookAndFeels()) {
+            for (Object[] defaultTitlePosition : DEFAULT_TITLE_POSITIONS) {
+                if (defaultTitlePosition[0].equals(lookAndFeel.getName())) {
+                    UIManager.setLookAndFeel(lookAndFeel.getClassName());
+
+                    final int expectedPosition = (Integer) defaultTitlePosition[1];
+
+                    SwingUtilities.invokeAndWait(new Runnable() {
+                        @Override
+                        public void run() {
+                            List<TitledBorder> borders = new ArrayList<>();
+
+                            borders.add(BorderFactory.createTitledBorder(new EmptyBorder(0, 0, 0, 0), "Title"));
+
+                            try {
+                                Method getPositionMethod = TitledBorder.class.getDeclaredMethod("getPosition");
+
+                                getPositionMethod.setAccessible(true);
+
+                                for (TitledBorder border : borders) {
+                                    int position = (Integer) getPositionMethod.invoke(border);
+
+                                    if (position != expectedPosition) {
+                                        throw new RuntimeException("Invalid title position");
+                                    }
+                                }
+                            } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
+                                throw new RuntimeException(e);
+                            }
+                        }
+                    });
+
+                    System.out.println("Test passed for LookAndFeel " + lookAndFeel.getName());
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/synth/7158712/bug7158712.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7158712
+   @summary Synth Property "ComboBox.popupInsets" is ignored
+   @library ../../../regtesthelpers
+   @author Pavel Porvatov
+*/
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicComboPopup;
+import javax.swing.plaf.synth.SynthLookAndFeel;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.io.ByteArrayInputStream;
+import java.util.concurrent.Callable;
+
+public class bug7158712 {
+    private static final String SYNTH_XML = "<synth>" +
+            "    <style id=\"all\">" +
+            "      <font name=\"Dialog\" size=\"12\"/>" +
+            "    </style>" +
+            "    <bind style=\"all\" type=\"REGION\" key=\".*\"/>" +
+            "    <style id=\"arrowButton\">" +
+            "      <property key=\"ArrowButton.size\" type=\"integer\" value=\"18\"/>" +
+            "    </style>" +
+            "    <bind style=\"arrowButton\" type=\"region\" key=\"ArrowButton\"/>" +
+            "    <style id=\"comboBox\">" +
+            "      <property key=\"ComboBox.popupInsets\" type=\"insets\" value=\"-5 -5 5 -5\"/>" +
+            "    </style>" +
+            "    <bind style=\"comboBox\" type=\"region\" key=\"ComboBox\"/>" +
+            "</synth>";
+
+    private static JComboBox<String> comboBox;
+
+    public static void main(String[] args) throws Exception {
+        Robot robot = new Robot();
+
+        robot.setAutoDelay(500);
+
+        SynthLookAndFeel laf = new SynthLookAndFeel();
+
+        laf.load(new ByteArrayInputStream(SYNTH_XML.getBytes("UTF8")), bug7158712.class);
+
+        UIManager.setLookAndFeel(laf);
+
+        EventQueue.invokeAndWait(new Runnable() {
+            public void run() {
+                comboBox = new JComboBox<>(
+                        new String[]{"Very Looooooooooooooooooooong Text Item 1", "Item 2"});
+
+                JFrame frame = new JFrame();
+
+                frame.add(comboBox, BorderLayout.NORTH);
+                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                frame.setSize(new Dimension(400, 300));
+                frame.setLocationRelativeTo(null);
+                frame.setVisible(true);
+            }
+        });
+
+        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+
+        Point comboBoxLocation = Util.invokeOnEDT(new Callable<Point>() {
+            @Override
+            public Point call() throws Exception {
+                return comboBox.getLocationOnScreen();
+            }
+        });
+
+        robot.mouseMove(comboBoxLocation.x, comboBoxLocation.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                BasicComboPopup popup = (BasicComboPopup) comboBox.getAccessibleContext().getAccessibleChild(0);
+
+                Point popupPoint = popup.getLocationOnScreen();
+                Point comboBoxPoint = comboBox.getLocationOnScreen();
+
+                if (comboBoxPoint.x - 5 != popupPoint.x ||
+                        comboBoxPoint.y + comboBox.getHeight() - 5 != popupPoint.y) {
+                    throw new RuntimeException("Invalid popup coordinates. Popup location: " + popupPoint +
+                            ", comboBox location: " + comboBoxPoint);
+                }
+
+                System.out.println("Test bug7158712 passed");
+            }
+        });
+    }
+}
--- a/jdk/test/javax/swing/regtesthelpers/Util.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java	Wed Jul 05 18:09:02 2017 +0200
@@ -24,8 +24,10 @@
 import javax.swing.*;
 import java.awt.*;
 import java.awt.image.BufferedImage;
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.Callable;
 
 /**
  * <p>This class contains utilities useful for regression testing.
@@ -153,4 +155,31 @@
             robot.keyRelease(keys[i]);
         }
     }
+
+    /**
+     * Invokes the <code>task</code> on the EDT thread.
+     *
+     * @return result of the <code>task</code>
+     */
+    public static <T> T invokeOnEDT(final Callable<T> task) throws Exception {
+        final List<T> result = new ArrayList<>(1);
+        final Exception[] exception = new Exception[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    result.add(task.call());
+                } catch (Exception e) {
+                    exception[0] = e;
+                }
+            }
+        });
+
+        if (exception[0] != null) {
+            throw exception[0];
+        }
+
+        return result.get(0);
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/AbstractDocument/7146146/bug7146146.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7146146
+   @summary Deadlock between subclass of AbstractDocument and UndoManager
+   @author Pavel Porvatov
+*/
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.PlainDocument;
+import javax.swing.text.StringContent;
+import javax.swing.undo.UndoManager;
+
+public class bug7146146 {
+    public static void main(String[] args) throws Exception {
+        for (int i = 0; i < 1000; i++) {
+            System.out.print("Iteration " + i);
+
+            test();
+
+            System.out.print(" passed");
+        }
+    }
+
+    private static void test() throws Exception {
+        final PlainDocument doc = new PlainDocument(new StringContent());
+        final UndoManager undoManager = new UndoManager();
+
+        doc.addUndoableEditListener(undoManager);
+        doc.insertString(0, "<Test 1>", null);
+
+        Thread t1 = new Thread("Thread 1") {
+            @Override
+            public void run() {
+                try {
+                    doc.insertString(0, "<Test 2>", null);
+                } catch (BadLocationException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        };
+
+        Thread t2 = new Thread("Thread 2") {
+            @Override
+            public void run() {
+                undoManager.undo();
+            }
+        };
+
+        t1.start();
+        t2.start();
+
+        t1.join();
+        t2.join();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/awt/image/ImageWatched/AddNoLeak.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.ImageConsumer;
+import java.awt.Image;
+import java.awt.Container;
+
+/* @test 1.0 12/01/17
+   @bug 7104151
+   @summary Make sure that we don't leak image observers (or related objects)
+   @run main/othervm AddNoLeak
+   @author David Buck
+*/
+
+public class AddNoLeak {
+    public static void main(String[] args) {
+        System.setProperty("java.awt.headless", "true");
+        Container cont = new Container();
+        Image img = cont.createImage(new DummyImageSource());
+        for(int i=0;i < 15000;i++) {
+            img.getWidth(new ImageObserver() {
+                public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {return false;}
+            });
+            if (i % 100 == 0) {
+                System.gc();
+            }
+        }
+    }
+
+    private static class DummyImageSource implements ImageProducer {
+        public void addConsumer(ImageConsumer ic){}
+        public boolean isConsumer(ImageConsumer ic){return false;}
+        public void removeConsumer(ImageConsumer ic){}
+        public void startProduction(ImageConsumer ic){}
+        public void requestTopDownLeftRightResend(ImageConsumer ic){}
+    }
+}
--- a/jdk/test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.java	Wed Jul 05 18:09:02 2017 +0200
@@ -54,8 +54,12 @@
     public SharedMemoryPixmapsTest() {
         testFrame = new Frame("SharedMemoryPixmapsTest");
         testFrame.add(new TestComponent());
+        testFrame.setUndecorated(true);
+        testFrame.setResizable(false);
         testFrame.pack();
+        testFrame.setLocationRelativeTo(null);
         testFrame.setVisible(true);
+        testFrame.toFront();
     }
 
     public static void main(String[] args) {
--- a/jdk/test/sun/net/www/protocol/jar/B4957695.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/sun/net/www/protocol/jar/B4957695.java	Wed Jul 05 18:09:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,6 @@
 /**
  * @test
  * @bug 4957695
- * @library ../../httptest/
- * @build HttpCallback HttpServer ClosedChannelList HttpTransaction AbstractCallback
  * @summary URLJarFile.retrieve does not delete tmpFile on IOException
  */
 
@@ -34,8 +32,56 @@
 
 public class B4957695 {
 
-    static int count = 0;
-    static boolean error = false;
+    static Server server;
+
+    static class Server extends Thread {
+        final ServerSocket srv;
+        static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n'};
+
+        Server(ServerSocket s) {
+            srv = s;
+        }
+
+        void readOneRequest(InputStream is) throws IOException {
+            int requestEndCount = 0, r;
+            while ((r = is.read()) != -1) {
+                if (r == requestEnd[requestEndCount]) {
+                    requestEndCount++;
+                    if (requestEndCount == 4) {
+                        break;
+                    }
+                } else {
+                    requestEndCount = 0;
+                }
+            }
+        }
+
+        public void run() {
+            try (Socket s = srv.accept()) {
+                // read HTTP request from client
+                readOneRequest(s.getInputStream());
+                try (OutputStreamWriter ow =
+                     new OutputStreamWriter((s.getOutputStream()))) {
+                    FileInputStream fin = new FileInputStream("foo1.jar");
+                    int length = fin.available();
+                    byte[] b = new byte[length-10];
+                    fin.read(b, 0, length-10);
+                    ow.write("HTTP/1.0 200 OK\r\n");
+
+                    // Note: The client expects length bytes.
+                    ow.write("Content-Length: " + length + "\r\n");
+                    ow.write("Content-Type: text/html\r\n");
+                    ow.write("\r\n");
+
+                    // Note: The (buggy) server only sends length-10 bytes.
+                    ow.write(new String(b));
+                    ow.flush();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
 
     static void read (InputStream is) throws IOException {
         int c,len=0;
@@ -45,32 +91,13 @@
         System.out.println ("read " + len + " bytes");
     }
 
-    static class CallBack extends AbstractCallback {
-
-        public void request (HttpTransaction req, int count) {
-            try {
-                System.out.println ("Request received");
-                req.setResponseEntityBody (new FileInputStream ("foo1.jar"));
-                System.out.println ("content length " + req.getResponseHeader (
-                        "Content-length"
-                ));
-                req.sendPartialResponse (200, "Ok");
-                req.abortiveClose();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-
-    };
-
-    static HttpServer server;
-
     public static void main (String[] args) throws Exception {
         String tmpdir = System.getProperty("java.io.tmpdir");
         String[] list1 = listTmpFiles(tmpdir);
-        //server = new HttpServer (new CallBack(), 10, 1, 0);
-        server = new HttpServer (new CallBack(), 1, 5, 0);
-        int port = server.getLocalPort();
+        ServerSocket serverSocket = new ServerSocket(0);
+        server = new Server(serverSocket);
+        server.start();
+        int port = serverSocket.getLocalPort();
         System.out.println ("Server: listening on port: " + port);
         URL url = new URL ("jar:http://localhost:"+port+"!/COPYRIGHT");
         try {
@@ -81,14 +108,12 @@
         } catch (IOException e) {
             System.out.println ("Received IOException as expected");
         }
-        server.terminate();
         String[] list2 = listTmpFiles(tmpdir);
         if (!sameList (list1, list2)) {
             throw new RuntimeException ("some jar_cache files left behind");
         }
     }
 
-
     static String[] listTmpFiles (String d) {
         File dir = new File (d);
         return dir.list (new FilenameFilter () {
--- a/jdk/test/sun/nio/ch/SelProvider.java	Mon Apr 23 16:55:12 2012 -0700
+++ b/jdk/test/sun/nio/ch/SelProvider.java	Wed Jul 05 18:09:02 2017 +0200
@@ -38,20 +38,9 @@
         if ("SunOS".equals(osname)) {
             expected = "sun.nio.ch.DevPollSelectorProvider";
         } else if ("Linux".equals(osname)) {
-            String[] vers = osver.split("\\.", 0);
-            if (vers.length >= 2) {
-                int major = Integer.parseInt(vers[0]);
-                int minor = Integer.parseInt(vers[1]);
-                if (major > 2 || (major == 2 && minor >= 6)) {
-                    expected = "sun.nio.ch.EPollSelectorProvider";
-                } else {
-                    expected = "sun.nio.ch.PollSelectorProvider";
-                }
-            } else {
-                throw new RuntimeException("Test does not recognize this operating system");
-            }
+            expected = "sun.nio.ch.EPollSelectorProvider";
         } else if (osname.startsWith("Mac OS")) {
-            expected = "sun.nio.ch.PollSelectorProvider";
+            expected = "sun.nio.ch.KQueueSelectorProvider";
         } else
             return;
         if (!spName.equals(expected))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/nio/cs/TestSJIS0213_SM.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7152690
+   @summary Initialize SJIS_0213 charset with SecurityManager enabled
+ */
+public class TestSJIS0213_SM {
+    public static void main(String[] args) throws Throwable {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm == null) {
+            System.setSecurityManager(new SecurityManager());
+        }
+        java.nio.charset.Charset.forName("SJIS_0213");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Portions Copyright (c) 2012 IBM Corporation
+ */
+
+/* @test
+ * @bug 6610897
+ * @summary New constructor in sun.tools.java.ClassPath builds a path using
+ *          File.separator instead of File.pathSeparator
+ * @run main RMICClassPathTest
+ */
+
+import java.io.File;
+
+import sun.rmi.rmic.BatchEnvironment;
+
+public class RMICClassPathTest {
+    public static void main(String[] args) throws Exception {
+        String sysPath = "/home/~user/jdk/jre/lib/rt.jar";
+        String extDir = "";
+        String clPath = "/home/~user/user.jar" + File.pathSeparator +
+            "/home/~user/user2.jar" + File.pathSeparator +
+            "/home/~user/user3.jar";
+
+        String cpStr = BatchEnvironment.createClassPath(clPath, sysPath, extDir).toString();
+
+        String[] paths = cpStr.split(File.pathSeparator);
+
+        if (paths.length != 4) {
+            throw new Exception("ClassPath length is not correct: the expected length is 4 and the actual length is " + paths.length);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/ccache/EmptyCC.java	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7158329
+ * @summary NPE in sun.security.krb5.Credentials.acquireDefaultCreds()
+ * @compile -XDignore.symbol.file EmptyCC.java
+ * @run main EmptyCC
+ */
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import sun.security.krb5.Credentials;
+import sun.security.krb5.PrincipalName;
+import sun.security.krb5.internal.ccache.CredentialsCache;
+
+public class EmptyCC {
+    public static void main(String[] args) throws Exception {
+        final PrincipalName pn = new PrincipalName("dummy@FOO.COM");
+        final String ccache = "tmpcc";
+
+        if (args.length == 0) {
+            // Main process, write the ccache and launch sub process
+            CredentialsCache cache = CredentialsCache.create(pn, ccache);
+            cache.save();
+
+            // java -cp $test.classes EmptyCC readcc
+            ProcessBuilder pb = new ProcessBuilder(
+                    new File(new File(System.getProperty("java.home"), "bin"),
+                        "java").getPath(),
+                    "-cp",
+                    System.getProperty("test.classes"),
+                    "EmptyCC",
+                    "readcc"
+                    );
+
+            pb.environment().put("KRB5CCNAME", ccache);
+            pb.redirectErrorStream(true);
+
+            Process p = pb.start();
+            try (InputStream ins = p.getInputStream()) {
+                byte[] buf = new byte[8192];
+                int n;
+                while ((n = ins.read(buf)) > 0) {
+                    System.out.write(buf, 0, n);
+                }
+            }
+            if (p.waitFor() != 0) {
+                throw new Exception("Test failed");
+            }
+        } else {
+            // Sub process, read the ccache
+            String cc = System.getenv("KRB5CCNAME");
+            if (!cc.equals(ccache)) {
+                throw new Exception("env not set correctly");
+            }
+            Credentials.acquireTGTFromCache(pn, null);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jcmd/dcmd-big-script.txt	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,95 @@
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jcmd/jcmd-big-script.sh	Wed Jul 05 18:09:02 2017 +0200
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+#
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+
+# @test
+# @bug 7154822
+# @summary test if we can send a file over 1024 bytes large via jcmd -f
+# @author David Buck
+#
+# @library ../common
+# @build SimpleApplication ShutdownSimpleApplication
+# @run shell jcmd-big-script.sh
+
+. ${TESTSRC}/../common/CommonSetup.sh
+. ${TESTSRC}/../common/ApplicationSetup.sh
+
+# Start application and use PORTFILE for coordination
+PORTFILE="${TESTCLASSES}"/shutdown.port
+startApplication SimpleApplication "${PORTFILE}"
+
+failed=0;
+
+# -f <script>
+rm -f jcmd.out 2>/dev/null
+set +e # even if jcmd fails, we do not want abort the script yet.
+${JCMD} -J-XX:+UsePerfData $appJavaPid -f ${TESTSRC}/dcmd-big-script.txt > jcmd.out 2>&1
+status="$?"
+set -e
+if [ "$status" != 0 ]; then
+  echo "jcmd command returned non-zero exit code (status=$status). Failed."
+  failed=1;
+fi
+cat jcmd.out
+set +e # if the test passes, grep will "fail" with an exit code of 1
+grep Exception jcmd.out > /dev/null 2>&1
+status="$?"
+set -e
+if [ "$status" = 0 ]; then
+  echo "Output of \"jcmd [pid] -f dcmd-big-script.txt\" contains string \"Exception\". Failed."
+  failed=1;
+fi
+
+# clean up
+rm -f jcmd.out 2>/dev/null
+stopApplication "${PORTFILE}"
+waitForApplication
+
+exit $failed